forked from kc596/Facebook_Timer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpopup.js
More file actions
37 lines (32 loc) · 1.41 KB
/
popup.js
File metadata and controls
37 lines (32 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/**
* popup.js - popup script for Facebook Timer extension
* @author Kunal Chaudhary
*/
var _total, _curr; //timer variables
function set_timer(){
var totalTimerBox = document.getElementById('total-timer-display');
totalTimerBox.innerHTML = getHours(_total)+" : "+getMinutes(_total)+" : "+getSeconds(_total);
var currentTimerBox = document.getElementById('current-timer-display');
currentTimerBox.innerHTML = getHours(_curr)+" : "+getMinutes(_curr)+" : "+getSeconds(_curr);
}
document.addEventListener('DOMContentLoaded', function(){
getTimerValue();
setTimeout(set_timer, 500);
//Refreshing the timer
var refreshButton = document.getElementById('refreshButton');
refreshButton.addEventListener('click', function(){
getTimerValue();
setTimeout(set_timer, 500);
}, false);
//Reseting the current timer
var timerResetButton = document.getElementById('resetButton');
timerResetButton.addEventListener('click', function(){
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
chrome.tabs.sendMessage(tabs[0].id, {clear: "true"}, function(response) {
console.log(response.message);
setTimeout(getTimerValue, 1200); //since one second required by timer.js to store the _curr value
setTimeout(set_timer, 1500); //refreshing the timer value on popup
});
});
}, false);
}, false);