| 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(); | |
| 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; | |
| 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 |