We relaunched the TWiki.org project with an expanded TWiki charter, and we invite you to participate! The TWiki.org Code of Conduct agreement took effect on 27 Oct 2008. We ask existing twiki.org users to opt-in. You need to opt-in to participate in the Blog, Codev, Plugins and TWiki webs. -- PeterThoeny - 27 Oct 2008
You are here: TWiki> Codev Web>SaveChangesWarning (11 Feb 2003, DanBoitnott)
Tags:
create new tag
, view all tags
Adding a "Save Your Changes" warning to the edit template

One of my users asked me to implement this so that he would remember to save his changes regularly. My approach uses Javascript to set a five minute timer which, when finished, starts the background flashing between red and white. This can be VERY annoying (which is the point) so I'm looking into the possibility of controling it through a user preferences variable (suggestions would be welcome). Here's the code:

mod = 0;
function setwarn() {
  mod = 0;
  setTimeout("savewarn()", 1000 * 60 * 5);
}
function savewarn() {
  if (mod > 0) {
    document.body.bgColor = "white";
  } else {
    document.body.bgColor = "red";
  }
  mod = (mod + 1) % 2;
  setTimeout("savewarn()", 1000 * 1);
}

Just put the code in the Javascript section of your edit template and you're set. If you're using SectionalEditPlugin you can do the same thing to the editsection template.

-- DanBoitnott - 06 Feb 2003

Here's a less anoying way to do it. Instead of the flashing background it gives you a pop-up box reminding you to save. Much easier on the eyes.

function setwarn() {
  setTimeout("showwarn()", 1000 * 60 * 10);
}
function showwarn() {
  alert("Remember to save your work!");
  setTimeout("showwarn()", 1000 * 60 * 10);
}

Also, I forgot to mention it above but for both styles you need to call setwarn() in the body's onLoad event:

<body bgcolor="#ffffff" onLoad="initForm(); setwarn();">

-- DanBoitnott - 11 Feb 2003

Topic revision: r3 - 11 Feb 2003 - 21:15:12 - DanBoitnott
 
TWIKI.NET
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback