User:Brackenheim/Personality rights.js
Jump to navigation
Jump to search
Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
Documentation for this user script can be added at User:Brackenheim/Personality rights. |
- Report page listing warnings and errors.
//<nowiki>
// get URL parameters (used for page type variables)
var UrlParameters = new Array ();
readparams();
function readparams() {
var asReadInUrlParameters;
var asReadInUrlParameter;
// Get URL parameters
asReadInUrlParameters = location.search.substring(1, location.search.length).split("&");
for (i = 0; i < asReadInUrlParameters.length; i++) {
asReadInUrlParameter = asReadInUrlParameters[i].split("=");
UrlParameters[decodeURIComponent(asReadInUrlParameter[0])] = decodeURIComponent(asReadInUrlParameter[1]);
}
}
function newtext (subj,text,wo)
{ //wo=1 : Text austauschen
//wo=2 : Text am Ende anhängen
//wo=3 : Text vorne Einfügen
if (subj > "") {
if (document.editform.wpSummary.value > "") document.editform.wpSummary.value += ", ";
document.editform.wpSummary.value = document.editform.wpSummary.value + subj;
}
switch (wo) {
case 1 : document.editform.wpTextbox1.value=text+'\n'; break;
case 2 : document.editform.wpTextbox1.value=document.editform.wpTextbox1.value+'\n'+text;break;
case 3 : document.editform.wpTextbox1.value=text+'\n'+document.editform.wpTextbox1.value;break;
}
document.editform.wpTextbox1.focus();
}
var isEdit = ((UrlParameters['action']=='edit') || (UrlParameters['action']=='submit'));
function addpersonalityrightsbutton() {
mediaWiki.util.addPortletLink("p-tb", "javascript:addpersonalityrights();", "Personality rights" , "p-impart", "Vorlage:Personality rights ergänzen", "");
}
if (mw.config.get('wgCanonicalNamespace') == 'File') $(addpersonalityrightsbutton);
function addpersonalityrights() {
if (!isEdit) {
location.href = "//commons.wikimedia.org/w/index.php?title=" + wgPageName + "&action=edit§ion=2";
} else {
addpersonalityrights2();
}
}
function addpersonalityrights2(type) {
newtext("+[[Template:Personality rights]]","{{Personality rights}}",3);
var regexp = document.editform.wpTextbox1.value.match(/(={2,}[^\n]*\n)/g);
var lastheadline = RegExp.$1;
}
if (UrlParameters["addimpart"]) { window.setTimeout(function() { $(addpersonalityrights2); }, 500); }
//</nowiki>