-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
406 lines (382 loc) · 15 KB
/
index.html
File metadata and controls
406 lines (382 loc) · 15 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
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
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
<html>
<head>
<title>Binary search Visualisation</title>
<link rel="stylesheet" href="css/style.css">
<script src="js/jquery-3.5.1.min.js"></script>
<script src="js/script.js"></script>
</head>
<body>
<!-- =========== Push question popup ========== -->
<div class="question-modal" id="dropmenu">
<div id="modal-head">
<h2>Where do you want to drop the Bomb?</h2>
<span class="close-menu close-btn">×</span>
</div>
<div id="modal-content">
<div id="answer">
<div id="ans-left">
<div class="option" id="option-a">
<div class="option-title">Park</div>
<div class="population">100</div>
</div>
<div class="option" id="option-b">
<div class="option-title">School</div>
<div class="population">500</div>
</div>
<div class="option" id="option-c">
<div class="option-title">Temple</div>
<div class="population">600</div>
</div>
<div class="option" id="option-d">
<div class="option-title">Hospital</div>
<div class="population">800</div>
</div>
</div>
<div id="ans-right">
<div class="option" id="option-e">
<div class="option-title">Mall</div>
<div class="population">1000</div>
</div>
<div class="option" id="option-f">
<div class="option-title">Bus Stop</div>
<div class="population">1500</div>
</div>
<div class="option" id="option-g">
<div class="option-title">Railways</div>
<div class="population">2000</div>
</div>
<div class="option" id="option-h">
<div class="option-title">Not this city</div>
<div class="population">>5000</div>
</div>
</div>
</div>
</div>
</div>
<!-- ======== Push question popup ends ======== -->
<!-- Wrapper for whole HTML document -->
<div class="wrapper">
<!-- ==== launch buttons ==== -->
<div class="btn-wrapper">
<button id="launch">Instructions</button>
<button id="gameLaunch">Instructions</button>
</div>
<!-- ===== Instructions for algorithmic Visualisation ===== -->
<div id="popup">
<span class="close">×</span>
<h2>Instructions :</h2>
<ul id="instructions">
<h3 style="text-align: left;">Limiatations of Binary search -</h3>
<p class="code-line" style="text-align: justify; font-size: 18px; line-height: 24px;">
To Search any element in an array using Binary search, the array must be sorted.
For your convinience we are performing internal sorting of your given input. So, the array you will see in Simulation panel will already be sorted to give you a better experience of Binary search Algorithm.
</p>
<li class="list-items">Scroll Page for options available</li>
<li class="list-items">There are two panes in the bottom:</li>
<li class="list-items">One for taking Inputs and</li>
<li class="list-items">Second to elaborate code step-by-step</li>
<li class="list-items">
Enter the values and press "Show" to show the entered data
</li>
<li class="list-items">
To search any element, enter that and press "Start"
</li>
<li class="list-items">
Please don't enter any new search while one is Searching
</li>
</ul>
<!-- Actions -->
<div class="btn-container">
<input
type="button"
name="input"
value="Start Simulation"
onclick="init()"
class="btn btn-red"
/>
<input
type="button"
name="input"
value="Gamified Visualisation"
class="btn btn-yellow"
onclick="runVisualisation()"
/>
<input
type="button"
name="start"
value="Enter your Array"
onclick="input()"
class="btn btn-green"
/>
</div>
</div>
<!-- =========== Instructions for gamified Visualisation ============= -->
<div id="gamePopup">
<span class="gameClose">×</span>
<h2>Binary Search Visualisation using Drop the Bomb Game</h2><br>
<ul id="gameInstructions">
<li class="list-items">
This [Drop the Bomb] interface is a gamified approach to illustrate the working of binary Search algorithm.
In this interface there is a Cop present on the left most side of the user screen (beside all the places in a city).
</li>
<li class="list-items">
The list of places are already sorted in increasing population order to represent the concept of sorted array in binary search.
</li>
<li class="list-items">
You as a user will drop a bomb to one of the given places similar to entering an element
to search it in the array using binary search approach.
</li>
<li class="list-items">
Upon placing the bomb the Cop will start moving towards each place from its initial position.
</li>
<li class="list-items">
Hospital with a population of 800 people is used to represent mid (initially) of the sorted array so the cop will move according to it.
</li>
<li class="list-items">
The cop will find its target place on binary search method moving <span style="color: #ffd000;">RIGHT</span> (to search a value larger than mid) and <span style="color: #ffd000;">LEFT</span> (to search a value lower than mid)
</li>
<li class="list-items">
If the cop reaches the location where bomb was planted it will glow with Green color showing <span style="color: #4caf50;">SUCCESS</span>.
</li>
<li class="list-items">
If it fails finding the bomb at a given place it will glow in Red showing <span style="color: #ff0730;">FAILURE</span>. and will move towards next place.
</li>
</ul>
<!-- Actions -->
<div class="btn-container">
<input
type="button"
name="start"
value="Drop the Bomb"
onclick="drop()"
class="btn btn-red"
/>
<input
type="button"
name="start"
value="Back to Algorithmic Visualisation"
class="btn btn-green"
onclick="loadSimulation()"
/>
</div>
</div>
<!-- ========= content for gameboard ========= -->
<div id="gameboard">
<div id="up">
<div id="places">
<fieldset class="place" id="park">
<legend class="icon"><img src="images/park.png" alt="park"></legend>
Park
<p class="population-count">100</p>
</fieldset>
<fieldset class="place" id="school">
<legend class="icon"><img src="images/school.png" alt="school"></legend>
School
<p class="population-count">500</p>
</fieldset>
<fieldset class="place" id="temple">
<legend class="icon"><img src="images/temple.png" alt="temple"></legend>
Temple
<p class="population-count">600</p>
</fieldset>
<fieldset class="place" id="hospital">
<legend class="icon"><img src="images/hospital.png" alt="hospital"></legend>
Hospital
<p class="population-count">800</p>
</fieldset>
<fieldset class="place" id="shopping">
<legend class="icon"><img src="images/mall.png" alt=""></legend>
Mall
<p class="population-count">1000</p>
</fieldset>
<fieldset class="place" id="bus">
<legend class="icon"><img src="images/bus.png" style="background: #b3a55b;" alt="bus"></legend>
Bus Stop
<p class="population-count">1500</p>
</fieldset>
<fieldset class="place" id="railway">
<legend class="icon"><img src="images/train.png" alt="railway"></legend>
Railway
<p class="population-count">2000</p>
</fieldset>
</div>
</div>
<div id="down">
<img src="images/policeman.png" alt="" id="cop" class="cop animate">
<div id="trail">
<div class="spot"></div>
<div class="spot"></div>
<div class="spot"></div>
<div class="spot"></div>
<div class="spot"></div>
<div class="spot"></div>
<div class="spot"></div>
<div class="spot"></div>
</div>
<div class="btn-container">
<div class="btn btn-yellow" onclick="location.reload();">Search Again ↺ </div>
<input
type="button"
name="start"
value="Jump to Algorithmic Visualisation"
class="btn btn-green"
onclick="loadSimulation()"
/>
</div>
<div id="content-row">
<!-- ========== tooltip label ============ -->
<div class="tooltip">
<div class="right">
<h4 style="color: #d0fffd; font-weight: 400; text-shadow: none; text-align: left; font-size: 16px;">What's your Status, Cop?</h4>
<p id="status" class="animtext"></p>
<i></i>
</div>
</div>
<!-- ========= drop icon ========= -->
<div id="clickIcon" onclick="drop();">
<span style="padding: 20px 10px; font-size: 18px; color: #dbdbdb;">Click Here ^_~</span>
<img src="images/bomb.png" alt="bomb icon" id="bomb" class="blinkbomb" caption="Click Me!">
</div>
</div>
</div>
</div>
<!-- ===== container for simulator area ===== -->
<div id="simulator-area">
<div id="container">
<!-- ======= This is Canvas area ========= -->
<div id="canvas" class="box box-full">
<h2 style="position: absolute">Binary Search Visualisation</h2>
<!-- Canvas Element to draw Animations -->
<div id="canvas-wrapper">
<div id="target"></div>
</div>
<!-- Labels to show data steps -->
<div class="check" id="check">
<p id="label1"></p>
<p id="label2"></p>
</div>
<!-- Current Step in Algorithm -->
<li class="code-line current-step" id="explanation">
Current Algorithm steps explaination will appear here<br/>
</li>
<!-- Canvas Actions -->
<div class="btn-container" id="actions">
<input
type="button"
name="input"
value="< Prev"
onclick = "backward()"
class="btn btn-yellow hide"
id="prev"
/>
<input hidden
id="h1"
type="button"
name="input"
value="Reset steps"
onclick="reset()"
class="btn btn-red"
/>
<input hidden
id="h2"
type="button"
name="input"
value="Next Step"
onclick="next()"
class="btn btn-green"
/>
<input
type="button"
name="reset"
value="Start"
onclick="init()"
class="btn btn-red show"
id="start"
/>
<input
type="button"
name="start"
value="Next >"
onclick="forward()"
class="btn btn-green hide"
id="next"
/>
</div>
</div>
<!-- ============= Canvas area ends here ============ -->
<!-- ========= This is Input Area ======== -->
<div id="input" class="box hide">
<h2>Enter the values to perform Binary Search</h2>
<!-- Form Inputs -->
<div class="inputs">
<input
type="text"
id="length"
class="input"
placeholder="Enter size of array"
required
/><br />
<input
type="text"
id="array"
class="input values"
placeholder="Enter Array elements in ''Sorted Order'' using , (comma)"
required
/><br />
<input
type="text"
name="input"
id="enter"
class="input"
placeholder="Element to Search"
required
/><br />
</div>
<!-- Actions to perform -->
<div class="btn-container">
<input
type="button"
name="input"
value="Show"
onclick="execute()"
class="btn btn-yellow"
/>
<input
type="button"
name="reset"
value="Reset"
onclick="reset()"
class="btn btn-red"
/>
</div>
<!-- </form> -->
</div>
<!-- ========= Live Updates area ========== -->
<div id="code" class="box box-half">
<h2>Values of Variables at each step</h2>
<!-- ========= box for live tracking of variables values =========== -->
<div id="step-tracker">
<!-- Start Box -->
<div id="start-step" class="step-box">
<h3 class="box-title">Value of <br> <b class="blink">"Start"</b> <br> is</h3>
<h1 class="box-value" id="start-val"></h1>
</div>
<!-- Mid Box -->
<div id="mid-step" class="step-box">
<h3 class="box-title">Value of <br> <b class="blink">"Mid"</b> <br> is</h3>
<h1 class="box-value" id="mid"></h1>
</div>
<!-- Last Box -->
<div id="last-step" class="step-box">
<h3 class="box-title">Value of <br> <b class="blink">"Last"</b> <br> is</h3>
<h1 class="box-value" id="last"></h1>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
<script src="js/jquery-3.5.1.min.js"></script>
<script src="js/script.js"></script>
</html>