-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathheatmapControl.html
More file actions
435 lines (349 loc) · 12.4 KB
/
heatmapControl.html
File metadata and controls
435 lines (349 loc) · 12.4 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
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
<html>
<head>
<!-- <meta name="viewport" content="initial-scale=1.0, user-scalable=no"/> -->
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?libraries=geometry,visualization&sensor=true"></script>
<script type="text/javascript" src="http://d3js.org/d3.v3.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script>
<script src="./jslib/controlpanel.js"></script>
<script src="./jslib/heatmap.js"></script>
<script src="./jslib/util.js"></script>
<style type="text/css">
#slider-range {width: 500px; left: 10px;}
#time-slider-option {width: 700px; left: 5px; visibility: hidden; display: none}
#basket-ball-period {visibility: visible; display: block}
#rounded{ /* the outermost div element */
width:800px;
margin:20px auto; /*center it on the page*/
}
.container{ /* this one contains our navigation, titles, and fetched content */
background-color:#FFFFFF;
padding:10px 20px 20px 20px;
}
input[type="button"] {
-moz-box-shadow:inset 0px -4px 0px 0px #ffffff;
-webkit-box-shadow:inset 0px -4px 0px 0px #ffffff;
box-shadow:inset 0px -4px 0px 0px #ffffff;
background-color:#ededed;
-moz-border-radius:6px;
-webkit-border-radius:6px;
border-radius:6px;
border:2px solid #dbdbdb;
display:inline-block;
color:#777777;
font-family:arial;
font-size:14px;
font-weight:bold;
padding:6px 24px;
text-decoration:none;
text-shadow:1px 1px 0px #ffffff;
height: 29px;
}input[type="button"]:hover {
background-color:#dfdfdf;
}input[type="button"]:active {
position:relative;
top:1px;
}
h1{ /* the heading */
font-size:28px;
font-weight:bold;
font-family:"Trebuchet MS",Arial, Helvetica, sans-serif;
}
h3{ /* the subheading */
font-weight:normal;
font-size:20px;
color:#999999;
}
select{
width: 100px;
height: 28px;
overflow: hidden;
/* background: url(new_arrow.png) no-repeat right #ddd;*/
border: 1px solid #ccc;
}
label {
color: #B4886B;
font-weight: bold;
display: block;
/*width: 150px;*/
float: left;
}
p{
color: #B4886B;
font-weight: bold;
display: block;
}
body{ /* styling the body */
margin-top:20px;
/* color:#51555C;*/
font-size:16px;
background-color:#123456;
}
#menu_div{ /* the container that holds our AJAX loaded content */
margin-top:20px;
border:1px dashed #cccccc;
padding:10px;
-moz-border-radius: 5px; /* rounding the element */
-khtml-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
}
/*#outer_pane {border-width: 1px; width: 800px; border-style: solid;}*/
</style>
<script>
</script>
</head>
<body>
<div id="rounded">
<img src="img/top_bg.gif" /><!-- image with rounded left and right top corners -->
<div id="main" class="container">
<h1 align="center">Spatiotemporal Data Analytics Tool</h1>
<div id = "menu_div">
<input type="button" id="home" value="Home" onClick="goHome()"></input>
</div>
<div id="outer_pane">
<span>
<p>Heat Map Options:
<select id="heatmap" onChange="onSelectOption()">
<option value="select">--select--</option>
<option value="Time">Time</option>
</select>
</br>
</p>
<div id="progress-bar-id" class="progress-bar-wrapper" style="visibility: hidden;">
<progress id="progressbar" value="0" max="100"></progress>
<span class="progress-value">0%</span>
</div>
<div id="time-slider-option" style="visibility: hidden;">
<div id="time-label-header">
<label for="range">Time range:</label>
<input type="text" id="range" style="border: 0; color: #f6931f; font-weight: bold; width: 300px;" />
</div>
</br>
<div id="slider-range"> </div>
</br>
<div id="basket-ball-period">
<div id="periodCombo">
<label for="period_label">Period Time: </label>
<select id="bb_time_period">
<option value="select">--select--</option>
<option value="p1">1</option>
<option value="p2">2</option>
<option value="p3">3</option>
<option value="p4">4</option>
</select>
</div>
<br/>
<input type="checkbox" id="all_bb_period_checkbox" value="value" onChange="onCheck()"/> All Period
</div>
</br>
<div id="generate_button">
<input type="button" id="generate_heatmap" value="Generate Visualization" onClick="generateHeatmap()"/>
</div>
</div>
</div>
</div>
<img src="img/bottom_bg.gif" />
</div>
</span>
<script type="text/javascript">
var objectParamsURL;
var jsonData;
var selectedDataSet;
var queryURL;
window.onload=function(){
getURLParameters();
ajaxCall(objectParamsURL);
}
function goHome(){
window.location.href = "index.html" + "?" + queryURL;
}
function ajaxCall(urlParams){
if(selectedDataSet == "Twitter"){
url ='twitter_heatmap.php?' + urlParams;
}else if(selectedDataSet == "BasketBall"){
url = 'bb_heatmap.php?' + urlParams;
}else if(selectedDataSet == "Campus Cruiser"){
url = 'cc_heatmap.php?' + urlParams;
}
$.ajax({
url: url,
type: 'GET',
dataType: 'text',
success: function(data){
jsonData = jQuery.parseJSON(data);
console.log(jsonData);
},
error: function(error, jqXHR)
{
alert(jqXHR);
}
});
}
function generateHeatmap(){
var startTime = $( "#slider-range" ).slider( "values", 0 );
var endTime = $( "#slider-range" ).slider( "values", 1 );
var url;
if(selectedDataSet == "Twitter"){
var end_date = createDate(endTime);
end_date.setDate(end_date.getDate() + 1);
var urlParams = objectParamsURL + "&" + "startTime=" + $.datepicker.formatDate('dd-MM-yy', createDate(startTime)) + "&" + "endTime=" + $.datepicker.formatDate('dd-MM-yy', end_date);
//url ='twitter_heatmap.php?' + urlParams;
url = urlParams;
}else if(selectedDataSet == "BasketBall"){
var period;
if(document.getElementById("all_bb_period_checkbox").checked){
// url = 'bb_heatmap.php?' + objectParamsURL + "&" + "startTime=" + startTime + "&" + "endTime=" + endTime;
url = objectParamsURL + "&" + "startTime=" + startTime + "&" + "endTime=" + endTime;
}
else{
var comboElement = document.getElementById("bb_time_period");
var selectedOption = comboElement.options[comboElement.selectedIndex].innerHTML;
if(selectedOption == "select"){
alert("Select the period.");
return;
}
url = objectParamsURL + "&" + "startTime=" + startTime + "&" + "endTime=" + endTime + "&" + "period=" + selectedOption;
}
}else if(selectedDataSet == "Campus Cruiser"){
url = objectParamsURL + "&" + "startTime=" + $.datepicker.formatDate('dd-MM-yy', createDate(startTime)) + "&" + "endTime=" + $.datepicker.formatDate('dd-MM-yy', createDate(endTime));
}
window.location.href = "heatmap.html?dataset=" + selectedDataSet + "&" + url;
}
function onSelectOption(){
var comboElement = document.getElementById("heatmap");
var selectedOption = comboElement.options[comboElement.selectedIndex].value;
var min;
var max;
if(selectedOption == "Time"){
if(jsonData == null || jsonData.length <= 0){
showProgressBar();
fnProgressBar();
}else{
slider();
}
}else if(selectedOption == "select"){
var slider_div = document.getElementById("time-slider-option");
slider_div.style.visibility = "hidden";
slider_div.style.display = "none";
}
}
function fnProgressBar(){
var progressbar = $('#progressbar'),
max = progressbar.attr('max'),
time = (1000/max)*5,
value = progressbar.val();
var loading = function() {
if(value <= max){
value += 1;
addValue = progressbar.val(value);
$('.progress-value').html(value + '%');
if(jsonData == null || jsonData.length <= 0){
setTimeout(function() {progressbar.val(value + 3);}, 1500);
}
}
if (value >= max) {
clearInterval(animate);
progressbar.val(0);
slider();
}
};
var animate = setInterval(function() {
loading();
}, time);
}
function hideProgressBar(){
document.getElementById("progress-bar-id").style.visibility = 'hidden';
document.getElementById("progress-bar-id").style.display = 'none';
}
function showProgressBar(){
document.getElementById("progress-bar-id").style.visibility = 'visible';
document.getElementById("progress-bar-id").style.display = 'block';
}
function slider(){
var slider_div = document.getElementById("time-slider-option");
slider_div.style.visibility = "visible";
slider_div.style.display = "block";
var bb_period_div = document.getElementById("basket-ball-period");
bb_period_div.style.visibility = "hidden";
bb_period_div.style.display = "none";
hideProgressBar();
if(selectedDataSet == "Twitter" || selectedDataSet == "Campus Cruiser"){
min = getMinDate(jsonData).getTime();
max = getMaxDate(jsonData).getTime();
console.log("min: " + createDate(getMinDate(jsonData)));
console.log("max: " + createDate(getMaxDate(jsonData)));
if(!min && !max){
alert("Incorrect date");
}
$( "#slider-range" ).slider({
range: true,
min: min,
max: max,
step: 86400000,
values: [ min, max ],
slide: function( event, ui ) {
$( "#range" ).val( $.datepicker.formatDate('dd/MM/yy', createDate(ui.values[ 0 ])) + " - " + $.datepicker.formatDate('dd/MM/yy', createDate(ui.values[ 1 ] )));
}
});
$( "#range" ).val( $.datepicker.formatDate('dd/MM/yy', createDate($( "#slider-range" ).slider( "values", 0 ))) +
" - " + $.datepicker.formatDate('dd/MM/yy', createDate($( "#slider-range" ).slider( "values", 1 ))));
}else{
var bb_period_div = document.getElementById("basket-ball-period");
bb_period_div.style.visibility = "visible";
bb_period_div.style.display = "block";
min = 0;
max = 720;
if(!min && !max){
alert("Incorrect Range");
}
$( "#slider-range" ).slider({
range: true,
min: min,
max: max,
step: 60,
values: [ min, max ],
slide: function( event, ui ) {
start = (ui.values[ 0 ])/60;
end = (ui.values[ 1 ])/60;
$( "#range" ).val( start + " - " + end);
}
});
start = $( "#slider-range" ).slider( "values", 0 ) / 60;
end = $( "#slider-range" ).slider( "values", 1 ) / 60;
$( "#range" ).val(start +
" - " + end);
}
}
function getURLParameters()
{
var sURL = window.document.URL.toString();
if (sURL.indexOf("?") > 0)
{
var arrParams = sURL.split("?");
queryParams = arrParams[1];
queryURL = arrParams[1];
if(queryParams.indexOf("&") > 0){
var queryParamsSplitArray = queryParams.split("&");
var selectedDataSetURL = queryParamsSplitArray[0];
objectParamsURL = queryParamsSplitArray[1];
if(selectedDataSetURL.indexOf("=") > 0){
selectedDataSet = selectedDataSetURL.split("=")[1];
selectedDataSet = selectedDataSet.replace("%20", " ");
}
}
}
return "No Parameters Found";
}
function onCheck(){
if(document.getElementById("all_bb_period_checkbox").checked){
document.getElementById("bb_time_period").disabled = true;
}else{
document.getElementById("bb_time_period").disabled = false;
}
}
</script>
</body>
</html>