משתמש:1Or/misdar.js
הערה: לאחר הפרסום, ייתכן שיהיה צורך לנקות את זיכרון המטמון (cache) של הדפדפן כדי להבחין בשינויים.
- פיירפוקס / ספארי: להחזיק את המקש Shift בעת לחיצה על טעינה מחדש (Reload) או ללחוץ על צירוף המקשים Ctrl-F5 או Ctrl-R (במחשב מק: ⌘-R).
- גוגל כרום: ללחוץ על צירוף המקשים Ctrl-Shift-R (במחשב מק: ⌘-Shift-R).
- אינטרנט אקספלורר / אדג': להחזיק את המקש Ctrl בעת לחיצה על רענן (Refresh) או ללחוץ על צירוף המקשים Ctrl-F5.
- אופרה: ללחוץ על Ctrl-F5.
mw.loader.using( [ 'mediawiki.util' ] ).then( function() {
if (mw.util.getParamValue('title') == 'מיוחד:חיפוש' || mw.config.get('wgPageName') == "מיוחד:חיפוש") {
var searchMisdarNum = 1;
function searchMisdar() {
searchMisdarAPI(0);
}
function searchMisdarWrite(API){
if (API && API.query){
for (x in API.query.pages){
$('#mw-content-text').append(searchMisdarNum + '. <a href=https://he.wikipedia.org/wiki/' + encodeURIComponent(API.query.pages[x].title) + '>' + API.query.pages[x].title);
$('#mw-content-text').append('<br />');
searchMisdarNum++;
}
if (API.continue && API.continue.gsroffset) {
searchMisdarAPI(API.continue.gsroffset);
}else{
if ($("#mw-content-text")["0"].innerHTML.match(/\d+\. </g)) {
$("#bodyContent").before(" ");
$("#bodyContent").before($("<button style='background-color: #36c; color: white'>").click(function() {document.getElementById("mw-content-text").innerHTML = $("#mw-content-text")["0"].innerHTML.replace(/\d+\. </g, "<"); $(".searchresults").remove(); $("#wdsearch_container").remove();}).append('גרסה להעתקה'));
if ($("#mw-content-text")["0"].innerHTML.match(/\d+\. </g).length >= "9999"){
$("#firstHeading").after($("<b>").append($("<div style='color: Red'>").append("שימו לב! ישנן תשובות נוספות. מנגנון המדיה ויקי לא מאפשר החזרת יותר מ-10,000 תוצאות חיפוש. כדאי לשקול לחדד את השאילתה.")));
}else{
mw.notify("החיפוש הושלם בהצלחה");
mw.notify("נמצאו " + $("#mw-content-text")["0"].innerHTML.match(/\d+\. </g).length + " תוצאות");
}
}
}
}else{mw.notify("לא נמצאו תוצאות");}}
function searchMisdarAPI(Glimit){
var GsrNS;
switch (mw.util.getParamValue('profile')) {
case "images":
GsrNS = "6";
break;
case "default":
GsrNS = "0";
break;
case "all":
GsrNS = "*";
break;
case "advanced":
if (document.URL.match(/&ns(\d+)/g)) {
for (x in document.URL.match(/&ns(\d+)/g)){
if (GsrNS === "") {
GsrNS = document.URL.match(/&ns(\d+)/g)[x].match(/\d+/)["0"];
}
GsrNS = GsrNS + "|" + document.URL.match(/&ns(\d+)/g)[x].match(/\d+/)["0"];
}
}else{GsrNS = "0";}
break;
default:
GsrNS = "0";
break;
}
if (GsrNS) {
new mw.Api().get({
"action": "query",
"format": "json",
"prop": "info",
"generator": "search",
"gsrsearch": $('#ooui-php-1')["0"].value,
"gsrnamespace": GsrNS,
"gsrlimit": "max",
"continue": "",
"gsrwhat": "text",
"gsroffset": Glimit
}).done(function(ans) {
searchMisdarWrite(ans);
});
}}
$("#bodyContent").before($("<button style='background-color: #36c; color: white'>").click(searchMisdar).append('חיפוש של מסדר הניקיון'));
}
});