Menü aufrufen
Toggle preferences menu
Persönliches Menü aufrufen
Nicht angemeldet
Ihre IP-Adresse wird öffentlich sichtbar sein, wenn Sie Änderungen vornehmen.

MediaWiki:Gadget-HotCat.js: Unterschied zwischen den Versionen

MediaWiki-Schnittstellenseite
Code aus Commons - mal sehen ob das unter 1.16 funktioniert
KKeine Bearbeitungszusammenfassung
Zeile 2: Zeile 2:


/*
/*
   HotCat V2.3
   HotCat V2.2b


   Ajax-based simple Category manager. Allows adding/removing/changing categories on a page view.
   Ajax-based simple Category manager. Allows adding/removing/changing categories on a page view.
Zeile 21: Zeile 21:
           highlighting of changed categories, enabling/disabling save button, search engine name
           highlighting of changed categories, enabling/disabling save button, search engine name
           localization, parent category engine).
           localization, parent category engine).
    V2.3: Aug 2010: [[User:Lupo]]: page up/down for scrolling in suggestion lists; suggestion list
          size configurable; minor bug fixes.


   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)
Zeile 43: Zeile 41:
// Configuration stuff.
// Configuration stuff.
var HotCat = {
var HotCat = {
  isCommonsVersion : true
    // If you copy HotCat to your wiki, you should set this to false!
   // Localize these messages to the main language of your wiki.
   // Localize these messages to the main language of your wiki.
   ,messages :
   messages :
     { cat_removed  : 'removed [[Category:$1]]'
     { cat_removed  : 'Entferne [[Kategorie:$1]]'
     ,template_removed  : 'removed {{[[Category:$1]]}}'
     ,template_removed  : 'Entferne {{[[Kategorie:$1|$1]]}}'
     ,cat_added    : 'added [[Category:$1]]'
     ,cat_added    : 'Ergänze [[Kategorie:$1]]'
     ,cat_keychange: 'new key for [[Category:$1]]: '
     ,cat_keychange: 'neuer Sortierschlüssel für [[Kategorie:$1]]: '
     ,cat_notFound : 'Category "$1" not found'
     ,cat_notFound : 'Kategorie "$1" konnte nicht gefunden werden'
     ,cat_exists  : 'Category "$1" already exists; not added.'
     ,cat_exists  : 'Kategorie "$1" bereits enthalten; nicht ergänzt'
     ,cat_resolved : ' (redirect [[Category:$1]] resolved)'
     ,cat_resolved : ' (Weiterleitung [[Kategorie:$1]] aufgelöst)' //wird nicht für dewiki benötigt
     ,uncat_removed: 'removed {{uncategorized}}'
     ,uncat_removed: 'entferne {{uncategorized}}' //wird nicht für dewiki benötigt
     ,prefix      : ""
     ,prefix      : '[[WP:HC|HC]]: '
         // Some text to prefix to the edit summary.
         // Some text to prefix to the edit summary.
     ,using        : ' using [[Help:Gadget-HotCat|HotCat]]'
     ,using        : ''
         // Some text to append to the edit summary. Named 'using' for historical reasons. If you prefer
         // Some text to append to the edit summary. Named 'using' for historical reasons. If you prefer
         // to have a marker at the front, use prefix and set this to the empty string.
         // to have a marker at the front, use prefix and set this to the empty string.
     ,multi_change : '$1 categories'
     ,multi_change : '$1 Kategorien'
         // $1 is replaced by a number
         // $1 is replaced by a number
     ,commit      : 'Save'
     ,commit      : 'Speichern'
         // Button text. Localize to wgContentLanguage here; localize to wgUserLanguage in a subpage,
         // Button text. Localize to wgContentLanguage here; localize to wgUserLanguage in a subpage,
         // see localization hook below.
         // see localization hook below.
Zeile 69: Zeile 64:
         // Button text. Localize to wgContentLanguage here; localize to wgUserLanguage in a subpage,
         // Button text. Localize to wgContentLanguage here; localize to wgUserLanguage in a subpage,
         // see localization hook below.
         // see localization hook below.
     ,cancel      : 'Cancel'
     ,cancel      : 'Abbrechen'
         // Button text. Localize to wgContentLanguage here; localize to wgUserLanguage in a subpage,
         // Button text. Localize to wgContentLanguage here; localize to wgUserLanguage in a subpage,
         // see localization hook below.
         // see localization hook below.
     ,multi_error  : 'Could not retrieve the page text from the server. Therefore, your category changes '
     ,multi_error  : 'Quelltext konnte nicht abrufen werden. Deine Änderungen wurden deshalb nicht gespeichert.'
                    +'cannot be saved. We apologize for the inconvenience.'
         // Localize to wgContentLanguage here; localize to wgUserLanguage in a subpage,
         // Localize to wgContentLanguage here; localize to wgUserLanguage in a subpage,
         // see localization hook below.
         // see localization hook below.
     }
     }
  ,category_regexp    : '[Cc][Aa][Tt][Ee][Gg][Oo][Rr][Yy]'
  ,category_regexp    : '[Cc][Aa][Tt][Ee][Gg][Oo][Rr][Yy]|[Kk][Aa][Tt][Ee][Gg][Oo][Rr][Ii][Ee]'
   // Regular sub-expression matching all possible names for the category namespace. Is automatically localized
   // Regular sub-expression matching all possible names for the category namespace. Is automatically localized
   // correctly if you're running MediaWiki 1.16 or later. Otherwise, set it appropriately, e.g. at the German
   // correctly if you're running MediaWiki 1.16 or later. Otherwise, set it appropriately, e.g. at the German
Zeile 83: Zeile 77:
   // Chinese Wikipedia, use '[Cc][Aa][Tt][Ee][Gg][Oo][Rr][Yy]|分类|分類'. Note that namespaces are case-
   // Chinese Wikipedia, use '[Cc][Aa][Tt][Ee][Gg][Oo][Rr][Yy]|分类|分類'. Note that namespaces are case-
   // insensitive!
   // insensitive!
  ,category_canonical : 'Category'
  ,category_canonical : 'Kategorie'
   // The standard category name on your wiki. Is automatically localized correctly if you're running
   // The standard category name on your wiki. Is automatically localized correctly if you're running
   // MediaWiki 1.16 or later; otherwise, set it to the preferred category name (e.g., "Kategorie").
   // MediaWiki 1.16 or later; otherwise, set it to the preferred category name (e.g., "Kategorie").
  ,categories        : 'Categories'
  ,categories        : 'Kategorien'
   // Plural of category_canonical
   // Plural of category_canonical
  ,disambig_category  : 'Disambiguation'
  ,disambig_category  : null
   // Any category in this category is deemed a disambiguation category; i.e., a category that should not contain
   // Any category in this category is deemed a disambiguation category; i.e., a category that should not contain
   // any items, but that contains links to other categories where stuff should be categorized. If you don't have
   // any items, but that contains links to other categories where stuff should be categorized. If you don't have
   // that concept on your wiki, set it to null.
   // that concept on your wiki, set it to null.
  ,redir_category    : 'Category redirects'
  ,redir_category    : null
   // Any category in this category is deemed a (soft) redirect to some other category defined by the first link
   // Any category in this category is deemed a (soft) redirect to some other category defined by the first link
   // to another category. If your wiki doesn't have soft category redirects, set this to null.
   // to another category. If your wiki doesn't have soft category redirects, set this to null.
Zeile 98: Zeile 92:
   // The little modification links displayed after category names.
   // The little modification links displayed after category names.
  ,tooltips : {
  ,tooltips : {
     change:  'Modify'
     change:  'Ändern'
   ,remove:  'Remove'
   ,remove:  'Entfernen'
   ,add:    'Add a new category'
   ,add:    'Neue Kategorie hinzufügen'
   ,restore: 'Undo changes'
   ,restore: 'Wiederherstellen'
   ,undo:    'Undo changes'
   ,undo:    'Zurücksetzen'
   ,down:    'Open for modifying and display subcategories'
   ,down:    'durch Unterkategorie ersetzen'
   ,up:      'Open for modifying and display parent categories'
   ,up:      'durch Überkategorie ersetzen'
   }
   }
   // The tooltips for the above links
   // The tooltips for the above links
  ,addmulti          : '<span>+<sup>+</sup></span>'
  ,addmulti          : '<span>+<sup>+</sup></span>'
   // The HTML content of the "enter multi-mode" link at the front.
   // The HTML content of the "enter multi-mode" link at the front.
  ,multi_tooltip      : 'Modify several categories'
  ,multi_tooltip      : 'Mehrere Kategorien ändern'
   // Tooltip for the "enter multi-mode" link
   // Tooltip for the "enter multi-mode" link
  ,disable            :
  ,disable            :
Zeile 119: Zeile 113:
                 && wgTitle && wgTitle.length >= 3 && wgTitle.lastIndexOf ('.js') + 3 == wgTitle.length
                 && wgTitle && wgTitle.length >= 3 && wgTitle.lastIndexOf ('.js') + 3 == wgTitle.length
                 // User scripts
                 // User scripts
               || typeof (wgNamespaceIds) != 'undefined'
               || typeof (wgNamespaceIds) != 'unknown'
                 && (  wgNamespaceNumber == wgNamespaceIds['creator']
                 && (  wgNamespaceNumber == wgNamespaceIds['creator']
                     || wgNamespaceNumber == wgNamespaceIds['timedtext']
                     || wgNamespaceNumber == wgNamespaceIds['timedtext']
Zeile 125: Zeile 119:
             );
             );
     }
     }
  ,uncat_regexp : /\{\{\s*([Uu]ncat(egori[sz]ed( image)?)?|[Nn]ocat|[Nn]eedscategory)[^}]*\}\}\s*(<\!--.*?--\>)?/g
  ,uncat_regexp : null
   // A regexp matching a templates used to mark uncategorized pages, if your wiki does have that.
   // A regexp matching a templates used to mark uncategorized pages, if your wiki does have that.
   // If not, set it to null.
   // If not, set it to null.
Zeile 131: Zeile 125:
  ,existsNo    : 'http://upload.wikimedia.org/wikipedia/commons/thumb/4/42/P_no.svg/20px-P_no.svg.png'
  ,existsNo    : 'http://upload.wikimedia.org/wikipedia/commons/thumb/4/42/P_no.svg/20px-P_no.svg.png'
   // The images used for the little indication icon. Should not need changing.
   // The images used for the little indication icon. Should not need changing.
  ,template_regexp   : '[Tt][Ee][Mm][Pp][Ll][Aa][Tt][Ee]'
  ,template_regexp : '[Tt][Ee][Mm][Pp][Ll][Aa][Tt][Ee]'  
   // Regexp to recognize templates. Like "category" above; autolocalized for MW 1.16+, otherwise set manually here.
   // Regexp to recognize templates. Like "category" above; autolocalized for MW 1.16+, otherwise set manually here.
   // On the German Wikipedia, you might use '[Tt][Ee][Mm][Pp][Ll][Aa][Tt][Ee]|[Vv][Oo][Rr][Ll][Aa][Gg][Ee]'.
   // On the German Wikipedia, you might use '[Tt][Ee][Mm][Pp][Ll][Aa][Tt][Ee]'.
  ,template_categories : {}
  ,template_categories : {}
   // a list of categories which can be removed by removing a template
   // a list of categories which can be removed by removing a template
Zeile 140: Zeile 134:
   // If you don't have this at your wiki, or don't want this, set it to an empty object {}.
   // If you don't have this at your wiki, or don't want this, set it to an empty object {}.
  ,engine_names : {
  ,engine_names : {
     searchindex : 'Search index'
     searchindex : 'Indexsuche'
   ,pagelist    : 'Page list'
   ,pagelist    : 'Seitenliste'
   ,combined    : 'Combined search'
   ,combined    : 'Kombinierte Suche'
   ,subcat      : 'Subcategories'
   ,subcat      : 'Unterkategorien'
   ,parentcat  : 'Parent categories'
   ,parentcat  : 'Überkategorien'
   }
   }
  // Names for the search engines
  // Names for the search engines
,capitalizePageNames : true
  ,capitalizePageNames : true
   // Set to false if your wiki has case-sensitive page names. MediaWiki has two modes: either the first letter
   // Set to false if your wiki has case-sensitive page names. MediaWiki has two modes: either the first letter
   // of a page is automatically capitalized ("first-letter"; Category:aa == Category:Aa), or it isn't
   // of a page is automatically capitalized ("first-letter"; Category:aa == Category:Aa), or it isn't
Zeile 156: Zeile 150:
   // MediaWiki:Gadget-HotCat.js/local_defaults if you hotlink to the Commons-version, to ensure it is set even
   // MediaWiki:Gadget-HotCat.js/local_defaults if you hotlink to the Commons-version, to ensure it is set even
   // if that API query should fail for some strange reason.
   // if that API query should fail for some strange reason.
   // Stuff changeable by users:
   // Stuff changeable by users:
  ,bg_changed : '#F8CCB0'
  ,bg_changed : '#F8CCB0'
Zeile 174: Zeile 167:
  ,use_up_down : true
  ,use_up_down : true
   // If false, do not display the "up" and "down" links
   // If false, do not display the "up" and "down" links
,list_size : 5
  // Default list size
};
};


if (HotCat.isCommonsVersion && wgServer.indexOf ('/commons') < 0) {
importScript ('MediaWiki:Gadget-HotCat.js/' + wgUserLanguage);
  // We're running in some other wiki, which hotlinks to the Commons version. The other wiki can put local settings
// Localization hook to localize HotCat.messages.commit and HotCat.messages.multi_error. For German, the
  // in this file to override the Commons settings for all user languages. For instance, if on your wiki people do
// file would be "MediaWiki:Gadget-HotCat.js/de", and its contents could be for instance
  // 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
// HotCat.messages.commit      = 'Speichern';
  // English plural "Categories", and you should provide translations in wgContentLanguage of your wiki of all messages,
// HotCat.messages.ok          = 'OK';
  // tooltips, and of the engine names.  
// HotCat.messages.cancel      = 'Abbrechen';
  importScript ('MediaWiki:Gadget-HotCat.js/local_defaults');
// HotCat.messages.multi_error = 'Seitentext konnte nicht vom Server geladen werden. Die Änderungen können '
}
//                             +'leider nicht gespeichert werden.';
 
if (wgUserLanguage != 'en') {
  importScript ('MediaWiki:Gadget-HotCat.js/' + wgUserLanguage);
}
// Localization hook to localize HotCat messages, tooltips, and engine names for wgUserLanguage.


// No further changes should be necessary here.
// No further changes should be necessary here.
   
   
(function () {
(function () {
 
 
   // First auto-localize the regexps for the category and the template namespaces.
   // First auto-localize the regexps for the category and the template namespaces.
   if (typeof (wgFormattedNamespaces) != 'undefined') {
   if (typeof (wgFormattedNamespaces) != 'undefined') {
Zeile 400: Zeile 386:
         } else {
         } else {
           if (wikitext.length > 0 && wikitext.substr (wikitext.length - 1, 1) != '\n')
           if (wikitext.length > 0 && wikitext.substr (wikitext.length - 1, 1) != '\n')
            wikitext += '\n';
          if (wikitext.length > 0 && wikitext.substr (wikitext.length - 2, 1) != '\n')
             wikitext += '\n';
             wikitext += '\n';
           wikitext += newcatstring;
           wikitext += newcatstring;
Zeile 532: Zeile 520:
         function () {
         function () {
           if (request.readyState != 4) return;
           if (request.readyState != 4) return;
           if (request.status == 200 && request.responseText && /^\s*\{/.test(request.responseText)) {
           if (request.status == 200 && request.responseText && request.responseText.charAt(0) == '{') {
             var json = eval ('(' + request.responseText + ')');
             var json = eval ('(' + request.responseText + ')');
             if (json && json.query) {
             if (json && json.query) {
Zeile 585: Zeile 573:
     // it doesn't succeed), getting the page text. Perform the changes on the text, then construct
     // it doesn't succeed), getting the page text. Perform the changes on the text, then construct
     // a form to submit all this as a diff.
     // a form to submit all this as a diff.
     // Note: we have to do this even if we already got the page text. Other scripts may have already
     // Note: we have to do this even if we already got the page text. Other scripts may have already
     // edited the text, and we don't necessarily get an edit conflict with ourself. Use case: open
     // edited the text, and we don't necessarily get an edit conflict with ourself. Use case: open
     // a file page, add an image note through ImageAnnotator, then change the categories. If HotCat
     // a file page, add an image note through ImageAnnotator, then change the categories. If HotCat
Zeile 597: Zeile 585:
       request.open ('GET', uri, false); // Yes, synchronous
       request.open ('GET', uri, false); // Yes, synchronous
       request.send (null);
       request.send (null);
       if (request.status == 200 && request.responseText && /^\s*\{/.test (request.responseText)) {
       if (request.status == 200 && request.responseText && request.responseText.charAt(0) == '{') {
         setPage (eval ('(' + request.responseText + ')'));
         setPage (eval ('(' + request.responseText + ')'));
      } else {
        pageText = null;
       }
       }
    } else {
      pageText = null;
     }
     }
     if (pageText === null) {
     if (pageText === null) {
Zeile 751: Zeile 739:
       function () {
       function () {
         if (request.readyState != 4) return;
         if (request.readyState != 4) return;
         if (request.status != 200 || !request.responseText || !/^\s*\{/.test (request.responseText)) {
         if (request.status != 200) {
           callback (toResolve);
           callback (toResolve);
           return;
           return;
Zeile 857: Zeile 845:
       ,handler : // Function to convert result of uri into an array of category names
       ,handler : // Function to convert result of uri into an array of category names
           function (responseText, queryKey) {
           function (responseText, queryKey) {
             if (!/^\s*\[/.test (responseText)) return null;
             if (responseText.charAt (0) != '[') return null;
             var queryResult = eval ('(' + responseText + ')');
             var queryResult = eval ('(' + responseText + ')');
             if (  queryResult != null && queryResult.length == 2
             if (  queryResult != null && queryResult.length == 2
Zeile 884: Zeile 872:
       ,handler :  
       ,handler :  
           function (responseText, queryKey) {
           function (responseText, queryKey) {
             if (!/^\s*\{/.test (responseText)) return null;
             if (responseText.charAt (0) != '{') return null;
             var queryResult = eval ('(' + responseText + ')');
             var queryResult = eval ('(' + responseText + ')');
             if (queryResult && queryResult.query && queryResult.query.allpages) {
             if (queryResult && queryResult.query && queryResult.query.allpages) {
Zeile 905: Zeile 893:
       ,handler :  
       ,handler :  
           function (responseText, queryKey) {
           function (responseText, queryKey) {
             if (!/^\s*\{/.test (responseText)) return null;
             if (responseText.charAt (0) != '{') return null;
             var queryResult = eval ('(' + responseText + ')');
             var queryResult = eval ('(' + responseText + ')');
             if (queryResult && queryResult.query && queryResult.query.categorymembers) {
             if (queryResult && queryResult.query && queryResult.query.categorymembers) {
Zeile 921: Zeile 909:
       ,handler :  
       ,handler :  
           function (responseText, queryKey) {
           function (responseText, queryKey) {
             if (!/^\s*\{/.test (responseText)) return null;
             if (responseText.charAt (0) != '{') return null;
             var queryResult = eval ('(' + responseText + ')');
             var queryResult = eval ('(' + responseText + ')');
             if (queryResult && queryResult.query && queryResult.query.pages) {
             if (queryResult && queryResult.query && queryResult.query.pages) {
Zeile 940: Zeile 928:


   var suggestionConfigs = {
   var suggestionConfigs = {
     searchindex : {name: 'Search index', engines: ['opensearch'], cache: {}, show: true, temp: false, noCompletion : false}
     searchindex : {name: 'Search index', engines: ['opensearch'], cache: {}, show: true, temp: false}
   ,pagelist    : {name: 'Page list', engines: ['internalsearch'], cache: {}, show: true, temp: false, noCompletion : false}
   ,pagelist    : {name: 'Page list', engines: ['internalsearch'], cache: {}, show: true, temp: false}
   ,combined    : {name: 'Combined search', engines: ['opensearch', 'internalsearch'], cache: {}, show: true, temp: false, noCompletion : false}
   ,combined    : {name: 'Combined search', engines: ['opensearch', 'internalsearch'], cache: {}, show: true, temp: false}
   ,subcat      : {name: 'Subcategories', engines: ['subcategories'], cache: {}, show: true, temp: true, noCompletion : true}
   ,subcat      : {name: 'Subcategories', engines: ['subcategories'], cache: {}, show: true, temp: true}
   ,parentcat  : {name: 'Parent categories', engines: ['parentcategories'], cache: {}, show: true, temp: true, noCompletion : true}
   ,parentcat  : {name: 'Parent categories', engines: ['parentcategories'], cache: {}, show: true, temp: true}
   };
   };


Zeile 992: Zeile 980:
         }
         }
         this.linkSpan = make ('span');
         this.linkSpan = make ('span');
         this.linkSpan.className = 'noprint hotcatlink';
         this.linkSpan.className = 'noprint';
         var lk = make ('a'); lk.href = '#catlinks'; lk.onclick = bind (this.open, this);
         var lk = make ('a'); lk.href = '#catlinks'; lk.onclick = bind (this.open, this);
         lk.appendChild (make (HotCat.links.add, true)); lk.title = HotCat.tooltips.add;       
         lk.appendChild (make (HotCat.links.add, true)); lk.title = HotCat.tooltips.add;       
Zeile 1.061: Zeile 1.049:
       }
       }
       this.linkSpan = make ('span');
       this.linkSpan = make ('span');
       this.linkSpan.className = 'noprint hotcatlink';
       this.linkSpan.className = 'noprint';
       this.linkSpan.appendChild (this.normalLinks);
       this.linkSpan.appendChild (this.normalLinks);
       this.undelLink = make ('span');
       this.undelLink = make ('span');
Zeile 1.084: Zeile 1.072:
               evt = evt || window.event || window.Event; // W3C, IE, Netscape
               evt = evt || window.event || window.Event; // W3C, IE, Netscape
               var key = evt.keyCode || 0;
               var key = evt.keyCode || 0;
               if (key == 38 || key == 40 || key == 33 || key == 34) { // Up and down arrows, page up/down
               if (key == 38 || key == 40) { // Up and down arrows
                 // In case a browser doesn't generate keypress events for arrow keys...
                 // In case a browser doesn't generate keypress events for arrow keys...
                 if (this.keyCount == 0) return this.processKey (evt);
                 if (this.keyCount == 0) return this.processKey (evt);
               } else {
               } else {
                 if (key == 27) { // ESC
                 if (key == 27) this.resetKeySelection (); // ESC
                  if (!this.resetKeySelection ()) {
                    // No undo of key selection: treat ESC as "cancel".
                    this.cancel ();
                    return;
                  }
                }
                 // Also do this for ESC as a workaround for Firefox bug 524360
                 // Also do this for ESC as a workaround for Firefox bug 524360
                 // https://bugzilla.mozilla.org/show_bug.cgi?id=524360
                 // https://bugzilla.mozilla.org/show_bug.cgi?id=524360
Zeile 1.105: Zeile 1.087:
                 window.setTimeout (function () {self.textchange (dont_autocomplete);}, HotCat.suggest_delay);
                 window.setTimeout (function () {self.textchange (dont_autocomplete);}, HotCat.suggest_delay);
               }
               }
              return true;
             }
             }
           ,this
           ,this
Zeile 1.116: Zeile 1.097:
               this.keyCount = 0;
               this.keyCount = 0;
               // Handle return explicitly, to override the default form submission to be able to check for ctrl
               // Handle return explicitly, to override the default form submission to be able to check for ctrl
               if (this.lastKey == 13) this.accept (evt);
               if (evt.keyCode == 13) this.accept (evt);
              // Inhibit default behavior of ESC (revert to last real input in FF: we do that ourselves)
              if (this.lastKey == 27) return evtKill (evt);
              return true;
             }
             }
           ,this
           ,this
Zeile 1.134: Zeile 1.112:
       if (!noSuggestions) {
       if (!noSuggestions) {
         list = make ('select');
         list = make ('select');
         list.onclick    = bind ( function (e) { if (this.highlightSuggestion (0)) this.textchange (false, true); }, this);
         list.onclick    = bind (function () { if (this.setValueFromList ()) this.textchange (); }, this);
         list.ondblclick = bind (function (e) { if (this.highlightSuggestion (0)) this.accept (e); }, this);
         list.ondblclick = bind (function (e) { if (this.setValueFromList ()) this.accept (e); }, this);
         list.onchange = bind (function (e) { this.highlightSuggestion (0); this.text.focus(); }, this);
         list.onchange = bind (function (e) { this.setValueFromList (); this.text.focus(); }, this);
         list.onkeyup =
         list.onkeyup =
           bind (
           bind (
Zeile 1.193: Zeile 1.171:
       }
       }


       // Do not use type 'submit'; we cannot detect modifier keys if we do
       // Do not use type 'submit'; we cannot detect modifier keys if we do
       var OK = make ('input'); OK.type = 'button';
       var OK = make ('input'); OK.type = 'button';
       OK.value = button_label ('wpOkUploadLbl', HotCat.messages.ok);
       OK.value = button_label ('wpOkUploadLbl', HotCat.messages.ok);
Zeile 1.231: Zeile 1.209:
       if (this.list) this.list.style.display = 'none';
       if (this.list) this.list.style.display = 'none';
       if (this.engineSelector) this.engineSelector.style.display = 'none';
       if (this.engineSelector) this.engineSelector.style.display = 'none';
       this.currentCategory = this.lastSavedCategory;
       this.currentCategroy = this.lastSavedCategory;
       this.currentExists  = this.lastSavedExists;
       this.currentExists  = this.lastSavedExists;
       this.currentKey      = this.lastSavedKey;
       this.currentKey      = this.lastSavedKey;
Zeile 1.373: Zeile 1.351:
         return false;
         return false;
       }
       }
       if (!dontCheck && wgNamespaceNumber == 14 && v == wgTitle) {
       if (   !dontCheck
          && (  v == this.lastSavedCategory && key == this.lastSavedKey
              || wgNamespaceNumber == 14 && v == wgTitle
            )
        )
      {
         this.cancel ();
         this.cancel ();
         return false;
         return false;
Zeile 1.552: Zeile 1.535:
      
      
     // Internal operations
     // Internal operations
          
   
    setValueFromList : function (idx) {
      if (typeof (idx) == 'undefined') idx = this.list.selectedIndex;
      if (idx >= 0 && idx < this.list.options.length) {
         var v = this.text.value.split ('|');
        this.text.value = this.list.options[idx].text + (v.length > 1 ? '|' + v[1] : "");
        this.inputExists = true; // Might be wrong if from a dab list...
        if (this.icon) this.icon.src = HotCat.existsYes;
        return true;
      }
      return false;
    },
   
     selectEngine : function (engineName) {
     selectEngine : function (engineName) {
       if (!this.engineSelector) return;
       if (!this.engineSelector) return;
Zeile 1.648: Zeile 1.643:
       var engineName  = suggestionConfigs[this.engine] ? this.engine : 'combined';
       var engineName  = suggestionConfigs[this.engine] ? this.engine : 'combined';


      dont_autocomplete = dont_autocomplete || suggestionConfigs[engineName].noCompletion;
       if (suggestionConfigs[engineName].cache[v]) {
       if (suggestionConfigs[engineName].cache[v]) {
         this.showSuggestions (suggestionConfigs[engineName].cache[v], dont_autocomplete, v, engineName);
         this.showSuggestions (suggestionConfigs[engineName].cache[v], dont_autocomplete, v, engineName);
Zeile 1.691: Zeile 1.685:
       var v = this.text.value.split('|');
       var v = this.text.value.split('|');
       var key = v.length > 1 ? '|' + v[1] : "";
       var key = v.length > 1 ? '|' + v[1] : "";
       v = (HotCat.capitalizePageNames ? capitalize (v[0]) : v[0]);
       v = capitalize (v[0]);


       if (titles) {
       if (titles) {
Zeile 1.753: Zeile 1.747:
         return;
         return;
       }
       }
       var nofItems = (titles.length > HotCat.list_size ? HotCat.list_size : titles.length);
       var nofItems = (titles.length > 5 ? 5 : titles.length);
       if (nofItems <= 1) nofItems = 2;
       if (nofItems <= 1) nofItems = 2;
       this.list.size = nofItems;
       this.list.size = nofItems;
Zeile 1.773: Zeile 1.767:
       // Approximate calculation of maximum list size
       // Approximate calculation of maximum list size
       var maxListHeight = listh;
       var maxListHeight = listh;
       if (nofItems < HotCat.list_size) maxListHeight = (listh / nofItems) * HotCat.list_size;
       if (nofItems < 5) maxListHeight = (listh / nofItems) * 5;


       function scroll_offset (what) {
       function scroll_offset (what) {
Zeile 1.858: Zeile 1.852:
         var opt = make ('option') ;
         var opt = make ('option') ;
         opt.appendChild (make (titles[i], true));
         opt.appendChild (make (titles[i], true));
        opt.selected = completed && (i == 0);
         this.list.appendChild (opt);
         this.list.appendChild (opt);
       }
       }
Zeile 1.915: Zeile 1.908:


     processKey : function (evt) {
     processKey : function (evt) {
       var dir = 0;
       if (this.lastKey == 38 || this.lastKey == 40) { // Up and down arrows
      switch (this.lastKey) {
        if (this.list.style.display != 'none') {
        case 38: dir = -1; // Up arrow
          // List is visible, so there are suggestions
        case 40: if (dir == 0) dir = 1; // Down arrow
          this.highlightSuggestion (this.lastKey == 38 ? -1 : 1);
        case 33: if (dir == 0) dir = -HotCat.list_size; // Page up
          // Kill the event, otherwise some browsers (e.g., Firefox) may additionally treat an up-arrow as
        case 34: if (dir == 0) dir = HotCat.list_size; // Page down
          // "place the text cursor at the front", which we don't want here.
          if (this.list.style.display != 'none') {
          return evtKill (evt);
            // List is visible, so there are suggestions
        } else if (  this.keyCount <= 1
            this.highlightSuggestion (dir);
                  && (!this.callbackObj || this.callbackObj.callsMade == this.callbackObj.nofCalls)
            // Kill the event, otherwise some browsers (e.g., Firefox) may additionally treat an up-arrow
                  )
            // as "place the text cursor at the front", which we don't want here.
        {
            return evtKill (evt);
          // If no suggestions displayed, get them, unless we're already getting them.
          } else if (  this.keyCount <= 1
          this.textchange ();
                    && (!this.callbackObj || this.callbackObj.callsMade == this.callbackObj.nofCalls)
        }
                    )
          {
            // If no suggestions displayed, get them, unless we're already getting them.
            this.textchange ();
          }
          break;
        case 27: // ESC: inhibit default behavior (revert to last real input in FF: we do that ourselves)
          return evtKill (evt);
       }
       }
       return true;
       return true;
Zeile 1.942: Zeile 1.927:


     highlightSuggestion : function (dir) {
     highlightSuggestion : function (dir) {
       if (noSuggestions || !this.list || this.list.style.display == 'none') return false;
       if (noSuggestions || !this.list || this.list.style.display == 'none') return;
       var curr = this.list.selectedIndex;
       var curr = this.list.selectedIndex;
       var tgt  = -1;
       var tgt = curr < 0 ? 0 : curr + dir;
      if (dir == 0) {
      tgt = tgt < 0 ? 0 : tgt;
        if (curr < 0 || curr >= this.list.options.length) return false;
      if (tgt != curr && tgt < this.list.options.length) {
        tgt = curr;
         if (curr >= 0 && curr < this.list.options.length) this.list.options[curr].selected = false;
      } else {
        tgt = curr < 0 ? 0 : curr + dir;
        tgt = tgt < 0 ? 0 : tgt;
        if (tgt >= this.list.options.length) tgt = this.list.options.length - 1;
      }
      if (tgt != curr || dir == 0) {
         if (curr >= 0 && curr < this.list.options.length && dir != 0) this.list.options[curr].selected = false;
         this.list.options[tgt].selected = true;
         this.list.options[tgt].selected = true;
         // Get current input text
         // Get current input text
         var v = this.text.value.split('|');
         var v = this.text.value.split('|');
         var key = v.length > 1 ? '|' + v[1] : "";
         var key = v.length > 1 ? '|' + v[1] : "";
         var completed = this.autoComplete (this.list.options[tgt].text, this.lastRealInput, key, false);
         var completed = this.autoComplete (this.list.options[tgt].text, this.lastInput, key, false);
         if (!completed) {
         if (!completed) {
           this.text.value = this.list.options[tgt].text + key;
           this.text.value = this.list.options[tgt].text + key;
         }
         }
         this.lastInput = this.list.options[tgt].text;
         this.lastInput = this.list.options[tgt].text;
        this.inputExists = true; // Might be wrong if from a dab list...
        if (this.icon) this.icon.src = HotCat.existsYes;
        this.state = CategoryEditor.CHANGE_PENDING;
       }
       }
      return true;
     },
     },


     resetKeySelection : function () {
     resetKeySelection : function () {
       if (noSuggestions || !this.list || this.list.style.display == 'none') return false;
       if (noSuggestions || !this.list || this.list.style.display == 'none') return;
       var curr = this.list.selectedIndex;
       var curr = this.list.selectedIndex;
       if (curr >= 0 && curr < this.list.options.length) {
       if (curr >= 0 && curr < this.list.options.length) {
Zeile 1.979: Zeile 1.953:
         var v = this.text.value.split('|');
         var v = this.text.value.split('|');
         var key = v.length > 1 ? '|' + v[1] : "";
         var key = v.length > 1 ? '|' + v[1] : "";
         // ESC is handled strangely by some browsers (e.g., FF); somehow it resets the input value before
         this.text.value = this.lastRealInput + key;
        // our event handlers ever get a chance to run.
        var result = v[0] != this.lastInput;
        if (v[0] != this.lastRealInput) {
          this.text.value = this.lastRealInput + key;
          result = true;
        }
         this.lastInput = this.lastRealInput;
         this.lastInput = this.lastRealInput;
        return result;
       }
       }
      return false;
     }
     }


Zeile 2.036: Zeile 2.002:
           )
           )
       );
       );
    HotCat.list_size =    window.hotcat_list_size
                      || typeof (JSconfig) != 'undefined' && JSconfig.keys['HotCatListSize']
                      || HotCat.list_size;
    // Numeric input, make sure we have a numeric value
    HotCat.list_size = parseInt (HotCat.list_size, 10);
    if (isNaN (HotCat.list_size) || HotCat.list_size < 5) HotCat.list_size = 5;
    if (HotCat.list_size > 15) HotCat.list_size = 15;
     // Localize search engine names
     // Localize search engine names
     if (HotCat.engine_names) {
     if (HotCat.engine_names) {
Zeile 2.187: Zeile 2.146:


   var initialized = false;
   var initialized = false;
  var setupTimeout = null;


   function setup () {
   function setup () {
     if (initialized) return;
     if (initialized) return;
     initialized = true;
     initialized = true;
    if (setupTimeout) {
      window.clearTimeout (setupTimeout);
      setupTimeout = null;
    }
     // Find the category bar, or create an empty one if there isn't one. Then add -/+- links after
     // Find the category bar, or create an empty one if there isn't one. Then add -/+- links after
     // each category, and add the + link.
     // each category, and add the + link.
Zeile 2.308: Zeile 2.262:
     } else {
     } else {
       var url = wgServer + wgScriptPath + '/api.php?format=json&callback=HotCat.start&action=query&titles='
       var url = wgServer + wgScriptPath + '/api.php?format=json&callback=HotCat.start&action=query&titles='
               + encodeURIComponent (wgPageName)
               + encodeURIComponent (wgPageName) + '&prop=info%7Crevisions&rvprop=content%7Ctimestamp&meta=siteinfo';
              + '&prop=info%7Crevisions&rvprop=content%7Ctimestamp&meta=siteinfo&rvlimit=1&rvstartid='
              + wgCurRevisionId;
       var s = make ('script');
       var s = make ('script');
       s.src = url;
       s.src = url;
Zeile 2.316: Zeile 2.268:
       HotCat.start = function (json) { setPage (json); setup (); };
       HotCat.start = function (json) { setPage (json); setup (); };
       document.getElementsByTagName ('head')[0].appendChild (s);
       document.getElementsByTagName ('head')[0].appendChild (s);
       setupTimeout = window.setTimeout (setup, 4000); // 4 sec, just in case getting the wikitext takes longer.
       window.setTimeout (setup, 4000); // 4 seconds. Just in case getting the wikitext takes longer.
     }
     }
   }
   }