From 168d5a3836eef49492e581abfdab587a0bab8c23 Mon Sep 17 00:00:00 2001 From: Henrik Levkowetz Date: Sun, 10 Mar 2013 14:56:28 +0000 Subject: [PATCH] From cabo@tzi.org: Added javascript functionality to make the UTC agenda convert it's UTC times to Browser local time. - Legacy-Id: 5544 --- ietf/templates/meeting/agenda_utc.html | 220 ++----------------------- static/js/browsertime.js | 66 ++++++++ 2 files changed, 80 insertions(+), 206 deletions(-) create mode 100644 static/js/browsertime.js diff --git a/ietf/templates/meeting/agenda_utc.html b/ietf/templates/meeting/agenda_utc.html index f79a0d0a8..d53ee8126 100644 --- a/ietf/templates/meeting/agenda_utc.html +++ b/ietf/templates/meeting/agenda_utc.html @@ -76,212 +76,9 @@ img.hidden { display: none; } {% block pagehead %} - + + + {% endblock pagehead %} {% block bodyAttrs %}onload='setGroupState();updateAgendaColors()'{% endblock %} @@ -290,6 +87,17 @@ img.hidden { display: none; }

{{ meeting.city }}, {{ meeting.date|date:"F j" }} – {% ifnotequal meeting.date.month meeting.end_date.month %}{{ meeting.end_date|date:"F " }}{% endifnotequal %}{{ meeting.end_date|date:"j, Y" }}
Updated {{ modified|date:"Y-m-d H:i:s T" }}

+ +

Time zone information:

+ The agenda times in this version of the agenda + are by default in UTC, but there's a handy conversion function which + you can use to make the page show times in your Browser's time. +
+
+ + +
+
(There's also a agenda with local times, a plaintext agenda and a tools-style agenda available)
diff --git a/static/js/browsertime.js b/static/js/browsertime.js new file mode 100644 index 000000000..3c8d349fc --- /dev/null +++ b/static/js/browsertime.js @@ -0,0 +1,66 @@ +jQuery(function($) { + $(document).ready( + function() { + $("#displayinbrowsertime") + .removeAttr("disabled") + .val("Display in Browser time"); + + }); + $("#displayinbrowsertime").click( + function() { + var datere = new RegExp("^\\s*(\\w\\w\\w) (\\d\\d)"); + var timere = new RegExp("(\\d\\d)(\\d\\d)-(\\d\\d)(\\d\\d)"); + var months = { "Jan": 0, "Feb": 1, "Mar": 2, "Apr": 3, "May": 4, "Jun": 5, "Jul": 6, "Aug": 7, "Sep": 8, "Oct": 9, "Nov": 10, "Dec": 11 }; + + var twod = function(n) { + return (n < 10 ? "0" : "") + n; + }; + + var timehhmm = function(d) { + return twod(d.getHours()) + twod(d.getMinutes()); + }; + + var tzshhmm = function(d) { + var tzo = -d.getTimezoneOffset(); + var s = "+"; + if (tzo < 0) { + s = "\u2013"; // en dash + tzo = - tzo; + } + return s + twod(~~(tzo / 60)) + twod(tzo % 60); + }; + + // to fill in the blank left from the text (will be wrong a year after the event): + var thisyear = (new Date).getFullYear(); + $(".timecolumn").each ( + function() { + var deco = $(this).find(".ietf-tiny"); // brittle... + if (deco[1].innerHTML == "UTC") { // i.e., we haven't done this already + var mdday = datere.exec(deco.html()); + var mdfine = timere.exec($(this).html()); + if (mdday && mdfine) { + var month = mdday[1]; + var daystr = mdday[2] + var date1 = new Date(Date.UTC(thisyear, months[month], +daystr, + +mdfine[1], +mdfine[2], 0, 0)); + var time1 = timehhmm(date1); + var date2 = new Date(Date.UTC(thisyear, months[month], +daystr, + +mdfine[3], +mdfine[4], 0, 0)); + var time2 = timehhmm(date2); + + deco[0].innerHTML = date1.toString().slice(4,11) + " "; // month, day + deco[1].innerHTML = tzshhmm(date1); + // outerHTML replacement that is portable back to Firefox < 11 + var d0 = $(deco[0]).clone().wrap('
').parent().html(); + var d1 = $(deco[1]).clone().wrap('
').parent().html(); + $(this).html(d0 + time1 + "\u2013" + time2 + " " + d1); + }; + }; + + }); + $("#displayinbrowsertime") + .attr("disabled", "disabled") // FIX THIS to true for jQuery 1.6+ + .val("Shown in Browser time"); + } + ); +});