User:PleaseStand/segregate-refs-dev.js: Difference between revisions

Content deleted Content added
 
added code to warn user of empty first occurrence of a ref
Line 39:
buttonStyle: "background: #dfd;",
autoWord: "Auto",
emptyRefsWarning: "IMPORTANT: This page includes one or more named " +
"footnotes of which the first occurrence(s) have no contents, which is " +
"not best practice.\n\n" +
"BEFORE concluding from the footnotes list that a ref is in fact empty, " +
"please manually check all identically-named ref tags for the contents." +
"\n\nDo you acknowledge this limitation of the script?",
refsHeader: "Inline footnotes"
};
Line 158 ⟶ 164:
var unnamedRefs = 0; var refNames = {}; var ref;
var parser; var attributes; var refName; var refLong; var refShort;
var refCodes = []; var emptyRefsWarningGiven = false;
while((ref = scanner.getRef())) {
Line 177 ⟶ 183:
refName = attributes.name;
refLong = ref;
// Since this script only checks the first occurrence of a ref
// for contents, inform the user of this limitation if it may
// pose a problem.
if(!refLong.length && !emptyRefsWarningGiven) {
if(!window.confirm(messages.emptyRefsWarning)) {
return false;
}
emptyRefsWarningGiven = true;
}
}
Line 320 ⟶ 335:
// Do the actual segregation work and save the random prefix
var segFormat = segregateRefs(mainTextbox.value);
if(!segFormat) {
return false;
}
randPrefix = segFormat.randPrefix;