forked from vinfinity7/js_assignment
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstrangerThings.js
More file actions
60 lines (50 loc) · 1.68 KB
/
strangerThings.js
File metadata and controls
60 lines (50 loc) · 1.68 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
let ele;
/*
A simple function which is used to wait for a particular time (in miliseconds)
*/
function sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
/*
TODO:
This function should return a list of all the distinct characters in UPPERCASE that have been typed in the textbox with the id "message"
*/
function getCharacters() {}
/*
Sets the CSS properties of the DOM elements to create a nice visual effect
TODO: Play with the colour codes provided to create a theme which has more resemblance to Netflix's Stranger Things
*/
async function setCSS(character) {
let index = character.charCodeAt(0) - 65;
let colorValue = "";
if (index >= 0 && index <= 7) {
ele = document.getElementById("setOne").getElementsByTagName("li");
} else if (index >= 8 && index <= 16) {
ele = document.getElementById("setTwo").getElementsByTagName("li");
index = index - 8;
} else if (index >= 17 && index <= 25) {
ele = document.getElementById("setThree").getElementsByTagName("li");
index = index - 17;
}
if (index % 2 != 0) {
//PINK
ele[index].style.backgroundColor = "#ff99ff";
colorValue = "rgba(255,105,180,0.9)";
ele[index].style.boxShadow = "0px 2px 20px 4px #ffff00";
} else {
//BLUE
ele[index].style.backgroundColor = "aqua";
colorValue = "rgba(0,153,255,0.8)";
ele[index].style.boxShadow = "0px 2px 20px 4px #ffff00";
}
await sleep(1000);
ele[index].style.backgroundColor = colorValue;
ele[index].style.boxShadow = "0px 2px 20px 4px " + colorValue;
await sleep(500);
}
async function illuminateLight(index) {
const message = getCharacters();
/*
TODO: Call the setCSS function asynchronously for each character present in the message array
*/
}