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

Edit | Attach | Watch | Print version | History: r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r3 - 2003-02-11 - DanBoitnott
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.