-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathplugin.js
More file actions
544 lines (482 loc) · 22.1 KB
/
plugin.js
File metadata and controls
544 lines (482 loc) · 22.1 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
//array of total time per day in the past week
let week = [0, 0, 0, 0, 0, 0, 0]
let dayIdx = 0
let candyWeek = [0, 0, 0, 0, 0, 0, 0]
const getWeek = () => {
return week
}
const getCandy = () => {
return candyWeek
}
var chart = new CanvasJS.Chart("chartContainer", {
week: getWeek(),
candyWeek: getCandy(),
animationEnabled: true,
backgroundColor: null,
theme: "light2",
title: {
text: "Time Spent Over the Last Week"
},
axisY: {
includeZero: true
},
legend: {
verticalAlign: "bottom",
horizontalAlign: "left",
dockInsidePlotArea: true
},
data: [{
type: "line",
lineThickness: 4,
showInLegend: true,
name: "Daily Time",
markerType: "square",
color: "#f72585",
dataPoints: [
{ x: 0, y: week[0] },
{ x: 1, y: week[1] },
{ x: 2, y: week[2] },
{ x: 3, y: week[3] },
{ x: 4, y: week[4] },
{ x: 5, y: week[5] },
{ x: 6, y: week[6] }
]
},
{
type: "line",
lineThickness: 4,
showInLegend: true,
name: "Candies Accumulated",
markerType: "triangle",
color: "#480ca8",
dataPoints: [
{ x: 0, y: candyWeek[0] },
{ x: 1, y: candyWeek[1] },
{ x: 2, y: candyWeek[2] },
{ x: 3, y: candyWeek[3] },
{ x: 4, y: candyWeek[4] },
{ x: 5, y: candyWeek[5] },
{ x: 6, y: candyWeek[6] }
]
},
{
type: "line",
lineThickness: 4,
showInLegend: true,
name: "Goal Daily Time",
lineDashType: "dash",
color: "#4895ef",
dataPoints: [
{ x: 0, y: 125 },
{ x: 1, y: 125 },
{ x: 2, y: 125 },
{ x: 3, y: 125 },
{ x: 4, y: 125 },
{ x: 5, y: 125 },
{ x: 6, y: 125 }
]
}
]
});
chart.render()
const pomodoroTimer = document.querySelector('#pomodoro-timer')
const startButton = document.querySelector('#pomodoro-start')
const pauseButton = document.querySelector('#pomodoro-pause')
const stopButton = document.querySelector('#pomodoro-stop')
const dayButton = document.querySelector('#pomodoro-day')
// START
startButton.addEventListener('click', () => {
toggleClock()
})
// PAUSE
pauseButton.addEventListener('click', () => {
toggleClock()
})
// STOP
stopButton.addEventListener('click', () => {
toggleClock(true)
})
dayButton.addEventListener('click', () => {
week[dayIdx] = timeTotalDay
candyWeek[dayIdx] = currentCandies
dayIdx += 1
timeTotalDay = 0
const changeIdx = (dayIdx) => {
if (dayIdx === 7) {
dayIdx = 0
}
}
changeIdx(dayIdx)
//toggleClock(true)
var chart = new CanvasJS.Chart("chartContainer", {
week: getWeek(),
candyWeek: getCandy(),
animationEnabled: true,
backgroundColor: null,
theme: "light2",
title: {
text: "Time Spent Over the Last Week"
},
axisY: {
includeZero: true
},
legend: {
verticalAlign: "bottom",
horizontalAlign: "left",
dockInsidePlotArea: true
},
data: [{
type: "line",
lineThickness: 4,
showInLegend: true,
name: "Daily Time",
markerType: "square",
color: "#f72585",
dataPoints: [
{ x: 0, y: week[0] },
{ x: 1, y: week[1] },
{ x: 2, y: week[2] },
{ x: 3, y: week[3] },
{ x: 4, y: week[4] },
{ x: 5, y: week[5] },
{ x: 6, y: week[6] }
]
},
{
type: "line",
lineThickness: 4,
showInLegend: true,
name: "Candies Accumulated",
markerType: "triangle",
color: "#480ca8",
dataPoints: [
{ x: 0, y: candyWeek[0] },
{ x: 1, y: candyWeek[1] },
{ x: 2, y: candyWeek[2] },
{ x: 3, y: candyWeek[3] },
{ x: 4, y: candyWeek[4] },
{ x: 5, y: candyWeek[5] },
{ x: 6, y: candyWeek[6] }
]
},
{
type: "line",
lineThickness: 4,
showInLegend: true,
name: "Goal Daily Time",
lineDashType: "dash",
color: "#4895ef",
dataPoints: [
{ x: 0, y: 125 },
{ x: 1, y: 125 },
{ x: 2, y: 125 },
{ x: 3, y: 125 },
{ x: 4, y: 125 },
{ x: 5, y: 125 },
{ x: 6, y: 125 }
]
}
]
});
chart.render()
})
//label the entry box
let currentTaskLabel = document.querySelector('#pomodoro-clock-task')
let currentCandies = 0;
let type = 'Work'
let isClockRunning = false
// in seconds = 25 mins
let workSessionDuration = 1500
let currentTimeLeftInSession = 1500
// in seconds = 5 mins;
let breakSessionDuration = 300
//keep track of seconds spent
let timeSpentInCurrentSession = 0
//keep track of total time spent
let timeTotalDay = 0
const toggleClock = reset => {
if (reset) {
// STOP THE TIMER
stopClock()
} else {
if (isClockRunning === true) {
clearInterval(clockTimer)
// PAUSE THE TIMER
isClockRunning = false
} else {
// START THE TIMER
isClockRunning = true
clockTimer = setInterval(() => {
// decrease time left / increase time spent
stepDown()
displayCurrentTimeLeftInSession()
}, 1000)
}
}
}
function show_image(src, width, height, alt) {
var img = document.createElement("img");
img.src = src;
img.width = width;
img.height = height;
img.alt = alt;
currentCandies++;
showCandies();
document.getElementById("p1").innerHTML = `Current Candies: ${currentCandies} `
// This next line will just add it to the <body> tag
document.body.appendChild(img);
if (currentCandies === 5) {
alert("You have enough candies for a break! Spend them!");
var x = document.createElement("BUTTON");
var t = document.createTextNode("Click me to spend 5 candies!");
var foo = document.getElementById("pomo-buttons");
x.appendChild(t);
foo.appendChild(x);
x.setAttribute("onClick", "button1()");
}
if (currentCandies === 10) {
alert("You have enough candies for a break! Spend them!");
var x = document.createElement("BUTTON");
var t = document.createTextNode("Click me to spend 10 candies!");
var foo = document.getElementById("pomo-buttons");
x.appendChild(t);
foo.appendChild(x);
x.setAttribute("onClick", "button2()");
}
if (currentCandies === 15) {
alert("You have enough candies for a break! Spend them!");
var x = document.createElement("BUTTON");
var t = document.createTextNode("Click me to spend 15 candies!");
var foo = document.getElementById("pomo-buttons");
x.appendChild(t);
foo.appendChild(x);
x.setAttribute("onClick", "button3()");
}
}
const showCandies = () => {
let cand = ''
for (let j = 0; j < currentCandies; j++) {
cand += "🍬"
}
var myWindow = window.open("", "MsgWindow", "width=200,height=100");
myWindow.document.write(`<p>You've earned ${currentCandies + cand}!</p>`);
}
const stepDown = () => {
if (currentTimeLeftInSession > 0) {
// decrease time left / increase time spent
currentTimeLeftInSession--
timeSpentInCurrentSession++
} else if (currentTimeLeftInSession === 0) {
timeSpentInCurrentSession = 0
// Timer is over -> if work switch to break, viceversa
if (type === 'Work') {
currentTimeLeftInSession = breakSessionDuration
displaySessionLog('Work')
type = 'Break';
currentTaskLabel.value = 'Break';
currentTaskLabel.disabled = true;
} else {
currentTimeLeftInSession = workSessionDuration
type = 'Work'
if (currentTaskLabel.value === 'Break') {
currentTaskLabel.value = workSessionLabel;
}
currentTaskLabel.disabled = false;
displaySessionLog('Break')
}
}
displayCurrentTimeLeftInSession()
candyQualification()
}
const displaySessionLog = type => {
const sessionsList = document.querySelector('#pomodoro-sessions')
// append li to it
const li = document.createElement('li')
if (type === 'Work') {
sessionLabel = currentTaskLabel.value ? currentTaskLabel.value : 'Work'
workSessionLabel = sessionLabel
} else {
sessionLabel = 'Break'
}
let elapsedTime = parseInt(timeSpentInCurrentSession / 60)
timeTotalDay += elapsedTime
elapsedTime = elapsedTime > 0 ? elapsedTime : '< 1'
const text = document.createTextNode(`${sessionLabel} : ${elapsedTime} min`)
li.appendChild(text)
sessionsList.appendChild(li)
}
const displayCurrentTimeLeftInSession = () => {
const secondsLeft = currentTimeLeftInSession
let result = ''
const seconds = secondsLeft % 60
const minutes = parseInt(secondsLeft / 60) % 60
let hours = parseInt(secondsLeft / 3600)
// add leading zeroes if it's less than 10
function addLeadingZeroes(time) {
return time < 10 ? `0${time}` : time
}
if (hours > 0) result += `${hours}:`
result += `${addLeadingZeroes(minutes)}:${addLeadingZeroes(seconds)}`
pomodoroTimer.innerText = result.toString()
}
const candyQualification = () => {
const secondsLeft = currentTimeLeftInSession
let result = ''
const earn = secondsLeft % 300
// add leading zeroes if it's less than 10
if (earn === 0) {
show_image('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAP0AAADHCAMAAADlCqUFAAAAkFBMVEX39/f/qtT2a73/rdX2aLz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Z9YoWQqZC7QVnvBIlYV6QqAjfGfpzeTSiwTdMpdeUzE0Cb9x9q9ptW2QauX0o3haIaPgH8MuurhJ9XXJkxBzFtUjWnmswD/wJOdlfyF2pScnLYIiOly7sJw/wd+7cV2dv+lezj6k7mznIpYg5uJ+2Yqqqm3NE5RlVBgQopj5ZamBtnQpzO5KXVHUAz98wQeP9OI4Fix8HcOzwv/0KuMpLEHc1uW6fBt+IxnTXXHyMPLEL82T4Hce2w8nxQKDuwiyBuxYjZ1VbdEQ5wokjVWy6g+VxN4lv+gT+ZLP+M9dcsylCV+BuxJxthd2X0+JZt02a/7OSFZg4XYbZLJkLEEt0zVaU61r7WiGei7R1RZ1e7MiAvCXiFoi0dZXqi/0o4FtOfosBr9hUrBfgF35ztmBeC75Dq+rgC/ZwR0luhCUesHlG9nLosNzbbTH7P5ebs9p77uUISvnkmbD5+5bdeHKPVkWxqhk7sW6BHL4qbU1rra8Xw+XL/FlZreaHn98iiCQX8/pFeV2lwdhpm+LnNqugMOr1Z2lSP8eeb4WCuyDlZhBNF9marGkh9HtdNc/LAyG4W6Fuh9yjpn6EQGZ7xHqYRuy8/iUIHhYkKxkaZhVbafSArz+9DWRQ+HwX0k+bg8U8jQOzBeNekINX9KQnOy1O5n4u3PUwdwJrk+JifldRfOezEc3lN4C4X1Pb+XEAWKi8SN5CT08Au4fjJLRtSp18o57YixS0VPFPINjE2uFrf9wFso8LzcTjLq1VfAESA5vuVnnHTExNt8/JLwHRfrgAjXnZpgaQ1XlTRjOedqkJ+QJ/iy/7YihPxKSib6WXWwqy0hXdR9PnOfUp8FLRfaDvcP9FyPK27qyf6tQnIEQs1gwaWqG/B+SQ9XDbjZgcrhvWPon8mH18Or1PYX6HlLJ96x38EsSR3wLka9T/CM9n7l544YUXXnjhhRdeAIn/AY3QxsJjNl57AAAAAElFTkSuQmCC', 100, 100, 'pic')
}
}
const button1 = () => {
if (currentCandies >= 5) {
'use strict';
function r(f) { /in/.test(document.readyState) ? setTimeout('r(' + f + ')', 9) : f() }
r(function() {
if (!document.getElementsByClassName) {
// IE8 support
var getElementsByClassName = function(node, classname) {
var a = [];
var re = new RegExp('(^| )' + classname + '( |$)');
var els = node.getElementsByTagName("*");
for (var i = 0, j = els.length; i < j; i++)
if (re.test(els[i].className)) a.push(els[i]);
return a;
}
var videos = getElementsByClassName(document.body, "youtube");
} else {
var videos = document.getElementsByClassName("youtube");
}
var nb_videos = videos.length;
for (var i = 0; i < nb_videos; i++) {
// Based on the YouTube ID, we can easily find the thumbnail image
videos[i].style.backgroundImage = 'url(http://i.ytimg.com/vi/' + videos[i].id + '/sddefault.jpg)';
// Overlay the Play icon to make it look like a video player
var play = document.createElement("div");
play.setAttribute("class", "play");
videos[i].appendChild(play);
videos[i].onclick = function() {
// Create an iFrame with autoplay set to true
var iframe = document.createElement("iframe");
var iframe_url = "https://www.youtube.com/embed/" + this.id + "?autoplay=1&autohide=1";
if (this.getAttribute("data-params")) iframe_url += '&' + this.getAttribute("data-params");
iframe.setAttribute("src", iframe_url);
iframe.setAttribute("frameborder", '0');
// The height and width of the iFrame should be the same as parent
iframe.style.width = this.style.width;
iframe.style.height = this.style.height;
// Replace the YouTube thumbnail with YouTube Player
this.parentNode.replaceChild(iframe, this);
}
}
});
currentCandies = currentCandies - 5;
} else {
alert("Not enough candies yet!");
}
}
const button2 = () => {
if (currentCandies >= 10) {
'use strict';
function r(f) { /in/.test(document.readyState) ? setTimeout('r(' + f + ')', 9) : f() }
r(function() {
if (!document.getElementsByClassName) {
// IE8 support
var getElementsByClassName = function(node, classname) {
var a = [];
var re = new RegExp('(^| )' + classname + '( |$)');
var els = node.getElementsByTagName("*");
for (var i = 0, j = els.length; i < j; i++)
if (re.test(els[i].className)) a.push(els[i]);
return a;
}
var videos = getElementsByClassName(document.body, "youtube");
} else {
var videos = document.getElementsByClassName("youtube");
}
var nb_videos = videos.length;
for (var i = 0; i < nb_videos; i++) {
// Based on the YouTube ID, we can easily find the thumbnail image
videos[i].style.backgroundImage = 'url(http://i.ytimg.com/vi/' + videos[i].id + '/sddefault.jpg)';
// Overlay the Play icon to make it look like a video player
var play = document.createElement("div");
play.setAttribute("class", "play");
videos[i].appendChild(play);
videos[i].onclick = function() {
// Create an iFrame with autoplay set to true
var iframe = document.createElement("iframe");
var iframe_url = "https://www.youtube.com/embed/" + this.id + "?autoplay=1&autohide=1";
if (this.getAttribute("data-params")) iframe_url += '&' + this.getAttribute("data-params");
iframe.setAttribute("src", iframe_url);
iframe.setAttribute("frameborder", '0');
// The height and width of the iFrame should be the same as parent
iframe.style.width = this.style.width;
iframe.style.height = this.style.height;
// Replace the YouTube thumbnail with YouTube Player
this.parentNode.replaceChild(iframe, this);
}
}
});
currentCandies = currentCandies - 10;
} else {
alert("Not enough candies yet!");
}
}
const button3 = () => {
if (currentCandies >= 15) {
'use strict';
function r(f) { /in/.test(document.readyState) ? setTimeout('r(' + f + ')', 9) : f() }
r(function() {
if (!document.getElementsByClassName) {
// IE8 support
var getElementsByClassName = function(node, classname) {
var a = [];
var re = new RegExp('(^| )' + classname + '( |$)');
var els = node.getElementsByTagName("*");
for (var i = 0, j = els.length; i < j; i++)
if (re.test(els[i].className)) a.push(els[i]);
return a;
}
var videos = getElementsByClassName(document.body, "youtube");
} else {
var videos = document.getElementsByClassName("youtube");
}
var nb_videos = videos.length;
for (var i = 0; i < nb_videos; i++) {
// Based on the YouTube ID, we can easily find the thumbnail image
videos[i].style.backgroundImage = 'url(http://i.ytimg.com/vi/' + videos[i].id + '/sddefault.jpg)';
// Overlay the Play icon to make it look like a video player
var play = document.createElement("div");
play.setAttribute("class", "play");
videos[i].appendChild(play);
videos[i].onclick = function() {
// Create an iFrame with autoplay set to true
var iframe = document.createElement("iframe");
var iframe_url = "https://www.youtube.com/embed/" + this.id + "?autoplay=1&autohide=1";
if (this.getAttribute("data-params")) iframe_url += '&' + this.getAttribute("data-params");
iframe.setAttribute("src", iframe_url);
iframe.setAttribute("frameborder", '0');
// The height and width of the iFrame should be the same as parent
iframe.style.width = this.style.width;
iframe.style.height = this.style.height;
// Replace the YouTube thumbnail with YouTube Player
this.parentNode.replaceChild(iframe, this);
}
}
});
currentCandies = currentCandies - 15;
} else {
alert("Not enough candies yet!");
}
}
const stopClock = () => {
// new
displaySessionLog(type)
clearInterval(clockTimer)
isClockRunning = false
currentTimeLeftInSession = workSessionDuration
displayCurrentTimeLeftInSession()
// new
type = 'Work'
}
pomodoroTimer.innerText = result