4545 < div class ="container-fluid ">
4646 < div id ="default_content ">
4747 {{ customizations|get_item:"kiosk_message"|default_if_none:"< h1 > Scan your badge to control tools</ h1 > "|safe }}
48- < div id ="occupancy "> </ div >
49- < div id ="usage_title "> </ div >
50- < div class ="tab-pane{% if tools_exist and tab == 'tools' %} active{% endif %} info-tooltip-container "
51- id ="tools ">
52- < div id ="usage "> </ div >
53- </ div >
54- < div id ="alerts "> </ div >
48+ < div id ="dynamic_content "> </ div >
5549 </ div >
5650 < div id ="error " style ="display: none ">
5751 < h1 > There was a problem communicating with the web server. Please visit the user office for assistance.</ h1 >
@@ -100,7 +94,21 @@ <h1 style="color:lightgrey" id="badge_number"></h1>
10094 { % endwith % }
10195 let timeout_handle = null ;
10296 let countdown_handle = null ;
97+
98+ // Reorder divs based on URL parameter order
99+ const dynamic_container = $ ( "#dynamic_content" ) ;
103100 const current_url_parameters = new URLSearchParams ( window . location . search ) ;
101+
102+ for ( const [ key , value ] of current_url_parameters . entries ( ) ) {
103+ if ( key === 'occupancy' ) {
104+ dynamic_container . append ( '<div id="occupancy"></div>' ) ;
105+ } else if ( key === 'usage' ) {
106+ dynamic_container . append ( '<div id="usage_title"></div><div class="info-tooltip-container" id="tools"><div id="usage"></div></div>' ) ;
107+ } else if ( key === 'alerts' ) {
108+ dynamic_container . append ( '<div id="alerts"></div>' ) ;
109+ }
110+ }
111+
104112 const occupancy = current_url_parameters . get ( "occupancy" ) ;
105113 const usage = current_url_parameters . get ( "usage" ) !== null ;
106114 const alerts = current_url_parameters . get ( "alerts" ) !== null ;
@@ -184,9 +192,9 @@ <h1 style="color:lightgrey" id="badge_number"></h1>
184192 }
185193 function revert_to_default_content ( )
186194 {
187- fetch_occupancy ( ) ;
188- fetch_usage ( ) ;
189- fetch_alerts ( ) ;
195+ if ( occupancy ) fetch_occupancy ( ) ;
196+ if ( usage ) fetch_usage ( ) ;
197+ if ( alerts ) fetch_alerts ( ) ;
190198 clear_timeout ( ) ;
191199 close_numpads ( ) ;
192200 close_keyboards ( ) ;
@@ -487,10 +495,7 @@ <h1 style="color:lightgrey" id="badge_number"></h1>
487495 }
488496 function fetch_occupancy ( )
489497 {
490- if ( occupancy )
491- {
492- ajax_get ( '{% url ' kiosk_occupancy ' %}' , { 'occupancy' : occupancy } , function ( response ) { $ ( "#occupancy" ) . html ( response ) ; } ) ;
493- }
498+ ajax_get ( '{% url ' kiosk_occupancy ' %}' , { 'occupancy' : occupancy } , function ( response ) { $ ( "#occupancy" ) . html ( response ) ; } ) ;
494499 }
495500 function logout_user ( tool_id , badge_number )
496501 {
@@ -499,25 +504,19 @@ <h1 style="color:lightgrey" id="badge_number"></h1>
499504 }
500505 function fetch_usage ( )
501506 {
502- if ( usage )
503- {
504- $ ( "#usage_title" ) . html ( "<h2>Tools in use</h2>" )
505- ajax_get ( '{% url ' kiosk_usage ' %}' , { 'interest' : 'tools' } ,
506- function ( response ) {
507- $ ( "#usage" ) . html ( response ) ;
508- $ ( ".in_use" ) . css ( "display" , "table-row" ) ;
509- $ ( ".idle" ) . hide ( ) ;
510- $ ( ".glyphicon-remove-circle" ) . hide ( ) ;
511- }
512- ) ;
513- }
507+ $ ( "#usage_title" ) . html ( "<h2>Tools in use</h2>" )
508+ ajax_get ( '{% url ' kiosk_usage ' %}' , { 'interest' : 'tools' } ,
509+ function ( response ) {
510+ $ ( "#usage" ) . html ( response ) ;
511+ $ ( ".in_use" ) . css ( "display" , "table-row" ) ;
512+ $ ( ".idle" ) . hide ( ) ;
513+ $ ( ".glyphicon-remove-circle" ) . hide ( ) ;
514+ }
515+ ) ;
514516 }
515517 function fetch_alerts ( )
516518 {
517- if ( alerts )
518- {
519- $ ( "#alerts" ) . load ( "{% url 'kiosk_alerts' %}" ) ;
520- }
519+ $ ( "#alerts" ) . load ( "{% url 'kiosk_alerts' %}" ) ;
521520 }
522521 function close_numpads ( )
523522 {
0 commit comments