This repository has been archived by the owner on Oct 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathchores.html
108 lines (91 loc) · 3.34 KB
/
chores.html
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style type="text/css">
table {
width: 320px;
height: 500px;
border: solid thin black;
border-collapse: collapse;
border-spacing: 0;
font-size: 18px;
}
tr {
text-align: center;
line-height: 2;
height: 100px;
font-weight: bold;
color: white;
background-color:blue;
}
td {
padding: 0;
margin: 0;
border: 0;
width: auto;
}
td.contestant {
background-color: yellow;
color: red;
}
#randomize {
width: 320px;
background-color: red;
color: yellow;
height: 68px;
font-size: 28px;
}
</style>
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>Bootstrap 101 Template</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<table id="chore_chart">
</table>
<button id="randomize">RANDOMIZE!</button>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script type="text/javascript">
var chores = ['Unload Dishwasher', 'Load Dishwasher', 'Clean Counters', 'Clean Table', 'Sweep and Mop Floor'];
var contestants = ['Michael', 'Raelyn', 'Cheyenne', 'Cadee', 'Shaun'];
function shuffle(array) {
var currentIndex = array.length, temporaryValue, randomIndex;
// While there remain elements to shuffle...
while (0 !== currentIndex) {
// Pick a remaining element...
randomIndex = Math.floor(Math.random() * currentIndex);
currentIndex -= 1;
// And swap it with the current element.
temporaryValue = array[currentIndex];
array[currentIndex] = array[randomIndex];
array[randomIndex] = temporaryValue;
}
return array;
}
function randomize() {
var chart = document.getElementById("chore_chart");
chart.innerHTML = '';
contestants = shuffle(contestants);
for (i = 0; i < contestants.length; i++) {
chart.innerHTML += "<tr><td class='chore'>"+chores[i]+"</td><td class='contestant'>"+contestants[i]+"</td></tr>";
}
}
document.getElementById("randomize").addEventListener("click", randomize);
(function() {
randomize();
})();
</script>
</body>
</html>