Weitere Optionen
Code aus Commons - mal sehen ob das unter 1.16 funktioniert |
KKeine Bearbeitungszusammenfassung |
||
| Zeile 2: | Zeile 2: | ||
/* | /* | ||
HotCat V2. | 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). | ||
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 = { | ||
// Localize these messages to the main language of your wiki. | // Localize these messages to the main language of your wiki. | ||
messages : | |||
{ cat_removed : ' | { cat_removed : 'Entferne [[Kategorie:$1]]' | ||
,template_removed : ' | ,template_removed : 'Entferne {{[[Kategorie:$1|$1]]}}' | ||
,cat_added : ' | ,cat_added : 'Ergänze [[Kategorie:$1]]' | ||
,cat_keychange: ' | ,cat_keychange: 'neuer Sortierschlüssel für [[Kategorie:$1]]: ' | ||
,cat_notFound : ' | ,cat_notFound : 'Kategorie "$1" konnte nicht gefunden werden' | ||
,cat_exists : ' | ,cat_exists : 'Kategorie "$1" bereits enthalten; nicht ergänzt' | ||
,cat_resolved : ' ( | ,cat_resolved : ' (Weiterleitung [[Kategorie:$1]] aufgelöst)' //wird nicht für dewiki benötigt | ||
,uncat_removed: ' | ,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 : '' | ||
// 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 | ,multi_change : '$1 Kategorien' | ||
// $1 is replaced by a number | // $1 is replaced by a number | ||
,commit : ' | ,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 : '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 : ' | ,multi_error : 'Quelltext konnte nicht abrufen werden. Deine Änderungen wurden deshalb nicht gespeichert.' | ||
// 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_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 : 'Kategorien' | ||
// Plural of category_canonical | // Plural of category_canonical | ||
,disambig_category : | ,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 : | ,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: ' | change: 'Ändern' | ||
,remove: ' | ,remove: 'Entfernen' | ||
,add: ' | ,add: 'Neue Kategorie hinzufügen' | ||
,restore: ' | ,restore: 'Wiederherstellen' | ||
,undo: ' | ,undo: 'Zurücksetzen' | ||
,down: ' | ,down: 'durch Unterkategorie ersetzen' | ||
,up: ' | ,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 : ' | ,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) != ' | || typeof (wgNamespaceIds) != 'unknown' | ||
&& ( wgNamespaceNumber == wgNamespaceIds['creator'] | && ( wgNamespaceNumber == wgNamespaceIds['creator'] | ||
|| wgNamespaceNumber == wgNamespaceIds['timedtext'] | || wgNamespaceNumber == wgNamespaceIds['timedtext'] | ||
| Zeile 125: | Zeile 119: | ||
); | ); | ||
} | } | ||
,uncat_regexp : | ,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 | ,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 | // 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 : ' | searchindex : 'Indexsuche' | ||
,pagelist : ' | ,pagelist : 'Seitenliste' | ||
,combined : ' | ,combined : 'Kombinierte Suche' | ||
,subcat : ' | ,subcat : 'Unterkategorien' | ||
,parentcat : ' | ,parentcat : 'Überkategorien' | ||
} | } | ||
// Names for the search engines | |||
,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 | ||
}; | }; | ||
importScript ('MediaWiki:Gadget-HotCat.js/' + wgUserLanguage); | |||
// Localization hook to localize HotCat.messages.commit and HotCat.messages.multi_error. For German, the | |||
// file would be "MediaWiki:Gadget-HotCat.js/de", and its contents could be for instance | |||
// | |||
// HotCat.messages.commit = 'Speichern'; | |||
// HotCat.messages.ok = 'OK'; | |||
// HotCat.messages.cancel = 'Abbrechen'; | |||
// HotCat.messages.multi_error = 'Seitentext konnte nicht vom Server geladen werden. Die Änderungen können ' | |||
// +'leider nicht gespeichert werden.'; | |||
// | |||
// 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 && | 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 && | if (request.status == 200 && request.responseText && request.responseText.charAt(0) == '{') { | ||
setPage (eval ('(' + request.responseText + ')')); | setPage (eval ('(' + request.responseText + ')')); | ||
} | } | ||
} 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 | 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 ( | 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 ( | 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 ( | 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 ( | 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 | searchindex : {name: 'Search index', engines: ['opensearch'], cache: {}, show: true, temp: false} | ||
,pagelist : {name: 'Page list', engines: ['internalsearch'], cache: {}, show: true, temp | ,pagelist : {name: 'Page list', engines: ['internalsearch'], cache: {}, show: true, temp: false} | ||
,combined : {name: 'Combined search', engines: ['opensearch', 'internalsearch'], cache: {}, show: true, temp | ,combined : {name: 'Combined search', engines: ['opensearch', 'internalsearch'], cache: {}, show: true, temp: false} | ||
,subcat : {name: 'Subcategories', engines: ['subcategories'], cache: {}, show: true, temp | ,subcat : {name: 'Subcategories', engines: ['subcategories'], cache: {}, show: true, temp: true} | ||
,parentcat : {name: 'Parent categories', engines: ['parentcategories'], cache: {}, show: true, temp | ,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 | 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 | 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 | 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) | if (key == 27) this.resetKeySelection (); // ESC | ||
// 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); | ||
} | } | ||
} | } | ||
,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 ( | if (evt.keyCode == 13) this.accept (evt); | ||
} | } | ||
,this | ,this | ||
| Zeile 1.134: | Zeile 1.112: | ||
if (!noSuggestions) { | if (!noSuggestions) { | ||
list = make ('select'); | list = make ('select'); | ||
list.onclick = bind ( function ( | list.onclick = bind (function () { if (this.setValueFromList ()) this.textchange (); }, this); | ||
list.ondblclick = bind (function (e) { if (this. | list.ondblclick = bind (function (e) { if (this.setValueFromList ()) this.accept (e); }, this); | ||
list.onchange = bind (function (e) { 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. | 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'; | ||
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 = | v = capitalize (v[0]); | ||
if (titles) { | if (titles) { | ||
| Zeile 1.753: | Zeile 1.747: | ||
return; | return; | ||
} | } | ||
var nofItems = (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 < | 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)); | ||
this.list.appendChild (opt); | this.list.appendChild (opt); | ||
} | } | ||
| Zeile 1.915: | Zeile 1.908: | ||
processKey : function (evt) { | processKey : function (evt) { | ||
if (this.lastKey == 38 || this.lastKey == 40) { // Up and down arrows | |||
if (this.list.style.display != 'none') { | |||
// List is visible, so there are suggestions | |||
this.highlightSuggestion (this.lastKey == 38 ? -1 : 1); | |||
// 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); | |||
} else if ( this.keyCount <= 1 | |||
&& (!this.callbackObj || this.callbackObj.callsMade == this.callbackObj.nofCalls) | |||
) | |||
{ | |||
// If no suggestions displayed, get them, unless we're already getting them. | |||
this.textchange (); | |||
} | |||
} | } | ||
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 | if (noSuggestions || !this.list || this.list.style.display == 'none') return; | ||
var curr = this.list.selectedIndex; | var curr = this.list.selectedIndex; | ||
var | var tgt = curr < 0 ? 0 : curr + dir; | ||
tgt = tgt < 0 ? 0 : tgt; | |||
if (tgt != curr && tgt < this.list.options.length) { | |||
if (curr >= 0 && curr < this.list.options.length) this.list.options[curr].selected = false; | |||
if (curr >= 0 && curr < this.list.options.length | |||
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. | 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; | ||
} | } | ||
}, | }, | ||
resetKeySelection : function () { | resetKeySelection : function () { | ||
if (noSuggestions || !this.list || this.list.style.display == 'none') return | 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] : ""; | ||
this.text.value = this.lastRealInput + key; | |||
this.lastInput = this.lastRealInput; | this.lastInput = this.lastRealInput; | ||
} | } | ||
} | } | ||
| Zeile 2.036: | Zeile 2.002: | ||
) | ) | ||
); | ); | ||
// 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; | ||
function setup () { | function setup () { | ||
if (initialized) return; | if (initialized) return; | ||
initialized = true; | initialized = true; | ||
// 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'; | ||
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); | ||
window.setTimeout (setup, 4000); // 4 seconds. Just in case getting the wikitext takes longer. | |||
} | } | ||
} | } | ||