מדיה ויקי: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_xmlhttp = null;


var hotcat_modify_blacklist = new Array (
var hotcat_modify_blacklist = new Array (
שורה 466: שורה 465:


   if ( v != "" ) {
   if ( v != "" ) {
     var url = wgServer + "/" + wgScriptPath + "/api.php?format=xml&action=query&list=allpages&apnamespace=14&apfrom=" + encodeURIComponent( v ) ;
     var url = wgServer + wgScriptPath
     if (hotcat_xmlhttp != null) {
            + "/api.php?format=xml&action=query&list=allpages&apnamespace=14&apfrom="
      hotcat_xmlhttp.abort() ; // Just to make sure...
            + encodeURIComponent( v ) ;
      delete hotcat_xmlhttp;
     var request = sajax_init_object() ;
    }
     if (request == null) {
    hotcat_xmlhttp = sajax_init_object() ;
     if (hotcat_xmlhttp == null) {
       //Oops! We don't have XMLHttp...
       //Oops! We don't have XMLHttp...
       hotcat_nosuggestions = true;
       hotcat_nosuggestions = true;
שורה 482: שורה 479:
       return;
       return;
     }
     }
     hotcat_xmlhttp.open('GET', url, true);
     request.open('GET', url, true);
     hotcat_xmlhttp.onreadystatechange = function () {
     request.onreadystatechange = function () {
           if ( typeof hotcat_xmlhttp == "undefined" ) return ;
           if (request.readyState == 4) {
          if (hotcat_xmlhttp.readyState == 4) {
            var xml = request.responseXML ;
              var xml = hotcat_xmlhttp.responseXML ;
            if ( xml == null ) return ;
              if ( xml == null ) return ;
            var pages = xml.getElementsByTagName( "p" ) ;
              var pages = xml.getElementsByTagName( "p" ) ;
            var titles = new Array () ;
              var titles = new Array () ;
            for ( var i = 0 ; i < pages.length ; i++ ) {
              for ( var i = 0 ; i < pages.length ; i++ ) {
              var s = pages[i].getAttribute("title").split(":",2).pop() ;
                var s = pages[i].getAttribute("title").split(":",2).pop() ;
              if ( s.substr ( 0 , hotcat_last_v.length ) != hotcat_last_v ) break ;
                if ( s.substr ( 0 , hotcat_last_v.length ) != hotcat_last_v ) break ;
              titles.push ( s ) ;
                titles.push ( s ) ;
            }
              }
            hotcat_show_suggestions ( titles ) ;
              hotcat_show_suggestions ( titles ) ;
           }
           }
       };
       };
     hotcat_xmlhttp.send(null);
     request.setRequestHeader ('Pragma', 'cache=yes');
    request.setRequestHeader ('Cache-Control', 'no-transform');
    request.send(null);
   } else {
   } else {
     var titles = new Array () ;
     hotcat_show_suggestions ( new Array () ) ;
    hotcat_show_suggestions ( titles ) ;
   }
   }
   hotcat_running = 0 ;
   hotcat_running = 0 ;