User:Erutuon/scripts/footnoteCleanup.js: Difference between revisions

Content deleted Content added
m Erutuon moved page User:Erutuon/footnoteCleanup.js to User:Erutuon/scripts/footnoteCleanup.js: Placing all scripts in the same path
declare function only if necessary; fiddle with variable scope
Line 4:
*/
 
varconst namespaceNumber = mw.config.values.wgNamespaceNumber;
 
// Add a link just above the edit box, if you're in the main namespace.
Line 14:
$("#editform").prepend('<div id="wikitext-cleanup-button-wrapper"></div>');
$("#wikitext-cleanup-button-wrapper")
.append(`<div id="footnote-cleanup" class="wikitext-cleanup-button">clean up footnotes</div>`);
$("#footnote-cleanup")
.click(cleanUpFootnotes);
}
 
function var cleanUpFootnotes = function ()
{
var textbox = $("#wpTextbox1");
if ( textbox )
{
var oldContentstextbox = textbox.val$("#wpTextbox1");
if ( !textbox )
return;
const oldContents = textbox.val();
var contents = oldContents;
Line 42 ⟶ 43:
{
escaped[i] = match;
var replacement = "%%" + i + "%%";
i += 1;
return replacement;
Line 138 ⟶ 139:
var addition = "made sure refs are after punctuation with [[User:Erutuon/footnoteCleanup.js|JavaScript]]; see [[WP:REFPUNC]]";
const afterSectionName = summary.match(/^(?:\/\*[^\*]+\*\/)?\s*(.+)/);
if ( afterSectionName && afterSectionName[1].length > 1 )
Line 151 ⟶ 152:
}
);
};
}