softwareWeb dev

Usability improvement for MT

This web site is hosted on the very slow server and the consequence is that the rebuilding of files takes forever, sometimes up to 1 minute. :'(

Side-effect of this is that, when you submit a comment, it appears that nothing is happening (except the upper right browser icon is rotating) so you naturally click again and again and it sometimes posts the same comment several times. I’m not able to repeat that (which puzzles me), but I have seen it happen (and spent time deleting identical comments).

So, to save my self some time, I changed MT comment handling script. I added this into form tags on entry comment template (as well as on comment listing, preview and error templates):

onsubmit="return SubmitComment(this)"

and this is the SubmitComment function:

function SubmitComment(oForm) {

  if (oForm.submitClicked) {

    alert("Form is submitted, processing <span class="code-break">»</span>

       will take a bit (it is a slow server :( )");

    return false;

  }

  oForm.submitClicked = true;

  if (oForm.bakecookie)

    if (oForm.bakecookie[0].checked)

      rememberMe(oForm);

  return true;

}

It is very simple DOM trick: property submitClicked is added to form object and later on checked, so if you click more than once you’ll be notified and that second (third etc.) submit will be canceled.

bakecookie thing is from original MT build.