Skip to content

Commit 6055a40

Browse files
committed
Updates to new runs view
1 parent 4485dfe commit 6055a40

File tree

3 files changed

+245
-17
lines changed

3 files changed

+245
-17
lines changed

components/emo/js/emo_runs_streamer.js

Lines changed: 116 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,6 @@ function MakeRunsTable(div, url, templatediv, counterdiv){
5858
tags+='<a style="cursor:pointer;" onclick="ShowTag('+"'"+
5959
record['tags'][x]['name']+"')" + '">'+
6060
record['tags'][x]['name']+' </a>';
61-
//href='+"'"+
62-
// '/runs/?startdate=&enddate=&detector=tpc&custom=%7B"tags"'+
63-
// '%3A+%7B"%24elemMatch"%3A+%7B"name"%3A+"'+
64-
// record.tags[x]['name']+'"%7D%7D%7D&submit='+"'>"+
65-
// record.tags[x]['name']+"</a>&nbsp;";
6661
}
6762
}
6863

@@ -162,6 +157,8 @@ function ShowDetail(name, detector){
162157
};
163158
DrawDetailWindow(runs_url, params,
164159
"template_run_header", "run_detail_top",
160+
"template_tags", "template_tagbutton", "run_detail_tags",
161+
"template_storage", "template_site", "detail_locations",
165162
function(){SlideOutDetail()});
166163
}
167164

@@ -180,7 +177,10 @@ function DateToString(dateval){
180177
return ret;
181178
}
182179

183-
function DrawDetailWindow(url, params, header_template, header_div, callback)
180+
function DrawDetailWindow(url, params, header_template, header_div,
181+
tag_template, tagbutton_template, tag_div,
182+
storage_template, storageloc_template,
183+
storage_div, callback)
184184
//,
185185
/*//add piece by piece comment_template, comment_div,
186186
json_div, data_template, data_div,
@@ -223,18 +223,126 @@ function DrawDetailWindow(url, params, header_template, header_div, callback)
223223
};
224224
$("#"+header_div).html(Mustache.render(title_template,
225225
title_args));
226-
227-
226+
$("#"+tag_div).html(DrawTagWindow(data, tag_template,
227+
tagbutton_template));
228+
$("#"+storage_div).html(DrawStorageWindow(data, storage_template,
229+
storageloc_template));
228230
callback();
229231

230232
});
231233

234+
}
235+
function GetColor(string){
236+
if (string=="transferred" || string=="processing")
237+
return "#36bc98";
238+
if(string=="transferring" || string=="checking" || string=="verifying")
239+
return "#f9a100";
240+
else
241+
return "#ec2c35";
242+
}
243+
244+
245+
function DrawStorageWindow(data, storage_template, storageloc_template){
246+
var storageloctemplate= $.trim($("#"+storageloc_template).html());
247+
Mustache.parse(storageloctemplate);
248+
249+
rawhtml="";
250+
processedhtml="";
251+
otherhtml="";
252+
253+
var untriggered = [];
254+
var raw = [];
255+
var processed = [];
256+
257+
for(i=0; i< data['data'].length; i+=1){
258+
pars = {
259+
"host": data['data'][i]['host'],
260+
"status": data['data'][i]['status'],
261+
"type": data['data'][i]['type'],
262+
"location": data['data'][i]['location'],
263+
"status_color": GetColor(data['data'][i]['status']),
264+
"display_paxversion": "style='display:none'",
265+
"pax_version": "trolololol"
266+
}
267+
console.log(pars);
268+
if(data['data'][i]['type'] == 'raw')
269+
raw.push(Mustache.render(storageloctemplate, pars));
270+
else if(data['data'][i]['type'] == 'processed'){
271+
pars['pax_version'] = data['data'][i]['pax_version'];
272+
parx['display_paxcersion'] = "";
273+
processed.push(Mustache.render(storageloctemplate, pars));
274+
}
275+
else
276+
untriggered.push(Mustache.render(storageloctemplate, pars));
277+
}
232278

279+
if(raw.length!=0){
280+
rawhtml += "<h4 style='margin-bottom:2px;'>Raw data</h4><hr style='margin-top:0px;margin-bottom:4px;'>";
281+
for(x=0;x<raw.length;x+=1){
282+
rawhtml+=raw[x];
283+
}
284+
}
285+
if(processed.length!=0){
286+
processedhtml+= "<h4 style='margin-bottom:2px;'>Processed data</h4><hr style='margin-top:0px;margin-bottom:4px;'>";
287+
for(x=0;x<processed.length;x+=1){
288+
processedhtml+=processed[x];
289+
}
290+
}
291+
if(untriggered.length!=0){
292+
otherhtml += "<h4 style='margin-bottom:2px;'>Other</h4><hr style='margin-top:0px;margin-bottom:4px;'>";
293+
for(x=0;x<untriggered.length;x+=1){
294+
otherhtml+=untriggered[x];
295+
}
296+
}
297+
298+
var storagetemplate = $.trim($("#"+storage_template).html());
299+
Mustache.parse(storagetemplate);
300+
pars = {
301+
"raw": rawhtml,
302+
"processed": processedhtml,
303+
"other": otherhtml
304+
};
305+
console.log(pars);
306+
console.log( Mustache.render(storagetemplate, pars));
307+
return Mustache.render(storagetemplate, pars);
233308

234309
}
310+
function DrawTagWindow(data, tag_template, tagbutton_template){
311+
var tagtemplate = $.trim($("#"+tag_template).html());
312+
Mustache.parse(tagtemplate);
313+
var tagbuttontemplate= $.trim($("#"+tagbutton_template).html());
314+
Mustache.parse(tagbuttontemplate);
315+
316+
buttonhtml = "";
317+
if("tags" in data){
318+
buttonhtml="<br style='margin:1px'><div style='width:100%'>";
319+
for(var i=0; i<data['tags'].length; i+=1){
320+
bargs = {
321+
"name": data['tags'][i]['name'],
322+
'oid': data['_id']['$oid'],
323+
'hideifnotme': 'style="display:none"'
324+
};
325+
if(document.whoami == data['tags'][i]['user'])
326+
bargs['hideifnotme'] = "";
327+
buttonhtml += Mustache.render(tagbuttontemplate, bargs);
328+
}
329+
buttonhtml += "</div><br style='margin:1px'>";
330+
}
331+
332+
targs = {
333+
'oid': data['_id']['$oid'],
334+
'tag_html': buttonhtml
335+
};
336+
console.log(targs);
337+
return Mustache.render(tagtemplate, targs);
338+
339+
}
235340

236341

237342
function GetDataState(data){
343+
344+
if(data==null)
345+
return "";
238346

239347
// Hosts
240348
hosts = {"reader": 0,

components/emo/js/game.js

Lines changed: 62 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,15 @@ function rotateAroundObjectAxis(object, axis, radians) {
290290
// new code for Three.js r59+:
291291
object.rotation.setFromRotationMatrix(object.matrix);
292292
}
293+
$(document).mousedown(function(e){
294+
295+
document.wantposx = ((e.clientX - window.innerWidth/2) );
296+
document.wantposy = (-(e.clientY -window.innerHeight));
297+
if(!document.autofire){
298+
document.autofire=true;
299+
fire();
300+
}
301+
});
293302

294303
$(document).on("keydown", function (e) {
295304

@@ -365,6 +374,7 @@ function DetonateMissle(){
365374

366375
}
367376
function FireBullet(n){
377+
console.log("FIREBULLET");
368378
colors = [0x4444aa, 0x44aa44, 0xaa4444, 0xffffff];
369379
color = colors[0];
370380
if(n<colors.length)
@@ -409,6 +419,9 @@ function FireBullet(n){
409419

410420
$(document).on("keyup", function(e){
411421

422+
document.wantposx = null;
423+
document.wantposy = null;
424+
document.autofire = false;
412425
if(e.which == 87)
413426
document.udown=false;
414427
else if(e.which == 83)
@@ -457,21 +470,22 @@ function locationOf(element, array, key, start, end) {
457470
}
458471

459472
function fire(){
473+
console.log("FIRING");
460474
if(document.autofire == false) return;
461475
if(document.run_animation==false) return;
462-
476+
console.log("YES");
463477
autofire_rate = 250; // base rate
464478
if(document.score > 2500) autofire_rate-=50;
465479
if(document.score > 5000) autofire_rate-=50;
466480
if(document.score > 7500) autofire_rate-=50;
467481
if(document.score > 10000) autofire_rate-=50;
468482
if(document.score > 20000) autofire_rate-=25;
469483

470-
if(!document.fire){
471-
setTimeout(fire, autofire_rate);
472-
return;
473-
}
474-
FireBullet();
484+
//if(!document.fire){
485+
// setTimeout(fire, autofire_rate);
486+
// return;
487+
// }
488+
FireBullet(0);
475489
/*bullet = new THREE.Mesh(new THREE.SphereGeometry(5,1,1),
476490
new THREE.MeshBasicMaterial(
477491
{color: 0xff0000}))
@@ -622,7 +636,47 @@ function animate(){
622636
//console.log(document.powerWeaponCharge);
623637

624638

639+
var osize=15;
640+
// PLAYER MOVEMENT MOUSE
641+
if(document.wantposx != null && document.player.position.x !=
642+
document.wantposx){
643+
myx = document.player.position.x;
644+
console.log("POS");
645+
console.log(myx);
646+
console.log(document.wantposx);
647+
if(myx < document.wantposx){
648+
if(Math.abs(document.wantposx - myx) < osize*clock_corr)
649+
document.player.position.x = document.wantposx;
650+
else
651+
document.player.position.x += osize*clock_corr;
652+
}
653+
else if(myx > document.wantposx){
654+
if(Math.abs(document.wantposx - myx) < osize*clock_corr)
655+
document.player.position.x = document.wantposx;
656+
else
657+
document.player.position.x -= osize*clock_corr;
658+
}
659+
}
660+
if(document.wantposy != null && document.player.position.y !=
661+
document.wantposy){
662+
myy = document.player.position.y;
663+
if(myy < document.wantposy){
664+
if(Math.abs(document.wantposy - myy) < osize*clock_corr)
665+
document.player.position.y = document.wantposy;
666+
else
667+
document.player.position.y += osize*clock_corr;
668+
}
669+
else if(myy > document.wantposy){
670+
if(Math.abs(document.wantposy - myy) < osize*clock_corr)
671+
document.player.position.y = document.wantposy;
672+
else
673+
document.player.position.y -= osize*clock_corr;
674+
}
675+
676+
}
677+
625678

679+
// PLAYER MOVEMENT KEYBOARD
626680
var msize=15;
627681
if(document.udown && document.player.position.y < window.innerHeight){
628682
document.player.position.y += msize*clock_corr;
@@ -1241,6 +1295,8 @@ document.n_stars=15;
12411295
document.ldown=false;
12421296
document.rdown=false;
12431297
document.udown=false;
1298+
document.wantposx = null;
1299+
document.wantposy = null;
12441300
document.impurities=0;
12451301
document.ddown=false;
12461302
document.en_bullet_chance=10; // 1-1000, rand()*1000 < num

runs/templates/runs/runs_new.html

Lines changed: 67 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ <h4 class="modal-title">Help</h4>
196196
<script>
197197

198198
$(function(){
199-
199+
document.whoami="{{ request.user.username }}";
200200
MakeRunsTable("runstable", "/runs/runs_stream", "template", "counterdiv");
201201

202202
});
@@ -224,11 +224,11 @@ <h4 class="modal-title">Help</h4>
224224

225225
<!-- BELOW ARE ALL THE TEMPLATES FOR VARIOUS PARTS OF THE PAGE -->
226226
<script id="template_run_header" type="text/html">
227-
<h4 style="margin-bottom:2px"
227+
<h4 style="margin-bottom:5px"
228228
id="run_detail_head">Detail for run {% verbatim %}{{ run_number }}{% endverbatim %}
229229
</h4>
230230
<div style='position:absolute;right:50px;top:15px;'>
231-
<button class='btn btn-default' style='color:black;background-color:white'
231+
<button class='btn btn-default btn-lg' style='color:black;background-color:white'
232232
onclick="HideDetail()">
233233
Hide
234234
</button>
@@ -290,6 +290,70 @@ <h4 class="modal-title">Help</h4>
290290
</table>
291291
</script>
292292

293+
<script id="template_tagbutton" type="text/html">
294+
295+
<span class="tagButton">
296+
<a style="color:white;cursor:pointer;" onclick="ShowTag('{% verbatim %}{{ name }}{% endverbatim %}')">{% verbatim %}{{ name }}{% endverbatim %} </a>
297+
<div {% verbatim %}{{{ hideifnotme }}}{% endverbatim %}>
298+
&nbsp;&nbsp;
299+
<span class="badge" style="cursor:hand;cursor:pointer;"
300+
onclick="RemoveTag('{% verbatim %}{{ oid }}{% endverbatim %}', '{% verbatim %}{{ name }}{% endverbatim %}')">x</span>
301+
</div>
302+
</span>&nbsp;
303+
</script>
304+
305+
306+
<script id="template_site" type="text/html">
307+
<div class='row'>
308+
<div class='col-xs-12'>
309+
<h5><strong>{% verbatim %}{{ host }}{% endverbatim %}</strong></h5>
310+
</div>
311+
<div class='col-xs-12'>
312+
<strong style='padding-left:15px;'>Type: </strong>{% verbatim %}{{ type }}{% endverbatim %}
313+
<strong style='padding-left:15px';>Status: </strong>
314+
<strong style='padding-left:15px;color:{% verbatim %}{{{ status_color }}}{% endverbatim %}'>
315+
{% verbatim %}{{ status }}{% endverbatim %}
316+
</strong></div>
317+
<div class='col-xs-12' {% verbatim %}{{{ display_paxversion }}}{% endverbatim %}>
318+
<strong style='padding-left:15px'>Pax version: </strong>&nbsp;{% verbatim %}{{ pax_version }}{% endverbatim %}
319+
</div>
320+
<div class='col-xs-12'><strong>Location: </strong>&nbsp;{% verbatim %}{{ location }}{% endverbatim %}
321+
</div>
322+
</div>
323+
</script>
324+
325+
<script id="template_storage" type="text/html">
326+
<table>
327+
<div>{% verbatim %}{{{ raw }}}{% endverbatim %}</div>
328+
<div>{% verbatim %}{{{ processed }}}{% endverbatim %}</div>
329+
<div>{% verbatim %}{{{ other }}}{% endverbatim %}</div>
330+
</table>
331+
</script>
332+
333+
<script id="template_tags" type="text/html">
334+
335+
{% verbatim %}{{{ tag_html }}}{% endverbatim %}
336+
<form class='new_tag_form' method='get' onsubmit='return NewTag(this)'>
337+
<div class="row">
338+
<div class="col-xs-12 text-info">
339+
<emph>
340+
Please avoid redundant tags, i.e. re-stating the source type as well as overly specific tags like the I-Belt position (this goes in comments). There does not have to be a tag for each run.
341+
</emph>
342+
</div>
343+
<div class="col-xs-9">
344+
<input type="text" id="{% verbatim %}{{ oid }}{% endverbatim %}_formtext"
345+
style="width:100%" name="content"></input>
346+
</div>
347+
<div class="col-xs-3">
348+
<input type="hidden" name="id"
349+
value="{% verbatim %}{{ oid }}{% endverbatim%}"/>
350+
<button class="btn btn-info" type="submit"
351+
style="margin-bottom:15px;">New Tag</button>
352+
</div>
353+
</div>
354+
</form>
355+
</script>
356+
293357

294358
<script id="template" type="text/html">
295359
<tr>

0 commit comments

Comments
 (0)