<?xml version="1.0" encoding="UTF-8"?>
<essay xml:lang="en" version="5.0" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:gal="http://norman.walsh.name/rdf/gallery#" xmlns:foaf="http://xmlns.com/foaf/0.1/">
<info>
    
    
    
    
    
    
    
    
<title>Agenda bookmarklet</title><biblioid class="uri">http://norman.walsh.name/2008/05/09/bookmarklet</biblioid>
<volumenum>11</volumenum>
<issuenum>44</issuenum>
<pubdate>2008-05-09T07:15:54-04:00</pubdate>
<author>
      <personname>
<firstname>Norman</firstname>
	<surname>Walsh</surname>
</personname>
    </author>
<copyright>
      <year>2008</year>
      <holder>Norman Walsh</holder>
    </copyright>
<abstract>
<para>A ten minute hack to fix a ten second problem, linking to working
group agendas and minutes.</para>
</abstract>
<dc:subject rdf:resource="http://norman.walsh.name/knows/taxonomy#TheWeb"/>
<dc:subject rdf:resource="http://norman.walsh.name/knows/taxonomy#W3C"/>
</info>

<para xml:id="p1">In typical programmer fashion, I spent ten minutes last
night crafting a solution to a problem that takes ten seconds by hand.
But in the long run, I'll be ahead, right?
</para>

<para xml:id="p2">Several times a week, I go looking for
the most recent agenda for a working group, and often the most recent
minutes as well. For some working groups, XProc for example, the
pattern for these links is entirely predictable:
“<literal>http://www.w3.org/XML/XProc/<replaceable>YEAR</replaceable>/<replaceable>MONTH</replaceable>/<replaceable>DAY</replaceable>-agenda</literal>”.</para>

<para xml:id="p3">So I go into the address bar and start typing. Eventually, I find it
in the drop down or I get to the end of the string. Either way, it's tedious
and I'm doing something the computer could do for me.</para>

<para xml:id="p4">Thus are born the
<link xlink:href="javascript:nw=function(base,suffix,weekday)%7Bvar today=new Date(),dayms=3600*24*1000,dow=today.getDay(),date=new Date(),offset=today.valueOf()-(dow*dayms)+(weekday*dayms);if(weekday%3Cdow)%7Boffset+=7*dayms;%7Ddate.setTime(offset);var uri=base+'/'+date.getFullYear()+'/';if(date.getMonth()%3C9)%7Buri+='0';%7Duri+=(date.getMonth()+1)+'/';if(date.getDate()%3C10)%7Buri+='0';%7Duri+=date.getDate()+'-'+suffix+'.html';document.location=uri;%7D;nw('http://www.w3.org/XML/XProc','agenda',4)">agenda</link>
and
<link xlink:href="javascript:lw=function(base,suffix,weekday)%7Bvar today=new Date(),dayms=3600*24*1000,dow=today.getDay(),date=new Date(),offset=today.valueOf()-(dow*dayms)+(weekday*dayms);if(weekday%3Edow)%7Boffset-=7*dayms;%7Ddate.setTime(offset);var uri=base+'/'+date.getFullYear()+'/';if(date.getMonth()%3C9)%7Buri+='0';%7Duri+=(date.getMonth()+1)+'/';if(date.getDate()%3C10)%7Buri+='0';%7Duri+=date.getDate()+'-'+suffix+'.html';document.location=uri;%7D;lw('http://www.w3.org/XML/XProc','agenda',4)">minutes</link>
bookmarklets.</para>

<para xml:id="p5">The “agenda” link takes you to the agenda for next week's
meeting;
the “minutes” link takes you to the minutes for the last week's
meeting. Depending on the day of the week, one or the other might
not exist yet, though both do today (9 May 2008).</para>

<para xml:id="p6">In case you're curious, here's the code for the business end of
the agenda link, before it's obfuscated into a URI:</para>

<programlisting>function nw(base,suffix,weekday) {
  var today = new Date();
  var dayms = 3600 * 24 * 1000;
  var dow = today.getDay();

  var date = new Date();
  var offset = today.valueOf() - (dow * dayms) + (weekday * dayms);
  if (weekday &lt; dow) {
    offset += 7 * dayms;
  }
  date.setTime(offset);

  var uri = base + "/" + date.getFullYear() + "/";
  if (date.getMonth() &lt; 9) {
    uri += "0";
  }
  uri += (date.getMonth()+1) + "/";
  if (date.getDate() &lt; 10) {
    uri += "0";
  }
  uri += date.getDate() + "-" + suffix + ".html";

  document.location = uri;
}</programlisting>

<para xml:id="p7">Calling “<code>nw('http://www.w3.org/XML/XProc','agenda',4)</code>”
takes you to the agenda for the XProc call,
“<code>nw('http://www.w3.org/2001/tag','agenda',4)</code>” takes you to
the agenda for the TAG call (both of which happen to be on Thursday, day 4),
etc. Putting the whole prefix in an argument
simplifies constructing a bookmarklet for the local copies of agendas and
minutes on my laptop.</para>

<para xml:id="p8">Converting the <function>nw</function> function for agendas into the
<function>lw</function> function for minutes is an exercise left to the
reader. You can avoid the tedious process of obfuscation by simply copying
the links above.</para>

</essay>

