Jump to content

User:PiaCarrot/monobook.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
var submitchecker_buttonclicked = false;

function install_submitchecker() {
  var f = document.getElementById("editform");
  if(f) {
    var inputs = f.getElementsByTagName("input");
    for(var i = 0; i < inputs.length; ++i)
      if(inputs[i].type == "submit")
        inputs[i].onclick = submitchecker_nocheck;
    f.onsubmit = submitchecker;
  }
}
function submitchecker() {
  if(submitchecker_buttonclicked) return true;
  return confirm("Are you sure you want to submit your changes?");
}
function submitchecker_nocheck() {
  submitchecker_buttonclicked = true;
  return true;
}

window.onload = install_submitchecker;