OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 var localStrings; | |
6 | |
7 // Timer that will check and update the countdown every second. | |
8 var countdownTimer; | |
9 // Time at which we should logout the user unless we've been closed. | |
10 var logoutTime; // ms | |
11 | |
12 /** | |
13 * Decrements the countdown timer and updates the display on the dialog. | |
14 */ | |
15 function decrementTimer() { | |
16 var currentTime = Date.Now(); | |
arv (Not doing code reviews)
2012/03/02 21:01:21
Date.now()
Maybe you should add a test to ensure
rkc
2012/03/02 21:47:09
Fixed and tested manually.
I've dedicated all of
| |
17 if (logoutTime > currentTime) { | |
18 secondsToRestart = Math.round((logoutTime - currentTime) / 1000); | |
19 $('warning').innerHTML = localStrings.getStringF('warning', | |
20 secondsToRestart); | |
21 } else { | |
22 clearInterval(countdownTimer); | |
23 chrome.send('requestLogout'); | |
24 } | |
25 } | |
26 | |
27 /** | |
28 * Starts the countdown to logout. | |
29 */ | |
30 function startCountdown(seconds) { | |
31 logoutTime = Date.Now() + (seconds * 1000); | |
arv (Not doing code reviews)
2012/03/02 21:01:21
useless parentheses
rkc
2012/03/02 21:47:09
Done.
| |
32 $('warning').innerHTML = localStrings.getStringF('warning', | |
33 seconds); | |
34 countdownTimer = setInterval(decrementTimer, 1000); | |
35 } | |
36 | |
37 /** | |
38 * Inserts translated strings on loading. | |
39 */ | |
40 function initialize() { | |
41 localStrings = new LocalStrings(); | |
42 | |
43 i18nTemplate.process(document, templateData); | |
44 chrome.send('requestCountdown'); | |
45 } | |
46 | |
47 document.addEventListener('DOMContentLoaded', initialize); | |
OLD | NEW |