99 This should be done before calling anything else in the file.
1010 */
1111
12- var meeting_timezone ;
1312var local_timezone = moment . tz . guess ( ) ;
1413
1514// get_current_tz_cb must be overwritten using set_current_tz_cb
16- window . get_current_tz_cb = function ( ) {
15+ function get_current_tz_cb ( ) {
1716 throw new Error ( 'Tried to get current timezone before callback registered. Use set_current_tz_cb().' )
1817} ;
1918
2019// Initialize moments
2120window . initialize_moments = function ( ) {
22- var times = $ ( 'span.time' )
23- $ . each ( times , function ( i , item ) {
24- item . start_ts = moment . unix ( this . getAttribute ( "data-start-time" ) ) . utc ( ) ;
25- item . end_ts = moment . unix ( this . getAttribute ( "data-end-time" ) ) . utc ( ) ;
21+ var times = $ ( 'div.time' )
22+ $ . each ( times , function ( i , item ) {
23+ item . start_ts = moment . unix ( this . getAttribute ( "data-start-time" ) )
24+ . utc ( ) ;
25+ item . end_ts = moment . unix ( this . getAttribute ( "data-end-time" ) )
26+ . utc ( ) ;
2627 if ( this . hasAttribute ( "weekday" ) ) {
27- item . format = 2 ;
28+ item . format = 2 ;
2829 } else {
29- item . format = 1 ;
30+ item . format = 1 ;
3031 }
3132 if ( this . hasAttribute ( "format" ) ) {
3233 item . format = + this . getAttribute ( "format" ) ;
3334 }
3435 } ) ;
35- var times = $ ( '[data-slot-start-ts]' )
36- $ . each ( times , function ( i , item ) {
37- item . slot_start_ts = moment . unix ( this . getAttribute ( "data-slot-start-ts" ) ) . utc ( ) ;
38- item . slot_end_ts = moment . unix ( this . getAttribute ( "data-slot-end-ts" ) ) . utc ( ) ;
36+ var times = $ ( '[data-slot-start-ts]' )
37+ $ . each ( times , function ( i , item ) {
38+ item . slot_start_ts = moment . unix ( this . getAttribute ( "data-slot-start-ts" ) )
39+ . utc ( ) ;
40+ item . slot_end_ts = moment . unix ( this . getAttribute ( "data-slot-end-ts" ) )
41+ . utc ( ) ;
3942 } ) ;
4043}
4144
42- window . format_time = function ( t , tz , fmt ) {
45+ function format_time ( t , tz , fmt ) {
4346 var out ;
44- var mtz = meeting_timezone ;
47+ var mtz = window . meeting_timezone ;
4548 if ( mtz == "" ) {
4649 mtz = "UTC" ;
4750 }
48-
4951 switch ( fmt ) {
5052 case 0 :
51- out = t . tz ( tz ) . format ( 'dddd, ' ) + '<span class="d-none d-sm-block">' +
52- t . tz ( tz ) . format ( 'MMMM Do YYYY, ' ) + '</span>' +
53- t . tz ( tz ) . format ( 'HH:mm' ) + '<span class="d-none d-sm-block">' +
54- t . tz ( tz ) . format ( ' Z z' ) + '</span>' ;
53+ out = t . tz ( tz )
54+ . format ( 'dddd, ' ) + '<span class="">' +
55+ t . tz ( tz )
56+ . format ( 'MMMM Do YYYY, ' ) + '</span>' +
57+ t . tz ( tz )
58+ . format ( 'HH:mm' ) + '<span class="">' +
59+ t . tz ( tz )
60+ . format ( ' Z z' ) + '</span>' ;
5561 break ;
5662 case 1 :
5763 // Note, this code does not work if the meeting crosses the
5864 // year boundary.
59- out = t . tz ( tz ) . format ( "HH:mm" ) ;
60- if ( + t . tz ( tz ) . dayOfYear ( ) < + t . tz ( mtz ) . dayOfYear ( ) ) {
65+ out = t . tz ( tz )
66+ . format ( "HH:mm" ) ;
67+ if ( + t . tz ( tz )
68+ . dayOfYear ( ) < + t . tz ( mtz )
69+ . dayOfYear ( ) ) {
6170 out = out + " (-1)" ;
62- } else if ( + t . tz ( tz ) . dayOfYear ( ) > + t . tz ( mtz ) . dayOfYear ( ) ) {
71+ } else if ( + t . tz ( tz )
72+ . dayOfYear ( ) > + t . tz ( mtz )
73+ . dayOfYear ( ) ) {
6374 out = out + " (+1)" ;
6475 }
6576 break ;
6677 case 2 :
67- out = t . tz ( mtz ) . format ( "dddd, " ) . toUpperCase ( ) +
68- t . tz ( tz ) . format ( "HH:mm" ) ;
69- if ( + t . tz ( tz ) . dayOfYear ( ) < + t . tz ( mtz ) . dayOfYear ( ) ) {
78+ out = t . tz ( mtz )
79+ . format ( "dddd, " )
80+ . toUpperCase ( ) +
81+ t . tz ( tz )
82+ . format ( "HH:mm" ) ;
83+ if ( + t . tz ( tz )
84+ . dayOfYear ( ) < + t . tz ( mtz )
85+ . dayOfYear ( ) ) {
7086 out = out + " (-1)" ;
71- } else if ( + t . tz ( tz ) . dayOfYear ( ) > + t . tz ( mtz ) . dayOfYear ( ) ) {
87+ } else if ( + t . tz ( tz )
88+ . dayOfYear ( ) > + t . tz ( mtz )
89+ . dayOfYear ( ) ) {
7290 out = out + " (+1)" ;
7391 }
7492 break ;
7593 case 3 :
76- out = t . utc ( ) . format ( "YYYY-MM-DD" ) ;
94+ out = t . utc ( )
95+ . format ( "YYYY-MM-DD" ) ;
7796 break ;
7897 case 4 :
79- out = t . tz ( tz ) . format ( "YYYY-MM-DD HH:mm" ) ;
98+ out = t . tz ( tz )
99+ . format ( "YYYY-MM-DD HH:mm" ) ;
80100 break ;
81101 case 5 :
82- out = t . tz ( tz ) . format ( "HH:mm" ) ;
102+ out = t . tz ( tz )
103+ . format ( "HH:mm" ) ;
83104 break ;
84105 }
85106 return out ;
86107}
87108
88-
89109// Format tooltip notice
90- window . format_tooltip_notice = function ( start , end ) {
110+ function format_tooltip_notice ( start , end ) {
91111 var notice = "" ;
92112
93113 if ( end . isBefore ( ) ) {
@@ -102,110 +122,140 @@ window.format_tooltip_notice = function (start, end) {
102122}
103123
104124// Format tooltip table
105- window . format_tooltip_table = function ( start , end ) {
125+ function format_tooltip_table ( start , end ) {
106126 var current_timezone = get_current_tz_cb ( ) ;
107- var out = '<table><tr><th>Timezone </th><th>Start </th><th>End </th></tr>' ;
108- if ( meeting_timezone !== "" ) {
109- out += '<tr><td class="timehead">Meeting timezone:</td ><td>' +
110- format_time ( start , meeting_timezone , 0 ) + '</td><td>' +
111- format_time ( end , meeting_timezone , 0 ) + '</td></tr>' ;
127+ var out = '<div class="text-start">< table class="table text-light table-sm" ><tr><th></th><th>Session start </th><th>Session end </th></tr>' ;
128+ if ( window . meeting_timezone !== "" ) {
129+ out += '<tr><th class="timehead">Meeting timezone</th ><td>' +
130+ format_time ( start , window . meeting_timezone , 0 ) + '</td><td>' +
131+ format_time ( end , window . meeting_timezone , 0 ) + '</td></tr>' ;
112132 }
113- out += '<tr><td class="timehead">Local timezone:</td ><td>' +
133+ out += '<tr><th class="timehead">Local timezone</th ><td>' +
114134 format_time ( start , local_timezone , 0 ) + '</td><td>' +
115135 format_time ( end , local_timezone , 0 ) + '</td></tr>' ;
116136 if ( current_timezone !== 'UTC' ) {
117- out += '<tr><td class="timehead">Selected Timezone:</td ><td>' +
137+ out += '<tr><th class="timehead">Selected Timezone</th ><td>' +
118138 format_time ( start , current_timezone , 0 ) + '</td><td>' +
119139 format_time ( end , current_timezone , 0 ) + '</td></tr>' ;
120140 }
121- out += '<tr><td class="timehead">UTC:</td ><td>' +
141+ out += '<tr><th class="timehead">UTC</th ><td>' +
122142 format_time ( start , 'UTC' , 0 ) + '</td><td>' +
123143 format_time ( end , 'UTC' , 0 ) + '</td></tr>' ;
124- out += '</table>' + format_tooltip_notice ( start , end ) ;
144+ out += '</table>' + format_tooltip_notice ( start , end ) + '</div>' ;
125145 return out ;
126146}
127147
128148// Format tooltip for item
129- window . format_tooltip = function ( start , end ) {
149+ function format_tooltip ( start , end ) {
130150 return '<div class="timetooltiptext">' +
131151 format_tooltip_table ( start , end ) +
132152 '</div>' ;
133153}
134154
135155// Add tooltips
136156window . add_tooltips = function ( ) {
137- $ ( 'span.time' ) . each ( function ( ) {
138- var tooltip = $ ( format_tooltip ( this . start_ts , this . end_ts ) ) ;
139- tooltip [ 0 ] . start_ts = this . start_ts ;
140- tooltip [ 0 ] . end_ts = this . end_ts ;
141- tooltip [ 0 ] . ustart_ts = moment ( this . start_ts ) . add ( - 2 , 'hours' ) ;
142- tooltip [ 0 ] . uend_ts = moment ( this . end_ts ) . add ( 2 , 'hours' ) ;
143- $ ( this ) . parent ( ) . append ( tooltip ) ;
144- } ) ;
157+ $ ( 'div.time' )
158+ . each ( function ( ) {
159+ var tooltip = $ ( format_tooltip ( this . start_ts , this . end_ts ) ) ;
160+ tooltip [ 0 ] . start_ts = this . start_ts ;
161+ tooltip [ 0 ] . end_ts = this . end_ts ;
162+ tooltip [ 0 ] . ustart_ts = moment ( this . start_ts )
163+ . add ( - 2 , 'hours' ) ;
164+ tooltip [ 0 ] . uend_ts = moment ( this . end_ts )
165+ . add ( 2 , 'hours' ) ;
166+ $ ( this )
167+ . closest ( "th, td" )
168+ . attr ( "data-bs-toggle" , "tooltip" )
169+ . attr ( "title" , $ ( tooltip )
170+ . html ( ) )
171+ . tooltip ( {
172+ html : true ,
173+ sanitize : false
174+ } ) ;
175+ } ) ;
145176}
146177
147178// Update times on the agenda based on the selected timezone
148179window . update_times = function ( newtz ) {
149- $ ( 'span.current-tz' ) . html ( newtz ) ;
150- $ ( 'span.time' ) . each ( function ( ) {
151- if ( this . format == 4 ) {
152- var tz = this . start_ts . tz ( newtz ) . format ( " z" ) ;
153- if ( this . start_ts . tz ( newtz ) . dayOfYear ( ) ==
154- this . end_ts . tz ( newtz ) . dayOfYear ( ) ) {
155- $ ( this ) . html ( format_time ( this . start_ts , newtz , this . format ) +
156- '-' + format_time ( this . end_ts , newtz , 5 ) + tz ) ;
180+ $ ( 'span.current-tz' )
181+ . html ( newtz ) ;
182+ $ ( 'div.time' )
183+ . each ( function ( ) {
184+ if ( this . format == 4 ) {
185+ var tz = this . start_ts . tz ( newtz )
186+ . format ( " z" ) ;
187+ if ( this . start_ts . tz ( newtz )
188+ . dayOfYear ( ) ==
189+ this . end_ts . tz ( newtz )
190+ . dayOfYear ( ) ) {
191+ $ ( this )
192+ . html ( format_time ( this . start_ts , newtz , this . format ) +
193+ '-' + format_time ( this . end_ts , newtz , 5 ) + tz ) ;
194+ } else {
195+ $ ( this )
196+ . html ( format_time ( this . start_ts , newtz , this . format ) +
197+ '-' +
198+ format_time ( this . end_ts , newtz , this . format ) + tz ) ;
199+ }
157200 } else {
158- $ ( this ) . html ( format_time ( this . start_ts , newtz , this . format ) +
159- '-' +
160- format_time ( this . end_ts , newtz , this . format ) + tz ) ;
201+ $ ( this )
202+ . html ( format_time ( this . start_ts , newtz , this . format ) + '-' +
203+ format_time ( this . end_ts , newtz , this . format ) ) ;
161204 }
162- } else {
163- $ ( this ) . html ( format_time ( this . start_ts , newtz , this . format ) + '-' +
164- format_time ( this . end_ts , newtz , this . format ) ) ;
165- }
166- } ) ;
205+ } ) ;
167206 update_tooltips_all ( ) ;
168207 update_clock ( ) ;
169208}
170209
171210// Highlight ongoing based on the current time
172211window . highlight_ongoing = function ( ) {
173- $ ( "div#now" ) . remove ( "#now" ) ;
174- $ ( '.ongoing' ) . removeClass ( "ongoing" ) ;
175- var agenda_rows = $ ( '[data-slot-start-ts]' )
176- agenda_rows = agenda_rows . filter ( function ( ) {
177- return moment ( ) . isBetween ( this . slot_start_ts , this . slot_end_ts ) ;
212+ $ ( "div#now" )
213+ . remove ( "#now" ) ;
214+ $ ( '.table-warning' )
215+ . removeClass ( "table-warning" ) ;
216+ var agenda_rows = $ ( '[data-slot-start-ts]' )
217+ agenda_rows = agenda_rows . filter ( function ( ) {
218+ return moment ( )
219+ . isBetween ( this . slot_start_ts , this . slot_end_ts ) ;
178220 } ) ;
179- agenda_rows . addClass ( "ongoing" ) ;
180- agenda_rows . first ( ) . children ( "th, td" ) .
221+ agenda_rows . addClass ( "table-warning" ) ;
222+ agenda_rows . first ( )
223+ . children ( "th, td" )
224+ .
181225 prepend ( $ ( '<div id="now" class="anchor-target"></div>' ) ) ;
182226}
183227
184228// Update tooltips
185229window . update_tooltips = function ( ) {
186- var tooltips = $ ( '.timetooltiptext' ) ;
187- tooltips . filter ( function ( ) {
188- return moment ( ) . isBetween ( this . ustart_ts , this . uend_ts ) ;
189- } ) . each ( function ( ) {
190- $ ( this ) . html ( format_tooltip_table ( this . start_ts , this . end_ts ) ) ;
191- } ) ;
230+ var tooltips = $ ( '.timetooltiptext' ) ;
231+ tooltips . filter ( function ( ) {
232+ return moment ( )
233+ . isBetween ( this . ustart_ts , this . uend_ts ) ;
234+ } )
235+ . each ( function ( ) {
236+ $ ( this )
237+ . html ( format_tooltip_table ( this . start_ts , this . end_ts ) ) ;
238+ } ) ;
192239}
193240
194241// Update all tooltips
195242window . update_tooltips_all = function ( ) {
196- var tooltips = $ ( '.timetooltiptext' ) ;
243+ var tooltips = $ ( '.timetooltiptext' ) ;
197244 tooltips . each ( function ( ) {
198- $ ( this ) . html ( format_tooltip_table ( this . start_ts , this . end_ts ) ) ;
245+ $ ( this )
246+ . html ( format_tooltip_table ( this . start_ts , this . end_ts ) ) ;
199247 } ) ;
200248}
201249
202250// Update clock
203251window . update_clock = function ( ) {
204- $ ( '#current-time' ) . html ( format_time ( moment ( ) , get_current_tz_cb ( ) , 0 ) ) ;
252+ $ ( '#current-time' )
253+ . html ( format_time ( moment ( ) , get_current_tz_cb ( ) , 0 ) ) ;
205254}
206255
207- $ . urlParam = function ( name ) {
208- var results = new RegExp ( '[\?&]' + name + '=([^&#]*)' ) . exec ( window . location . href ) ;
256+ $ . urlParam = function ( name ) {
257+ var results = new RegExp ( '[\?&]' + name + '=([^&#]*)' )
258+ . exec ( window . location . href ) ;
209259 if ( results == null ) {
210260 return null ;
211261 } else {
@@ -217,10 +267,10 @@ window.init_timers = function () {
217267 var fast_timer = 60000 / ( speedup > 600 ? 600 : speedup ) ;
218268 update_clock ( ) ;
219269 highlight_ongoing ( ) ;
220- setInterval ( function ( ) { update_clock ( ) ; } , fast_timer ) ;
221- setInterval ( function ( ) { highlight_ongoing ( ) ; } , fast_timer ) ;
222- setInterval ( function ( ) { update_tooltips ( ) ; } , fast_timer ) ;
223- setInterval ( function ( ) { update_tooltips_all ( ) ; } , 3600000 / speedup ) ;
270+ setInterval ( function ( ) { update_clock ( ) ; } , fast_timer ) ;
271+ setInterval ( function ( ) { highlight_ongoing ( ) ; } , fast_timer ) ;
272+ setInterval ( function ( ) { update_tooltips ( ) ; } , fast_timer ) ;
273+ setInterval ( function ( ) { update_tooltips_all ( ) ; } , 3600000 / speedup ) ;
224274}
225275
226276// set method used to find current time zone
0 commit comments