MediaWiki:Common.js: Difference between revisions

From Linjauskone
No edit summary
No edit summary
Line 1: Line 1:
(function($, mw) {
(function ($, mw) {
   var fn = function() {
   var fn = function () {
     var cats = mw.config.get('wgCategories'), newClasses;
     var cats = mw.config.get('wgCategories'), newClasses;
     if (cats) {
     if (cats) {
       newClasses = $.map(cats, function(el) {
       newClasses = $.map(cats, function (el) {
         return 'cat-' + encodeURIComponent(el.replace(/[ .]/g, '_')).replace(/%/g, '_');
         return 'cat-' + encodeURIComponent(el.replace(/[ .]/g, '_')).replace(/%/g, '_');
       }).join(' ');
       }).join(' ');
Line 16: Line 16:




$.getScript("https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/js/bootstrap.bundle.min.js", function() {
  $.getScript("https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/js/bootstrap.bundle.min.js", function () {
     $.getScript("https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.14/dist/js/bootstrap-select.min.js", function() {
     $.getScript("https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.14/dist/js/bootstrap-select.min.js", function () {
$('#org').selectpicker();
      $('#org').selectpicker();
    // setup click handlers
      // setup click handlers
    $('#org').on('changed.bs.select', function (e, clickedIndex, isSelected, previousValue) {      
      $('#org').on('changed.bs.select', function (e, clickedIndex, isSelected, previousValue) {
         $('#actions').text('')
         $('#actions').text('')
         $('#connected_actors').text('')
         $('#connected_actors').text('')
Line 26: Line 26:
         org_name = orgs[selectedBusinessID].name
         org_name = orgs[selectedBusinessID].name
         var actors = orgs[selectedBusinessID].responsible_actors
         var actors = orgs[selectedBusinessID].responsible_actors
         $('#connected_actors').text('linkitetyt toimijat: ' + actors.map(function(a) {return a.fi}).join(','))
         $('#connected_actors').text('linkitetyt toimijat: ' + actors.map(function (a) { return a.fi }).join(','))
         filtered_actions = filter_actions(new Set(actors.map(function(a) { return a.id})))
         filtered_actions = filter_actions(new Set(actors.map(function (a) { return a.id })))
         console.log(filtered_actions)
         console.log(filtered_actions)
         groups1 = group_actions_by_year(filtered_actions)
         groups1 = group_actions_by_year(filtered_actions)
Line 35: Line 35:
         render_actions(groups1)
         render_actions(groups1)
         $('body').scrollspy({ target: '#year-shortcut' })
         $('body').scrollspy({ target: '#year-shortcut' })
 
       });
       });
       $(".year-link").on('click', function(e) {
       $(".year-link").on('click', function (e) {
         e.preventDefault();
         e.preventDefault();
         var target = '#' + e.currentTarget.id.split('nav-item-')[1];
         var target = '#' + e.currentTarget.id.split('nav-item-')[1];
Line 44: Line 44:
         }, 1000);
         }, 1000);
       });
       });
    // fetch data
      // fetch data
       fetch_data();
       fetch_data();
    });


    if ($('#overview_actions').length) {  
      if ($('#overview_actions').length) {
console.log('heps')
        console.log('heps')
$('#domains').selectpicker();
        $('#domains').selectpicker();
console.log('heps')
        console.log('heps')
$('#years').selectpicker();
        $('#years').selectpicker();
$('#actors').selectpicker();
        $('#actors').selectpicker();
$('#row_grouping').selectpicker();
        $('#row_grouping').selectpicker();
$('#col_grouping').selectpicker();
        $('#col_grouping').selectpicker();
         $('#domains').on('changed.bs.select', function (e, clickedIndex, isSelected, previousValue) {
         $('#domains').on('changed.bs.select', function (e, clickedIndex, isSelected, previousValue) {
            updateActionView()
          updateActionView()
         });
         });
         $('#years').on('changed.bs.select', function (e, clickedIndex, isSelected, previousValue) {
         $('#years').on('changed.bs.select', function (e, clickedIndex, isSelected, previousValue) {
            updateActionView()
          updateActionView()
         });
         });


         $('#actors').on('changed.bs.select', function (e, clickedIndex, isSelected, previousValue) {
         $('#actors').on('changed.bs.select', function (e, clickedIndex, isSelected, previousValue) {
            updateActionView()
          updateActionView()
         });
         });
         $('#row_grouping').on('changed.bs.select', function (e, clickedIndex, isSelected, previousValue) {
         $('#row_grouping').on('changed.bs.select', function (e, clickedIndex, isSelected, previousValue) {
            updateActionView()
          updateActionView()
         });
         });
         $('#col_grouping').on('changed.bs.select', function (e, clickedIndex, isSelected, previousValue) {
         $('#col_grouping').on('changed.bs.select', function (e, clickedIndex, isSelected, previousValue) {
            updateActionView()
          updateActionView()
         });
         });


         // select all as by default
         // select all as by default
console.log('heps')
        console.log('heps')
         $('#domains').selectpicker('selectAll');
         $('#domains').selectpicker('selectAll');
console.log('heps')
        console.log('heps')
         $('#years').selectpicker('selectAll');
         $('#years').selectpicker('selectAll');
         $('#actors').selectpicker('selectAll');
         $('#actors').selectpicker('selectAll');
         fetch_data().then(updateActionView)
         fetch_data().then(updateActionView)
     }
      }
});
     });
 
 
 
  });


})(jQuery, mw);
})(jQuery, mw);

Revision as of 07:03, 28 November 2022

(function ($, mw) {
  var fn = function () {
    var cats = mw.config.get('wgCategories'), newClasses;
    if (cats) {
      newClasses = $.map(cats, function (el) {
        return 'cat-' + encodeURIComponent(el.replace(/[ .]/g, '_')).replace(/%/g, '_');
      }).join(' ');
      $(document.body).addClass(newClasses);
    }
  };
  if (document.body) {
    fn();
  } else {
    $(fn);
  }


  $.getScript("https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/js/bootstrap.bundle.min.js", function () {
    $.getScript("https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.14/dist/js/bootstrap-select.min.js", function () {
      $('#org').selectpicker();
      // setup click handlers
      $('#org').on('changed.bs.select', function (e, clickedIndex, isSelected, previousValue) {
        $('#actions').text('')
        $('#connected_actors').text('')
        var selectedBusinessID = e.target.value
        org_name = orgs[selectedBusinessID].name
        var actors = orgs[selectedBusinessID].responsible_actors
        $('#connected_actors').text('linkitetyt toimijat: ' + actors.map(function (a) { return a.fi }).join(','))
        filtered_actions = filter_actions(new Set(actors.map(function (a) { return a.id })))
        console.log(filtered_actions)
        groups1 = group_actions_by_year(filtered_actions)
        console.log(groups1)
        //groups2 = group_years_by_actors(groups1, actors)
        //console.log(groups2)
        render_actions(groups1)
        $('body').scrollspy({ target: '#year-shortcut' })

      });
      $(".year-link").on('click', function (e) {
        e.preventDefault();
        var target = '#' + e.currentTarget.id.split('nav-item-')[1];
        $('html, body').animate({
          scrollTop: $(target).offset().top
        }, 1000);
      });
      // fetch data
      fetch_data();

      if ($('#overview_actions').length) {
        console.log('heps')
        $('#domains').selectpicker();
        console.log('heps')
        $('#years').selectpicker();
        $('#actors').selectpicker();
        $('#row_grouping').selectpicker();
        $('#col_grouping').selectpicker();
        $('#domains').on('changed.bs.select', function (e, clickedIndex, isSelected, previousValue) {
          updateActionView()
        });
        $('#years').on('changed.bs.select', function (e, clickedIndex, isSelected, previousValue) {
          updateActionView()
        });

        $('#actors').on('changed.bs.select', function (e, clickedIndex, isSelected, previousValue) {
          updateActionView()
        });
        $('#row_grouping').on('changed.bs.select', function (e, clickedIndex, isSelected, previousValue) {
          updateActionView()
        });
        $('#col_grouping').on('changed.bs.select', function (e, clickedIndex, isSelected, previousValue) {
          updateActionView()
        });

        // select all as by default
        console.log('heps')
        $('#domains').selectpicker('selectAll');
        console.log('heps')
        $('#years').selectpicker('selectAll');
        $('#actors').selectpicker('selectAll');
        fetch_data().then(updateActionView)
      }
    });



  });

})(jQuery, mw);



/* Any JavaScript here will be loaded for all users on every page load. */

/*
mw.loader.load( '/index.php?title=MediaWiki:Policy.js&action=raw&ctype=text/javascript' );

mw.loader.load( '/index.php?title=MediaWiki:AcrionList.js&action=raw&ctype=text/javascript' );
*/
/*
mw.loader.using( ['jquery'] ).then( function () {
mw.loader.load( '/index.php?title=MediaWiki:Select.js&action=raw&ctype=text/javascript' );
});
*/

$('body.page-Special_FormEdit_Progress #firstHeading').text('Uusi edistysaskel');
$('body.page-Special_FormEdit_Progress #wpSave > button').text('Tallenna');
$('#searchform').append('<input type="hidden" value="default" name="profile" />');

Sivustoa ylläpitää Avoimen tieteen ja tutkimuksen (AVOTT) kansallisen koordinaation sihteeristö, joka toimii Tieteellisten seurain valtuuskunnassa (TSV) Opetus- ja kulttuuriministeriön (OKM) rahoituksella. Avoimen tieteen ja tutkimuksen koordinaatio edistää avoimen tieteen ja tutkimuksen toteutumista sekä keskustelua sen mahdollisuuksista, haasteista sekä niiden ratkaisuista Suomessa.

Webbplatsen upprätthålls av Sekretariatet för den nationella samordningen av öppen vetenskap och forskning. Sekretariatet verkar vid Vetenskapliga samfundens delegation med finansiering från undervisnings- och kulturministeriet. Samordningen främjar öppen vetenskap och forskning samt diskussion kring dess möjligheter, utmaningar och lösningar i Finland.

This website is maintained by the Secretariat of the National Coordination for Open Science and Research in Finland (AVOTT), which operates in the Federation of Finnish Learned Societies (TSV) with funding from the Ministry of Education and Culture (OKM). The Open Science and Research Coordination promotes open science and research, as well as discussion on its opportunities, challenges and their solutions in Finland.