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

Content deleted Content added
bug fix - don't break "forward/back button compatibility"
Undid revision 356075499 by PleaseStand (talk) - breaks the script
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 unloadHandlersubmitHandler(evt) {
// Local variables
var result, refName, unusedRefNamesQuoted = [];
// wikEd compatibility (frame -> textarea)
if(typeof wikEdUseWikEd != "undefined" && wikEdUseWikEd) {
WikEdUpdateTextarea();
}
// Do the actual integration work
result = integrateRefs(mainTextbox.value, refsTextbox.value,
randPrefix, complete);
// Find all unused ref names
Line 449 ⟶ 443:
unusedRefNamesQuoted.join(", "))) {
// Don't submit form
evt.preventDefault();
return false;
}
Line 456 ⟶ 449:
// 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 470 ⟶ 454:
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 534 ⟶ 524:
// Set up the submit handler (to integrate refs when done editing)
if(typeof wikEdUseWikEdeditForm.onsubmit != "undefined" && wikEdUseWikEd) {
window.addEventListener("unload", unloadHandler, false);
editForm.PsOnsubmit = editForm.onsubmit;
unloadHandlerRegistered = true;
}
editForm.onsubmit = submitHandler;
// Don't submit form
Line 614 ⟶ 606:
 
function getEditboxContents() { // ajaxPreview compatibility
if(unloadHandlerRegisterededitForm.onsubmit == submitHandler) {
// wikEd compatibility (frame -> textarea)
if(typeof wikEdUseWikEd != "undefined" && wikEdUseWikEd) {
WikEdUpdateTextarea();
}
return integrateRefs(mainTextbox.value, refsTextbox.value,
randPrefix, complete).wikiText;