@@ -139,9 +139,11 @@ function ShowTag(tagname){
139139}
140140
141141function SlideOutDetail ( ) {
142- $ ( "#detail_window > div" ) . height ( $ ( window ) . height ( ) - 50 ) ;
142+ $ ( "#loading_run" ) . hide ( ) ;
143+ //$("#detail_window > div").height($(window).height()-50);
143144 // $(".runsHider").show("fade", 50);
144- $ ( "#detail_window" ) . show ( "slide" , { direction : "right" } , 200 ) ;
145+ //$("#detail_window").show("slide", { direction: "right" }, 200);
146+
145147}
146148function HideDetail ( ) {
147149 $ ( "#detail_window" ) . hide ( "fade" , 50 ) ;
@@ -150,6 +152,11 @@ function HideDetail(){
150152
151153function ShowDetail ( name , detector ) {
152154
155+ $ ( "#detail_window > #emobox" ) . height ( $ ( window ) . height ( ) - 50 ) ;
156+ $ ( "#loading_run" ) . show ( ) ;
157+ $ ( "#detail_window" ) . show ( "slide" , { direction : "right" } , 200 ,
158+ function ( ) {
159+
153160 runs_url = "/runs/get_run" ;
154161 params = {
155162 "detector" : detector ,
@@ -159,7 +166,8 @@ function ShowDetail(name, detector){
159166 "template_run_header" , "run_detail_top" ,
160167 "template_tags" , "template_tagbutton" , "run_detail_tags" ,
161168 "template_storage" , "template_site" , "detail_locations" ,
162- function ( ) { SlideOutDetail ( ) } ) ;
169+ "template_comment" , "template_comments" , "detail_comments" ,
170+ function ( ) { SlideOutDetail ( ) } ) ; } ) ;
163171}
164172
165173function DateToString ( dateval ) {
@@ -180,7 +188,8 @@ function DateToString(dateval){
180188function DrawDetailWindow ( url , params , header_template , header_div ,
181189 tag_template , tagbutton_template , tag_div ,
182190 storage_template , storageloc_template ,
183- storage_div , callback )
191+ storage_div , comment_template , comments_template ,
192+ comments_div , callback )
184193//,
185194/*//add piece by piece comment_template, comment_div,
186195 json_div, data_template, data_div,
@@ -227,6 +236,10 @@ function DrawDetailWindow(url, params, header_template, header_div,
227236 tagbutton_template ) ) ;
228237 $ ( "#" + storage_div ) . html ( DrawStorageWindow ( data , storage_template ,
229238 storageloc_template ) ) ;
239+ $ ( "#" + comments_div ) . html ( DrawCommentsWindow ( data , comment_template ,
240+ comments_template ) ) ;
241+ document . getElementById ( "json" ) . innerHTML = "" ;
242+ $ ( "#json" ) . jsonView ( data , { collapsed : true } ) ;
230243 callback ( ) ;
231244
232245 } ) ;
@@ -241,6 +254,31 @@ function GetColor(string){
241254 return "#ec2c35" ;
242255}
243256
257+ function DrawCommentsWindow ( data , comment_template , comments_template ) {
258+
259+ var commenttemplate = $ . trim ( $ ( "#" + comment_template ) . html ( ) ) ;
260+ Mustache . parse ( commenttemplate ) ;
261+
262+ var comments = "" ;
263+ for ( i = 0 ; i < data [ 'comments' ] . length ; i += 1 ) {
264+ pars = {
265+ "user" : data [ 'comments' ] [ i ] [ 'user' ] ,
266+ "date" : DateToString ( data [ 'comments' ] [ i ] [ 'date' ] ) ,
267+ "text" : data [ 'comments' ] [ i ] [ 'text' ]
268+ }
269+ comments += ( Mustache . render ( commenttemplate , pars ) ) ;
270+ }
271+
272+ pars2 = {
273+ "comments" : comments ,
274+ "oid" : data [ '_id' ] [ '$oid' ] ,
275+ "name" : data [ 'name' ] ,
276+ "detector" : data [ 'detector' ]
277+ } ;
278+ var commentstemplate = $ . trim ( $ ( "#" + comments_template ) . html ( ) ) ;
279+ Mustache . parse ( commentstemplate ) ;
280+ return Mustache . render ( commentstemplate , pars2 ) ;
281+ }
244282
245283function DrawStorageWindow ( data , storage_template , storageloc_template ) {
246284 var storageloctemplate = $ . trim ( $ ( "#" + storageloc_template ) . html ( ) ) ;
@@ -269,7 +307,7 @@ function DrawStorageWindow(data, storage_template, storageloc_template){
269307 raw . push ( Mustache . render ( storageloctemplate , pars ) ) ;
270308 else if ( data [ 'data' ] [ i ] [ 'type' ] == 'processed' ) {
271309 pars [ 'pax_version' ] = data [ 'data' ] [ i ] [ 'pax_version' ] ;
272- parx [ 'display_paxcersion '] = "" ;
310+ pars [ 'display_paxversion '] = "" ;
273311 processed . push ( Mustache . render ( storageloctemplate , pars ) ) ;
274312 }
275313 else
@@ -318,20 +356,24 @@ function DrawTagWindow(data, tag_template, tagbutton_template){
318356 buttonhtml = "<br style='margin:1px'><div style='width:100%'>" ;
319357 for ( var i = 0 ; i < data [ 'tags' ] . length ; i += 1 ) {
320358 bargs = {
321- "name " : data [ 'tags' ] [ i ] [ 'name' ] ,
359+ "tagname " : data [ 'tags' ] [ i ] [ 'name' ] ,
322360 'oid' : data [ '_id' ] [ '$oid' ] ,
361+ 'detector' : data [ 'detector' ] ,
362+ 'name' : data [ 'name' ] ,
323363 'hideifnotme' : 'style="display:none"'
324364 } ;
325365 if ( document . whoami == data [ 'tags' ] [ i ] [ 'user' ] )
326- bargs [ 'hideifnotme' ] = "" ;
366+ bargs [ 'hideifnotme' ] = "style='display:inline;' " ;
327367 buttonhtml += Mustache . render ( tagbuttontemplate , bargs ) ;
328368 }
329369 buttonhtml += "</div><br style='margin:1px'>" ;
330370 }
331371
332372 targs = {
333373 'oid' : data [ '_id' ] [ '$oid' ] ,
334- 'tag_html' : buttonhtml
374+ 'tag_html' : buttonhtml ,
375+ 'name' : data [ 'name' ] ,
376+ 'detector' : data [ 'detector' ]
335377 } ;
336378 console . log ( targs ) ;
337379 return Mustache . render ( tagtemplate , targs ) ;
@@ -402,3 +444,85 @@ function GetDataState(data){
402444 }
403445 return html ;
404446}
447+
448+ function NewComment ( form ) {
449+
450+ // e.preventDefault();
451+ // validate
452+ form_array = $ ( form ) . serializeArray ( ) ;
453+ name = "" ;
454+ detector = "" ;
455+ for ( i = 0 ; i < form_array . length ; i += 1 ) {
456+ if ( form_array [ i ] [ 'name' ] == 'name' )
457+ name = form_array [ i ] [ 'value' ] ;
458+ if ( form_array [ i ] [ 'name' ] == 'detector' )
459+ detector = form_array [ i ] [ 'value' ] ;
460+ if ( form_array [ i ] [ 'name' ] == "content"
461+ && form_array [ i ] [ 'value' ] == "" )
462+ return false ;
463+ }
464+ $ . ajax ( {
465+ type : "POST" ,
466+ url : "/runs/newcomment" ,
467+ data : $ ( form ) . serialize ( ) ,
468+ success : function ( data ) {
469+ ShowDetail ( name , detector ) ;
470+ return false ;
471+ }
472+ } ) ;
473+ return false ;
474+ } ;
475+
476+
477+ function RemoveTag ( id , name , runname , detector ) {
478+ if ( id != "" && name != "" ) {
479+ URL = "newtag?remove=true;id=" + id + ";tagname=" + name ;
480+ $ . ajax ( {
481+ type : "GET" ,
482+ url : "/runs/newtag" ,
483+ data : {
484+ "remove" : true ,
485+ "id" : id ,
486+ "tagname" : name
487+ } ,
488+ success : function ( data ) {
489+ console . log ( "SUCCESS" ) ;
490+ console . log ( runname ) ;
491+ console . log ( detector ) ;
492+ ShowDetail ( runname , detector ) ;
493+ return false ;
494+ } ,
495+ error : function ( data ) {
496+ console . log ( data ) ;
497+ } ,
498+ } ) ;
499+ }
500+ return false ;
501+ }
502+
503+ function NewTag ( form , name , detector ) {
504+ arr = $ ( form ) . serializeArray ( ) ;
505+ var id = "" ;
506+ var content = "" ;
507+ console . log ( arr ) ;
508+ for ( var x = 0 ; x < arr . length ; x += 1 ) {
509+ if ( arr [ x ] [ "name" ] == "content" )
510+ content = arr [ x ] [ "value" ] ;
511+ else if ( arr [ x ] [ "name" ] == "id" )
512+ id = arr [ x ] [ "value" ] ;
513+ }
514+ if ( content . indexOf ( ' ' ) >= 0 ) {
515+ alert ( "Tags should be one word. Please use the comments tab for more extensive comments." ) ;
516+ return false ;
517+ }
518+
519+ if ( id != "" && content != "" ) {
520+ URL = "newtag?id=" + id + ";tagname=" + content ;
521+
522+ $ . get ( URL , function ( ) {
523+ ShowDetail ( name , detector ) ;
524+ return false ;
525+ } ) ;
526+ }
527+ return false ;
528+ } ;
0 commit comments