Skip to content

Commit 168d5a3

Browse files
committed
From cabo@tzi.org: Added javascript functionality to make the UTC agenda convert it's UTC times to Browser local time.
- Legacy-Id: 5544
1 parent 5ff6e28 commit 168d5a3

2 files changed

Lines changed: 80 additions & 206 deletions

File tree

ietf/templates/meeting/agenda_utc.html

Lines changed: 14 additions & 206 deletions
Original file line numberDiff line numberDiff line change
@@ -76,212 +76,9 @@
7676

7777
{% block pagehead %}
7878
<script type="text/javascript" src='/js/agenda2.js'></script>
79-
<script type="text/javascript">
80-
81-
var lastfrag;
82-
83-
function setGroupState()
84-
{
85-
var frag = window.location.hash.replace("#",'');
86-
window.setTimeout("setGroupState()",1000);
87-
if (frag == lastfrag) { return; }
88-
89-
var weekview = document.getElementById('weekview');
90-
var ical_link = document.getElementById('ical-link');
91-
var ical_href = document.getElementById('ical-href');
92-
93-
94-
lastfrag = frag;
95-
96-
var fragment = frag.split(',');
97-
98-
if (frag.length)
99-
{
100-
weekview.setAttribute("src","week-view.html#"+frag);
101-
weekview.className = '';
102-
ical_url = ical_href.getAttribute("href").split("?")[0];
103-
ical_href.setAttribute("href",ical_url+"?"+frag);
104-
ical_link.className = '';
105-
}
106-
else
107-
{
108-
weekview.className = 'hidden';
109-
ical_link.className = 'hidden';
110-
}
111-
112-
var selectors = document.getElementsByTagName('div');
113-
var re = RegExp("^selector-");
114-
var re2 = RegExp("^selector-(" + fragment.join('|') + ")$");
115-
116-
for (var i=0 ; i<selectors.length; i++)
117-
{
118-
if (re.test(selectors[i].id))
119-
{
120-
var wg = selectors[i].textContent?selectors[i].textContent:selectors[i].text;
121-
var area_groups = document.getElementById(wg + "-groups");
122-
if (re2.test(selectors[i].id))
123-
{
124-
selectors[i].className="selected";
125-
if (area_groups)
126-
{
127-
area_groups.className = 'inactive';
128-
}
129-
}
130-
else
131-
{
132-
selectors[i].className="unselected";
133-
if (area_groups)
134-
{
135-
area_groups.className = '';
136-
}
137-
}
138-
}
139-
}
140-
var rows = document.getElementsByTagName('tr');
141-
var hidenone = false;
142-
if (frag.length == 0) { hidenone=true; }
143-
144-
var re = RegExp("-(" + fragment.join('|') + ")($|-)");
145-
146-
for (var i = 0; i < rows.length; i++)
147-
{
148-
if (rows[i].className == 'groupagenda' || rows[i].className == 'grouprow')
149-
{
150-
if (re.test(rows[i].id) || (hidenone && rows[i].className == 'grouprow'))
151-
{
152-
rows[i].style.display="table-row";
153-
if (rows[i].className == 'groupagenda')
154-
{
155-
var iframe = rows[i].firstElementChild.nextElementSibling.firstElementChild;
156-
if (iframe.getAttribute("xsrc") != iframe.getAttribute("src"))
157-
{
158-
iframe.setAttribute("src",iframe.getAttribute("xsrc"));
159-
}
160-
}
161-
}
162-
else
163-
{
164-
rows[i].style.display="none";
165-
}
166-
}
167-
}
168-
169-
// Handle special cases (checkboxes)
170-
var special = ['edu','ietf','tools','iesg','iab'];
171-
var re3 = RegExp("^(" + fragment.join('|') + ")$");
172-
for (i in special)
173-
{
174-
var include = document.getElementById("include-"+special[i]);
175-
include.checked = ! re3.test("\-"+special[i]);
176-
}
177-
}
178-
179-
/* Resizes an IFRAME to fit its contents. */
180-
function r(iframe)
181-
{
182-
try
183-
{
184-
iframe.height = 1;
185-
iframe.style.border = "solid";
186-
iframe.style.borderWidth = "1px";
187-
iframe.style.margin = "0";
188-
iframe.style.padding = "10px";
189-
iframe.style.overflow = "auto";
190-
docHeight = iframe.contentWindow.document.body.scrollHeight;
191-
iframe.height = docHeight;
192-
}
193-
catch (e) { return; }
194-
195-
/* The following code works really well UNLESS some crazy chair
196-
decides to submit a text agenda that is, say, 500 columns wide.
197-
But this tends to happen. So, until I find a way to stop
198-
that brand of crazy from breaking the world, I'm disabling
199-
this code. Too bad, really -- it made the page much nicer to
200-
use. */
201-
return;
202-
203-
if (iframe.contentWindow.document.body.innerHTML)
204-
{
205-
var div = document.createElement("div");
206-
div.style.border = "solid";
207-
div.style.borderWidth = "1px";
208-
div.style.margin = "0";
209-
div.style.padding = "10px";
210-
div.style.overflow = "auto";
211-
div.innerHTML=iframe.contentWindow.document.body.innerHTML;
212-
iframe.parentNode.replaceChild(div,iframe);
213-
}
214-
}
215-
216-
function add_hash_item(item)
217-
{
218-
if (window.location.hash.replace("#","").length == 0)
219-
{
220-
window.location.hash = item;
221-
}
222-
else
223-
{
224-
window.location.hash += "," + item;
225-
}
226-
window.location.hash = window.location.hash.replace(/^#?,/,'');
227-
}
228-
229-
function remove_hash_item(item)
230-
{
231-
var re = new RegExp('(^|#|,)' + item + "(,|$)");
232-
window.location.hash = window.location.hash.replace(re,"$2")
233-
window.location.hash = window.location.hash.replace(/^#?,/,'');
234-
}
235-
236-
function toggle(selection)
237-
{
238-
var active = selection.className;
239-
var wg = selection.textContent?selection.textContent:selection.text;
240-
241-
if (active == "selected")
242-
{
243-
remove_hash_item(wg);
244-
}
245-
else
246-
{
247-
add_hash_item(wg);
248-
}
249-
setGroupState();
250-
}
251-
252-
function toggle_special(checkbox)
253-
{
254-
var special = checkbox.id.replace('include-','');
255-
if (checkbox.checked)
256-
{
257-
remove_hash_item("-"+special);
258-
}
259-
else
260-
{
261-
add_hash_item("-"+special);
262-
}
263-
}
264-
265-
function toggle_wg_selector ()
266-
{
267-
var wg_selector = document.getElementById('wg-selector');
268-
var triangle_right = document.getElementById('wg-selector-triangle-right');
269-
var triangle_down = document.getElementById('wg-selector-triangle-down');
270-
if (wg_selector.className == 'hidden')
271-
{
272-
wg_selector.className = '';
273-
triangle_right.className = 'hidden';
274-
triangle_down.className = '';
275-
}
276-
else
277-
{
278-
wg_selector.className = 'hidden';
279-
triangle_right.className = '';
280-
triangle_down.className = 'hidden';
281-
}
282-
setGroupState();
283-
}
284-
</script>
79+
<script type="text/javascript" src='/js/jquery-1.5.1.min.js'></script>
80+
<script type="text/javascript" src='/js/browsertime.js'></script>
81+
<script type="text/javascript" src='/js/weekview.js'></script>
28582

28683
{% endblock pagehead %}
28784
{% block bodyAttrs %}onload='setGroupState();updateAgendaColors()'{% endblock %}
@@ -290,6 +87,17 @@ <h1>IETF {{ meeting.number }} Meeting Agenda</h1>
29087

29188
<p>{{ meeting.city }}, {{ meeting.date|date:"F j" }} &#8211; {% ifnotequal meeting.date.month meeting.end_date.month %}{{ meeting.end_date|date:"F " }}{% endifnotequal %}{{ meeting.end_date|date:"j, Y" }}<br />
29289
Updated {{ modified|date:"Y-m-d H:i:s T" }}</p>
90+
91+
<blockquote style="background-color: #ffc; text-align: center;"><h3>Time zone information:</h3>
92+
The agenda times in this version of the agenda
93+
are by default in UTC, but there's a handy conversion function which
94+
you can use to make the page show times in your Browser's time.
95+
</blockquote>
96+
<div style="text-align: center; margin-bottom: 1em;">
97+
<input type="button" name="displayinbrowsertime" id="displayinbrowsertime" value="Display in browser time"/>
98+
99+
</div>
100+
293101
<div class="noprint">
294102
(There's also a <a href="/meeting/agenda">agenda with local times</a>, a <a href="/meeting/{{meeting.number}}/agenda.txt">plaintext agenda</a> and a <a href="http://tools.ietf.org/agenda/{{meeting.number}}/">tools-style agenda</a> available)</div>
295103

static/js/browsertime.js

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
jQuery(function($) {
2+
$(document).ready(
3+
function() {
4+
$("#displayinbrowsertime")
5+
.removeAttr("disabled")
6+
.val("Display in Browser time");
7+
8+
});
9+
$("#displayinbrowsertime").click(
10+
function() {
11+
var datere = new RegExp("^\\s*(\\w\\w\\w) (\\d\\d)");
12+
var timere = new RegExp("(\\d\\d)(\\d\\d)-(\\d\\d)(\\d\\d)");
13+
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 };
14+
15+
var twod = function(n) {
16+
return (n < 10 ? "0" : "") + n;
17+
};
18+
19+
var timehhmm = function(d) {
20+
return twod(d.getHours()) + twod(d.getMinutes());
21+
};
22+
23+
var tzshhmm = function(d) {
24+
var tzo = -d.getTimezoneOffset();
25+
var s = "+";
26+
if (tzo < 0) {
27+
s = "\u2013"; // en dash
28+
tzo = - tzo;
29+
}
30+
return s + twod(~~(tzo / 60)) + twod(tzo % 60);
31+
};
32+
33+
// to fill in the blank left from the text (will be wrong a year after the event):
34+
var thisyear = (new Date).getFullYear();
35+
$(".timecolumn").each (
36+
function() {
37+
var deco = $(this).find(".ietf-tiny"); // brittle...
38+
if (deco[1].innerHTML == "UTC") { // i.e., we haven't done this already
39+
var mdday = datere.exec(deco.html());
40+
var mdfine = timere.exec($(this).html());
41+
if (mdday && mdfine) {
42+
var month = mdday[1];
43+
var daystr = mdday[2]
44+
var date1 = new Date(Date.UTC(thisyear, months[month], +daystr,
45+
+mdfine[1], +mdfine[2], 0, 0));
46+
var time1 = timehhmm(date1);
47+
var date2 = new Date(Date.UTC(thisyear, months[month], +daystr,
48+
+mdfine[3], +mdfine[4], 0, 0));
49+
var time2 = timehhmm(date2);
50+
51+
deco[0].innerHTML = date1.toString().slice(4,11) + "&nbsp"; // month, day
52+
deco[1].innerHTML = tzshhmm(date1);
53+
// outerHTML replacement that is portable back to Firefox < 11
54+
var d0 = $(deco[0]).clone().wrap('<div>').parent().html();
55+
var d1 = $(deco[1]).clone().wrap('<div>').parent().html();
56+
$(this).html(d0 + time1 + "\u2013" + time2 + " " + d1);
57+
};
58+
};
59+
60+
});
61+
$("#displayinbrowsertime")
62+
.attr("disabled", "disabled") // FIX THIS to true for jQuery 1.6+
63+
.val("Shown in Browser time");
64+
}
65+
);
66+
});

0 commit comments

Comments
 (0)