User:Frietjes/addcheckforunknownparameters.js: Difference between revisions

Content deleted Content added
No edit summary
features
Line 11:
function wpBuildCheckForUnknownParameters()
{
var mycontent = document.getElementById('wpTextbox1');
// Copy the contents of the text window so we can modify it without problems
var mytxt = document.getElementById('wpTextbox1')mycontent.value;
var mytxt2 = document.getElementById('wpTextbox1')mycontent.value;
// Remove {PAGENAME}, {BASEPAGENAME}, ...
mytxt = mytxt.replace(/\{\{(?:PAGENAME|BASEPAGENAME|FULLPAGENAME|CURRENTYEAR)\}\}/g, '');
Line 65 ⟶ 66:
alert('Found ' + plist.length + ' unique keys');
}
var alphasort = confirm('Sort parameters alphabetically?');
// Sort
if(alphasort == true) {
plist = plist.sort(function(a,b) { return klist[a] - klist[b] } );
plist.sort();
} else {
plist = plist.sort(function(a,b) { return klist[a] - klist[b] } );
}
// Finally, build the blank template
mytxt = '{' + '{#invoke:'
Line 79 ⟶ 85:
mytxt = mytxt + "}}";
alert( mytxt );
document.getElementById('wpTextbox1')mycontent.value = document.getElementById('wpTextbox1')mycontent.value + mytxt;
// Move up
mycontent.value = mycontent.value.replace(/([\r\n \t][\r\n \t]*)(\{\{#invoke:Check for unknown parameters(?:\{\{[^{}]*\}\}|[^{}])*\}\})/gi, '$2$1');
mycontent.value = mycontent.value.replace(/(<noinclude>(?:<!--[^<>]*-->|[^<>])*<\/noinclude>)(\{\{#invoke:Check for unknown parameters(?:\{\{[^{}]*\}\}|[^{}])*\}\})/gi, '$2$1');
mycontent.value = mycontent.value.replace(/([\r\n \t][\r\n \t]*)(\{\{#invoke:Check for unknown parameters(?:\{\{[^{}]*\}\}|[^{}])*\}\})/gi, '$2$1');
}
// -------------------------------------------------------------------------------- //