-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
50 lines (40 loc) · 1.74 KB
/
script.js
File metadata and controls
50 lines (40 loc) · 1.74 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
//Contact alert function
function contact() {
alert("Hello! App produced by koolsport.se and friends");
}
//The randomizer with an list of participants
function coffeySpinner() {
var allCards = document.querySelectorAll(".show");
for (var i = 0; i < allCards.length; i++) {
allCards[i].className = "hide";
}
console.log(allCards);
var teamList = ['bill', 'steve', 'linus', 'mark', 'instant', 'grace', 'richard', 'james'];
var random = Math.floor(Math.random() * teamList.length)
var showWinner = document.getElementById(teamList[random]);
//showWinner.className = "show";
if(showWinner.className === "hide") {
showWinner.className = "show";
console.log(random)
} else {
showWinner.className = "hide";
}
}
//TEST Toggle. Works but the randomizer take a new person the old stays
//21.9 Not working try adding eventlistner instead of onclick
/*tested ifelse,hide/show x2, location reload
if(showWinner.className === "show") {
showWinner.className = "hide";
} else {
showWinner.className = "hide";
}*/
//NOTES AND LEARNED DURING PROJECT (ITHS 2017 jon, andreas,oliver)
//Read code with falcon eyes, see the mistakes.
//Use inspect element console
//console.log(showWinner);
//console.log(luckyWinner);
//jon comments: class to hide instead of id, id changed to person name, you can //.addClass(), .removeClass(), ex bill. id = "#show";
//var teamList Array takes ids of element ['bill','steve'..]
//Randomizer returns array numbers[0], [3] because of this when getting element you need to use teamList[random] to target it ex: var showWinner = document.getElementById(teamList[random]);
//Use Queryselector to match elements
//Use for loop to run through the query selected elements and change their class