מדיה ויקי:Gadget-HotCat.js: הבדלים בין גרסאות בדף

מאין תקציר עריכה
V2.7: ResourceLoader fixes
שורה 29: שורה 29:
     V2.6: Feb 2011: [[User:Ciencia Al Poder]] & [[User:Lupo]]: get rid of old URI-param based edit
     V2.6: Feb 2011: [[User:Ciencia Al Poder]] & [[User:Lupo]]: get rid of old URI-param based edit
           interface, preventing unwanted single-category changes following malicious links
           interface, preventing unwanted single-category changes following malicious links
    V2.7: March 2011: [[User:Lupo]]: fixes for being loaded as a gadget through the resource loader.


   License: Quadruple licensed GFDL, GPL, LGPL and Creative Commons Attribution 3.0 (CC-BY-3.0)
   License: Quadruple licensed GFDL, GPL, LGPL and Creative Commons Attribution 3.0 (CC-BY-3.0)
שורה 43: שורה 44:
//    sajax_init_object
//    sajax_init_object
//  wikibits.js
//  wikibits.js
//    addOnloadHook, window.ie6_bugs, window.is_safari, window.is_opera, importScript
//    window.ie6_bugs, window.is_safari, window.is_opera, addOnloadHook (or alternatively jQuery)


if (typeof (HotCat) == 'undefined' && wgAction != 'edit') { // Guard against double inclusions, and inactivate on edit pages
if (typeof (HotCat) == 'undefined' && wgAction != 'edit') { // Guard against double inclusions, and inactivate on edit pages
שורה 193: שורה 194:
};
};


if (HotCat.isCommonsVersion && wgServer.indexOf ('/commons') < 0) {
(function () { // Local scope to avoid polluting global namespace with declarations
  // We're running in some other wiki, which hotlinks to the Commons version. The other wiki can put local settings
  // in this file to override the Commons settings for all user languages. For instance, if on your wiki people do
  // not like automatic saving, you'd add in that file the line HotCat.no_autocommit = true; If you hotlink, you
  // *must* adapt HotCat.categories in this file to the local translation in wgContentLanguage of your wiki of the
  // English plural "Categories", and you should provide translations in wgContentLanguage of your wiki of all messages,
  // tooltips, and of the engine names.
  importScript ('MediaWiki:Gadget-HotCat.js/local_defaults');
}


if (wgUserLanguage != 'en') {
  // If we're loaded through the resource loader, we may sometimes not have importScript or importScriptURI.
  if (window.hotcat_translations_from_commons && wgServer.indexOf ('/commons') < 0) {
  // Try to work around this.
    importScriptURI (
 
      ((wgServer.indexOf( "https://secure.wikimedia.org") == 0)
  function load (uri) {
        ? '/wikipedia/commons/w/index.php?title='
    if (window.mediaWiki) { // Resource loader present?
        : 'http://commons.wikimedia.org/w/index.php?title='
      window.mediaWiki.loader.load (uri);
      )
    } else if (typeof (window.importScriptURI) == 'function') {
      + 'MediaWiki:Gadget-HotCat.js/' + wgUserLanguage
      window.importScriptURI (uri);
      + '&action=raw&ctype=text/javascript&smaxage=21600&maxage=86400'
    } else {
    );
      var s = document.createElement ('script');
  } else {
      s.setAttribute ('src', uri);
    // Load translations locally
      s.setAttribute ('type', 'text/javascript');
    importScript ('MediaWiki:Gadget-HotCat.js/' + wgUserLanguage);
      document.getElementsByTagName ('head')[0].appendChild (s);
    }
  }
 
  function loadJS (page) {
    load (wgServer + wgScript + '?title=' + encodeURIComponent (page) + '&action=raw&ctype=text/javascript');
  }
 
  function loadURI (href) {
    var url = href;
    if (url.substring (0, 2) == '//') {
      url = window.location.protocol + url;
    } else if (url.substring (0, 1) == '/') {
      url = wgServer + url;
    }
    load (url);
  }
 
  if (HotCat.isCommonsVersion && wgServer.indexOf ('/commons') < 0) {
    // We're running in some other wiki, which hotlinks to the Commons version. The other wiki can put local settings
    // in this file to override the Commons settings for all user languages. For instance, if on your wiki people do
    // not like automatic saving, you'd add in that file the line HotCat.no_autocommit = true; If you hotlink, you
    // *must* adapt HotCat.categories in this file to the local translation in wgContentLanguage of your wiki of the
    // English plural "Categories", and you should provide translations in wgContentLanguage of your wiki of all messages,
    // tooltips, and of the engine names.
    loadJS ('MediaWiki:Gadget-HotCat.js/local_defaults');
  }
 
  if (wgUserLanguage != 'en') {
    if (window.hotcat_translations_from_commons && wgServer.indexOf ('/commons') < 0) {
      loadURI (
        ((wgServer.indexOf( "https://secure.wikimedia.org") == 0)
          ? '/wikipedia/commons/w/index.php?title='
          : 'http://commons.wikimedia.org/w/index.php?title='
        )
        + 'MediaWiki:Gadget-HotCat.js/' + wgUserLanguage
        + '&action=raw&ctype=text/javascript&smaxage=21600&maxage=86400'
      );
    } else {
      // Load translations locally
      loadJS ('MediaWiki:Gadget-HotCat.js/' + wgUserLanguage);
    }
   }
   }
}
  // Localization hook to localize HotCat messages, tooltips, and engine names for wgUserLanguage.
// Localization hook to localize HotCat messages, tooltips, and engine names for wgUserLanguage.
 
})(); // End local scope, invoke function. We use a separate scope to keep localizations separate from the rest.


// No further changes should be necessary here.
// No further changes should be necessary here.
שורה 2,358: שורה 2,393:
     HotCat.started = true;
     HotCat.started = true;
     if (window.is_safari) {
     if (window.is_safari) {
       // Safari/Mac calls initialize before the importScript of /local_defaults (and /wgUserLang) are done. Let's wait a bit.
       // Safari/Mac calls initialize before the load of /local_defaults (and /wgUserLang) are done. Let's wait a bit.
       // (This is a hack.)
       // (This is a hack.)
       window.setTimeout (really_run, 1000);
       window.setTimeout (really_run, 1000);
שורה 2,465: שורה 2,500:
   window.hotcat_close_form = function () { closeForm (); };
   window.hotcat_close_form = function () { closeForm (); };


   addOnloadHook (run);
   if (window.jQuery) {
    window.jQuery(document).ready(run);
  } else {
    addOnloadHook (run);
  }
})();
})();


} // end if (guard)
} // end if (guard)
//</source>
//</source>