-
Notifications
You must be signed in to change notification settings - Fork 0
/
name.js
52 lines (42 loc) · 1.42 KB
/
name.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
const name = getNameFromUrl() || "Keine Argumente angegeben!";
const nameEle = document.getElementById("name");
const ylno = document.getElementById("ylno");
const greetings = document.getElementById("greetings");
createNameSpans(name);
const letterEles = document.querySelectorAll(".letter");
console.log(letterEles);
lightUpName(1);
function createNameSpans(name) {
let nameArray = name.split("");
let htmlString = "";
nameArray.forEach((letter, index) => {
htmlString += `<span class="letter" id="letter-${index}">${letter}</span>`;
});
if(name == "Alex"){
ylno.textContent = "Es war ein Jahr, wie kein anderes. Bald ist es auch vorbei, deswegen steht jetzt Weihnachten vor der Tür. Deswegen diese Weihnachtsgrüße, du kleines Kitzelmonster!!"
greetings.textContent = "Dein FIGGO Simon"
}
if(name == "Carmen"){
greetings.textContent = "Dein FIGGO Simon"
}
if(name == "Mama"){
greetings.textContent = "Dein FIGGO Simon"
}
nameEle.innerHTML = htmlString;
}
function lightUpName(n) {
let length = letterEles.length;
for (let i = 0; i < length; i++) {
let ele = letterEles[i];
ele.className = (n + i) % 2 == 0 ? "green" : "red";
}
setTimeout(function () {
lightUpName(n + 1);
}, 500);
}
function getNameFromUrl() {
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
let urlName = urlParams.get("n");
return urlName;
}