Content deleted Content added
PleaseStand (talk | contribs) avoid doing the impossible: stopping the unload of the page |
PleaseStand (talk | contribs) avoid extending the built-in String object |
||
Line 85:
(function(){
// "Semi-global" variables (function-scoped variables private to this script)
var editForm, refsDiv, refsH2, mainTextbox, refsTextbox, randPrefix, messages,
refsButton, convertButton, complete, unloadHandlerRegistered = false;
Line 94:
}
▲// Add support for setting a slice of a string.
▲String.prototype.PsSetSlice = function(replacement, indexFrom, indexTo) {
if(typeof indexTo == "undefined") {
return
}
return
}
//
function htmlUnquote(t) {
// Let's use the browser's functionality for the hard work,
// since MediaWiki/PHP supports many different HTML entities.
// (Note: innerHTML is not W3C-standard)
var d = window.document.createElement("div");
d.innerHTML = "<input value=" +
return d.firstChild.value;
}
//
// double quotes depending on which is shorter.
function htmlQuote(t) {
// Escape ampersands
var s =
// Try both kinds of quotes
var sQ = "'" + s.replace(/'/g, "'") + "'",
Line 126 ⟶ 122:
// Choose the shorter, preferring double quotes if equal in length
return (sQ.length < dQ.length ? sQ : dQ);
}
// OBJECTS
Line 175 ⟶ 171:
var attributes = {}, results;
while((results = attParseRegex.exec(this.parsedRef[1]))) {
attributes[results[1].toLowerCase()] = htmlUnquote(results[2]
}
return attributes;
Line 234 ⟶ 230:
refName = randPrefix + (++unnamedRefs).toString(10);
// Change the corresponding ref code
refLong = "<ref name=" +
parser.parsedRef[1] + parser.parsedRef[2];
} else {
Line 272 ⟶ 268:
} else if(!refGroup.length) {
refShort = refPreferred + "name=" +
} else {
refShort = refPreferred + "name=" +
" " + "group=" +
}
// Otherwise, is the current longcode not empty?
Line 286 ⟶ 282:
if(!refGroup.length) {
refShort = refPreferred + "name=" +
} else {
refShort = refPreferred + "name=" +
" " + "group=" +
}
} else {
Line 301 ⟶ 297:
}
// Replace the long code with the short code
scanner.wikiText = setSlice(scanner.wikiText
scanner.refScanRegex.lastIndex - ref.length,
scanner.refScanRegex.lastIndex);
Line 407 ⟶ 403:
// Replace the short code with the long code
scanner.wikiText = setSlice(scanner.wikiText
scanner.refScanRegex.lastIndex - ref.length,
scanner.refScanRegex.lastIndex);
Line 446 ⟶ 442:
for(refName in result.unusedRefs) {
if(has(result.unusedRefs, refName)) {
unusedRefNamesQuoted.push(
}
}
Line 560 ⟶ 556:
return false;
}
group =
// The first button should disappear
|