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

Content deleted Content added
adding a compatibility function for use by scripts like ajaxPreview
bug fix - don't break "forward/back button compatibility"
Line 87:
// Semi-global variables (private to this script)
var editForm, refsDiv, refsH2, mainTextbox, refsTextbox, randPrefix, messages,
refsButton, convertButton, complete, unloadHandlerRegistered = false;
 
// Extend the string object with new methods
Line 424:
}
 
function submitHandlerunloadHandler(evt) {
// Local variables
var result, refName, unusedRefNamesQuoted = [];
}
// wikEd compatibility (frame -> textarea)
if(typeof editForm.onsubmitwikEdUseWikEd != "undefined" && wikEdUseWikEd) {
WikEdUpdateTextarea();
}
// Do the actual integration work
result = integrateRefs(mainTextbox.value, refsTextbox.value,
randPrefix, complete);
// Find all unused ref names
Line 443 ⟶ 449:
unusedRefNamesQuoted.join(", "))) {
// Don't submit form
evt.preventDefault();
return false;
}
Line 449 ⟶ 456:
// Otherwise, update the textbox.
mainTextbox.value = result.wikiText;
// wikEd compatibility (textarea -> frame)
if(typeof wikEdUseWikEd != "undefined" && wikEdUseWikEd) {
WikEdUpdateFrame();
}
// Deactivate this event handler
window.removeEventListener("unload", unloadHandler, false);
unloadHandlerRegistered = false;
// We can delete the header and refs textbox now
Line 454 ⟶ 470:
refsDiv.removeChild(refsTextbox);
// Deactivate this submit handler and run any previously registered handler
editForm.onsubmit = null;
if(typeof editForm.PsOnsubmit == "function") {
editForm.onsubmit = editForm.PsOnsubmit;
editForm.onsubmit.apply(this, arguments);
}
return true;
}
Line 524 ⟶ 534:
// Set up the submit handler (to integrate refs when done editing)
window.addEventListener("unload", unloadHandler, false);
if(typeof editForm.onsubmit != "undefined") {
unloadHandlerRegistered = true;
editForm.PsOnsubmit = editForm.onsubmit;
}
editForm.onsubmit = submitHandler;
// Don't submit form
Line 606 ⟶ 614:
 
function getEditboxContents() { // ajaxPreview compatibility
if(editForm.onsubmit == submitHandlerunloadHandlerRegistered) {
// wikEd compatibility (frame -> textarea)
if(typeof wikEdUseWikEd != "undefined" && wikEdUseWikEd) {
WikEdUpdateTextarea();
}
return integrateRefs(mainTextbox.value, refsTextbox.value,
randPrefix, complete).wikiText;