-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdisease_testing.html
More file actions
160 lines (139 loc) · 3.16 KB
/
disease_testing.html
File metadata and controls
160 lines (139 loc) · 3.16 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
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<!DOCTYPE html>
<html>
<head>
<style>
.button {
background-color: #4CAF50;
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
cursor: pointer;
}
.divider{
width:10px;
height:auto;
display:inline-block;
}
html {
margin: 0;
padding: 0;
}
body {
color: #325050;
background: #fff;
font-family: 'Libre Baskerville', sans-serif;
font-size: 200%;
}
p {
margin-top: 0;
text-align: center;
}
h1 {
font: italic normal 1.4em georgia, sans-serif;
letter-spacing: 1px;
margin-bottom: 0;
color: #7D775C;
padding-bottom: 20px
}
</style>
</head>
<body>
<div style="text-align: center">
<h1>Disease Simulator</h1>
<p>Push the button to advance or reset.</p>
<button class="button"; onclick="advanceStage()">AdvanceStage</button>
<div class="divider"/></div>
<button class="button"; onclick="reset()">Reset</button>
<p></p>
<p id="month">Month:</p>
<p id="students"></p>
</div>
<script>
var month = 1;
var initialized = false;
var names = [ "Fabricio Aguilar",
"Katrina Alvarez",
"Michelle Avila",
"Patricia Aziz",
"Tracy Cherubin",
"Marion Couzens",
"Erik Feldtmann",
"Larissa Flores",
"Judi Fusco",
"Daniel Gonzalez",
"Christopher Gray",
"Daniel Hernandez",
"Catherine Ice",
"Mary Ice",
"Kaley Laveigne",
"Raven Mccall",
"Joshua Norris",
"Jeremiah Owens",
"Nicole Pineda",
"Amanda Rodriguez",
"Ivanna Ward",
"Nora Wartan"];
var students = [];
function reset()
{
students = [];
month = 1;
initialized = false;
document.getElementById("students").innerHTML = "";
document.getElementById("month").innerHTML = "Month: ";
}
function Student(name) {
this.name = name;
this.diseased = false;
this.accountedFor = false;
}
function advanceStage()
{
document.getElementById("students").innerHTML = "";
if (initialized) {
for (let s of students) {
chanceDiseased = Math.floor((Math.random() * 3) + 1);
if (s.diseased == false && chanceDiseased == 1)
{
s.diseased = true;
}
}
printDiseased();
}
else {
initStudents()
initialized = true;
printDiseased();
}
}
function printDiseased()
{
count = 0;
document.getElementById("month").innerHTML = "Month: " + month + "<br />";
month += 1;
for (let s of students) {
if (s.diseased && !s.accountedFor) {
count += 1;
document.getElementById("students").innerHTML += s.name + "<br />";
s.accountedFor = true;
}
}
if (count == 0) {
document.getElementById("students").innerHTML = "No one diseaed this month. <br />";
}
}
function initStudents() {
for (let value of names) {
students.push(new Student(value));
}
initDiseased = Math.floor((Math.random() * names.length) + 1);
students[initDiseased].diseased = true;
}
</script>
</body>
</html>