-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
47 lines (36 loc) · 1.42 KB
/
index.js
File metadata and controls
47 lines (36 loc) · 1.42 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
import render from './render.js';
render();
function makeEvent(name, data) {
const event = new Event(name);
for (const key in data) {
event[key] = data[key];
}
return event;
}
if (location.pathname === '/home/runner/work/week-planner/week-planner/index.html') {
// Clear the local storage for local development, it is always empty on the CI
localStorage.clear();
const table = document.querySelector('table');
const trs = document.querySelectorAll('tr');
const typeInput = document.querySelector('#typeInput');
for (const tr of trs) {
const tds = tr.querySelectorAll('td');
// Make the first 48 slots (8 hours of 6 10-minute slots) as "sleeping"
for (let index = 0; index < 48; index++) {
const td = tds[index];
td.dispatchEvent(makeEvent('mousedown', { buttons: 1 }));
}
table.dispatchEvent(makeEvent('mouseup'));
typeInput.value = 'sleeping';
typeInput.dispatchEvent(makeEvent('keydown', { key: 'Enter' }));
// Make the next 48 slots (8 hours of 6 10-minute slots) as "coding"
for (let index = 48; index < 96; index++) {
const td = tds[index];
td.dispatchEvent(makeEvent('mousedown', { buttons: 1 }));
}
table.dispatchEvent(makeEvent('mouseup'));
typeInput.value = 'coding';
typeInput.dispatchEvent(makeEvent('keydown', { key: 'Enter' }));
}
document.querySelector('#slotSpan').textContent = `Screenshot @ ${new Date().toISOString()}`;
}