מדיה ויקי:Gadget-HotCat.js: הבדלים בין גרסאות בדף
מ autocommit bug |
Use a local variable for the request; don't bother about aborting. Most important: remove extra "/" between wgServer and wgScriptPath, it made us get 403's on many requests! |
||
| שורה 14: | שורה 14: | ||
// displayed, and there won't be any checking whether the category exists. | // displayed, and there won't be any checking whether the category exists. | ||
// Lupo, 2008-01-20 | // Lupo, 2008-01-20 | ||
var hotcat_modify_blacklist = new Array ( | var hotcat_modify_blacklist = new Array ( | ||
| שורה 466: | שורה 465: | ||
if ( v != "" ) { | if ( v != "" ) { | ||
var url = wgServer | var url = wgServer + wgScriptPath | ||
+ "/api.php?format=xml&action=query&list=allpages&apnamespace=14&apfrom=" | |||
+ encodeURIComponent( v ) ; | |||
var request = sajax_init_object() ; | |||
if (request == null) { | |||
if ( | |||
//Oops! We don't have XMLHttp... | //Oops! We don't have XMLHttp... | ||
hotcat_nosuggestions = true; | hotcat_nosuggestions = true; | ||
| שורה 482: | שורה 479: | ||
return; | return; | ||
} | } | ||
request.open('GET', url, true); | |||
request.onreadystatechange = function () { | |||
if ( | if (request.readyState == 4) { | ||
var xml = request.responseXML ; | |||
if ( xml == null ) return ; | |||
var pages = xml.getElementsByTagName( "p" ) ; | |||
var titles = new Array () ; | |||
for ( var i = 0 ; i < pages.length ; i++ ) { | |||
var s = pages[i].getAttribute("title").split(":",2).pop() ; | |||
if ( s.substr ( 0 , hotcat_last_v.length ) != hotcat_last_v ) break ; | |||
titles.push ( s ) ; | |||
} | |||
hotcat_show_suggestions ( titles ) ; | |||
} | } | ||
}; | }; | ||
request.setRequestHeader ('Pragma', 'cache=yes'); | |||
request.setRequestHeader ('Cache-Control', 'no-transform'); | |||
request.send(null); | |||
} else { | } else { | ||
hotcat_show_suggestions ( new Array () ) ; | |||
} | } | ||
hotcat_running = 0 ; | hotcat_running = 0 ; | ||