-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
72 lines (54 loc) · 1.18 KB
/
script.js
File metadata and controls
72 lines (54 loc) · 1.18 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
var counter = 0;
var time = [5, 10, 22, 4, 9, 3];
var website = ["google.com", "facebook.com", "netflix.com", "youtube.com", "learn.uwaterloo.ca", "khanacademy.com"];
//functions HTML need
function totalTime(){
return 53;
}
function totalTimeDisplay(){
return 53 + 'min'
}
function mostTimeWeb(){
return 'Neflix.com';
}
function mostTime(){
return 22;
}
function mostTimePercent(){
return Math.round ((100 * ( mostTime() / totalTime() ))) + '%'
}
function timeProductive() {
return '75%';
}
//Timer function
function elementIndex(tab,array)
{
for(var j=0; j<array.length; j++)
{
if(array[j]==tab)
return j;
}
return -1;
}
function hello(){
chrome.tabs.getSelected(null, function (tab) {
link.href = tab.url;
return link.href;
}
)}
function timer() {
var currentTab = hello();
// find it in array, add 1 second IMPLEMENT
var i = elementIndex(currentTab, website);
if (i == -1) {
website.push(currentTab);
time.push(0.01);
}
else {
time[i] += 0.02;
time[i] = Math.fround(time[i]*100)/100;
}
if (counter !== 0) {
chart.update();}
}
setInterval(timer, 1000);