Content deleted Content added
PleaseStand (talk | contribs) m writing the code a bit more concisely |
PleaseStand (talk | contribs) adding a compatibility function for use by scripts like ajaxPreview |
||
Line 86:
// Semi-global variables (private to this script)
var editForm
// Extend the string object with new methods
Line 117:
var s = this.replace(/\&/g, "&");
// Try both kinds of quotes
var sQ = "'" + s.replace(/'/g, "'") + "'"
// Choose the shorter, preferring double quotes if equal in length
return (sQ.length < dQ.length ? sQ : dQ);
Line 192:
// Create a random prefix for autogenerated ref names.
// in theory this has a 1/1296 probability of collision - extremely low
var prefixChars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
(prefixChars.length * prefixChars.length));
randPrefix = messages.autoWord + prefixChars.charAt(Math.floor(randNo /
Line 203:
// Variables for the main code
var scanner = new RefScanner(argWikiText)
ref, refStored, parser, attributes, refName, refLong, refShort,
▲ var refCodes = []; var refEmpty; var emptyRefsWarningGiven = false;
// Disable the empty refs warning (see below) if the user has disabled it
Line 325 ⟶ 323:
// Variables for the main code
var scanner
// First, we build an associative array of all the ref codes
Line 422 ⟶ 420:
// from the DOM and then inserting it again.
function clearUndoHistory(ta) {
var pn = ta.parentNode, ns = ta.nextSibling;
pn.insertBefore(pn.removeChild(ta), ns);
}
Line 429 ⟶ 426:
function submitHandler() {
// Local variables
var result
// Do the actual integration work
Line 607 ⟶ 604:
return false;
}
function getEditboxContents() { // ajaxPreview compatibility
if(editForm.onsubmit == submitHandler) {
return integrateRefs(mainTextbox.value, refsTextbox.value,
randPrefix, complete).wikiText;
} else {
return mainTextbox.value;
}
}
// Leave a global for ajaxPreview to use.
window.getEditboxContents = getEditboxContents;
function loadHandler() { // This function is called on page load
Line 660 ⟶ 670:
}
}
// Register load handler
|