Diferencia entre revisiones de «MediaWiki:Common.js»

De OHO - search engine for sustainable open hardware projects
(Sin diferencias)

Revisión del 07:42 26 ago 2019

/* 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:'Keywords'}).done(
                        function (data) {
                            var dataf = [];
                            dataf = processListAC(request.term, data, 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;
}
OPEN HARDWARE OBSERVATORY 2020
| |
|||