-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
34 lines (28 loc) · 903 Bytes
/
script.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
32
33
34
const queryString = window.location.search;
const urlParameters = new URLSearchParams(queryString);
const speed = (urlParameters.has('speed')) ? urlParameters.get('speed') : 95;
let i = 0;
if (urlParameters.has('title')) {
document.getElementById("title").innerHTML = "";
let setTo = urlParameters.get('title');
writing("title", setTo);
}
if (urlParameters.has('description')) {
document.getElementById("description").innerHTML = "";
}
function writing(elementID, text) {
if (i <= text.length) {
document.getElementById(elementID).innerHTML = text.substring(0, i+1);
i++;
setTimeout(writing, speed, elementID, text);
} else {
i = 0;
}
if (elementID != 'description') setDescription();
}
function setDescription() {
if (i == 0) {
let setTo = urlParameters.get('description');
writing("description", setTo);
}
}