Open yoderjen opened 7 years ago
I just thought of another thing it would be nice to have - instead of just being able to reset a timer, I'd like to be able to set its value.
then I could call that to set the timer to zero after a save.
On a page refresh, I can save the old timer value to localStorage, and on page initialization I could pull out that value and add it to the timer. Then I would update times only on project save.
Any hope of a "setTimerToValue('page_name', value) function?
Ah, I read the code and found out my problem (one of my problems). After calling ResetRecordedPageTime, you don't want to reinitialize the timer - you need to call startTimer('timer-name'). If you re-initialize the timer again with the same name, the idle time gets all screwy.
I save time the user spends working on a project on my page. Because saving to my database isn't that reliable just on unload, I also save the time spent every time the user saves their project.
So, after a user saves their project, I send that time to be saved to my database, and want to reset the timer to zero.
I thought that's what ResetRecordedPageTime(my page name) would do. What it actually seemed to do is remove the timer altogether - if I reset the page time, then wait, then try to retrieve time spent, I get NaN.
What I'm doing is calling ResetRecordedPageTime(mypage), then re-initializing the timer (same page name every time). This seems to work and have the behavior I want.
Should ResetRecordedPageTime destroy the timer? The docs should indicate this, if so. And it would be nice to have a function that lets you set a timer value to whatever you want so you can zero it out after saving the time saved.