מדיה ויקי:Gadget-HotCat.js: הבדלים בין גרסאות בדף
Now it works. Needed to ensure that the text field has the focus. |
Fix for category suggestions containing colons |
||
| שורה 190: | שורה 190: | ||
function hotcat_is_on_blacklist ( cat_title ) { | function hotcat_is_on_blacklist ( cat_title ) { | ||
if ( !cat_title ) return 0 ; | if ( !cat_title ) return 0 ; | ||
cat_title = cat_title.split(":",2).pop() ; | // cat_title = cat_title.split(":",2).pop() ; // Not needed anymore: we work without 'Category:' | ||
for ( var i = 0 ; i < hotcat_modify_blacklist.length ; i++ ) { | for ( var i = 0 ; i < hotcat_modify_blacklist.length ; i++ ) { | ||
if ( cat_title.substr ( 0 , hotcat_modify_blacklist[i].length ) == hotcat_modify_blacklist[i] ) return 1 ; | if ( cat_title.substr ( 0 , hotcat_modify_blacklist[i].length ) == hotcat_modify_blacklist[i] ) return 1 ; | ||
| שורה 611: | שורה 611: | ||
var xml = request.responseXML ; | var xml = request.responseXML ; | ||
if ( xml == null ) return ; | if ( xml == null ) return ; | ||
var pages = xml.getElementsByTagName( "p" ) ; | var pages = xml.getElementsByTagName( "p" ) ; // results are *with* namespace here | ||
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"). | // Remove the namespace. No hardcoding of 'Category:', please, other Wikis may have | ||
// local names ("Kategorie:" on de-WP, for instance). Also don't break on category | |||
// names containing a colon | |||
var s = pages[i].getAttribute("title"); | |||
s = s.substring (s.indexOf (':') + 1); | |||
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 ) ; | ||