<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jon Plummer &#187; Implementation</title>
	<atom:link href="http://jonplummer.com/category/implementation/feed" rel="self" type="application/rss+xml" />
	<link>http://jonplummer.com</link>
	<description>Interface and interaction designer</description>
	<lastBuildDate>Mon, 14 Sep 2009 12:17:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Updated Today &#8220;Lite&#8221; v0.2: slight tweaks should be more compatible</title>
		<link>http://jonplummer.com/archives/109</link>
		<comments>http://jonplummer.com/archives/109#comments</comments>
		<pubDate>Tue, 01 May 2007 04:41:22 +0000</pubDate>
		<dc:creator>Jon Plummer</dc:creator>
				<category><![CDATA[Implementation]]></category>
		<category><![CDATA[Plugins]]></category>

		<guid isPermaLink="false">http://jonplummer.com/archives/109</guid>
		<description><![CDATA[Chris K was kind enough to review the tweaks I had made to his original Updated Today plugin . He endorsed the removal of pngfix.js but complained that my use of bloginfo() caused the new plugin to fail on his WordPress install. He also revealed his intent to make certain features of the plugin available [...]]]></description>
			<content:encoded><![CDATA[<p>
<a href="http://chriskdesigns.com/blog/" title="Chris K Designs">Chris K
</a> was kind enough to review the tweaks I had made to his original 
<a href="http://chriskdesigns.com/blog/updated-today-plugin/">Updated Today plugin
</a>. He endorsed the removal of 
<a href="http://homepage.ntlworld.com/bobosola/pnghowto.htm">
<code>pngfix.js
</code>
</a> but complained that my use of 
<code>bloginfo()
</code> caused the new plugin to fail on his WordPress install. He also revealed his intent to make certain features of the plugin available to an admin page, requiring that portions of the output be salted away in variables for future manipulation. I was also dissatisfied with the amount of repetition in my otherwise very short plugin.
</p>
<p>Here is the new code:
</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">/* config variables (later to be made available to an admin menu) */</span>
&nbsp;
<span style="color: #000088;">$UTL</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'element'</span><span style="color: #009900;">&#93;</span>    <span style="color: #339933;">=</span> <span style="color: #0000ff;">'div'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$UTL</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'elementId'</span><span style="color: #009900;">&#93;</span>  <span style="color: #339933;">=</span> <span style="color: #0000ff;">'updated'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$UTL</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'imageUrl'</span><span style="color: #009900;">&#93;</span>   <span style="color: #339933;">=</span> get_bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'url'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/wp-content/plugins/updatedtodaylite/updatedbanner.png'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$UTL</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'style'</span><span style="color: #009900;">&#93;</span>      <span style="color: #339933;">=</span> <span style="color: #0000ff;">'position: absolute; display: block; top: 0px; left: 0px; height: 120px; width: 120px; z-index: 99;'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/* set up the action */</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> showUpdateBanner<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$UTL</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$today</span> <span style="color: #339933;">=</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Y-m-d&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT post_date, id FROM wp_posts WHERE wp_posts.post_date LIKE '&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$today</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;%'&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//will need to sort by date/time to enable the element to be a link to the most recet content</span>
    <span style="color: #000088;">$results</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">mysql_num_rows</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$results</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	    <span style="color: #000088;">$msieRegex</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'/msie\s(5\.[5-9]|[6]\.[0-9]*).*(win)/i'</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_USER_AGENT'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$msieRegex</span><span style="color: #339933;">,</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_USER_AGENT'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span><span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/opera/i'</span><span style="color: #339933;">,</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_USER_AGENT'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$UTL</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'style'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=scale, src=<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #006699; font-weight: bold;">$UTL[imageUrl]</span><span style="color: #000099; font-weight: bold;">\&quot;</span>)&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$UTL</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'style'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot; background-image: url(<span style="color: #006699; font-weight: bold;">$UTL[imageUrl]</span>)&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;<span style="color: #006699; font-weight: bold;">$UTL[element]</span> id=<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #006699; font-weight: bold;">$UTL[elementId]</span><span style="color: #000099; font-weight: bold;">\&quot;</span> style=<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #006699; font-weight: bold;">$UTL[style]</span><span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&lt;/<span style="color: #006699; font-weight: bold;">$UTL[element]</span>&gt;&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/* make it happen */</span>
&nbsp;
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp_footer'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'showUpdateBanner'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>This has the following improvements over my previous attempt:
</p>
<ul>
<li>You can choose what sort of element to wrap the image in.
</li>
<li>Uses 
<code>get_bloginfo()
</code> rather than 
<code>bloginfo()
</code> to prevent parsing errors
</li>
<li>Exposes inline styles, element type, element ID, and image URL as variables
</li>
<li>These config variables are wrapped up in an array to prevent stepping on toes
</li>
<li>
<code>USER_AGENT
</code> condition adds only the appropriate style to the inline styles
</li>
<li>Tolerant of an empty style variable, allowing folks to handle placement in a separate stylesheet if they like
</li>
<li>We only output any HTML once in the script
</li>
</ul>
<p>Still not much to it. Download the new plugin: 
<a href='http://jonplummer.com/wp-content/uploads/2007/04/updatedtodaylitev02.zip' title='Updated Today “Lite” v0.2'>Updated Today “Lite” v0.2
</a></p>
<p>In the future, it would be nice to:
</p>
<ul>
<li>Make this a clickable link to the most recent article, ideally on a page containing all recent content.
</li>
<li>Make it appear if the site has been updated in the past 23 hours or so, since I like to post at night, causing the banner to be visible for a only few hours at most.
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://jonplummer.com/archives/109/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Updated Today &#8220;Lite&#8221; – A lesser and lighter version of the &#8220;Updated Today&#8221; WordPress plugin</title>
		<link>http://jonplummer.com/archives/101</link>
		<comments>http://jonplummer.com/archives/101#comments</comments>
		<pubDate>Tue, 24 Apr 2007 13:39:39 +0000</pubDate>
		<dc:creator>Jon Plummer</dc:creator>
				<category><![CDATA[Implementation]]></category>
		<category><![CDATA[Plugins]]></category>

		<guid isPermaLink="false">http://jonplummer.com/archives/101</guid>
		<description><![CDATA[Courtesy of Weblog Tools Collection comes Chris K &#8217;s Updated Today plugin , which displays a banner at the top left of your WordPress blog if a post exists in the loop with today&#8217;s date as its post date. It is a simple and effective idea, and coded without much fuss; it uses the wp_head [...]]]></description>
			<content:encoded><![CDATA[<p>Courtesy of 
<a href="http://weblogtoolscollection.com/archives/2007/04/20/wordpress-plugin-releases-for-0420/" title="WordPress Plugin Releases for 4/20/2007">Weblog Tools Collection
</a> comes 
<a href="http://chriskdesigns.com/blog/" title="Chris K Designs">Chris K
</a>&#8217;s 
<a href="http://chriskdesigns.com/blog/updated-today-plugin/">Updated Today plugin
</a>, which displays a banner at the top left of your WordPress blog if a post exists in the loop with today&#8217;s date as its post date. It is a simple and effective idea, and coded without much fuss; it uses the 
<code>wp_head
</code> and 
<code>wp_footer
</code> hooks to add styles to the page, write a 
<code>SCRIPT
</code> tag, and conditionally write an 
<code>IMG
</code> wrapped in a 
<code>DIV
</code>. And it seems to work great.
</p>
<p>Upon further inspection I noticed that the plugin relies on 
<a href="http://homepage.ntlworld.com/bobosola/pnghowto.htm">
<code>pngfix.js
</code>
</a> to make IE 5.5 and IE 6 show alpha transparency on the PNG used for the banner. This is necessary because of the nice drop shadow that on the &#8220;updated today&#8221; banner; that shadow has to work well overlaid on any content that happens to be present, so alpha blending is essential. 
<code>pngfix.js
</code> iterates over all of the 
<code>IMG
</code> elements in the document; whenever it finds a PNG it replaces that PNG with a 
<code>SPAN
</code> and uses the Microsoft-proprietary 
<code>DXImageTransform.Microsoft.AlphaImageLoader
</code> to display the PNG within that SPAN.
</p>
<p>There&#8217;s nothing wrong with this technique, selectively used. But I didn&#8217;t want 
<code>pngfix.js
</code> tromping all over my site rewriting my DOM just because I used PNGs. I like PNGs, and I don&#8217;t want them messed with willy-nilly. (Never mind that 
<code>pngfix.js
</code> also does not pass 
<a href="http://www.jslint.com/">jslint
</a>.) I wanted a quick fix that would not require this script.
</p>
<p>I also wasn&#8217;t sure I wanted an additional stylesheet added to the page containing one selector and rules to style the added 
<code>DIV
</code>. I could rip these styles out and place them in my own stylesheet, but in the interest of a quick fix, I decided to leave them in the plugin.
</p>
<p>Here is the original PHP code for the plugin.
</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">/* ### Configuration Variables ### */
&nbsp;
$conf_manual_placement = false;
$conf_manual_style = false;
$conf_use_pngfix = true;
&nbsp;
/* ### End Configuration Variables ### */
&nbsp;
$banneradded = null;
&nbsp;
add_action('wp_head', 'ck_wp_head');
if (!$conf_manual_placement) {
    add_action('wp_footer', 'ck_wp_footer');
}
&nbsp;
function ck_wp_head ()
{
    global $conf_manual_style, $conf_use_pngfix;
    if (!$conf_manual_style) {
        echo '&lt;style type=&quot;text/css&quot; media=&quot;screen&quot;&gt; #updated { position: absolute; display: block; top: 0px; left: 0px; height: 120px; width: 120px; z-index: 99; } &lt;/style&gt;';
    }
    if ($conf_use_pngfix) {
        echo '&lt;!--[if lt IE 7]&gt;&lt;script defer type=&quot;text/javascript&quot; src=&quot;wp-content/plugins/updatedtoday/pngfix.js&quot;&gt;&lt;!--[endif]--&gt;';
    }
}
&nbsp;
function updated_banner()
{
    $today = date(&quot;Y-m-d&quot;);
    $query = &quot;SELECT post_date, id FROM wp_posts WHERE wp_posts.post_date LIKE '&quot;.$today.&quot;%'&quot;;
    $results = mysql_query($query);
    $num_results = mysql_num_rows($results);
    if ($num_results &gt; 0) {
        $results_assoc = mysql_fetch_assoc($results);
        $postid = $results_assoc['id'];
	echo '&lt;p id=&quot;updated&quot;&gt;&lt;img src=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'url'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>/wp-content/plugins/updatedtoday/updated.png&quot; border=&quot;0&quot; /&gt;&lt;/p&gt;';
    }
}
&nbsp;
function ck_wp_footer ()
{
    updated_banner();
}</pre></td></tr></table></div>

<p>Not much to it, really, but more than I&#8217;d like. Near as I can tell, 
<code>$banneradded
</code> is not used. That bit about 
<code>$results_assoc = mysql_fetch_assoc($results); $postid = $results_assoc['id'];
</code> seems to be the beginnings of making the banner a link to the most recent post. To make sure that would work we&#8217;ll need to change the 
<code>SELECT
</code> to ensure the results are sorted by date, so we&#8217;ll trim that for now, and leave it on the to-do list for a later version.
</p>
<p>If we put the styles inline on the 
<code>DIV
</code> and make the image a background of that 
<code>DIV
</code>, we solve the transparency problem in IE for indexed PNGs without need of 
<code>pngfix.js
</code> and eliminate our need to hook the 
<code>wp_head
</code> event. But we&#8217;d like a nice dropshadow even in IE. The quickest way is to choose one of two similar 
<code>DIV
</code>s, one containing the proprietary AlphaImageLoader CSS filter, based on PHP&#8217;s 
<code>HTTP_USER_AGENT
</code>. This leaves the much shorter:
</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp_footer'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'showUpdatedBanner'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> showUpdatedBanner<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$today</span> <span style="color: #339933;">=</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Y-m-d&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT post_date, id FROM wp_posts WHERE wp_posts.post_date LIKE '&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$today</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;%'&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$results</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$num_results</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_num_rows</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$results</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$num_results</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span>
        <span style="color: #000088;">$msie</span><span style="color: #339933;">=</span><span style="color: #0000ff;">'/msies(5.[5-9]|[6].[0-9]*).*(win)/i'</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_USER_AGENT'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$msie</span><span style="color: #339933;">,</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_USER_AGENT'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span><span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/opera/i'</span><span style="color: #339933;">,</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_USER_AGENT'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span>
            <span style="color: #b1b100;">echo</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;div id=<span style="color: #000099; font-weight: bold;">\&quot;</span>updated<span style="color: #000099; font-weight: bold;">\&quot;</span> style=<span style="color: #000099; font-weight: bold;">\&quot;</span>position: absolute; display: block; top: 0px; left: 0px; height: 120px; width: 120px; z-index: 99; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=scale, src='&quot;</span> <span style="color: #339933;">.</span> bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'url'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;/wp-content/plugins/updatedtodaylite/updatedbanner.png');<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&lt;/div&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">else</span> <span style="color: #339933;">:</span>
            <span style="color: #b1b100;">echo</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;div id=<span style="color: #000099; font-weight: bold;">\&quot;</span>updated<span style="color: #000099; font-weight: bold;">\&quot;</span> style=<span style="color: #000099; font-weight: bold;">\&quot;</span>position: absolute; display: block; top: 0px; left: 0px; height: 120px; width: 120px; z-index: 99; background-image: url( &quot;</span> <span style="color: #339933;">.</span> bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'url'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;/wp-content/plugins/updatedtodaylite/updatedbanner.png );<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&lt;/div&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>This is much simpler, does the same work, and can easily be altered to be more semantically appropriate (a topic for later). Download the new plugin: 
<a href="http://jonplummer.com/wp-content/uploads/2007/04/updatedtodaylite.zip">Updated Today “Lite”
</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://jonplummer.com/archives/101/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>I&#8217;m picky about pullquotes</title>
		<link>http://jonplummer.com/archives/67</link>
		<comments>http://jonplummer.com/archives/67#comments</comments>
		<pubDate>Sun, 08 Apr 2007 21:10:02 +0000</pubDate>
		<dc:creator>Jon Plummer</dc:creator>
				<category><![CDATA[Implementation]]></category>

		<guid isPermaLink="false">http://jonplummer.com/archives/67</guid>
		<description><![CDATA[No, really. In a magazine, a pullquote can pull a browsing reader into an article by highlighting a provocative comment or deft turn of phrase, or help steel a reader&#8217;s resolve to press on, teasing them with a little deferred gratification. That magazine-ey feel can be helpful on sites with long, multi-page articles that are [...]]]></description>
			<content:encoded><![CDATA[<p>No, really.
</p>
<p>In a magazine, a pullquote can pull a browsing reader into an article by highlighting a provocative comment or deft turn of phrase, or help steel a reader&#8217;s resolve to press on, teasing them with a little deferred gratification. That magazine-ey feel can be helpful on sites with long, multi-page articles that are otherwise relatively unbroken by pictures, blockquotes, or other places for the eye to rest.
</p>
<p>There are many examples of pullquotes on the web. But each fails to satisfy in some way.
</p>
<p>Many authors 
<a href="http://www.htmldog.com/articles/pullquotes/" title="HTML Dog: Pull Quotes">add the content of the pullquote to the document
</a>, unnecessarily repeating content or interrupting the HTML stream with a non-sequitur. This could have a jarring effect on a reader browsing without benefit of CSS, or using a screen reader (unless the CSS rule 
<code>speak: none
</code> were used by the author and supported by the reader).
</p>
<p>Many go a step further, identifying content that would make a nice pullquote, wrapping it in a 
<code>span
</code> and using JavaScript to replicate it in the DOM. Roger Johansson&#8217;s technique is the 
<a href="http://www.456bereastreet.com/archive/200609/automatic_pullquotes_with_javascript_and_css" title="465 Berea St: Automatic pullquotes with JavaScript and CSS">definitive example
</a> of this method. This is great because we do not have excess content for what is essentially a presentational effect. It does put the pullquote right next to its source text, though, which is unfortunate.
</p>
<p>Also, the above method requires your pullquote to be a direct quote of the source text. Pullquote text often does not exactly match its source. Dependent clauses are trimmed, prepositions adjusted, other editing is done to allow the pullquote to stand alone. This requirement led me to toy with the notion of using JavaScript to collect one or more spans selected from the text into a single pullquote, but I stopped when I realized that that would only allow me to drop words from the source text, not change them if necessary.
</p>
<p>So far we&#8217;ve identified the following requirements:
</p>
<ol>
<li>No repeated or extra content
</li>
<li>Control over pullquote placement in source text
</li>
<li>Pullquote text not necessarily a direct copy of source text
</li>
</ol>
<p>If we relax the first requirement slightly, this can be done. We might add an empty 
<code>span
</code> to our HTML where we want the pullquote to appear, and place the content for the pullquote in its 
<code>title
</code> attribute. We then use some JavaScript to find this empty span and put its title text inside. A little CSS makes it pretty. I&#8217;ve made an 
<a href="http://jonplummer.com/wp-content/uploads/2007/04/pullquote_example.html" title="Pullquote example">example page
</a> with very simple code so the effect is obvious.</p>
]]></content:encoded>
			<wfw:commentRss>http://jonplummer.com/archives/67/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>A JavaScript date formatter</title>
		<link>http://jonplummer.com/archives/84</link>
		<comments>http://jonplummer.com/archives/84#comments</comments>
		<pubDate>Fri, 06 Apr 2007 22:22:30 +0000</pubDate>
		<dc:creator>Jon Plummer</dc:creator>
				<category><![CDATA[Implementation]]></category>

		<guid isPermaLink="false">http://jonplummer.com/archives/84</guid>
		<description><![CDATA[Some time ago I was asked to build a multi-day date-picking interface that was to accept dates selected from a calendar and display them in a list without making a round-trip to the server. Since this was for a web application with an international audience, I needed to handle different date formats (localization) and languages [...]]]></description>
			<content:encoded><![CDATA[<p>Some time ago I was asked to build a multi-day date-picking interface that was to accept dates selected from a calendar and display them in a list without making a round-trip to the server. Since this was for a web application with an international audience, I needed to handle different date formats (localization) and languages (translation). Translation was no big deal; we had long ago established the convention of receiving from the server a JSON object with the necessary terms and phrases, populated by resource bundles. But the date formatting was another matter. And since the back-end was in Java, it would be nice to use the same date-formatting strings that the back-end guys were using, to make adding new locales easier. My formatDate() was the result:
</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">/**
 * formatDate()
 * - follows Java SimpleDateFormat pattern conventions but does not support time zones
 * - depends on dateLanguage object
 *
 * @param   dDate        a javascript date object
 * @param   patternStr   a Java-style date format string
 * @return  string representation of the date
 */</span>
<span style="color: #003366; font-weight: bold;">function</span> formatDate<span style="color: #009900;">&#40;</span>dDate<span style="color: #339933;">,</span> patternStr<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #009966; font-style: italic;">/* interior functions */</span>
&nbsp;
    <span style="color: #006600; font-style: italic;">//countTokenLength() counts the number of repetitions of the individual date format token appearing next in the string</span>
    <span style="color: #003366; font-weight: bold;">function</span> countTokenLength<span style="color: #009900;">&#40;</span>str<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003366; font-weight: bold;">var</span> re <span style="color: #339933;">=</span> <span style="color: #009966; font-style: italic;">/^([a-zA-Z])(1){0,100}/g</span><span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">var</span> matchStr <span style="color: #339933;">=</span> str.<span style="color: #660066;">match</span><span style="color: #009900;">&#40;</span>re<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>matchStr<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000066; font-weight: bold;">return</span> matchStr<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">length</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #006600; font-style: italic;">//padResult() adds copies of padStr to num until it is as wide as necessary</span>
    <span style="color: #006600; font-style: italic;">//in retrospect, this could be made much shorter and more efficient</span>
    <span style="color: #003366; font-weight: bold;">function</span> padResult<span style="color: #009900;">&#40;</span>num<span style="color: #339933;">,</span> width<span style="color: #339933;">,</span> padStr<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #006600; font-style: italic;">//dependent function</span>
        <span style="color: #003366; font-weight: bold;">var</span> returnStr <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>width <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #003366; font-weight: bold;">var</span> padLength <span style="color: #339933;">=</span> width <span style="color: #339933;">-</span> num.<span style="color: #660066;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">length</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>padLength<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>padLength<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    returnStr <span style="color: #339933;">+=</span> padStr<span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
        returnStr <span style="color: #339933;">+=</span> num.<span style="color: #660066;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">return</span> returnStr<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #006600; font-style: italic;">//here is where the action begins</span>
    <span style="color: #003366; font-weight: bold;">var</span> resultStr <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #003366; font-weight: bold;">var</span> subPatternLength <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span>patternStr.<span style="color: #660066;">length</span> <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        subPatternLength <span style="color: #339933;">=</span> countTokenLength<span style="color: #009900;">&#40;</span>patternStr<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">var</span> token <span style="color: #339933;">=</span> patternStr.<span style="color: #660066;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">switch</span> <span style="color: #009900;">&#40;</span>token<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">case</span> <span style="color: #3366CC;">&quot;G&quot;</span><span style="color: #339933;">:</span>
            resultStr <span style="color: #339933;">+=</span> <span style="color: #009900;">&#40;</span>dDate.<span style="color: #660066;">getFullYear</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;=</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">?</span> dateLanguage.<span style="color: #660066;">eraNames</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">:</span> dateLanguage.<span style="color: #660066;">eraNames</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">case</span> <span style="color: #3366CC;">&quot;y&quot;</span><span style="color: #339933;">:</span>
            <span style="color: #003366; font-weight: bold;">var</span> x <span style="color: #339933;">=</span> dDate.<span style="color: #660066;">getFullYear</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>dDate.<span style="color: #660066;">getFullYear</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #CC0000;">999</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>subPatternLength <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    resultStr <span style="color: #339933;">+=</span> x<span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
                <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
                    resultStr <span style="color: #339933;">+=</span> x.<span style="color: #660066;">substring</span><span style="color: #009900;">&#40;</span>x.<span style="color: #660066;">length</span> <span style="color: #339933;">-</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> x.<span style="color: #660066;">length</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span>
            <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
                resultStr <span style="color: #339933;">+=</span> x <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot; &quot;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>dDate.<span style="color: #660066;">getFullYear</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;=</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">?</span> dateLanguage.<span style="color: #660066;">eraNames</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">:</span> dateLanguage.<span style="color: #660066;">eraNames</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
            <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">case</span> <span style="color: #3366CC;">&quot;M&quot;</span><span style="color: #339933;">:</span>
            <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>subPatternLength <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                resultStr <span style="color: #339933;">+=</span> <span style="color: #009900;">&#40;</span>subPatternLength <span style="color: #339933;">==</span> <span style="color: #CC0000;">3</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">?</span> dateLanguage.<span style="color: #660066;">monthNamesShort</span><span style="color: #009900;">&#91;</span>dDate.<span style="color: #660066;">getMonth</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">:</span> dateLanguage.<span style="color: #660066;">monthNames</span><span style="color: #009900;">&#91;</span>dDate.<span style="color: #660066;">getMonth</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
            <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
                resultStr <span style="color: #339933;">+=</span> padResult<span style="color: #009900;">&#40;</span>dDate.<span style="color: #660066;">getMonth</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> subPatternLength<span style="color: #339933;">,</span> <span style="color: #3366CC;">'0'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
            <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">case</span> <span style="color: #3366CC;">&quot;w&quot;</span><span style="color: #339933;">:</span>
            <span style="color: #003366; font-weight: bold;">var</span> resultLength <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>subPatternLength <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;=</span> <span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">?</span> <span style="color: #CC0000;">2</span> <span style="color: #339933;">:</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
            resultStr <span style="color: #339933;">+=</span> <span style="color: #3366CC;">&quot;[week in year]&quot;</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">case</span> <span style="color: #3366CC;">&quot;W&quot;</span><span style="color: #339933;">:</span>
            <span style="color: #003366; font-weight: bold;">var</span> resultLength <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>subPatternLength <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;=</span> <span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">?</span> <span style="color: #CC0000;">2</span> <span style="color: #339933;">:</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
            resultStr <span style="color: #339933;">+=</span> <span style="color: #3366CC;">&quot;[week in month]&quot;</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">case</span> <span style="color: #3366CC;">&quot;D&quot;</span><span style="color: #339933;">:</span>
            <span style="color: #003366; font-weight: bold;">var</span> resultLength <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>subPatternLength <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;=</span> <span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">?</span> <span style="color: #CC0000;">2</span> <span style="color: #339933;">:</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
            resultStr <span style="color: #339933;">+=</span> <span style="color: #3366CC;">&quot;[day in year]&quot;</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">case</span> <span style="color: #3366CC;">&quot;d&quot;</span><span style="color: #339933;">:</span>
            <span style="color: #003366; font-weight: bold;">var</span> resultLength <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>subPatternLength <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;=</span> <span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">?</span> <span style="color: #CC0000;">2</span> <span style="color: #339933;">:</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
            resultStr <span style="color: #339933;">+=</span> padResult<span style="color: #009900;">&#40;</span>dDate.<span style="color: #660066;">getDate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> resultLength<span style="color: #339933;">,</span> <span style="color: #3366CC;">'0'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">case</span> <span style="color: #3366CC;">&quot;F&quot;</span><span style="color: #339933;">:</span>
            <span style="color: #003366; font-weight: bold;">var</span> resultLength <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>subPatternLength <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;=</span> <span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">?</span> <span style="color: #CC0000;">2</span> <span style="color: #339933;">:</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
            resultStr <span style="color: #339933;">+=</span> <span style="color: #3366CC;">&quot;[day of week in month]&quot;</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">case</span> <span style="color: #3366CC;">&quot;E&quot;</span><span style="color: #339933;">:</span>
            <span style="color: #000066; font-weight: bold;">switch</span> <span style="color: #009900;">&#40;</span>subPatternLength<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000066; font-weight: bold;">case</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">:</span>
                resultStr <span style="color: #339933;">+=</span> dateLanguage.<span style="color: #660066;">weekDayNamesAbbrev</span><span style="color: #009900;">&#91;</span>dDate.<span style="color: #660066;">getDay</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
                <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">case</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">:</span>
                resultStr <span style="color: #339933;">+=</span> dateLanguage.<span style="color: #660066;">weekDayNamesTiny</span><span style="color: #009900;">&#91;</span>dDate.<span style="color: #660066;">getDay</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
                <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">case</span> <span style="color: #CC0000;">3</span><span style="color: #339933;">:</span>
                resultStr <span style="color: #339933;">+=</span> dateLanguage.<span style="color: #660066;">weekDayNamesShort</span><span style="color: #009900;">&#91;</span>dDate.<span style="color: #660066;">getDay</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
                <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
            <span style="color: #003366; font-weight: bold;">default</span><span style="color: #339933;">:</span>
                resultStr <span style="color: #339933;">+=</span> dateLanguage.<span style="color: #660066;">weekDayNames</span><span style="color: #009900;">&#91;</span>dDate.<span style="color: #660066;">getDay</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
                <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
            <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">case</span> <span style="color: #3366CC;">&quot;a&quot;</span><span style="color: #339933;">:</span>
            resultStr <span style="color: #339933;">+=</span> <span style="color: #009900;">&#40;</span>dDate.<span style="color: #660066;">getHours</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> <span style="color: #CC0000;">12</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">?</span> dateLanguage.<span style="color: #660066;">amPmNames</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">:</span> dateLanguage.<span style="color: #660066;">amPmNames</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">case</span> <span style="color: #3366CC;">&quot;H&quot;</span><span style="color: #339933;">:</span>
            <span style="color: #003366; font-weight: bold;">var</span> resultLength <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>subPatternLength <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;=</span> <span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">?</span> <span style="color: #CC0000;">2</span> <span style="color: #339933;">:</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
            resultStr <span style="color: #339933;">+=</span> padResult<span style="color: #009900;">&#40;</span>dDate.<span style="color: #660066;">getHours</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> resultLength<span style="color: #339933;">,</span> <span style="color: #3366CC;">'0'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">case</span> <span style="color: #3366CC;">&quot;k&quot;</span><span style="color: #339933;">:</span>
            <span style="color: #003366; font-weight: bold;">var</span> resultLength <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>subPatternLength <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;=</span> <span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">?</span> <span style="color: #CC0000;">2</span> <span style="color: #339933;">:</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>dDate.<span style="color: #660066;">getHours</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span> resultStr <span style="color: #339933;">+=</span> <span style="color: #3366CC;">&quot;24&quot;</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">else</span> resultStr <span style="color: #339933;">+=</span>padResult<span style="color: #009900;">&#40;</span>dDate.<span style="color: #660066;">getHours</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> resultLength<span style="color: #339933;">,</span> <span style="color: #3366CC;">'0'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">case</span> <span style="color: #3366CC;">&quot;K&quot;</span><span style="color: #339933;">:</span>
            <span style="color: #003366; font-weight: bold;">var</span> resultLength <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>subPatternLength <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;=</span> <span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">?</span> <span style="color: #CC0000;">2</span> <span style="color: #339933;">:</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
            <span style="color: #003366; font-weight: bold;">var</span> adjust <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>dDate.<span style="color: #660066;">getHours</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;=</span> <span style="color: #CC0000;">12</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">?</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">12</span> <span style="color: #339933;">:</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
            resultStr <span style="color: #339933;">+=</span> padResult<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>dDate.<span style="color: #660066;">getHours</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> adjust<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> resultLength<span style="color: #339933;">,</span> <span style="color: #3366CC;">'0'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">case</span> <span style="color: #3366CC;">&quot;h&quot;</span><span style="color: #339933;">:</span>
            <span style="color: #003366; font-weight: bold;">var</span> resultLength <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>subPatternLength <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;=</span> <span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">?</span> <span style="color: #CC0000;">2</span> <span style="color: #339933;">:</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
            <span style="color: #003366; font-weight: bold;">var</span> adjust <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>dDate.<span style="color: #660066;">getHours</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;=</span> <span style="color: #CC0000;">12</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">?</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">12</span> <span style="color: #339933;">:</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>dDate.<span style="color: #660066;">getHours</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> adjust<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                resultStr <span style="color: #339933;">+=</span> <span style="color: #3366CC;">&quot;12&quot;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
            <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
                resultStr <span style="color: #339933;">+=</span> padResult<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>dDate.<span style="color: #660066;">getHours</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> adjust<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> resultLength<span style="color: #339933;">,</span> <span style="color: #3366CC;">'0'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
            <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">case</span> <span style="color: #3366CC;">&quot;m&quot;</span><span style="color: #339933;">:</span>
            <span style="color: #003366; font-weight: bold;">var</span> resultLength <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>subPatternLength <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;=</span> <span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">?</span> <span style="color: #CC0000;">2</span> <span style="color: #339933;">:</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
            resultStr <span style="color: #339933;">+=</span> padResult<span style="color: #009900;">&#40;</span>dDate.<span style="color: #660066;">getMinutes</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> resultLength<span style="color: #339933;">,</span> <span style="color: #3366CC;">'0'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">case</span> <span style="color: #3366CC;">&quot;s&quot;</span><span style="color: #339933;">:</span>
            <span style="color: #003366; font-weight: bold;">var</span> resultLength <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>subPatternLength <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;=</span> <span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">?</span> <span style="color: #CC0000;">2</span> <span style="color: #339933;">:</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
            resultStr <span style="color: #339933;">+=</span> padResult<span style="color: #009900;">&#40;</span>dDate.<span style="color: #660066;">getSeconds</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> resultLength<span style="color: #339933;">,</span> <span style="color: #3366CC;">'0'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">case</span> <span style="color: #3366CC;">&quot;S&quot;</span><span style="color: #339933;">:</span>
            resultStr <span style="color: #339933;">+=</span> dDate.<span style="color: #660066;">getTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">case</span> <span style="color: #3366CC;">&quot;z&quot;</span><span style="color: #339933;">:</span>
            resultStr <span style="color: #339933;">+=</span> <span style="color: #3366CC;">&quot;[general time zone]&quot;</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">case</span> <span style="color: #3366CC;">&quot;Z&quot;</span><span style="color: #339933;">:</span>
            resultStr <span style="color: #339933;">+=</span> <span style="color: #3366CC;">&quot;[rfc 822 time zone]&quot;</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">case</span> <span style="color: #3366CC;">&quot;'&quot;</span><span style="color: #339933;">:</span>
            <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>patternStr.<span style="color: #660066;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot;'&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                resultStr <span style="color: #339933;">+=</span> <span style="color: #3366CC;">&quot;'&quot;</span><span style="color: #339933;">;</span>
                subPatternLength <span style="color: #339933;">=</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
            <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #003366; font-weight: bold;">var</span> txt <span style="color: #339933;">=</span> patternStr.<span style="color: #660066;">match</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/^'([^']|'')*'/g</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
                subPatternLength <span style="color: #339933;">=</span> txt.<span style="color: #660066;">length</span><span style="color: #339933;">;</span>
                <span style="color: #003366; font-weight: bold;">var</span> strippedTxt <span style="color: #339933;">=</span> txt.<span style="color: #660066;">substring</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> txt.<span style="color: #660066;">length</span><span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/''/g</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;'&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                resultStr <span style="color: #339933;">+=</span> strippedTxt<span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
            <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">default</span><span style="color: #339933;">:</span>
            <span style="color: #003366; font-weight: bold;">var</span> alphaRe <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> RegExp<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;[A-Za-z]&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;g&quot;</span><span style="color: #009900;">&#41;</span>
            <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>token.<span style="color: #660066;">match</span><span style="color: #009900;">&#40;</span>alphaRe<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                resultStr <span style="color: #339933;">+=</span> token<span style="color: #339933;">;</span>
                subPatternLength <span style="color: #339933;">=</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
            <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        patternStr <span style="color: #339933;">=</span> patternStr.<span style="color: #660066;">substring</span><span style="color: #009900;">&#40;</span>subPatternLength<span style="color: #339933;">,</span> patternStr.<span style="color: #660066;">length</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000066; font-weight: bold;">return</span> resultStr<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> dateLanguage <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
    monthNames <span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'January'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'February'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'March'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'April'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'May'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'June'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'July'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'August'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'September'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'October'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'November'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'December'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
    monthNamesShort <span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'Jan'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Feb'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Mar'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Apr'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'May'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Jun'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Jul'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Aug'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Sep'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Oct'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Nov'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Dec'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
    weekDayNames <span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'Sunday'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Monday'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Tuesday'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Wednesday'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Thursday'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Friday'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Saturday'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
    weekDayNamesShort <span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'Sun'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Mon'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Tue'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Wed'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Thu'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Fri'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Sat'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
    weekDayNamesTiny <span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'Su'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Mo'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Tu'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'We'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Th'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Fr'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Sa'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
    weekDayNamesAbbrev <span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'S'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'M'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'T'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'W'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'T'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'F'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'S'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
    eraNames <span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'BC'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'AD'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
    amPmNames <span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'AM'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'PM'</span><span style="color: #009900;">&#93;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>The core of this routine is a simple regular expression that counts the number of subsequent occurrences of the first token in the string. Once we have the token and its length, we add the correctly formatted date string to the result, trim the used token, and go on to the next one.
</p>
<p>There are a few items not yet implemented. The Java date tokens w (week in year), W (week in month), D (day in year), and F (day of week in month) weren&#8217;t necessary for the project, nor were the two time zone tokens, z and Z, because we were recording and redisplaying unadjusted dates and times reported by the user, making time zone immaterial.</p>
]]></content:encoded>
			<wfw:commentRss>http://jonplummer.com/archives/84/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Field Specifications for E-Commerce</title>
		<link>http://jonplummer.com/archives/74</link>
		<comments>http://jonplummer.com/archives/74#comments</comments>
		<pubDate>Tue, 27 Mar 2007 21:31:10 +0000</pubDate>
		<dc:creator>Jon Plummer</dc:creator>
				<category><![CDATA[Asides]]></category>
		<category><![CDATA[Implementation]]></category>

		<guid isPermaLink="false">http://jonplummer.com/archives/74</guid>
		<description><![CDATA[This might come in handy later: ECML v1.1: Field Specifications for E-Commerce]]></description>
			<content:encoded><![CDATA[<p>This might come in handy later: 
<a href="http://www.ietf.org/rfc/rfc3106">ECML v1.1: Field Specifications for E-Commerce
</a></p>
]]></content:encoded>
			<wfw:commentRss>http://jonplummer.com/archives/74/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google: Web Authoring Statistics</title>
		<link>http://jonplummer.com/archives/64</link>
		<comments>http://jonplummer.com/archives/64#comments</comments>
		<pubDate>Sun, 29 Jan 2006 18:14:00 +0000</pubDate>
		<dc:creator>Jon Plummer</dc:creator>
				<category><![CDATA[Asides]]></category>
		<category><![CDATA[Implementation]]></category>

		<guid isPermaLink="false">http://jonplummer.com/post/google-web-authoring-statistics/</guid>
		<description><![CDATA[Google has an interesting collection of pages up treating statistics surrounding the construction of web pages . An interesting read, if you&#8217;re into that sort of thing.]]></description>
			<content:encoded><![CDATA[<p>Google has an interesting collection of 
<a href="http://code.google.com/webstats/index.html" title="Web Authoring Statistics">pages up treating statistics surrounding the construction of web pages
</a>. An interesting read, if you&#8217;re into that sort of thing.</p>
]]></content:encoded>
			<wfw:commentRss>http://jonplummer.com/archives/64/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Actual user testing of pages read by a screen reader?</title>
		<link>http://jonplummer.com/archives/63</link>
		<comments>http://jonplummer.com/archives/63#comments</comments>
		<pubDate>Sat, 28 Jan 2006 19:23:01 +0000</pubDate>
		<dc:creator>Jon Plummer</dc:creator>
				<category><![CDATA[Asides]]></category>
		<category><![CDATA[Implementation]]></category>

		<guid isPermaLink="false">http://jonplummer.com/post/actual-user-testing-of-pages-read-by-a-screen-reader/</guid>
		<description><![CDATA[Actual user testing of pages read by a screen reader? To determine if source order and skip links really matter? Brilliant !]]></description>
			<content:encoded><![CDATA[<p>Actual user testing of pages read by a screen reader? To determine if source order and skip links really matter? 
<a href="http://www.usability.com.au/resources/source-order.cfm" title="Source Order, Skip Links and Structural Labels">Brilliant
</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://jonplummer.com/archives/63/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Making overloading the class attribute easier</title>
		<link>http://jonplummer.com/archives/41</link>
		<comments>http://jonplummer.com/archives/41#comments</comments>
		<pubDate>Mon, 02 Aug 2004 04:51:00 +0000</pubDate>
		<dc:creator>Jon Plummer</dc:creator>
				<category><![CDATA[Implementation]]></category>

		<guid isPermaLink="false">http://jonplummer.com/post/making-overloading-the-class-attribute-easier/</guid>
		<description><![CDATA[<p>It is becoming fashionable to use JavaScript to add behavior to a page without writing it into the (x)HTML. This is a good thing, in my view. But to do so easily we must either add custom attributes to the markup, or overload the class attribute. I&#8217;ve written some functions that make this second approach nearly painless.</p>]]></description>
			<content:encoded><![CDATA[<p>It is becoming fashionable to use JavaScript to add behavior to a page without writing it into the (x)HTML. This is a good thing, in my view; it further distinguishes content from interface behavior, makes the code tighter, smaller, more human-readable, and makes it more resilient to the well-meaning machinations of the back-end guys.
</p>
<p>Recently, noting the many different forms of (front-end) validation that would be necessary in a web application, I considered getting into using custom attributes to carry relevant metadata. I was considering something like this:
</p>
<p>
<code>&lt;input type="text" required="true" validation="float" value="" /&gt;
</code></p>
<p>which would have all of the aforementioned advantages, and allow all manner of interesting behaviors to be attached at runtime with minimal difficulty. But since 
<strong>no flavor of XHTML or HTML allows the use of custom attributes without inclusion of a custom DTD
</strong>, which is a big hassle, and since I had recently made validation a portion of some automated test cases, I had to abandon that route. I&#8217;ll pursue it elsewhere, naturally. But if you want your pages to validate, or if you care that your web-building friends will clown you mercilessly if your pages do not, this fact can spell trouble.
</p>
<p>The obvious alternative is to overload the class attribute. This is already becoming common for styling reasons, since the modern browsers and recent flavors of Interner Explorer all support putting multiple class names in the class attribute, delimited by spaces. Since we can easily get the contents of the class attribute via JavaScript, why not stuff class full of metadata? It is safe and it validates.
</p>
<p>Two reasons. One, I like to label my metadata. When you are no longer working at your current job, or on your current project, or when this phase of this project is over, someone else is going to have to look at the code, come to an understanding of it. You should be making it easy for them, or for yourself (because you&#8217;ll forget what you meant by 
<code>class="topmatter required multi"
</code>). Two, It has also become common to change or destroy classes as part of CSS-enabled JavaScript interface behaviors. When the class name is no longer a single value, this becomes more complicated.
</p>
<p>They are trivial, really, but I&#8217;ve whipped up some simple functions to help manage this situation. Unfortunately Ineternet Explorer doesn&#8217;t let you add methods to the Node prototype, or these would be even simpler, even tighter, even more useful. But here they are (mostly self-documenting):
</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> addClass<span style="color: #009900;">&#40;</span>element<span style="color: #339933;">,</span> classStr<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>element.<span style="color: #660066;">className</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    element.<span style="color: #660066;">className</span> <span style="color: #339933;">=</span> classStr<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
    element.<span style="color: #660066;">className</span> <span style="color: #339933;">=</span> element.<span style="color: #660066;">className</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot; &quot;</span> <span style="color: #339933;">+</span> classStr<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> removeClass<span style="color: #009900;">&#40;</span>element<span style="color: #339933;">,</span> classStr<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!!</span>element.<span style="color: #660066;">className</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> re <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> RegExp<span style="color: #009900;">&#40;</span>classStr<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    element.<span style="color: #660066;">className</span> <span style="color: #339933;">=</span> element.<span style="color: #660066;">className</span>.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span>re<span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> containsClass<span style="color: #009900;">&#40;</span>element<span style="color: #339933;">,</span> classStr<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #003366; font-weight: bold;">var</span> re <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> RegExp<span style="color: #009900;">&#40;</span>classStr<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!!</span>element.<span style="color: #660066;">className</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> element.<span style="color: #660066;">className</span>.<span style="color: #660066;">match</span><span style="color: #009900;">&#40;</span>re<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Granted, these aren&#8217;t exactly as squeaky-clean as they could be. 
<code>removeClass()
</code> does nothing about any extraneous spaces that might be left in the class name, which shouldn&#8217;t matter unless you use these functions to change the add and remove classes on a single element many many times in a page. And 
<code>addClass()
</code> doesn&#8217;t check to see whether or not the new class is already present, it just tacks it on to the end. I&#8217;ll extend these later, but I wanted to make sure they were very tight, very efficient.</p>
]]></content:encoded>
			<wfw:commentRss>http://jonplummer.com/archives/41/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Per-site user stylesheets, a friendlier way</title>
		<link>http://jonplummer.com/archives/39</link>
		<comments>http://jonplummer.com/archives/39#comments</comments>
		<pubDate>Thu, 15 Jul 2004 12:12:00 +0000</pubDate>
		<dc:creator>Jon Plummer</dc:creator>
				<category><![CDATA[Implementation]]></category>

		<guid isPermaLink="false">http://jonplummer.com/post/per-site-user-stylesheets-a-friendlier-way/</guid>
		<description><![CDATA[I&#8217;m intrigued by the possibilities of user stylesheets , currently supported reasonably well by the Mozilla browsers (although I have to bounce Firefox 0.8x to see changes; I haven&#8217;t investigated the capabilities of other browsers). The basic idea is that in addition to the site author&#8217;s stylesheet, you should be able to apply a stylesheet [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m intrigued by the possibilities of 
<em>user stylesheets
</em>, currently supported reasonably well by the Mozilla browsers (although I have to bounce Firefox 0.8x to see changes; I haven&#8217;t investigated the capabilities of other browsers). The basic idea is that in addition to the site author&#8217;s stylesheet, you should be able to apply a stylesheet of your own choosing/making to whatever site you like, thereby changing fonts, colors, layout, what have you to suit your as-yet-nascent nefarious aims.
</p>
<p>Eric Meyer had a post or two related to this a while ago, regarding &#8221;
<a href="http://archivist.incutio.com/viewlist/css-discuss/13291" title="[css-d] CSS signatures">css signatures
</a>&#8221; for sites. He advocated putting an 
<code>id
</code> on the 
<code>body
</code> tag, wherein the site is identified. For example, I might put an id on this site&#8217;s body tags of 
<code>misterjon-com
</code>. I was immediately taken aback by this suggestion, both in 1) the simplicity and appropriateness of the central idea and 2) the potential misguidedness of the implementation. Yes, a CSS-accessible way to identify the site is a splendid idea. No, the body tag might not be the right place for it, since I think of the body as the document and most sites are composed of several documents; to give each docment the same ID would be, well, odd, like naming all of your sons 
<a href="http://www.who2.com/georgeforeman.html" title="A Who2 Profile">George
</a>. And I (and many others) have recently been known to use an id on the body to identify where the heck I am in a site (which document, perhaps), for purposes of highlighting a portion of the navigation, etc. Perhaps an id on the 
<code>html
</code> tag would work?
</p>
<p>This is sort of a warmish topic lately, a handful of the big bloggers have been on about it briefly.
</p>
<p>Meanwhile, what about all of those sites that aren&#8217;t putting CSS signatures somewhere useful? Ryan Tomayko proposes a solution. In his article, &#8221;
<a href="http://naeblis.cx/weblog/PerSiteUserStyles">Per Site User Stylesheets
</a>,&#8221; Ryan outlines a way to insert signatures for sites that don&#8217;t have them. At its core, his code munges the 
<code>host
</code> portion of 
<code>window.location
</code> and sets an id on the body tag to match, allowing you to refer to 
<code>body#slashdot-org
</code> or what have you in your user stylesheet. 
<a href="http://naeblis.cx/weblog/PerSiteUserStyles" title="Per Site User Stylesheets">Read his article
</a> for the details when you finally get fed up with the default font on Slashdot, for example.
</p>
<p>Trouble is, Mr. Tomayko&#8217;s technique mercilessly breaks sites that already use an id on the body, since whatever was there is replaced by the results of his script.
</p>
<p>But there is an alternative. Set a 
<code>class
</code> on body. The modern browsers all support multiple classes, space-delimited. The critical portion of Mr. Tomayko&#8217;s code is as follows:
</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;!</span><span style="color: #009900;">&#91;</span>CDATA<span style="color: #009900;">&#91;</span>
    <span style="color: #003366; font-weight: bold;">var</span> sig <span style="color: #339933;">=</span> window.<span style="color: #660066;">location</span>.<span style="color: #660066;">host</span>.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/./g</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'-'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">setAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'id'</span><span style="color: #339933;">,</span> sig<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>Changing that to
</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;!</span><span style="color: #009900;">&#91;</span>CDATA<span style="color: #009900;">&#91;</span>
    <span style="color: #003366; font-weight: bold;">var</span> sig <span style="color: #339933;">=</span> window.<span style="color: #660066;">location</span>.<span style="color: #660066;">host</span>.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/./g</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'-'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    classStr <span style="color: #339933;">=</span> <span style="color: #339933;">!!</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">className</span> <span style="color: #339933;">?</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">className</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot; &quot;</span> <span style="color: #339933;">+</span> sig <span style="color: #339933;">:</span> sig<span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">className</span> <span style="color: #339933;">=</span> classStr<span style="color: #339933;">;</span>
<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>sets a class on body without destroying existing work, allowing you to neatly grab the body tag in your user stylesheet with 
<code>body.slashdot-org
</code>. Problem solved.
</p>
<p>I haven&#8217;t yet tried an id on html. Anyone?</p>
]]></content:encoded>
			<wfw:commentRss>http://jonplummer.com/archives/39/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quick and dirty PMS/RGB chart</title>
		<link>http://jonplummer.com/archives/33</link>
		<comments>http://jonplummer.com/archives/33#comments</comments>
		<pubDate>Fri, 18 Jun 2004 08:29:00 +0000</pubDate>
		<dc:creator>Jon Plummer</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Implementation]]></category>

		<guid isPermaLink="false">http://jonplummer.com/post/quick-and-dirty-pmsrgb-chart/</guid>
		<description><![CDATA[<p>A number of individuals have posted on their sites handy Pantone Matching System (PMS) to RGB color conversion charts. These can be pretty hefty downloads, but I&#8217;ve made a small one&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>A number of individuals have posted on their sites handy Pantone Matching System (PMS) to RGB color conversion charts. A freshly-minted example of such a chart has made the blog circuit recently (but I&#8217;ve lost the link already). Since there are so many PMS colors, even the standards-based online PMS charts can be hefty downloads.
</p>
<p>Poking around the net, I found one such chart that seemed official, it being Pantone branded and all (sorry, lost it just as fast). It was a pretty simple matter to use a regular expression to strip the color names and their RGB approximations out of the HTML and slap &#8216;em into a 
<a href="http://www.crockford.com/JSON/index.html" title="Douglas Crockford's Wrrrl Wide Web: Introducing JSON">JSON
</a> object, then write a little script to crawl that object and write some simple XHTML to display a panel of swatches.
</p>
<p>You can grab it at 
<a href="http://jonplummer.com/misc/pms.html">http://jonplummer.com/misc/pms.html
</a>. I suspect I&#8217;ll be making this prettier (and searchable, etc.) later, but at the moment it is reasonably useful, and a svelte 24KB (as opposed to the 240KB or so of many other examples). I&#8217;d love to hear your ideas about how to make this set of swatches more useful.</p>
]]></content:encoded>
			<wfw:commentRss>http://jonplummer.com/archives/33/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
