Content deleted Content added
mNo edit summary |
mNo edit summary |
||
(16 intermediate revisions by the same user not shown) | |||
Line 5:
if(mw.config.get("wgAction") !== "edit") return;
const debug = false;
console.log("Running RefCruncher");▼
window.rc_refsCrunched = false;▼
window.rc_refs = [];▼
rc_refs = [];
// Add key handler.
window.addEventListener("keydown", e =>
{
if(e.ctrlKey && e.altKey && e.which == 82)
{
run();
if(window.rc_refsCrunched)▼
{▼
uncrunchRefs();▼
window.rc_refsCrunched = false;▼
}▼
else▼
{▼
console.log("Crunching refs.");▼
}▼
}
});
function run()
{
}
function crunchRefs()
Line 40 ⟶ 42:
var counter = 0;
text = text.replace(/(<ref.*?\/>)|(<ref.*?>(.|\s)*?<\/ref>)/g,
{
rc_refs.push(match);
return `{ref#${counter++}}`;▼
});
txtarea.value = text;
return true;
}
Line 56 ⟶ 62:
var text = txtarea.value;
text = text.replace(/
{
if(debug) console.log(match);
return window.rc_refs.pop(Number(p1));▼
});
txtarea.value = text;
return false;
}
});
|