Content deleted Content added
No edit summary |
No edit summary |
||
Line 2:
function defaultsort() {
var txt = document.editform.wpTextbox1
var sortkey = '';
// create an array of all category links
var catlinks = txt.value.match(/\[\[\s*((C|K)at(e|é)gor(y|i|ie|ia|ía|ija|io)|Кат(е|э)гор(ия|ија|ія|ыя)|Luokka|Flokkur|Κατηγορία)\s*:.*\]\]/ig);▼
if (txt.value.match(/\{\{\s*defaultsort/i)) {
alert('There\'s already a defaultsort statement!');
return;
▲ var catlinks = txt.match(/\[\[\s*((C|K)at(e|é)gor(y|i|ie|ia|ía|ija|io)|Кат(е|э)гор(ия|ија|ія|ыя)|Luokka|Flokkur|Κατηγορία)\s*:.*\]\]/ig);
}
if (!catlinks) {
Line 24:
}
// strip the '|' and any trailing spaces
if (i == 0) {
sortkey = sk;
Line 35:
}
// Now that we know that everything is OK, we can proceed with modifying the content of the editbox
txt.value=txt.value.replace(catlinks[0], "{{DEFAULTSORT:"+sortkey+"}}\n"+catlinks[0]);
for (i=0; i< catlinks.length; i++) {
subst = catlinks[i].replace(/\|[^\]]+/,"");
txt.value=txt.value.replace(catlinks[i], subst);
}
}
|