This repository has been archived by the owner on Nov 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimGame.html
351 lines (342 loc) · 18.1 KB
/
simGame.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
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:svg="http://www.w3.org/2000/svg">
<head>
<!--[if lt IE 9]><script language="javascript" type="text/javascript" src="scripts/excanvas.js"></script><![endif]-->
<script type="text/javascript" src="scripts/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script type="text/javascript" src="scripts/jquery.jqplot.min.js"></script>
<script type="text/javascript" src="scripts/plugins/jqplot.cursor.min.js"></script>
<script type="text/javascript" src="scripts/plugins/jqplot.canvasTextRenderer.min.js"></script>
<script type="text/javascript" src="scripts/plugins/jqplot.canvasAxisLabelRenderer.min.js"></script>
<script type="text/javascript" src="scripts/plugins/jqplot.canvasAxisTickRenderer.min.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<link rel="stylesheet" href="/resources/demos/style.css" />
<link rel="stylesheet" type="text/css" media="screen" href="jsparc.css" />
<link rel="stylesheet" type="text/css" media="screen" href="scripts/jquery.jqplot.min.css" />
<script>
var kMax = 0;
var hours = ['00','01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24'];
var events = new Array();
var coinc = new Array();
var station = new Array();
var statInfo = new Array();
var url = new Array;
var year = 2013;
var month = 01;
var day = 01;
var hour = 01;
function createPage2(statInfo){//alert(statInfo[0].scintillators)
var statList = "<select><option value='Kaart'>Kaart</option>";
var detMap = "<div id='detectorMap'>";
var statTab = "";
var quantity = new Array('<td>r [m]</td>','<td>α [<sup>o</sup>]</td>','<td>β [<sup>o</sup>]</td>','<td>MIP-peak [mV]</td>','<td>n [MIP]</td>','<td>t [ns]</td>');
var captionTab = "<tr><td>detector</td><td align='center' class='det1' style='border-radius:2px;'>1</td>";
var rRow = "";
var alfaRow = "<tr>";
var betaRow = "<tr>";
var peakRow = "<tr>";
var mipRow = "<tr>";
var nanoRow = "<tr>";
captionTab += "<td align='center' class='det2' style='border-radius:2px;'>2</td>";
captionTab += "<td align='center' class='det3' style='border-radius:2px;'>3</td>";
captionTab += "<td align='center' class='det4' style='border-radius:2px;'>4</td></tr>";
for(i=0; i<statInfo.length;i++){
statTab += '<table id="statIn'+i+'">';
statTab += captionTab;
statList += "<option value="+statInfo[i].number+">"+statInfo[i].number+": "+statInfo[i].name+"</option>";
detMap += "<div id='detectorMap0'>" + statInfo[i].number;
detMap += '<img id="gps" src="images/gps.png" alt="gps" />';
for(j=0; j<statInfo[i].scintillators; j++){
rRow += '<td><input id="r'+i+j+'" type=text value='+0+' size=5 /></td>';
alfaRow += '<td><input id="alfa'+i+j+'" type=text value='+0+' size=5 /></td>';
betaRow += '<td><input id="beta'+i+j+'" type=text value='+0+' size=5 /></td>';
peakRow += '<td><input id="MIP-peak'+i+j+'" type=text value='+0+' size=5 /></td>';
mipRow += '<td><input id="mip'+i+j+'" type=text value='+0+' size=5 /></td>';
nanoRow += '<td><input id="nano'+i+j+'" type=text value='+0+' size=5 /></td>';
detMap += '<img id="detector' + i + j + '" src="images/detector' + j+ '.png" alt="detector' + i + j + '" />'
}
detMap += "</div>";
}
statList += "</select>"
detMap += "</div>";
$("#page2").prepend(detMap);
$("#page2").prepend(statList);
}
/*
<tr>
<td>r [m]</td>
<td><input id="r00" type=text value=8 size=5 /></td>
<td><input id="r01" type=text value=3 size=5 /></td>
<td><input id="r02" type=text value=5 size=5 /></td>
<td><input id="r03" type=text value=5 size=5 /></td>
</tr>
<tr>
<td>α [<sup>o</sup>]</td>
<td><input id="alfa00" type=text value=0 size=5 /></td>
<td><input id="alfa01" type=text value=0 size=5 /></td>
<td><input id="alfa02" type=text value=90 size=5 /></td>
<td><input id="alfa03" type=text value=270 size=5 /></td>
</tr>
<tr>
<td>β [<sup>o</sup>]</td>
<td><input id="beta00" type=text value=0 size=5 /></td>
<td><input id="beta01" type=text value=0 size=5 /></td>
<td><input id="beta02" type=text value=90 size=5 /></td>
<td><input id="beta03" type=text value=270 size=5 /></td>
</tr>
<tr>
<td>MIP-peak [mV]</td>
<td><input id="MIP-peak00" type=text value=150 size=5 /></td>
<td><input id="MIP-peak01" type=text value=150 size=5 /></td>
<td><input id="MIP-peak02" type=text value=150 size=5 /></td>
<td><input id="MIP-peak03" type=text value=150 size=5 /></td>
</tr>
<tr>
<td colspan=5><input type="button" id="changeMap0" value="Change map" style='width:320px;'></input><td>
</tr>
<tr>
<td>n [MIP]</td>
<td><input id="mip00" type=text size=5 /></td>
<td><input id="mip01" type=text size=5 /></td>
<td><input id="mip02" type=text size=5 /></td>
<td><input id="mip03" type=text size=5 /></td>
</tr>
<tr>
<td>t [ns]</td>
<td><input id="nano00" type=text size=5 /></td>
<td><input id="nano01" type=text size=5 /></td>
<td><input id="nano02" type=text size=5 /></td>
<td><input id="nano03" type=text size=5 /></td>
</tr>
</table>*/
function makeMenu(id,choices){
var menuOut = "</ul>";
var tabsOut = "";
for(i = choices.length-1; i>=0 ; i--){
menuOut = "<li><a href='#" + id + "-" + choices[i].number+"'>" + choices[i].name + "</a></li>" + menuOut;
tabsOut = "<div id='" + id + "-" + choices[i].number+"'></div>" + tabsOut;
}
menuOut = "<ul id='" + id + "'>" + menuOut;
$('#' + id).append(menuOut);
$('#' + id).append(tabsOut);
}
function padZero(number, length) {
var str = '' + number;
while (str.length < length) {
str = '0' + str;}
return str;
}
function changeSelect(stationID){
station.push(stationID);
}
function getStations(URL, j) {
$("#page1").hide();
$("#page2").show();
$.get(URL,function(data){
//alert(data.number)
statInfo.push(data);
j++
if(j < station.length) {
getStations(url[j], j);
}
else {
createPage2(statInfo);
}
});
}
function getData(URL, j) {
$.get(URL,function(data){
var event = new Array();
var dataStr = new String(data); // parses data into a string
var record = dataStr.split('\n'); // creates an array of records
for(i = 0; i < record.length; i++){ // removes comment lines
if(record[0].substr(0,1) == "#") {
record.splice(0,1);
i--;
}
}
for(i = 0; i < record.length; i++){
event[i] = record[i].split('\t'); // creates a 2d array of station event information
}
events[j] = event; // creates 3d array with information of the selected stations
kMax += event.length-1;
j++
if(j < station.length) {
getData(url[j], j);
}
else {
var first, firstTime;
var output = '<table border = "1"><tr><th>station</th><th>event time</th>';
for(k = 0; k < kMax; k++) { // creates a chronological 2d array of event information
first = 0;
firstTime = '23:59:59:999999999';
for(i = 0; i < station.length; i++){
events[i][0][3] = padZero(events[i][0][3], 9);
time = events[i][0][1] + ':' + events[i][0][3];
if(time < firstTime){
firstTime = time;
first = i;
}
}
coinc[k] = events[first][0];
coinc[k].unshift(station[first]);
events[first].splice(0,1);
output += '</tr><tr><td>' + coinc[k][0] + '</td><td>' + coinc[k][2] + ':'+ coinc[k][4] + '</td>';
}
output += '</tr></table>';
$( "#CSVTable" ).append( output );
}
});
}
$(function() {
$("#page2").hide();
var date = '2013-07-25';
var time = '00';
$.get('http://data.hisparc.nl/api/subclusters/',function(subclusters){
$.get('http://data.hisparc.nl/api/clusters/',function(clusters){
$.get('http://data.hisparc.nl/api/stations/',function(stations){
$( "#progressbar" ).progressbar({
value: 47.5
});
for(i = 0; i < station.length; i++){
url[i] = 'http://data.hisparc.nl/data/' + station[i] + '/events?start=' + date + '+'+time+':00:00&end=' + date + '+01:00:00';
}
$('#datepicker').datepicker({ dateFormat: 'yy-mm-dd' }).val();
$('#stations').menu();
var hour;//alert(clusters[0].name)
makeMenu('tabs', clusters);
var iSub = subclusters.length-1;
var iStat = stations.length-1;
var subOut = new Array();
for(iCl = clusters.length-1; iCl>=0; iCl--){
subOut.length = 0;
while((iSub >= 0)&&(subclusters[iSub].number >= clusters[iCl].number)){
subOut.splice(0,0,subclusters[iSub]);
iSub--;
}
makeMenu('tabs-'+clusters[iCl].number, subOut);
for(i=subOut.length-1; i >= 0; i--){
$('#tabs-'+subOut[i].number).tabs();
while((iStat >= 0)&&(stations[iStat].number > subOut[i].number)){
$('#tabs-'+clusters[iCl].number+'-'+subOut[i].number).prepend("<p><input type='checkbox' onchange='changeSelect("+stations[iStat].number+")')/> " +stations[iStat].number+" "+stations[iStat].name+"</p>");
iStat--;
}
}
}
$("#tabs").tabs();
$("#loadEvents" ).click(function() {
$( "#stations" ).menu({ select: function( event, ui ) { alert(ui.item.attr("tag")); }});
var hour = $('#hourpicker :selected').val();
var startTime = hours[hour];
hour++;
var stopTime = hours[hour]
date = $('#datepicker').val();
for(i = 0; i < station.length; i++){
url[i] = 'http://data.hisparc.nl/data/' + station[i] + '/events?start=' + date + '+'+startTime+':00:00&end=' + date + '+'+stopTime+':00:00';
}
getData(url[0], 0);
});
$("#simEvents" ).click(function() {
$( "#stations" ).menu({ select: function( event, ui ) { alert(ui.item.attr("tag")); }});
for(i = 0; i < station.length; i++){
url[i] = 'http://data.hisparc.nl/api/station/' + station[i] + '/';
}
getStations(url[0], 0);
});
});
});
});
});
</script>
</head>
<body>
<div id="page1">
<div id = "tabs">
</div>
<div id="CSVTable"></div>
<p>Date:
<input type="text" id="datepicker" value="2013-01-01"/>
Time:
<select id="hourpicker">
<option value="0" text="iug">00 / 01</option>
<option value="1">01 / 02</option>
<option value="2">02 / 03</option>
<option value="3">03 / 04</option>
<option value="4">04 / 05</option>
<option value="5">05 / 06</option>
<option value="6">06 / 07</option>
<option value="7">07 / 08</option>
<option value="8">08 / 09</option>
<option value="9">09 / 10</option>
<option value="10">10 / 11</option>
<option value="11">11 / 12</option>
<option value="12">12 / 13</option>
<option value="13">13 / 14</option>
<option value="14">14 / 15</option>
<option value="15">15 / 16</option>
<option value="16">16 / 17</option>
<option value="17">17 / 18</option>
<option value="18">18 / 19</option>
<option value="19">19 / 20</option>
<option value="20">20 / 21</option>
<option value="21">21 / 22</option>
<option value="22">22 / 23</option>
<option value="23">23 / 24</option>
</select>
<input type="button" id="loadEvents" value="Load events" />
<input type="button" id="simEvents" value="Start simulation" />
<a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/deed.en_US">
<img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" />
</a>
</p>
</div>
<div id="page2">
<div id="statList" />
<div id="detMap" />
<div id="logo">
<a target="_blank" href="http://www.hisparc.nl/"><img src="http://data.hisparc.nl/media/static/header.png" /></a>
</div>
<a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/deed.en_US">
<img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" />
</a>
<div id="dashboard">
<table>
<tr>
<td colspan=2>energy</td><td><input id="energy" type=text value=5e12 size=5 /></td>
</tr>
<tr>
<td colspan=2></td><td>θ [<sup>o</sup>]</td><td>Φ [<sup>o</sup>]</td>
</tr>
<tr>
<td colspan=2>direction</td>
<td><input id="theta" type=text value=0 size=5 /></td>
<td><input id="phi" type=text value=0 size=5 /></td>
</tr>
<tr>
<td colspan=2></td><td>r [m]</td><td>α [<sup>o</sup>]</td>
</tr>
<tr>
<td colspan=2>shower core</td>
<td><input id="r" type=text value=0 size=5 /></td>
<td><input id="alfa" type=text value=0 size=5 /></td>
</tr>
<tr>
<td colspan=4><input type="button" id="simShow" value="Simulate shower" style='width:200px;'></input></td>
</tr>
<tr>
<td id="ch0">
102
</td>
<td id="ch1">
104
</td>
<td id="ch2">
105
</td>
</tr>
</table>
</div>
</div>
</body>
</html>