Smart AJAX autosave?

Discussion in 'JavaScript' started by Triexa, Dec 5, 2006.

  1. #1
    I have an autosave feature that, well... autosaves every minute. Now I could very well become the biggest abuser of my own feature. I currently have 8 windows open - I tend to just leave windows open for a long time. As a result, the javascript would be running every minute saving, creating unnecessary load on the server.

    How could I make the autosave smart and only save if they are actively "working" with it? The only thing I can really think of is to have like a variable that sets to true whenever something happens, set to false whenever it saves, and only save when the var is true. Problem is, I have a lot of functions for events that I would need to attach it to... I'm sure I would miss it somewhere.

    Any other ideas?
     
    Triexa, Dec 5, 2006 IP
  2. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #2
    Can I have a look at the page in question so I can see what you're on about ?
     
    krakjoe, Dec 5, 2006 IP
  3. smallbuzz

    smallbuzz Peon

    Messages:
    125
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Can you put a key press event on the body element of all the pages? Whenever a key is pressed, set a global variable to true. Save only if that variable is true, reset it to false afterwards.
     
    smallbuzz, Dec 5, 2006 IP
  4. Triexa

    Triexa Active Member

    Messages:
    580
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #4
    99.9% sure you can't attach any key event to the body...
     
    Triexa, Dec 5, 2006 IP
  5. smallbuzz

    smallbuzz Peon

    Messages:
    125
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    how about wrap the page in a div, then you can put an event on it
     
    smallbuzz, Dec 5, 2006 IP