Content deleted Content added
mNo edit summary |
mNo edit summary |
||
(17 intermediate revisions by the same user not shown) | |||
Line 5:
if(mw.config.get("wgAction") !== "edit") return;
window.rc_refs = [];▼
if(debug) console.log("Running");
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.");▼
crunchRefs();▼
}▼
}
});
function run()
{
}
function crunchRefs()
Line 38 ⟶ 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 54 ⟶ 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;
}
});
|