Difference between revisions of "MediaWiki:Common.js"
From OHO - search engine for sustainable open hardware projects
Line 1: | Line 1: | ||
/* Das folgende JavaScript wird für alle Benutzer geladen. */ | /* Das folgende JavaScript wird für alle Benutzer geladen. */ | ||
jQuery(document).ready(function($) { | jQuery(document).ready(function($) { | ||
mw.loader.using('jquery.ui.autocomplete', function() { | mw.loader.using('jquery.ui.autocomplete', function() { | ||
(function (mw, $) { | (function (mw, $) { |
Revision as of 22:30, 27 October 2020
/* Das folgende JavaScript wird für alle Benutzer geladen. */ jQuery(document).ready(function($) { mw.loader.using('jquery.ui.autocomplete', function() { (function (mw, $) { $(function () { $('.searchInputProjectKWAC').autocomplete( { source: function(request, response) { var api = new mw.Api(); api.get({action:'pfautocomplete', limit:10, substr:request.term, property:'KeywordsEN'}).done( function (dataEN) { api.get({action:'pfautocomplete', limit:10, substr:request.term, property:'KeywordsES'}).done( function (dataES) { api.get({action:'pfautocomplete', limit:10, substr:request.term, property:'KeywordsDE'}).done( function (dataDE) { var dataf = []; dataf = processListAC(request.term, dataEN, dataf); dataf = processListAC(request.term, dataDE, dataf); dataf = processListAC(request.term, dataES, dataf); dataf = dataf.sort().slice(0, 10); response(dataf); }); }); }); } }); }); }(mediaWiki, jQuery)); }); }); 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; }