-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
31 lines (25 loc) · 937 Bytes
/
index.js
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
const timeInMinutes = new URLSearchParams(window.location.search).get('time');
if (timeInMinutes) {
// HANDLE IN THE CASE OF A FILLED IN USER
// We want to not show the input/form info
setTimeout(() => {
const formEl = document.getElementById('time-form');
formEl.remove();
addTextToBody(`You have selected ${timeInMinutes} minutes of timer`);
}, 0);
} else {
// HANDLE AS A NEW USER
// We want to show the form stuff
}
function addTextToBody() {
// Create a <p> tag
const para = document.createElement('p');
// Create the text to go inside
const node = document.createTextNode(`You have selected ${timeInMinutes} minutes of timer`);
// Find the body tag
const bodyEl = document.getElementById('body');
// Add the text to the newly created <p> tag
para.appendChild(node);
// Add the new element to the body
bodyEl.appendChild(para);
}