MediaWiki:Common.js

From OHO - search engine for sustainable open hardware projects
Revision as of 02:24, 18 February 2022 by Javierf (talk | contribs)

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
/* Das folgende JavaScript wird für alle Benutzer geladen. */
jQuery(document).ready(function($) {
    document.getElementsByClassName("wait_screen_box")[0].style.display = 'none';

    mw.loader.using('jquery.ui.autocomplete', function() {
        (function (mw, $) {
            $(function () {
                $('.searchInputProjectKWAC').autocomplete( {
                    source: function(request, response) {
                        mw.loader.using('mw.Api').then(function () {
                            var api = new mw.Api();
                            api.get({action:'pfautocomplete', limit:10, substr:request.term, property:'Keywords'}).done(
                            function (data) {
                                var dataf = [];
                                dataf = processListAC(request.term, data, dataf);
                                dataf = dataf.sort().slice(0, 10);
                                response(dataf);
                            });
                        });
                    }
                });
            });
        }(mediaWiki, jQuery));
    });

    $(".project_gallery_scroll_box").append('<div class="button_left"></div>');
    $(".project_gallery_scroll_box").append('<div class="button_right"></div>');
    $(".project_gallery_scroll_box a.image, .project_gallery_scroll_box img").unwrap('pre');
    $(".project_gallery_scroll_box > a.image, .project_gallery_scroll_box > img").wrap('<div class="imgbox"></div>');
    $(".project_gallery_scroll_box .imgbox").wrapAll('<div class="gallery_inner"></div>');
    $('.project_gallery_scroll_box img').each(function(){
        var imgClass = (this.width >= this.height) ? 'imgwfill' : 'imghfill';
        $(this).addClass(imgClass);
    });
    $(".project_gallery_scroll_box .button_left").click(function(){
        var binn = $(this).parent().find(".gallery_inner");
        if (binn.position().left < 0) {
            var imgW = binn.find(".imgbox").first().outerWidth();
            binn.animate({left:"+="+imgW});
        }
    });
    $(".project_gallery_scroll_box .button_right").click(function(){
        var binn = $(this).parent().find(".gallery_inner");
        if (binn.position().left + binn.width() > binn.parent().width()) {
            var imgW = binn.find(".imgbox").first().outerWidth();
            binn.animate({left:"-="+imgW});
        }
    });
    $(".project_gallery_scroll_box").removeClass('waitbox');
});

function processListAC(search, data, dataf) {
    for(var dlist in data) {
        for(var drow in data[dlist]) {
            var listW = data[dlist][drow].title.split(",");
            for(var w in listW) {
                wt = listW[w].trim();
                if (wt.length>0) {
                    wt = wt.charAt(0).toUpperCase() + wt.substr(1).toLowerCase();
                    if (wt.toLowerCase().indexOf(search.toLowerCase())===0 && $.inArray(wt, dataf)===-1) {
                        dataf[dataf.length] = wt;
                    }
                }
            }
        }
    }
    return dataf;
}

/* Das folgende JavaScript wird für alle Benutzer geladen. */
$(".materialRow .showComment").click(function(){
  $(this).parent().toggleClass("openComments");
  $(this).parent().parent().next().toggle(500);
});
$(".showGralComment").click(function(){
  $(".generalCommentsBox").toggle(500);
  var grhtml = $(".showGralComment").html();
  if (grhtml.indexOf('+') > -1) {
    grhtml = grhtml.replace('+', '-');
  }else{
    grhtml = grhtml.replace('-', '+');
  }
  $(".showGralComment").html(grhtml);
});

$(".project_material_table .showAllComments").click(function(e){
  e.preventDefault();
  var txt = $(this).html();
  if (txt=='Show All Comments') {
    $(".project_material_table .materialCommandsBox").addClass("openComments");
    $(".project_material_table .commentRow").not(".notFoundComment").css("display", "table-row");
    $(this).html('Hide All Comments');
  }else{
    $(".project_material_table .materialCommandsBox").removeClass("openComments");
    $(".project_material_table .commentRow").not(".notFoundComment").hide(500);
    $(this).html('Show All Comments');
  }
});

$(".searchMatCol").keyup(function(e){
  findRowsByCol($(".searchMatCol"));
});

if (window.initJSFuncts!==undefined) {
  for(ijsf=0; ijsf<window.initJSFuncts.length; ijsf++) {
    try {window.initJSFuncts[ijsf]();}catch(e){console.log(e);}
  }
}

function getUrlParameter(sParam) {
    var sPageURL = window.location.search.substring(1);
    var sURLVariables = sPageURL.split('&');
    for (i = 0; i < sURLVariables.length; i++) {
        sParameterName = sURLVariables[i].split('=');
        if (sParameterName[0] === sParam) {
            return sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]);
        }
    }
}

$(".newtablinks a, .newtablink").attr("target", "_blank");

window.isfirst = true; window.prevc = false;
$('ul.dropdown-menu li a').each(function(){
    if($(this).text().substr(0,1) == '_'){
         if (window.isfirst!==false) {$(this).parent().addClass('firstchild')}
         $(this).text($(this).text().substr(1)).parent().addClass('menuchild lastchild');
         if (window.prevc!==false) {window.prevc.parent().removeClass('lastchild');}
         window.isfirst = false;
         window.prevc = $(this);
    }else{
         window.isfirst = true;
         window.prevc = false;
    }
})


$(".home_resume_text.home_hidden_text .home_more_results_link a").click(function(e){
  e.preventDefault();
  $(this).parent().parent().removeClass('home_hidden_text');
  $(this).parent().hide();
});
OPEN HARDWARE OBSERVATORY 2020
| |
|||