@@ -246,23 +246,12 @@ <h3>Containers <i style="color:#999" id="helpme" class='fa fa-question-circle'>
246246 $ ( "#container_set" ) . text ( "" ) ;
247247 var list = '<ul>'
248248 $ . each ( containers , function ( index , container ) {
249- parts = container . split ( '|' )
250- container_id = parts [ 0 ] ;
251- container_name = parts [ 1 ] ;
252- list = list + "<li><a href='/containers/" + container_id + "/'> " + container_name + "</a></li>"
249+ list = list + "<li><a href='#'/>" + container + "</a></li>"
253250 } )
254251 list = list + "</ul>"
255252 $ ( "#container_set" ) . append ( $ ( list ) )
256253 }
257254 } )
258- . on ( 'click' , function ( d ) {
259- var containers = d . data . name . split ( "|||" )
260- if ( containers . length === 1 ) {
261- parts = containers [ 0 ] . split ( '|' )
262- container_id = parts [ 0 ] ;
263- container_name = parts [ 1 ] ;
264- document . location = "/containers/" + container_id + "/"
265- }
266255 } )
267256 . on ( 'mouseout' , function ( d ) {
268257 $ ( "#" + d . data . name . hashCode ( ) ) . hide ( ) ;
@@ -371,172 +360,11 @@ <h3>Containers <i style="color:#999" id="helpme" class='fa fa-question-circle'>
371360}
372361</ style >
373362
374- <!-- Bottom bar to hint that tools are there... -->
375- < div id ="containerbox ">
376- < button class ="btn btn-default " id ="show_container_set "> < i id ='show_container_set_icon ' class ="fa fa-3x fa-plus-square "> </ i > </ a > </ li > </ button >
377- < nav id ="controls " class ="navbar navbar-fixed-bottom hidden " style ="background-color:#F7F7F7;margin-left:15%;margin-right:15% ">
378- < div class ="navbar-brand notransition " id ="tool-toggle " style ="color:rgb(227, 41, 41) " href ="# "> Container Snacks
379- < i style ="padding-left:10px;float:right " id ="tool_direction " class ="fa fa-chevron-up "> </ i >
380- </ div >
381- < br >
382- < div id ="tools " style ='display:none '>
383- < p id ="full_message " class ="alert alert-info hidden "> This is a working set of containers for comparing, and visualizing (under development).</ p >
384- <!-- Containers will be appended here-->
385- < div id ="containers "> </ div >
386- < hr >
387- < div id ="container-operations " class ="hidden ">
388- < button id ="reset_container_box " class ="save btn btn-default btn-sm "> Empty Container Box</ button >
389- < button id ="compare_containers " class ="save btn btn-default btn-sm "> Intersect Containers</ button >
390- < button id ="subtract_containers " class ="save btn btn-default btn-sm "> Subtract Containers</ button >
391- </ div >
392- < p id ="empty_message " class ="alert alert-info hidden "> You don't have any snacks in your container box! Try a < a href ="/search "> search</ a > to add some.</ p >
393- < p id ="message_box " class ="alert alert-info hidden "> </ p >
394- </ div >
395- </ nav >
396- </ div >
397-
398-
399363< script >
400364
401365// Enable tooltips
402366$ ( '[data-toggle="tooltip"]' ) . tooltip ( )
403367
404- // Allow the user to reset tags
405- $ ( "#reset_container_box" ) . click ( function ( ) {
406- localStorage . removeItem ( 'containers' ) ;
407- console . log ( "Container box emptied." ) ;
408- $ ( "#containers" ) . empty ( ) ;
409- update_box ( ) ;
410- } )
411-
412-
413- // Function to populate box with containers from local storage
414- function populate_box ( div , contents ) {
415- var contents = JSON . parse ( contents ) ;
416- $ ( div ) . empty ( ) ;
417- $ . each ( contents , function ( container_id , container ) {
418- var new_box = '<div class="input-group container-box"><span class="input-group-addon"><input class="container-input" type="checkbox" aria-label="' + container_id + '"></span><div class="container-button">' + container + '</div></div>'
419- $ ( div ) . append ( new_box ) ;
420- } )
421- }
422-
423- // If we have containers saved in local storage
424- function update_box ( ) {
425- var tags = localStorage . getItem ( 'containers' )
426-
427- if ( tags != null ) {
428- populate_box ( "#containers" , tags ) ;
429- }
430-
431- // If tags are empty, hide box
432- if ( tags == null ) {
433- $ ( "#container-operations" ) . addClass ( 'hidden' ) ;
434- $ ( "#full_message" ) . addClass ( 'hidden' ) ;
435- $ ( "#empty_message" ) . removeClass ( 'hidden' ) ;
436- console . log ( "No saved containers in box." ) ;
437- } else {
438- $ ( "#full_message" ) . removeClass ( 'hidden' ) ;
439- $ ( "#empty_message" ) . addClass ( 'hidden' ) ;
440- $ ( "#container-operations" ) . removeClass ( 'hidden' ) ;
441- console . log ( "You have saved containers in your box!" ) ;
442- }
443-
444- // Make sure no more than two checkboxes are selected
445- $ ( '.container-input' ) . on ( 'change' , function ( evt ) {
446- var total = $ ( ".container-input:checked" ) . length ;
447- if ( total > 2 ) {
448- // Tell the user
449- $ ( "#message_box" ) . text ( "You can only have a maximum of two images for any comparison." ) ;
450- $ ( "#message_box" ) . removeClass ( "hidden" ) ;
451- this . checked = false ;
452- }
453- } ) ;
454-
455- }
456-
457- // Toggle box function controls changing icon, showing and hiding box
458- function toggle_box ( ) {
459-
460- if ( $ ( "#controls" ) . hasClass ( 'hidden' ) ) {
461- $ ( "#controls" ) . removeClass ( 'hidden' ) ;
462- $ ( "#show_container_set_icon" ) . removeClass ( 'fa-plus-square' ) ;
463- $ ( "#show_container_set_icon" ) . addClass ( 'fa-minus-square' ) ;
464- } else {
465- $ ( "#controls" ) . addClass ( 'hidden' ) ;
466- $ ( "#show_container_set_icon" ) . removeClass ( 'fa-minus-square' ) ;
467- $ ( "#show_container_set_icon" ) . addClass ( 'fa-plus-square' ) ;
468- }
469- }
470-
471-
472- // Save container when the user clicks save
473- $ ( ".save_container" ) . click ( function ( ) {
474- var container_set = localStorage . getItem ( 'containers' ) ;
475- var container_id = $ ( this ) . attr ( "data-id" ) . replace ( 'container_' , '' ) ;
476- var container_name = $ ( this ) . attr ( "data-name" ) ;
477- if ( container_set != null ) {
478- container_set = JSON . parse ( container_set ) ;
479- } else {
480- container_set = { } ;
481- }
482- container_set [ container_id ] = container_name ;
483- localStorage . setItem ( 'containers' , JSON . stringify ( container_set ) ) ;
484- console . log ( "Container saved to box." )
485- update_box ( ) ;
486- $ ( "#controls" ) . removeClass ( "hidden" ) ;
487- } )
488-
489- // General function to compare containers
490- function compare_containers ( comparison_operation ) {
491- var total = $ ( ".container-input:checked" ) . length ;
492- if ( total < 2 ) {
493- $ ( "#message_box" ) . text ( "You must select two containers for comparison" ) ;
494- $ ( "#message_box" ) . removeClass ( "hidden" ) ;
495- } else {
496- var container_ids = $ ( ".container-input:checked" ) . map ( function ( ) { return $ ( this ) . attr ( "aria-label" ) ; } ) . get ( ) ;
497- var url = "https://singularity-hub.org/tools/compare/" + container_ids [ 0 ] + "/" + comparison_operation + "/" + container_ids [ 1 ] ;
498- document . location = url ;
499- }
500- }
501-
502- // Compare containers
503- $ ( "#compare_containers" ) . click ( function ( ) {
504- compare_containers ( 'intersect' ) ;
505- } )
506-
507- // Subtract containers
508- // Compare containers
509- $ ( "#subtract_containers" ) . click ( function ( ) {
510- compare_containers ( 'subtract' ) ;
511- } )
512-
513- </ script >
514-
515-
516- < script >
517- $ ( document ) . ready ( function ( ) {
518-
519- $ ( "#tool-toggle" ) . click ( function ( ) {
520- if ( $ ( "#tool_direction" ) . hasClass ( "fa-chevron-up" ) ) {
521- $ ( "#tool_direction" ) . removeClass ( "fa-chevron-up" )
522- $ ( "#tool-toggle" ) . css ( "padding-top" , "3px" )
523- $ ( "#tool_direction" ) . addClass ( "fa-chevron-down" )
524- } else {
525- $ ( "#tool-toggle" ) . css ( "padding-top" , "20px" )
526- $ ( "#tool_direction" ) . removeClass ( "fa-chevron-down" )
527- $ ( "#tool_direction" ) . addClass ( "fa-chevron-up" )
528- }
529- $ ( "#tools" ) . toggle ( ) ;
530- } )
531-
532- // Show or hide container set
533- $ ( "#show_container_set" ) . click ( function ( ) {
534- toggle_box ( ) ;
535- } )
536-
537- // update container box on page start
538- update_box ( ) ;
539-
540368} ) ;
541369</ script >
542370
0 commit comments