Benutzer:Innotata/vector.js
Erscheinungsbild
Hinweis: Leere nach dem Veröffentlichen den Browser-Cache, um die Änderungen sehen zu können.
- Firefox/Safari: Umschalttaste drücken und gleichzeitig Aktualisieren anklicken oder entweder Strg+F5 oder Strg+R (⌘+R auf dem Mac) drücken
- Google Chrome: Umschalttaste+Strg+R (⌘+Umschalttaste+R auf dem Mac) drücken
- Edge: Strg+F5 drücken oder Strg drücken und gleichzeitig Aktualisieren anklicken
if(mw.config.get('wgNamespaceNumber') == 6) {
if(wgAction == 'edit' || wgAction == 'submit') {
addOnloadHook(function () {
mw.util.addPortletLink('p-cactions','javascript:doNcd()','ncd','ca-ncd');
mw.util.addPortletLink('p-cactions','javascript:doMtc()','mtc','ca-mtc');
mw.util.addPortletLink('p-cactions','javascript:doCH2()','ch','ca-ch');
});
} else {
addOnloadHook(function () {
var url = mw.config.get('wgServer') + mw.config.get('wgScript') + '?title=' + encodeURIComponent(mw.config.get('wgPageName')) + '&action=edit';
mw.util.addPortletLink('p-cactions',url + '&autoncd=true','ncd','ca-ncd');
mw.util.addPortletLink('p-cactions',url + '&automtc=true','mtc','ca-mtc');
var url = 'http://toolserver.org/~magnus/commonshelper.php?interface=en&image=' + encodeURIComponent(wgTitle) + '&lang=de';
mw.util.addPortletLink('p-cactions',url + '','ch','ca-ch');
});
}
}
if(queryString('autoncd')) addOnloadHook(function() { doNcd(); })
function doNcd() {
var txt = document.getElementById('wpTextbox1');
if(!txt) return;
txt.value = txt.value.replace(/\{\{[\s\t\n\r]*(mtc|Commonsfähig|commonsfähig|copy[ -_]to[ -_]wikimedia[ -_]commons)[\s\t\n\r]*\}\}/ig,'');
txt.value = '{' + '{' + 'NowCommons}}\n\n' + txt.value;
document.getElementById('wpSummary').value += ' Markiere mit [[Vorlage:NowCommons]]';
document.getElementById('wpSave').click();
}
if(queryString('automtc')) addOnloadHook(function() { doMtc(); })
function doMtc() {
var txt = document.getElementById('wpTextbox1');
if(!txt) return;
txt.value = '{' + '{' + 'commonsfähig}}\n\n' + txt.value;
document.getElementById('wpSummary').value += ' {'+'{commonsfähig}}';
document.getElementById('wpSave').click();
}
function queryString(p) {
var re = RegExp('[&?]' + p + '=([^&]*)');
var matches;
if (matches = re.exec(document.location)) {
try {
return decodeURI(matches[1]);
} catch (e) {
}
}
return null;
}