-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
358 lines (304 loc) · 13.1 KB
/
index.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
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HOW</title>
<script src="https://unpkg.com/packery@2/dist/packery.pkgd.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@tsparticles/preset-confetti@3/tsparticles.preset.confetti.bundle.min.js"></script>
<!-- <script src="packery.pkgd.min.js"></script> -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://unpkg.com/draggabilly@3/dist/draggabilly.pkgd.min.js"></script>
<link rel="stylesheet" href="style.css">
<script>
var widget_width = (10/100)*window.innerWidth
var gutter_width = (1/100)*window.innerWidth
$(document).ready(function(){
$('.check_button').click(function() {
// Your code here
var correct_order = true
let correct_order_array = [6, 2, 4, 7, 1, 5, 3, 0]
let color_array = ['#ffadad', '#ffd6a5', '#fdffb6', '#caffbf', '#9bf6ff', '#a0c4ff', '#bdb2ff', '#ffc6ff']
function check_order(){
pckry.getItemElements().forEach(itemElem => {
var position = parseFloat((itemElem.style.left.replace(/px$/, ''))).toFixed(0) + "px"
var target = (correct_order_array[$(itemElem).attr("index")]*(widget_width + gutter_width)).toFixed(0) + "px"
if (position != target) {
correct_order = false
// console.log("Position", position)
// console.log("Target", target)
$('#oxycard'+$(itemElem).attr("index")).css({backgroundColor: color_array[$(itemElem).attr("index")]});
$('#date'+correct_order_array[$(itemElem).attr("index")]).text('');
}else{
$('#oxycard'+$(itemElem).attr("index")).css({backgroundColor: '#27f26e'});
$('#date'+correct_order_array[$(itemElem).attr("index")]).text('✔');
toggleFreeze($(itemElem).attr("index"))
}
});
if (correct_order == true){
}
return correct_order
}
correct_order = check_order()
// Shuffle the order if 1 minute passes
var time = new Date().getTime();
$(document.body).bind("mousemove keypress", function(e) {
time = new Date().getTime();
});
function refresh() {
if(new Date().getTime() - time >= 60000)
window.location.reload(true);
else
setTimeout(refresh, 10000);
}
setTimeout(refresh, 10000);
if (correct_order == true){
} else {
$(document.body).bind("mousemove keypress", function(e) {
// check_order()
pckry.layout();
});
}
update_button();
});
$('.shuffle_button').click(function() {
window.location.reload();
update_button();
});
var i = 0;
pckry.getItemElements().forEach(itemElem => {
$(itemElem).attr('index', i)
i=(i+1);
})
});
// jQuery
function update_button(event, pointer){
}
document.addEventListener("DOMContentLoaded", runPackery, false);
var pckry;
var draggies = [];
function runPackery() {
pckry = new Packery(".grid", {
itemSelector: ".grid-item",
columnWidth: widget_width,
gutter: gutter_width,
horizontal: true
});
pckry.getItemElements().forEach(itemElem => {
let draggie = new Draggabilly(itemElem, {
containment: '.grid', // limit item with in boundary of container
handle: '.oxy-card',
axis: 'x',
// containment: '.demo--containment__container'
});
draggie.on( 'dragEnd', update_button)
pckry.bindDraggabillyEvents(draggie);
draggies.push(draggie);
});
}
// Function to toggle freeze state of a tile
function toggleFreeze(tileId) {
var tile = document.querySelector(`.grid-item[index='${tileId}']`);
if (tile.classList.contains('frozen')) {
}else{
tile.classList.add('frozen');
// console.log(tileId)
// console.log(tile)
var draggieIndex = draggies.findIndex(d => d.element === tile);
// console.log(draggieIndex)
var draggie = draggies[draggieIndex];
draggie.disable();
draggies.splice(draggieIndex, 1);
// console.log("I got here")
pckry.stamp(tile)
pckry.layout();
console.log(draggies)
}
}
</script>
</head>
<body>
<div class ="header">Tomography Time Traveler</div>
<div class = "description">Embark on a journey through time to uncover groundbreaking discoveries in tomography. Can you put these milestones in the correct sequence? Let's find out!</div>
<div class="demo--containment__container2">
<div class="grid2">
<div class="grid-item-date">1843</div>
<div class="grid-item-date">1895</div>
<div class="grid-item-date">1914</div>
<div class="grid-item-date">1917</div>
<div class="grid-item-date">1949</div>
<div class="grid-item-date">1971</div>
<div class="grid-item-date">1979</div>
<div class="grid-item-date">2007</div>
</div>
</div>
<div class="demo--containment__container">
<div class="grid">
<div class="grid-item mdl-shadow--2dp">
<oxy-card>
<div class="oxy-card" id="oxycard0" style="background:#ffadad">
<h6 class="oxy-card-title">Tomography Nobel Prize
</h6>
<div class="image_box">
<img src="Pictures/resized/nobel.png" style="width:10vw;">
</div>
<span class="collapsable">Did you know:</span>
<div class="oxy-card-content">
<div>
The Nobel Prize in Physiology/ Medicine was awarded to Allan Cormack and Godfrey Hounsfield for their work on computer assisted tomography.
</div>
</div>
</div>
</oxy-card>
<!-- <div class="result-container" id="date0">
</div> -->
</div>
<div class="grid-item mdl-shadow--2dp">
<oxy-card>
<div class="oxy-card" id="oxycard1" style="background:#ffd6a5">
<!---->
<h6 class="oxy-card-title">X-rays used in WW1
</h6>
<div class="image_box">
<img src="Pictures/resized/curie.jpg" style="width:10vw;">
</div>
<span class="collapsable">Did you know:</span>
<div class="oxy-card-content">
<div>
X-rays started to be used as a tool in medicine very soon after their discovery, for example in World War 1. The picture shows a mobile x-ray unit developed and run by Nobel prize winner Marie Curie.
</div>
</div>
</div>
</oxy-card>
</div>
<div class="grid-item mdl-shadow--2dp">
<oxy-card>
<div class="oxy-card" id="oxycard2" style="background:#fdffb6">
<!---->
<h6 class="oxy-card-title">Programmable computer
</h6>
<div class="image_box">
<img src="Pictures/resized/baby.jpg" style="width:10vw;">
</div>
<span class="collapsable">Did you know:</span>
<div class="oxy-card-content">
<div>
The Manchester baby machine was the first stored program computer. Its development paved the way for using computers for complex calculations, like tomographic reconstruction.
</div>
</div>
</div>
</oxy-card>
</div>
<div class="grid-item mdl-shadow--2dp">
<oxy-card>
<div class="oxy-card" id="oxycard3" style="background:#caffbf">
<!---->
<h6 class="oxy-card-title">Diamond Light Source opens
</h6>
<div class="image_box">
<img src="Pictures/resized/dls.jpg" style="width:10vw;">
</div>
<span class="collapsable">Did you know:</span>
<div class="oxy-card-content">
<div>
The UK's synchrotron Diamond Light Source is used for a wide range of science including high throughput tomographic imaging on samples as varied as space science and archaelogy.
</div>
</div>
</div>
</oxy-card>
</div>
<div class="grid-item mdl-shadow--2dp">
<oxy-card>
<div class="oxy-card mdl-shadow--2dp" id="oxycard4" style="background:#9bf6ff">
<!---->
<h6 class="oxy-card-title">Discovery of x-rays
</h6>
<div class="image_box">
<img src="Pictures/resized/rontgen.jpg" style="width:10vw;">
</div>
<span class="collapsable">Did you know:</span>
<div class="oxy-card-content">
<div>
The picture shows the first x-ray image, taken of Anna Bertha Ludwig's hand by Wilhelm Röntgen shortly after the discovery of x-rays. The image shows the bones of her hand and her wedding ring.
</div>
</div>
</div>
</oxy-card>
</div>
<div class="grid-item mdl-shadow--2dp">
<oxy-card>
<div class="oxy-card" id="oxycard5" style="background:#a0c4ff">
<!---->
<h6 class="oxy-card-title">First CT scanner
</h6>
<div class="image_box">
<img src="Pictures/resized/emi.jpg" style="width:10vw;">
</div>
<span class="collapsable">Did you know:</span>
<div class="oxy-card-content">
<div>
The first CT scanner was created at EMI central research laboratories by Godfrey Hounsfield, and later used to perform the first brain scans on patients.
</div>
</div>
</div>
</oxy-card>
</div>
<div class="grid-item mdl-shadow--2dp">
<oxy-card>
<div class="oxy-card" id="oxycard6" style="background:#bdb2ff">
<!---->
<h6 class="oxy-card-title">Radon transform
</h6>
<div class="image_box">
<img src="Pictures/resized/radon.png" style="width:10vw;">
</div>
<span class="collapsable">Did you know:</span>
<div class="oxy-card-content">
<div>
Johann Radon was the mathematician to first describe the integral transform of lines through a volume, a technique required to reconstruct an image from 2D x-ray projections.
</div>
</div>
</div>
</oxy-card>
</div>
<div class="grid-item mdl-shadow--2dp">
<oxy-card>
<div class="oxy-card" id="oxycard7" style="background:#ffc6ff">
<!---->
<h6 class="oxy-card-title">First computer algorithm
</h6>
<div class="image_box">
<img src="Pictures/resized/lovelace.jpg" style="width:10vw;">
</div>
<span class="collapsable">Did you know:</span>
<div class="oxy-card-content">
<div>
The first computer algorithm was written by Ada Lovelace, it was designed to be used on a hypothetical computational device to calculate the sequence of Bernoulli numbers.
</div>
</div>
</div>
</oxy-card>
</div>
</div>
</div>
<div class="demo--containment__container2">
<div class="grid2">
<div class="grid-item-result"><div class="result-container" id="date0"></div></div>
<div class="grid-item-result"><div class="result-container" id="date1"></div></div>
<div class="grid-item-result"><div class="result-container" id="date2"></div></div>
<div class="grid-item-result"><div class="result-container" id="date3"></div></div>
<div class="grid-item-result"><div class="result-container" id="date4"></div></div>
<div class="grid-item-result"><div class="result-container" id="date5"></div></div>
<div class="grid-item-result"><div class="result-container" id="date6"></div></div>
<div class="grid-item-result"><div class="result-container" id="date7"></div></div>
</div>
</div>
<div class="button-container">
<button type="button" id='btn' class="check_button green" class="inline" style="height:5vh;width:10vw;">Check order!</button>
<button type="button" class="shuffle_button red" class="inline" style="height:5vh;width:10vw;">Reset</button>
</div>
<!-- <div class="logo">
<img src="Science_Up_Close_Logo_CMYK.png" class="float-right" style="height:5vh;">
</div> -->
</body>
</html>