-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtask-run-navigator.html
704 lines (597 loc) · 25.3 KB
/
task-run-navigator.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
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
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-touch-fullscreen" content="yes" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
<!-- Primary Meta Tags -->
<title>Buried Archaeology</title>
<meta name="title" content="Buried Archaeology" />
<meta name="description" content="Buried Archaeology." />
<script type="text/javascript"
src="https://code.jquery.com/jquery-3.4.1.min.js"
integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
crossorigin="anonymous"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script type="text/javascript"
src="https://cdnjs.cloudflare.com/ajax/libs/PapaParse/5.0.0/papaparse.min.js" ></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"
integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM"
crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"></link>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T"
crossorigin="anonymous"></link>
<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.9.0/css/all.min.css">
</link>
<style>
.vertical-center-container {
height: 100%;
position: relative;
}
.vertical-center {
margin: 0;
position: absolute;
top: 50%;
-ms-transform: translateY(-50%);
transform: translateY(-50%);
}
.slider-container{
width: 220px;
overflow: hidden; /* will contain if #first is longer than #second */
}
.slider-label {
padding-top:5px;
width: 75px;
float:left; /* add this */
}
.slider-slider {
padding-top:12px;
padding-left:75px;
width: 180px;
}
.imagery {
/*transition: transform .2s;*/
border-width: 1px;
border-style: solid;
border-color: white;
border-radius: 0px;
padding: 0px;
}
div.disabled{
pointer-events: none;
/* for "disabled" effect */
opacity: 0.5;
}
/* Absolute Center Spinner */
.loading {
position: fixed;
z-index: 999;
height: 2em;
width: 2em;
overflow: visible;
margin: auto;
top: 0;
left: 0;
bottom: 0;
right: 0;
}
/* Transparent Overlay */
.loading:before {
content: '';
display: block;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0,0,0,0.3);
}
/* :not(:required) hides these rules from IE9 and below */
.loading:not(:required) {
/* hide "loading..." text */
font: 0/0 a;
color: transparent;
text-shadow: none;
background-color: transparent;
border: 0;
}
.loading:not(:required):after {
content: '';
display: block;
font-size: 10px;
width: 1em;
height: 1em;
margin-top: -0.5em;
-webkit-animation: spinner 1500ms infinite linear;
-moz-animation: spinner 1500ms infinite linear;
-ms-animation: spinner 1500ms infinite linear;
-o-animation: spinner 1500ms infinite linear;
animation: spinner 1500ms infinite linear;
border-radius: 0.5em;
-webkit-box-shadow: rgba(0, 0, 0, 0.75) 1.5em 0 0 0, rgba(0, 0, 0, 0.75) 1.1em 1.1em 0 0, rgba(0, 0, 0, 0.75) 0 1.5em 0 0, rgba(0, 0, 0, 0.75) -1.1em 1.1em 0 0, rgba(0, 0, 0, 0.5) -1.5em 0 0 0, rgba(0, 0, 0, 0.5) -1.1em -1.1em 0 0, rgba(0, 0, 0, 0.75) 0 -1.5em 0 0, rgba(0, 0, 0, 0.75) 1.1em -1.1em 0 0;
box-shadow: rgba(0, 0, 0, 0.75) 1.5em 0 0 0, rgba(0, 0, 0, 0.75) 1.1em 1.1em 0 0, rgba(0, 0, 0, 0.75) 0 1.5em 0 0, rgba(0, 0, 0, 0.75) -1.1em 1.1em 0 0, rgba(0, 0, 0, 0.75) -1.5em 0 0 0, rgba(0, 0, 0, 0.75) -1.1em -1.1em 0 0, rgba(0, 0, 0, 0.75) 0 -1.5em 0 0, rgba(0, 0, 0, 0.75) 1.1em -1.1em 0 0;
}
/* Animation */
@-webkit-keyframes spinner {
0% {
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-ms-transform: rotate(0deg);
-o-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
-moz-transform: rotate(360deg);
-ms-transform: rotate(360deg);
-o-transform: rotate(360deg);
transform: rotate(360deg);
}
}
@-moz-keyframes spinner {
0% {
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-ms-transform: rotate(0deg);
-o-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
-moz-transform: rotate(360deg);
-ms-transform: rotate(360deg);
-o-transform: rotate(360deg);
transform: rotate(360deg);
}
}
@-o-keyframes spinner {
0% {
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-ms-transform: rotate(0deg);
-o-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
-moz-transform: rotate(360deg);
-ms-transform: rotate(360deg);
-o-transform: rotate(360deg);
transform: rotate(360deg);
}
}
@keyframes spinner {
0% {
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-ms-transform: rotate(0deg);
-o-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
-moz-transform: rotate(360deg);
-ms-transform: rotate(360deg);
-o-transform: rotate(360deg);
transform: rotate(360deg);
}
}
/*
.imagery-sample {
transition: transform .2s;
}
/*
.imagery:hover{
transform: scale(2.5);
cursor: crosshair;
}*/
</style>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<div class="input-group">
<div class="custom-file" align="left">
<input type="file" class="custom-file-input" id="file-task-info"
onchange="handleTaskInfoCsvFile(this.files)">
<label class="file-task-info-label custom-file-label" for="file-task-info">Upload task info file...</label>
</div>
</div>
</li>
<li class="nav-item">
<div class="input-group" style="padding-left:20px;">
<div class="custom-file" align="left">
<input type="file" class="custom-file-input" id="file-task-runs"
onchange="handleTaskRunCsvFile(this.files)">
<label class="file-task-runs-label custom-file-label" for="file-task-runs">Upload task runs file...</label>
</div>
</div>
</li>
<li class="nav-item">
<form style="padding-left:20px;">
<div class="form-group">
<select class="threshold-select form-control">
<option>0</option>
<option selected>1</option>
<option>2</option>
<option>3+</option>
</select>
</div>
</form>
</li>
<li class="nav-item">
<div class="slider-container" style="padding-left:20px;">
<div class="slider-label">Tile size:</div>
<div class="slider-slider">
<div id="image-tile-size-slider"></div>
</div>
</div>
</li>
<li class="nav-item" style="width: 100px;">
<div class="task-id-value" style="padding-top: 5px;"></div>
</li>
<li class="nav-item" style="width: 100px;">
<div class="task-counter-label" style="padding-top: 5px;"></div>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle dropdown-toggle-locate" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fas fa-map-marked-alt"></i> Locate
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item link-bing-map" target="_blank" href="#">Bing Maps</a>
<a class="dropdown-item link-google-map" target="_blank" href="#">Google Maps</a>
</div>
</li>
</li>
</ul>
</div>
</nav>
<div class="alert alert-danger alert-no-task-run-with-requested-threshold" role="alert" align="center" style="display:none;margin:0">
There are no tasks with the requested threshold.
</div>
<div class="alert alert-primary alert-no-previous" role="alert" align="center" style="display:none;margin:0">
There are no more previous tasks.
</div>
<div class="alert alert-primary alert-no-next" role="alert" align="center" style="display:none;margin:0">
There are no more tasks left.
</div>
<div class="container-fluid" align="center">
<div class="row" style="height:100%">
<div class="col-sm-1 vertical-center-container" style="display:none;">
<div class="vertical-center">
<a class="btn btn-nav btn-nav-previous"
style="font-size: 48px; color: Dodgerblue;"
href="#">
<i class="fas fa-arrow-circle-left"></i>
</a>
</div>
</div>
<div class="col-sm-10">
<div id="imagery-container">
</div>
<p calls="imagery-credit" style="font-size:9px;display:none" >
<span>© 2018 Microsoft / Bolm</span>
</p>
</div>
<div class="col-sm-1 vertical-center-container" style="display:none;">
<div class="vertical-center">
<a class="btn btn-nav btn-nav-next"
style="font-size: 48px; color: Dodgerblue;"
href="#">
<i class="fas fa-arrow-circle-right"></i>
</a>
</div>
</div>
</div>
</div>
<script type="text/javascript">
var BING_API_KEY = 'XXXX';
var BING_URL = "https://www.bing.com/maps?cp="
var BING_ZOOM_LEVEL = 17
var BING_URL_PARAMS = "&lvl=" + BING_ZOOM_LEVEL + "&style=h&v=2&sV=2"
var GOOGLE_URL = "http://maps.google.com/maps"
var GOOGLE_ZOOM_LEVEL = 17
var GOOGLE_URL_PARAMS = "?z=" + GOOGLE_ZOOM_LEVEL + "&t=k&q=loc:"
var ANSWER_YES = 'Yes';
var ANSWER_NO = 'No';
var ANSWER_BAD_IMAGE = 'Bad Image';
var KEY_DATA = 'data';
var KEY_YES = 'yes';
var KEY_NO = 'no';
var KEY_BAD_IMAGE = 'bad';
var KEY_ID = 'id';
var KEY_TASK_ID = 'task_id';
var KEY_INFO = 'info';
var KEY_IMG_URL = 'img_url';
var KEY_IMG_URL_SUBDOMAIN = 'img_url_subdomain';
var KEY_LAT = 'lat';
var KEY_LNG = 'lng';
var KEY_TILES_X = 'tiles_x';
var KEY_TILES_Y = 'tiles_y';
var IMG_TILE_HEIGHT_DEFAULT = 160;
var img_height = null; // Custom image height.
var threshold = 1;
var task_run_view_index = 0;
var task_info_dict = {};
var task_run_dict = {};
var filtered_task_runs = {};
$("#file-task-runs").prop('disabled', true);
$(".threshold-select").prop('disabled', true);
$(".slider-container").addClass('disabled');
$('.dropdown-toggle-locate').addClass('disabled');
$('.threshold-select').on('change', function() {
threshold = this.value === '1' ? 1 : this.value;
// reset.
task_run_view_index = 0;
// rebuild task viewer slideshow.
renderTask(threshold, 0)
});
$("#image-tile-size-slider").slider({
orientation: "horizontal",
range: "min",
min: 0,
max: 200,
step: 20,
value: 0,
change: function( event, ui ) {
var height_increment = parseInt(ui.value);
img_height = IMG_TILE_HEIGHT_DEFAULT + height_increment;
$('.imagery').css('height', img_height + "px");
}
});
function handleTaskInfoCsvFile(files){
$('.container-fluid').addClass("loading");
task_info_dict = {};
// Process CSV file.
Papa.parse(files[0], {
header: true,
skipEmptyLines: true, // Doesn't seem to work.
dynamicTyping: true,
step: function(row){
var data = row[KEY_DATA];
if(data['img_url'] == undefined){
// When does this happen?
console.log("Skipped an empty row. Investigate this.", row);
}else{
task_info_dict[data[KEY_TASK_ID]] = {};
task_info_dict[data[KEY_TASK_ID]][KEY_IMG_URL] = data[KEY_IMG_URL].replace('{subdomain}', data[KEY_IMG_URL_SUBDOMAIN]).replace('BING_API_KEY', BING_API_KEY);
task_info_dict[data[KEY_TASK_ID]][KEY_LAT] = data[KEY_LAT];
task_info_dict[data[KEY_TASK_ID]][KEY_LNG] = data[KEY_LNG];
task_info_dict[data[KEY_TASK_ID]][KEY_TILES_X] = data[KEY_TILES_X];
task_info_dict[data[KEY_TASK_ID]][KEY_TILES_Y] = data[KEY_TILES_Y];
}
},
complete: function() {
console.log("" + Object.keys(task_info_dict).length + " task infos loaded.");
// TODO: Enable second file selector.
$(".file-task-info-label").html(files[0].name);
$("#file-task-runs").prop('disabled', false);
$('.container-fluid').removeClass("loading");
}
});
}
function handleTaskRunCsvFile(files){
$('.container-fluid').addClass("loading");
task_run_dict = {};
skip_header = true; // Use this flage because the header option for PapaParse does not work for this dataset.
// Process CSV file.
Papa.parse(files[0], {
header: false, // Papaparse fails miserable processing headers with some cells are blank.
skipEmptyLines: true, // Doesn't seem to work.
dynamicTyping: false, // Papaparse fails miserable at dynamic typing for this dataset.
step: function(row){
if(skip_header){
skip_header = false;
}else{
var data = row[KEY_DATA];
var task_run_id = parseInt(data[4]);
var task_id = parseInt(data[8]);
var answer = data[5];
if(task_id in task_run_dict){
if(answer === ANSWER_YES){
task_run_dict[task_id][KEY_YES] = task_run_dict[task_id][KEY_YES] + 1;
}else if(answer === ANSWER_NO){
task_run_dict[task_id][KEY_NO] = task_run_dict[task_id][KEY_NO] + 1;
}else if(answer === ANSWER_BAD_IMAGE){
task_run_dict[task_id][KEY_BAD_IMAGE] = task_run_dict[task_id][KEY_BAD_IMAGE] + 1;
}else{
var errorMsg = "Unexpected answer for input " + task_run_id + " in task " + task_id + ": " + answer;
console.error(errorMsg);
alert(errorMsg);
}
}else if(task_id in task_info_dict){
// Set the task info values retrieved from the task info only CSV.
task_run_dict[task_id] = {}
task_run_dict[task_id][KEY_INFO] = {}
task_run_dict[task_id][KEY_INFO][KEY_IMG_URL] = task_info_dict[task_id][KEY_IMG_URL]
task_run_dict[task_id][KEY_INFO][KEY_LAT] = task_info_dict[task_id][KEY_LAT]
task_run_dict[task_id][KEY_INFO][KEY_LNG] = task_info_dict[task_id][KEY_LNG]
task_run_dict[task_id][KEY_INFO][KEY_TILES_X] = task_info_dict[task_id][KEY_TILES_X]
task_run_dict[task_id][KEY_INFO][KEY_TILES_Y] = task_info_dict[task_id][KEY_TILES_Y]
if(answer === ANSWER_YES){
task_run_dict[task_id][KEY_YES] = 1;
task_run_dict[task_id][KEY_NO] = 0;
task_run_dict[task_id][KEY_BAD_IMAGE] = 0;
}else if(answer === ANSWER_NO){
task_run_dict[task_id][KEY_YES] = 0;
task_run_dict[task_id][KEY_NO] = 1;
task_run_dict[task_id][KEY_BAD_IMAGE] = 0;
}else if(answer === ANSWER_BAD_IMAGE){
task_run_dict[task_id][KEY_YES] = 0;
task_run_dict[task_id][KEY_NO] = 0;
task_run_dict[task_id][KEY_BAD_IMAGE] = 1;
}else{
var errorMsg = "Unexpected answer for input " + task_run_id + " in task " + task_id + ": " + answer;
console.error(errorMsg);
alert(errorMsg);
}
}else{
// When does this happen?
console.log("No task info for task id: " + task_id, row);
}
}
},
complete: function(results) {
// Filter based on positive answers
filtered_task_runs[0] = Object.keys(task_run_dict).reduce(function (filtered, key) {
if (task_run_dict[key][KEY_YES] == 0) filtered[key] = task_run_dict[key];
return filtered;
}, {});
filtered_task_runs[1] = Object.keys(task_run_dict).reduce(function (filtered, key) {
if (task_run_dict[key][KEY_YES] == 1) filtered[key] = task_run_dict[key];
return filtered;
}, {});
filtered_task_runs[2] = Object.keys(task_run_dict).reduce(function (filtered, key) {
if (task_run_dict[key][KEY_YES] == 2) filtered[key] = task_run_dict[key];
return filtered;
}, {});
filtered_task_runs[3] = Object.keys(task_run_dict).reduce(function (filtered, key) {
if (task_run_dict[key][KEY_YES] >= 3) filtered[key] = task_run_dict[key];
return filtered;
}, {});
console.log("" + Object.keys(filtered_task_runs[0]).length + " tasks with no positive user submission.");
console.log("" + Object.keys(filtered_task_runs[1]).length + " tasks with 1 positive user submission.");
console.log("" + Object.keys(filtered_task_runs[2]).length + " tasks with 2 positive user submissions.");
console.log("" + Object.keys(filtered_task_runs[3]).length + " tasks with at least 3 positive user submissions.");
renderTask(1, 0);
$(".file-task-runs-label").html(files[0].name);
$(".threshold-select").prop('disabled', false);
$(".slider-container").removeClass('disabled');
$('.dropdown-toggle-locate').removeClass('disabled');
$(".vertical-center-container").css('display', 'block');
$(".imagery-credit").css('display', 'block');
$('.container-fluid').removeClass("loading");
}
});
}
function renderTask(threshold, task_index){
// Check if there are task runs with the given threshold.
if($.isEmptyObject(filtered_task_runs[threshold])){
// If not let the user know.
$(".alert-no-task-run-with-requested-threshold").fadeTo(2000, 500).slideUp(500, function(){
$(".alert-no-task-run-with-requested-threshold").slideUp(500);
});
}else{
// There are task runs with the given threshold.
// Create gallery to navigate through task runs with the same threshold.
// Get the first task run and display it.
var task_run_id = Object.keys(filtered_task_runs[threshold])[task_index];
var task_run = filtered_task_runs[threshold][task_run_id];
// Each task is a 2D grid.
// Get the size of that grid in order to iterate over it.
var tiles_x = task_run[KEY_INFO][KEY_TILES_X];
var tiles_y = task_run[KEY_INFO][KEY_TILES_Y];
// Build an image HTML element for each tile in the grid.
var img_elem_dict = {};
for(var tile_id=0; tile_id < (tiles_x * tiles_y); tile_id++){
var img = $('<img class="imagery" id="imagery' + tile_id + '" data-index="' + tile_id + '" />');
// Build image URL.
var img_url = task_run[KEY_INFO][KEY_IMG_URL].replace('{tileId}', tile_id);
// Set HTML properties.
img.attr('src', img_url);
img.addClass('img-thumbnail img-responsive');
if(img_height == null){
img_height = IMG_TILE_HEIGHT_DEFAULT;
img.css('height', img_height);
}else{
img.css('height', img_height);
}
// Store image in an array
img_elem_dict['image' + tile_id] = img;
}
// Now that the image HTML elements have been built, append them to the container.
// This could have been done inline in the previous loop but we favoured copy and pasting
// already tested and validated logic from the task presenter.
// Start with clearing all images previously appended.
$('#imagery-container').empty();
// Track tile_id.
var tile_id = 0;
for(var y=0; y <tiles_y; y++){
for(var x=0; x<tiles_x; x++){
// If the tile grid is a 4x3 layout, then don't show the outer grids.
// This is because they are always mostly black and their areas are covered
// by neighboring tasks.
if(!((tiles_x == 4 && (tile_id+1) % 4 == 0) || (tiles_x == 4 && tile_id > 7))){
$('#imagery-container').append(img_elem_dict['image' + tile_id]);
}
// Increment tile Id prioe to next iteration so that next image is fetched.
tile_id++;
}
// Next loop is the beginning of a new row of tiles.
// Skip line to start a new row.
if((tiles_x == 3 && tile_id <= 9) || tiles_x == 4){
$('#imagery-container').append('<br>');
}
}
// Reset Bing and Google map links to load new map location.
var lat = task_run[KEY_INFO][KEY_LAT];
var lng = task_run[KEY_INFO][KEY_LNG];
var bing_url = BING_URL + lat + "~" + lng + BING_URL_PARAMS;
var google_url = GOOGLE_URL + GOOGLE_URL_PARAMS + lat + "+" + lng
$('.link-bing-map').attr('href', bing_url)
$('.link-google-map').attr('href', google_url)
// Update task id.
$('.task-id-value').text("Task #" + task_run_id);
// Update task counter.
$('.task-counter-label').text((task_index +1) + "/" + Object.keys(filtered_task_runs[threshold]).length);
}
}
function nextTask(){
if(task_run_view_index < Object.keys(filtered_task_runs[threshold]).length-1){
task_run_view_index++;
renderTask(threshold, task_run_view_index);
}else{
$(".alert-no-next").fadeTo(2000, 500).slideUp(500, function(){
$(".alert-no-next").slideUp(500);
});
}
}
function previousTask(){
if(task_run_view_index > 0){
task_run_view_index--;
renderTask(threshold, task_run_view_index);
}else{
$(".alert-no-previous").fadeTo(2000, 500).slideUp(500, function(){
$(".alert-no-previous").slideUp(500);
});
}
}
$(".btn-nav-next").click(function() {
nextTask();
});
$(".btn-nav-previous").click(function() {
previousTask();
});
// Making sure that the buttons are under the zoomed in tiles.
$("#imagery-container").mouseover(function() {
$( ".btn-nav").css('z-index', -1);
});
// Making sure that the buttons remain clickable.
$( "#imagery-container" ).mouseleave(function() {
$(".btn-nav").css('z-index', 1);
});
// Navigate using keys.
$(document).ready(function() {
$(this).keydown(function(e) {
if(e.keyCode == 8 || e.keyCode == 37){
// user has pressed backspace or arrow left.
e.preventDefault();
previousTask();
}
if(e.keyCode == 32 || e.keyCode == 39){
// user has pressed space or arrow right
e.preventDefault();
nextTask();
}
});
});
</script>
</body>
</html>