Content deleted Content added
Waldyrious (talk | contribs) ´sp |
Waldyrious (talk | contribs) Several fixes, and add documentation |
||
Line 2:
var txt = document.editform.wpTextbox1;
originalCiteTemplates = txt.value.match(/\{\{
tweakedCiteTemplates = originalCiteTemplates.slice();
for(i in originalCiteTemplates) {
if(vertical) {
// Clean up the parameters and calculate the length of the longest one
maxWidth = 0;
for(j in
tweakedParams[j] = originalParams[j].match(/[a-z1-9]+/)[0] // remove the delimiters and keep only the parameter string
maxWidth = (
}
maxWidth++; // We need an extra one because Array(n).join(' ') will produce a string with n-1 chars
for(k in paramsLong) {▼
numSpaces = maxWidth + 2 - paramsShort[k].length;▼
// Generate
tweakedCiteTemplates[i] = tweakedCiteTemplates[i].replace (paramsLong[k], aligned);▼
alignedParam = "\n | " + tweakedParams[k] + Array(numSpaces).join(" ") + " = ";
▲ tweakedCiteTemplates[i] = tweakedCiteTemplates[i].replace (
}
// Replace the original templates with the tweaked versions
txt = txt.replace(originalCiteTemplates[i], tweakedCiteTemplates[i].replace(/\}\}/,"\n}}")); // The replace() adds a newline to finish the alignment
} else {
txt.value = txt.value.replace(originalCiteTemplates[i],
tweakedCiteTemplates[i].replace(/\n/g, "") // Remove newlines
.replace(/ *\| */g, " |") // Normalize spaces before the pipes...
.replace(/ *= */g, " = ")); // ...and after the equal signs
}
}
|