//<source lang=javascript>
// Exempt
function exemptNld(autosave){
document.editform.wpTextbox1.value = document.editform.wpTextbox1.value.replace(/{{no license([^\}]*?)}}/g, '{{No license$1|del=exempt}}');
document.editform.wpSummary.value = 'File exempt from 'no license' deletion.';
document.editform.wpMinoredit.checked = true;
if(autosave){ document.editform.submit(); }
}
// Remover
function removeNld(autosave){
document.editform.wpTextbox1.value = document.editform.wpTextbox1.value.replace(/{{no license([^\}]*?)}}/g, '');
document.editform.wpSummary.value = 'Remove 'no license' tag.';
document.editform.wpMinoredit.checked = true;
if(autosave){ document.editform.submit(); }
}
// [review] link inserter
addOnloadHook(function(){
var targets = getElementsByClassName(document, 'div', 'NL');
if(targets.length === 0) return true;
targets[0].style.textAlign = 'center'; // center the text
var exemptlink = wgScript+"?title="+encodeURIComponent(mw.config.get('wgPageName'))+"&action=edit&functionName=exemptNld";
var removerlink = wgScript+"?title="+encodeURIComponent(mw.config.get('wgPageName'))+"&action=edit&functionName=removeNld";
targets[0].innerHTML = '[<a href="'+exemptlink+'">exempt</a>] [<a href="'+removerlink+'">remove</a>]';
return true;
}
});
// Link/Button maker
function addFunction(functionNameString, buttonDisplayName, buttonID){
if (getURLParamValue('functionName')==functionNameString){
addOnloadHook(function(){
eval(functionNameString+"(true)");
});
}
var _href;
if (wgAction=="edit"){
_href = "javascript:"+functionNameString+"(true);";
} else {
_href = wgScript+"?title="+encodeURIComponent(mw.config.get('wgPageName'))+"&action=edit&functionName="+functionNameString;
}
// Add buttons
addOnloadHook(function(){ mw.util.addPortletLink('p-cactions', _href, buttonDisplayName, 'ca-'+buttonID, '', null, 0); });
addOnloadHook(function(){ mw.util.addPortletLink('p-tb', _href, buttonDisplayName, 'tb-'+buttonID, '', null, 0); });
}
// Fire it off:
addFunction("exemptNld", "exempt", "NL");
addFunction("removeNld", "remove", "NL");
//</source>