diff --git a/ietf/static/js/agenda_timezone.js b/ietf/static/js/agenda_timezone.js deleted file mode 100644 index 187bea0e88d..00000000000 --- a/ietf/static/js/agenda_timezone.js +++ /dev/null @@ -1,306 +0,0 @@ -// Copyright The IETF Trust 2021, All Rights Reserved -/* - Timezone support specific to the agenda page - - To properly handle timezones other than local, needs a method to retrieve - the current timezone. Set this by passing a method taking no parameters and - returning the current timezone to the set_current_tz_cb() method. - This should be done before calling anything else in the file. - */ -(function() { - 'use strict'; - - const local_timezone = moment.tz.guess(); - - // get_current_tz_cb must be overwritten using set_current_tz_cb - let get_current_tz_cb = function() { - throw new Error('Tried to get current timezone before callback registered. Use set_current_tz_cb().'); - }; - - // Initialize moments - function initialize_moments() { - const times = $('.time'); - $.each(times, function (i, item) { - item.start_ts = moment.unix(this.getAttribute("data-start-time")) - .utc(); - item.end_ts = moment.unix(this.getAttribute("data-end-time")) - .utc(); - if (this.hasAttribute("data-weekday")) { - item.format = 2; - } else { - item.format = 1; - } - if (this.hasAttribute("format")) { - item.format = +this.getAttribute("format"); - } - }); - const things_with_slots = $('[data-slot-start-ts]'); - $.each(things_with_slots, function (i, item) { - item.slot_start_ts = moment.unix(this.getAttribute("data-slot-start-ts")) - .utc(); - item.slot_end_ts = moment.unix(this.getAttribute("data-slot-end-ts")) - .utc(); - }); - } - - function format_time(t, tz, fmt) { - let out; - const mtz = window.meeting_timezone || "UTC"; - switch (fmt) { - case 0: - out = t.tz(tz) - .format('dddd, ') + '' + - t.tz(tz) - .format('MMMM Do YYYY, ') + '' + - t.tz(tz) - .format('HH:mm') + '' + - t.tz(tz) - .format(' Z z') + ''; - break; - case 1: - // Note, this code does not work if the meeting crosses the - // year boundary. - out = t.tz(tz) - .format("HH:mm"); - if (+t.tz(tz) - .dayOfYear() < +t.tz(mtz) - .dayOfYear()) { - out = out + " (-1)"; - } else if (+t.tz(tz) - .dayOfYear() > +t.tz(mtz) - .dayOfYear()) { - out = out + " (+1)"; - } - break; - case 2: - out = t.tz(mtz) - .format("dddd, ") - .toUpperCase() + - t.tz(tz) - .format("HH:mm"); - if (+t.tz(tz) - .dayOfYear() < +t.tz(mtz) - .dayOfYear()) { - out = out + " (-1)"; - } else if (+t.tz(tz) - .dayOfYear() > +t.tz(mtz) - .dayOfYear()) { - out = out + " (+1)"; - } - break; - case 3: - out = t.utc() - .format("YYYY-MM-DD"); - break; - case 4: - out = t.tz(tz) - .format("YYYY-MM-DD HH:mm"); - break; - case 5: - out = t.tz(tz) - .format("HH:mm"); - break; - } - return out; - } - - // Format tooltip notice - function format_tooltip_notice(start, end) { - let notice = ""; - - if (end.isBefore()) { - notice = "Event ended " + end.fromNow(); - } else if (start.isAfter()) { - notice = "Event will start " + start.fromNow(); - } else { - notice = "Event started " + start.fromNow() + " and will end " + - end.fromNow(); - } - return '' + notice + ''; - } - - // Format tooltip table - function format_tooltip_table(start, end) { - const current_timezone = get_current_tz_cb(); - let out = '
| Session start | Session end | |
|---|---|---|
| Meeting timezone | ' + - format_time(start, window.meeting_timezone, 0) + ' | ' + - format_time(end, window.meeting_timezone, 0) + ' |
| Local timezone | ' + - format_time(start, local_timezone, 0) + ' | ' + - format_time(end, local_timezone, 0) + ' |
| Selected Timezone | ' + - format_time(start, current_timezone, 0) + ' | ' + - format_time(end, current_timezone, 0) + ' |
| UTC | ' + - format_time(start, 'UTC', 0) + ' | ' + - format_time(end, 'UTC', 0) + ' |