<?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>Davin&#039;s blog &#187; code</title>
	<atom:link href="http://blog.davingranroth.com/tag/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.davingranroth.com</link>
	<description>Experience design, faith, and family.</description>
	<lastBuildDate>Sat, 21 Jan 2012 13:42:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>How I use utm_source, utm_medium, utm_campaign from Google Analytics</title>
		<link>http://blog.davingranroth.com/2011/11/how-i-use-utm_source-utm_medium-utm_campaign-from-google-analytics/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-i-use-utm_source-utm_medium-utm_campaign-from-google-analytics</link>
		<comments>http://blog.davingranroth.com/2011/11/how-i-use-utm_source-utm_medium-utm_campaign-from-google-analytics/#comments</comments>
		<pubDate>Fri, 04 Nov 2011 03:10:23 +0000</pubDate>
		<dc:creator>Davin Granroth</dc:creator>
				<category><![CDATA[Web design and technology]]></category>
		<category><![CDATA[analytics]]></category>
		<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://blog.davingranroth.com/?p=1680</guid>
		<description><![CDATA[My friend Adam called me this evening to ask how I&#8217;ve used the Google Analytics tracking codes utm_source, utm_medium, and utm_campaign. He&#8217;s working on an app to help marketers generate HTML e-mails, and is thinking about automating the inclusion of &#8230; <a href="http://blog.davingranroth.com/2011/11/how-i-use-utm_source-utm_medium-utm_campaign-from-google-analytics/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>My friend Adam called me this evening to ask how I&#8217;ve used the Google Analytics tracking codes utm_source, utm_medium, and utm_campaign. He&#8217;s working on <a title="BlutTog: HTML Email Newsletter Generator" href="https://chrome.google.com/webstore/detail/cajjfgajofjnfcinmjcflkgdgcaomibm">an app to help marketers generate HTML e-mails</a>, and is thinking about automating the inclusion of these tracking codes.</p>
<p>The utm_medium is pretty straightforward in that the medium would be values like email, web, twitter, rss, and so on.</p>
<h2>But, what&#8217;s the difference between utm_source and utm_campaign?</h2>
<p><a href="http://www.google.com/support/analyticshelp/bin/answer.py?answer=1033863">Google&#8217;s documentation on these variables</a> is helpful in general, but is not all that clear on the difference between these two variables.</p>
<p>So, here&#8217;s how I think of those variables. The utm_source is like a noun, and utm_campaign is like an adjective. The utm_source will be more consistent from one edition to another, while the utm_campaign will change.</p>
<p>Let&#8217;s look at an example. Let&#8217;s say I send an e-mail newsletter called <em>Brilliant Widgets</em> every season (Spring, Summer, Fall, and Winter), and I want to track how many links back to my website each edition generates. Here are the utm_* values I would use.</p>
<p><strong>utm_* values for the Winter edition of Brilliant Widgets</strong></p>
<table>
<tbody>
<tr>
<th scope="row">utm_source</th>
<td>Brilliant_Widgets</td>
</tr>
<tr>
<th scope="row">utm_campaign</th>
<td>Winter_2011</td>
</tr>
<tr>
<th scope="row">utm_medium</th>
<td>email</td>
</tr>
</tbody>
</table>
<p>So, the href value of the link back to my website would look like this: <code>http://blog.davingranroth.com/?utm_source=Brilliant_Widgets&amp;utm_campaign=Winter_2011&amp;utm_medium=email</code></p>
<p>Now, assuming I use those parameters on the links back to my website and that my website activity is being tracked with Google Analytics, I&#8217;ll be able use Google Analytics to identify website visits that came from that e-mail newsletter. Then for the next edition, I would keep utm_source and utm_medium the same, but update to <code>utm_campaign=Spring_2012</code>.</p>
<p>With this thinking, you could define a set of values for all the e-mails you send out, and create a system that would help you know what those values should be when you introduce new online publications.</p>
<p>I&#8217;m sure that other people and companies have come up with their own approaches to using these utm_* values.</p>
<p>I&#8217;m curious, does anyone else have different ideas or examples to share?</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.davingranroth.com/2011/11/how-i-use-utm_source-utm_medium-utm_campaign-from-google-analytics/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Small-caps, web text, and CSS</title>
		<link>http://blog.davingranroth.com/2011/04/small-caps-web-text-and-css/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=small-caps-web-text-and-css</link>
		<comments>http://blog.davingranroth.com/2011/04/small-caps-web-text-and-css/#comments</comments>
		<pubDate>Wed, 13 Apr 2011 02:40:07 +0000</pubDate>
		<dc:creator>Davin Granroth</dc:creator>
				<category><![CDATA[Web design and technology]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[typography]]></category>

		<guid isPermaLink="false">http://blog.davingranroth.com/?p=1583</guid>
		<description><![CDATA[There&#8217;s a trick to getting small-caps to work on the web, and it&#8217;s counter-intuitive. Let&#8217;s say you had an abbreviation, like CSS, that you wanted to put into small-caps, say with a little extra tracking. You might think you could &#8230; <a href="http://blog.davingranroth.com/2011/04/small-caps-web-text-and-css/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>There&#8217;s a trick to getting small-caps to work on the web, and it&#8217;s counter-intuitive.</p>
<p>Let&#8217;s say you had an abbreviation, like <abbr title="Cascading Style Sheets">CSS</abbr>, that you wanted to put into small-caps, say with a little extra tracking. You might think you could use the <abbr title="Cascading Style Sheets">CSS</abbr> property font-variant: small-caps, and you&#8217;d be good to go. Not so.</p>
<p>Here&#8217;s why. Because for small-caps to work, you need to start with lowercase letters.</p>
<p>However, when you&#8217;re simply typing your thoughts out before you&#8217;ve decided on small-caps for abbreviations, acronyms, etc., you probably typed those abbreviations in uppercase.</p>
<p>So, when you tried small-caps, it simply didn&#8217;t work. For example, see this <a href="http://joeclark.org/standards/small-caps.html">web page from 2005 that Joe Clark wrote to test small-caps</a>. Note how the small-caps versions are more like regular capital letters. Not cool. It makes the hack look good, which is bad.</p>
<p>So, here&#8217;s what you can do (and what I think browsers ought to be doing automatically anyway):</p>
<ol>
<li>First apply <code>text-transform: lowercase</code></li>
<li>Then apply <code>font-variant: small-caps</code></li>
</ol>
<p>That ought to do it.</p>
<p>Here&#8217;s a more specific example of the <abbr title="Cascading Style Sheets">CSS</abbr>.</p>
<p><code>abbr, acronym {<br />
text-transform: lowercase;<br />
font-variant: small-caps;<br />
letter-spacing: 1px;<br />
}</code></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.davingranroth.com/2011/04/small-caps-web-text-and-css/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>The problem with the line break (BR) tag</title>
		<link>http://blog.davingranroth.com/2011/03/the-problem-with-the-line-break-tag/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=the-problem-with-the-line-break-tag</link>
		<comments>http://blog.davingranroth.com/2011/03/the-problem-with-the-line-break-tag/#comments</comments>
		<pubDate>Sun, 06 Mar 2011 01:25:33 +0000</pubDate>
		<dc:creator>Davin Granroth</dc:creator>
				<category><![CDATA[Web design and technology]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[HTML]]></category>

		<guid isPermaLink="false">http://blog.davingranroth.com/?p=1532</guid>
		<description><![CDATA[We&#8217;ve got the &#60;br /&#62; tag all wrong. It&#8217;s time to make it right. We all know the &#60;br /&#62; tag is used to insert a line break in HTML. But what we&#8217;ve been missing is that we were too &#8230; <a href="http://blog.davingranroth.com/2011/03/the-problem-with-the-line-break-tag/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>We&#8217;ve got the &lt;br /&gt; tag all wrong. It&#8217;s time to make it right.</p>
<p>We all know the &lt;br /&gt; tag is used to insert a line break in <abbr title="Hyper Text Markup Language">HTML</abbr>. But what we&#8217;ve been missing is that we were too often after something else. Let me explain.</p>
<h2>Common reasons to use line breaks</h2>
<p>Why would a web writer interrupt a passage of text with a forced line break? Here are a few possibilities.</p>
<ul>
<li>Trying to avoid an <a href="http://en.wikipedia.org/wiki/Widows_and_orphans">orphan</a></li>
<li>Inserting a line break <em>before</em> a 2-word proper noun, like &#8220;American Airlines,&#8221; so the noun isn&#8217;t split</li>
<li>Formatting content like a mailing address</li>
</ul>
<h2>The problem with line breaks (&lt;br /&gt; tags)</h2>
<p>Forcing a line to break in a document that will be printed is a no-brainer. But web writing has different constraints that we shouldn&#8217;t ignore.</p>
<p>Copy on the web has the luxury and burden of being portable. That text can show up anywhere:</p>
<ul>
<li>in an e-mail message</li>
<li>on some other web page</li>
<li>in an <abbr title="Really Simple Syndication">RSS</abbr> reader</li>
<li>copied and pasted into a Tweet</li>
<li>in a web browser on a mobile phone</li>
</ul>
<p>This means that the line length you wrote your text for is simply not reliable. You need to consider how that text will show up in other places too, at unknown line lengths.</p>
<p>A line break may look fine on your screen, but it might look really awkward when that text appears somewhere else beyond your control.</p>
<h2>Instead of splitting text, stick text together</h2>
<h3>Orphans</h3>
<p>Avoid orphans especially where the text is most likely to appear, but relax. You can&#8217;t prevent them altogether.</p>
<p>Instead of inserting a line break, opt to rephrase the text to change the length and prevent the orphan. But realize that when that text appears elsewhere, it might just have an orphan.</p>
<p>You also have the option of a special white-space character called a non-breaking space. In <abbr>HTML</abbr>, it looks like this: <code>&amp;nbsp;</code>. When you put a non-breaking space between two words, those two words will always be on the same line of text.</p>
<h3>2+ word proper nouns</h3>
<p>If you want to be sure that &#8220;American Airlines&#8221; remains on the same line in body text, employ a sprinkle of <abbr title="Cascading Style Sheets">CSS</abbr> magic. In the markup, a corporate name should be contained within a span element, like this:</p>
<p><code>&lt;span class="brand_name"&gt;American Airlines&lt;/span&gt;</code></p>
<p>And then to make sure that those two words stay on the same line, add a line like this to your <abbr title="Cascading Style Sheets">CSS</abbr> file.</p>
<p><code>.brand_name {white-space: nowrap;}</code></p>
<p>That will prevent the brand name text from being split at the end of a line. Instead, both words will flip to the next line if there is not enough room for them on the current line of text.</p>
<h3>Formatting content like mailing addresses</h3>
<p>In this case, I&#8217;m actually okay with using &lt;br /&gt; tags. But, left to my own devices, I might use some different markup and some <abbr title="Cascading Style Sheets">CSS</abbr> instead.</p>
<p>Let&#8217;s say we have an address like this fictional one.</p>
<address>Samuel Clemens<br />
1835 Huckleberry Row<br />
Hannibal, MO 63401<br />
</address>
<p>You could just put that text in an address element and use line breaks.</p>
<p>Or you could mark it up in the <a href="http://microformats.org/wiki/hcard">hcard microformat</a>, and then think about styling it based on that markup. So, it might instead be coded like this.</p>
<p><code>&lt;address class="vcard"&gt;<br />
&lt;span class="fn"&gt;Samuel Clemens&lt;/span&gt;<br />
&lt;span class="street-address"&gt;1835 Huckleberry Row&lt;/span&gt;<br />
&lt;span class="locality"&gt;Hannibal&lt;/span&gt;,<br />
&lt;abbr title="Missouri" class="region"&gt;MO&lt;/abbr&gt;<br />
&lt;span class="postal-code"&gt;63401&lt;/span&gt;<br />
&lt;/address&gt;</code></p>
<p>And then a little bit of <abbr title="Cascading Style Sheets">CSS</abbr> like this would take care of the line breaks.</p>
<p><code>.vcard .fn,<br />
.vcard .street-address{<br />
display: block;<br />
}</code></p>
<h2>The point: we overuse line breaks because they don&#8217;t require any extra thought</h2>
<p>Instead, let&#8217;s consider why we actually want a line break the next time we go to use one. There&#8217;s probably a better option once you realize that you don&#8217;t actually want to break a line of text, you really just want some of the text to stick together.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.davingranroth.com/2011/03/the-problem-with-the-line-break-tag/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Google Analytics for WordPress (version 4.09) trips HTML validation when tracking outbound links</title>
		<link>http://blog.davingranroth.com/2010/11/google-analytics-for-wordpress-version-4-09-trips-html-validation-when-tracking-outbound-links/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=google-analytics-for-wordpress-version-4-09-trips-html-validation-when-tracking-outbound-links</link>
		<comments>http://blog.davingranroth.com/2010/11/google-analytics-for-wordpress-version-4-09-trips-html-validation-when-tracking-outbound-links/#comments</comments>
		<pubDate>Sun, 28 Nov 2010 06:04:30 +0000</pubDate>
		<dc:creator>Davin Granroth</dc:creator>
				<category><![CDATA[Web design and technology]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://blog.davingranroth.com/?p=1438</guid>
		<description><![CDATA[When I write HTML, running code through the W3C Validator is part of my process. If the code doesn&#8217;t pass the validator, there&#8217;s a slim chance I&#8217;ll consider that code ready for anything. So after I upgraded this blog to &#8230; <a href="http://blog.davingranroth.com/2010/11/google-analytics-for-wordpress-version-4-09-trips-html-validation-when-tracking-outbound-links/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>When I write HTML, running code through the <a href="http://validator.w3.org/">W3C Validator</a> is part of my process. If the code doesn&#8217;t pass the validator, there&#8217;s a slim chance I&#8217;ll consider that code ready for anything.</p>
<p>So after I upgraded this blog to WordPress 3.01&#8242;s Twenty Ten theme, I was mildly irritated to find that I had a few validation errors. I viewed the source code to investigate the offending lines of code, and noted that the code the validator cited was not in the source.</p>
<p>This phantom code led me to suspect that DOM scripting from a plugin caused the errors by inserting more code into the markup. That was it, and this evening I finally took the time to track it down. Here&#8217;s the scoop.</p>
<h3>First, the phantom code that broke validation</h3>
<div id="attachment_1440" class="wp-caption alignnone" style="width: 692px"><a href="http://blog.davingranroth.com/wp-content/uploads/2010/11/Screen-shot-2010-11-28-at-12.06.59-AM.png"><img class="size-full wp-image-1440" title="Validation error" src="http://blog.davingranroth.com/wp-content/uploads/2010/11/Screen-shot-2010-11-28-at-12.06.59-AM.png" alt="W3C validator error message indicating an empty target attribute" width="682" height="175" /></a><p class="wp-caption-text">The error indicates an empty target attribute. It turned out, this code was inserted by a plugin.</p></div>
<p>Honestly, the first time I saw this error message, I didn&#8217;t notice the error text that pointed to the target attribute. No, I was first startled by a pattern that looked to me like the tail-end of Javascript code used in an anchor&#8217;s href or onclick attribute. I was startled because, having already looked through the code, I thought I would&#8217;ve noticed that pattern, since it is one that I avoid.</p>
<p>Where was this code? Well, all 9 errors were in the same area of code: links to other websites (blogroll) in the sidebar. I wanted to see it for myself, so I opened the page and viewed the source code. I used the Find command and pasted in some of the code from the validator error message, but the Find came up empty-handed.</p>
<p>While the offending code was not in the served markup, the validator was certainly picking it up, so I went back to the validator to examine that code in more detail.</p>
<div id="attachment_1442" class="wp-caption alignnone" style="width: 646px"><a href="http://blog.davingranroth.com/wp-content/uploads/2010/11/Screen-shot-2010-11-28-at-12.26.39-AM.png"><img class="size-full wp-image-1442" title="Code viewed from validator" src="http://blog.davingranroth.com/wp-content/uploads/2010/11/Screen-shot-2010-11-28-at-12.26.39-AM.png" alt="Code with an onclick javascript snippet inserted for Google Analytics tracking." width="636" height="63" /></a><p class="wp-caption-text">Code with an onclick Javascript snippet inserted for Google Analytics tracking. Note the target attribute.</p></div>
<p>The value of the onclick attribute was the immediate tell for where this code came from. It was the Google Analytics plugin I&#8217;m using.</p>
<h3>Investigating the plugin that caused the validation error</h3>
<p><em><a href="http://wordpress.org/extend/plugins/google-analytics-for-wordpress/">Google Analytics for WordPress</a> is a fantastic plugin.</em> It makes integrating Google Analytics easy, and it has some excellent advanced settings.</p>
<p>One setting is to track outbound clicks and downloads as events so they are are viewable in Google Analytics.</p>
<div id="attachment_1444" class="wp-caption alignnone" style="width: 641px"><a href="http://blog.davingranroth.com/wp-content/uploads/2010/11/Screen-shot-2010-11-28-at-12.05.35-AM.png"><img class="size-full wp-image-1444" title="Checkbox to track outbound links in WordPress" src="http://blog.davingranroth.com/wp-content/uploads/2010/11/Screen-shot-2010-11-28-at-12.05.35-AM.png" alt="Checkbox to track outbound links in WordPress." width="631" height="91" /></a><p class="wp-caption-text">Checkbox to track outbound links in WordPress.</p></div>
<p>To test the theory, I unchecked that box, saved the settings, and revalidated the web page.</p>
<p>It passed with flying colors.</p>
<h3>Validation error identified, but I&#8217;m actually curious about tracking downloads</h3>
<p>For the time being, I&#8217;m okay with leaving that feature turned off. I&#8217;ll let the plugin author know about it and hope the problem will be resolved soon.</p>
<p>Yes, I lose a feature to get back to valid code. Perhaps there is a support group for this kind of behavior.</p>
<p>But in my defense, this is just a personal site. I don&#8217;t make any money on it, and my interest in tracking downloads is just curiosity. I only have a few downloads or outbound links I&#8217;m interested in, and I have nothing riding on that knowledge beyond satisfied curiosity.</p>
<p>Still, the entirety of this problem can be laid to rest on a simple, meddlesome, and empty <code>target=""</code> attribute. That&#8217;s irritating.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.davingranroth.com/2010/11/google-analytics-for-wordpress-version-4-09-trips-html-validation-when-tracking-outbound-links/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>I got to help UXmatters with print styling</title>
		<link>http://blog.davingranroth.com/2010/10/i-got-to-help-uxmatters-with-print-styling/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=i-got-to-help-uxmatters-with-print-styling</link>
		<comments>http://blog.davingranroth.com/2010/10/i-got-to-help-uxmatters-with-print-styling/#comments</comments>
		<pubDate>Thu, 14 Oct 2010 01:53:35 +0000</pubDate>
		<dc:creator>Davin Granroth</dc:creator>
				<category><![CDATA[Web design and technology]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://blog.davingranroth.com/?p=1405</guid>
		<description><![CDATA[A few months ago I contacted UXmatters online magazine to let them know of a problem I had printing out articles with Firefox. The first page would print, but that was all. I could switch to Safari and print fine, &#8230; <a href="http://blog.davingranroth.com/2010/10/i-got-to-help-uxmatters-with-print-styling/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.davingranroth.com/wp-content/uploads/2010/10/Screen-shot-2010-10-13-at-9.22.20-PM.png"><img class="alignright size-medium wp-image-1406" title="UXMatters print page" src="http://blog.davingranroth.com/wp-content/uploads/2010/10/Screen-shot-2010-10-13-at-9.22.20-PM-252x300.png" alt="UXMatters print page" width="252" height="300" /></a>A few months ago I contacted <a href="http://www.uxmatters.com/">UXmatters online magazine</a> to let them know of a problem I had printing out articles with Firefox. The first page would print, but that was all. I could switch to Safari and print fine, but that just didn&#8217;t seem right.</p>
<p>I found out that they were a little shorthanded on specialized web help, so I  volunteered to assist. <a href="http://www.uxmatters.com/authors/archives/2005/11/pabini_gabriel-petit.php">Pabini Gabriel-Petit</a>, the publisher and editor-in-chief, graciously accepted my offer.</p>
<p>Creating print CSS is usually simpler than web page layouts, because the goal is typically to have the content of the page print out well on standard size paper. Multiple columns and site navigation are usually uncalled for.</p>
<p>My first try was to revise the existing print CSS file. After half an hour at that, I decided it would be simpler to start from scratch. The original print CSS was quite complex, and it seemed I was searching for one issue: why did the pages stop printing after page 1?</p>
<p>So I rewrote the CSS, simplifying the CSS code greatly. I had the layout in good shape, but oddly still had the 1 page issue.</p>
<p>I went back to the main screen CSS file and begin sifting through it, looking for clues. Then on a hunch, I found the issue.</p>
<p>The global CSS file is thick. There&#8217;s a ton going on there to defend against various cross browser issues. One particular rule I saw repeatedly was the use of <code>overflow: hidden</code>. That rule is used for a few reasons, but one of them is to force a floated box (div or what have you) to expand when it wants to collapse, vertically. This allows things like backgrounds to show through properly.</p>
<p>One of the selectors that this rule was used on was actually a wrapper for much of the page content. It made sense to me, in a way, that this could confound a browser into hiding paged content that went beyond a page.</p>
<p>So the real key to the much simpler CSS file was to add in an <code>overflow: visible</code> to a large set of selectors to override that <code>overflow: hidden</code> for printed pages.</p>
<p>I sent Pabini the new code, and over the following weeks she tested it and added some details I had missed. About a month ago she deployed the new print CSS code  to the website.</p>
<p>This little evening project was a fun puzzle, and I&#8217;m glad I was able to help make such great content on the UXmatters website print out better for more people.</p>
<p><em>(Back in 2002 or 2003, I forget when, I wrote an <a href="http://envisionic.com/webtips/user_experience/printer_friendly.php">article on print styling for web pages</a>.)</em></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.davingranroth.com/2010/10/i-got-to-help-uxmatters-with-print-styling/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Newsweek&#8217;s Spring 2010 Website Redesign</title>
		<link>http://blog.davingranroth.com/2010/05/newsweeks-spring-2010-website-redesign/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=newsweeks-spring-2010-website-redesign</link>
		<comments>http://blog.davingranroth.com/2010/05/newsweeks-spring-2010-website-redesign/#comments</comments>
		<pubDate>Tue, 01 Jun 2010 02:21:48 +0000</pubDate>
		<dc:creator>Davin Granroth</dc:creator>
				<category><![CDATA[Web design and technology]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[linkedin]]></category>
		<category><![CDATA[metadata]]></category>
		<category><![CDATA[newsweek]]></category>

		<guid isPermaLink="false">http://blog.davingranroth.com/?p=1220</guid>
		<description><![CDATA[I don&#8217;t know when it happened, exactly, but Newseek.com was recently redesigned. There is so much to say about it, and it is mostly good. I&#8217;ll start with the most obvious: the design. In short, the home page is easy &#8230; <a href="http://blog.davingranroth.com/2010/05/newsweeks-spring-2010-website-redesign/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div id="attachment_1221" class="wp-caption alignnone" style="width: 545px"><img class="size-full wp-image-1221" title="newsweek-home-page" src="http://blog.davingranroth.com/wp-content/uploads/2010/05/newsweek-home-page.jpg" alt="Home page of Newsweek.com, May 31, 2010" width="535" height="375" /><p class="wp-caption-text">Home page of Newsweek.com, May 31, 2010</p></div>
<p>I don&#8217;t know when it happened, exactly, but Newseek.com was recently redesigned. There is so much to say about it, and it is mostly good.</p>
<p>I&#8217;ll start with the most obvious: the design.</p>
<p>In short, the home page is easy to scan. There is a clear visual hierarchy. The lead photos and articles have been spot-on for Memorial Day news items, and the clarity of the layout made certain I couldn&#8217;t miss them.</p>
<p>The article pages are easy to read and keep enough of the patterns, like the byline and publication date, that it&#8217;s easy to figure out what&#8217;s what.</p>
<p>My biggest complaint is one that they no doubt haven&#8217;t figured out how to get rid of yet: the banner ads.</p>
<p><a href="http://nymag.com/daily/intel/2010/05/newsweekcom_redesign_launched.html">There&#8217;s more talk about the visuals for the new newsweek.com at nymag.com</a>. I won&#8217;t go on about that, myself, other than to say, gee, it looks like a professional blog. Oddly, that&#8217;s a compliment.</p>
<h3>Now let&#8217;s look at the markup.</h3>
<div id="attachment_1222" class="wp-caption alignright" style="width: 310px"><a href="http://blog.davingranroth.com/wp-content/uploads/2010/05/Screen-shot-2010-05-31-at-9.50.45-PM.png"><img class="size-medium wp-image-1222 " title="Newsweek.com namespaces" src="http://blog.davingranroth.com/wp-content/uploads/2010/05/Screen-shot-2010-05-31-at-9.50.45-PM-300x97.png" alt="Code for namespaces on newsweek.com" width="300" height="97" /></a><p class="wp-caption-text">Newsweek.com&#39;s namespaces point to interesting uses of meta data.</p></div>
<p>I&#8217;ve had a penchant for information architecture since the late 1990s, and about the first thing I noticed when glancing at the markup for the home page is the references to the Dublin Core meta data definitions and other meta data sets.</p>
<p>I was suddenly intrigued. Good use of meta data is sadly absent in many large-scale websites, and it&#8217;s really great to see an effort to play the game for real.</p>
<p>So, at a quick glance through the markup you&#8217;ll notice some unusual pieces, first this:<br />
<code>data-track="{'title':'stories being discussed'}"</code>, which is an attribute with a value that looks a bit like JSON.</p>
<p>I admit to being behind the times with studying HTML 5, but that attribute spurred my suspicion that this page was using HTML 5. I stopped wondering a few lines later when I spotted an <code>article</code> element, followed soon thereafter by a <code>header</code> element, and a <code>nav</code> element sporting an attribute of <code>role="navigation"</code>. Whoa. Newsweek jumped right in.</p>
<p>So what about the meta data? Well, I can&#8217;t really know what they&#8217;re actually doing, but here is an observation. In a sidebar, they have a list of quotes. Each quote is marked up as a blockquote with an id attribute. Following each quote is a span with attributes like <code>property="dc:creator"</code> and <code>about="#q1"</code>. The about attribute refers to the id of the blockquote in question. The content of that span itself is the name of the quoted person, plus which publication the quote came from.</p>
<p>Pretty cool idea: internal markup references like this can build relationships into the content. It could provide some interesting opportunities for parsing later on. Yeah, that&#8217;s right, the semantic web.</p>
<h3>The problem with this all is…it&#8217;s half-baked!</h3>
<div id="attachment_1226" class="wp-caption alignleft" style="width: 310px"><a href="http://blog.davingranroth.com/wp-content/uploads/2010/05/Screen-shot-2010-05-31-at-10.13.03-PM.png"><img class="size-medium wp-image-1226" title="Newsweek.com meta tags, bad markup" src="http://blog.davingranroth.com/wp-content/uploads/2010/05/Screen-shot-2010-05-31-at-10.13.03-PM-300x80.png" alt="Newsweek.com meta tags, bad markup" width="300" height="80" /></a><p class="wp-caption-text">Newsweek.com used &quot;http-equiv&quot; when they needed &quot;name&quot;. Oops.</p></div>
<p>That list of quotes with the ID attributes? All that meta data is duplicated and thereby meaningless! Further, why use a span element when they could have used a cite element? More semantic and those attributes would&#8217;ve played as well. Gah!</p>
<p>And back at the top of the markup by those meta data namespace references there is another set of meta tag elements which are sadly marked up incorrectly.</p>
<p>There is a stack of 5 meta elements that use the http-equiv attribute when they should have used the name attribute. I&#8217;ll bet whoever coded that knows the difference, but I wonder if they were rushed to get this version out. It feels like a beta.</p>
<p>They are so close to providing some really great examples of meta data use in HTML 5! I hope they release another version soon that gets more precise and cleans up some of this code.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.davingranroth.com/2010/05/newsweeks-spring-2010-website-redesign/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>jQuery: Show password checkbox</title>
		<link>http://blog.davingranroth.com/2010/02/jquery-show-password-checkbox/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=jquery-show-password-checkbox</link>
		<comments>http://blog.davingranroth.com/2010/02/jquery-show-password-checkbox/#comments</comments>
		<pubDate>Sat, 13 Feb 2010 16:09:41 +0000</pubDate>
		<dc:creator>Davin Granroth</dc:creator>
				<category><![CDATA[Web design and technology]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[linkedin]]></category>
		<category><![CDATA[password masking]]></category>
		<category><![CDATA[plugins]]></category>

		<guid isPermaLink="false">http://blog.davingranroth.com/?p=1078</guid>
		<description><![CDATA[I wrote version 1 of a jQuery plugin during the last couple of days. Read more about jquery.showPasswordCheckbox.js. The basic functionality is to provide a checkbox on web forms to reveal the password text, so people can choose to view &#8230; <a href="http://blog.davingranroth.com/2010/02/jquery-show-password-checkbox/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I wrote version 1 of a jQuery plugin during the last couple of days. <a href="http://blog.davingranroth.com/sandbox/jquery-plugin-show-password-checkbox/">Read more about jquery.showPasswordCheckbox.js</a>.</p>
<p>The basic functionality is to provide a checkbox on web forms to reveal the password text, so people can choose to view the password they are entering as they enter it.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.davingranroth.com/2010/02/jquery-show-password-checkbox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XSL to get text from Apple Pages documents</title>
		<link>http://blog.davingranroth.com/2009/11/xslt-to-get-text-from-apple-pages-documents/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=xslt-to-get-text-from-apple-pages-documents</link>
		<comments>http://blog.davingranroth.com/2009/11/xslt-to-get-text-from-apple-pages-documents/#comments</comments>
		<pubDate>Sun, 01 Nov 2009 16:36:33 +0000</pubDate>
		<dc:creator>Davin Granroth</dc:creator>
				<category><![CDATA[Web design and technology]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[Pages]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[XSL]]></category>

		<guid isPermaLink="false">http://blog.davingranroth.com/?p=925</guid>
		<description><![CDATA[Pages is the name of Apple&#8217;s basic word processor program that comes with their iWork suite of applications. It&#8217;s not a bad program, but a number of months ago I needed to switch up to MS Word for the Mac. &#8230; <a href="http://blog.davingranroth.com/2009/11/xslt-to-get-text-from-apple-pages-documents/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Pages is the name of Apple&#8217;s basic word processor program that comes with their iWork suite of applications. It&#8217;s not a bad program, but a number of months ago I needed to switch up to MS Word for the Mac.</p>
<p>Well, this morning I was looking through some old files and found a text document I wanted to print that I had done using Pages. Unfortunately, I had removed iWork from my Mac, so I no longer had the software to open the Pages document.</p>
<p>After a cursory search on the Internet for a program that would let me open Pages docs without having the program itself, I came up empty-handed.</p>
<p>So, I inspected the Pages document and realized it was a package. (Right click on the document icon and Show Package Contents.) The package contained an index.xml.gz file, which I unzipped and found within the body of my document amidst a whole bunch of XML code.</p>
<p>I momentarily considered reconstructing the text in TextWrangler, but thought it might be fun to write an XSLT file to do the work.</p>
<p>Please note that this is a 1st draft meant to retrieve the text from my document. It will not handle anything fancy, just text. Plus, it will only try to make each chunk of text into a plain-text paragraph in HTML, suitable for copying and pasting out of a browser window. Use at your own risk. <img src='http://blog.davingranroth.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Ok, <a href="http://blog.davingranroth.com/wp-content/uploads/2009/11/textFromPages.xsl">here&#8217;s the textFromPages.xsl file</a>.</p>
<p>Others may take this initial XSL file and do what they will with it. I hope that if you take this and make it better, you&#8217;ll comment on this post to let me (and others) know.</p>
<p>To have it be useful to you, you&#8217;ll need to know how to apply an XSL transformation to a source XML file (specifically the index.xml from Pages).</p>
<p>Hint: Firefox will do the transformation for you if you include the proper xml-stylesheet directive right after the XML prologue in the source XML file. It looks like this: <code>&lt;?xml-stylesheet href="textFromPages.xsl" type="text/xsl" ?&gt;</code></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.davingranroth.com/2009/11/xslt-to-get-text-from-apple-pages-documents/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>HTML form fields that, when not selected, do not even send a field name upon submit</title>
		<link>http://blog.davingranroth.com/2008/07/html-form-fields-that-when-not-selected-do-not-even-send-a-field-name-upon-submit/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=html-form-fields-that-when-not-selected-do-not-even-send-a-field-name-upon-submit</link>
		<comments>http://blog.davingranroth.com/2008/07/html-form-fields-that-when-not-selected-do-not-even-send-a-field-name-upon-submit/#comments</comments>
		<pubDate>Tue, 08 Jul 2008 01:08:08 +0000</pubDate>
		<dc:creator>Davin Granroth</dc:creator>
				<category><![CDATA[Web design and technology]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[forms]]></category>
		<category><![CDATA[HTML]]></category>

		<guid isPermaLink="false">http://blog.davingranroth.com/?p=369</guid>
		<description><![CDATA[
 <a href="http://blog.davingranroth.com/2008/07/html-form-fields-that-when-not-selected-do-not-even-send-a-field-name-upon-submit/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Checkboxes and radio buttons that have not been checked and multiple select lists that have no selection submit <em>nothing</em> upon submission of the form. It&#8217;s as though they aren&#8217;t even there.</p>
<p>At first, this may seem obvious (Well, yeah, you didn&#8217;t select them, dummy!), except that it runs counter to every other form field.</p>
<p>If you have a text field named &#8220;surname&#8221; and you submit the form with no value in &#8220;surname&#8221;, the submission still includes the variable name &#8220;surname&#8221; but it has no corresponding value. You have the key with a null value.</p>
<p>It&#8217;s the same with textareas, any other type of input element, and select lists (where you are limited to a single selection). Even named buttons submit their values.</p>
<p>So, the stealthy cuplrits:</p>
<ul>
<li>input type=&#8221;radio&#8221;</li>
<li>input type=&#8221;checkbox&#8221;</li>
<li>select multiple=&#8221;multiple&#8221;</li>
</ul>
<p>Adam and I learned this in the midst of discussing and testing code this evening.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.davingranroth.com/2008/07/html-form-fields-that-when-not-selected-do-not-even-send-a-field-name-upon-submit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ladies and gentlemen: introducing REGEXER.COM!</title>
		<link>http://blog.davingranroth.com/2008/04/ladies-and-gentlemen-introducing-regexercom/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=ladies-and-gentlemen-introducing-regexercom</link>
		<comments>http://blog.davingranroth.com/2008/04/ladies-and-gentlemen-introducing-regexercom/#comments</comments>
		<pubDate>Wed, 23 Apr 2008 03:09:54 +0000</pubDate>
		<dc:creator>Davin Granroth</dc:creator>
				<category><![CDATA[Web design and technology]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[regex]]></category>

		<guid isPermaLink="false">http://blog.davingranroth.com/?p=364</guid>
		<description><![CDATA[
 <a href="http://blog.davingranroth.com/2008/04/ladies-and-gentlemen-introducing-regexercom/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>My friend Adam has been tapping at the keyboard and pacing again. This time, he&#8217;s working on a project called <a href="http://regexer.com/">Regexer</a>.</p>
<p>For many programmers and Web developers, having to write up a regex (regular expression, a pattern matching utility found in many programming languages) involves having to dig out a book or look up a website that has the syntax. And then you need to figure out how to write a regular expression that will test some value to see if matches your expression.</p>
<p>Here&#8217;s a fun little example of a regex I found on a <a href="http://www.stylusstudio.com/xmldev/200108/post60960.html">listserv archive</a>. This one is supposed to verify a valid <abbr title="uniform resource indicator">URI</a>.</p>
<p><code class="codeblock"><br />
(([a-zA-Z][0-9a-zA-Z+\\-\\.]*:)?/{0,2}[0-9a-zA-Z;/?:@&#038;=+$\\.\\-_!~*'()%]+)?(#[0-9a-zA-Z;/?:@&#038;=+$\\.\\-_!~*'()%]+)?<br />
</code></p>
<p>Nobody wants to write that kind of madness. (Ok, yes, some of you do want to write that stuff. You are crazy. Thank you for being crazy. Just post your mad regexes to your blog so we can find them.)</p>
<p>So, regular expressions are helpful for things like validating input to a system. Any Web programmer realizes what an understatement that was.</p>
<p>The idea behind <a href="http://regexer.com/">regexer</a> is provide a website in which you can enter a few examples of the values that you want to test, and the site will suggest a regular expression that will do the trick for you.</p>
<p>Whoa. That&#8217;d be nice.</p>
<p>And helpful in a many applications, as regular expressions are used in Javascript, PHP, ASP, Perl, .Net, and so on.</p>
<p>So, this is a work in progress, but Adam does have some of it working. Go ahead and try it out the next time you need a regular expression. And, send him feedback if it works or if doesn&#8217;t work. He&#8217;ll take that info and it can help him make it better for all of us.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.davingranroth.com/2008/04/ladies-and-gentlemen-introducing-regexercom/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Revision: Using Javascript to add instructive text for input and textarea form fields</title>
		<link>http://blog.davingranroth.com/2008/04/revision-using-javascript-to-add-instructive-text-for-input-and-textarea-form-fields/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=revision-using-javascript-to-add-instructive-text-for-input-and-textarea-form-fields</link>
		<comments>http://blog.davingranroth.com/2008/04/revision-using-javascript-to-add-instructive-text-for-input-and-textarea-form-fields/#comments</comments>
		<pubDate>Mon, 14 Apr 2008 01:06:55 +0000</pubDate>
		<dc:creator>Davin Granroth</dc:creator>
				<category><![CDATA[Web design and technology]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[forms]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://blog.davingranroth.com/?p=361</guid>
		<description><![CDATA[
 <a href="http://blog.davingranroth.com/2008/04/revision-using-javascript-to-add-instructive-text-for-input-and-textarea-form-fields/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This is a code <a href="http://blog.davingranroth.com/blog/2008/01/using-javascript-to-add-instru.html">update to a prior post</a>. </p>
<p>The Javascript I had posted earlier fell short in one important arena: when you submitted the form without entering your own text, the form would send in the instructive text. It should instead have erased that text prior to the form submission.</p>
<p>Further, in retrospect, the code was trying to do too much. It is enough to simply set a class of <code>blurred</code> and then remove it, instead of replacing it with a class of <code>sharpened</code>.</p>
<p>So, with that in mind, here is an updated set of Javascript that can be used to insert instructive or suggested texts into form fields, like text input fields or textareas.</p>
<h2>The code</h2>
<p>To start with, we need some scripts to add and remove classes values from an element. The one caveat when doing this is to remember that you can have many class names assigned in a single class attribute. So, when adding and removing class names, you have to be sure to leave pre-existing class names alone. Instead of writing these functions, I did a quick Google search for &#8220;Javascript addClass&#8221; and found these handy Javascript functions, hasClass, addClass, and removeClass, at <a href="http://www.openjs.com/scripts/dom/class_manipulation.php">openjs.com</a>. I&#8217;ll let you look there for that code.</p>
<p>With those class manipulation functions in hand, I rewrote the setSuggestedFormText function down to this.</p>
<p><code class="codeblock"><br />
/* setSuggestedFormText takes 2 arguments, mode and field.<br />
/ mode is either set to put in place the suggested text<br />
/                clear is to remove the suggested text<br />
/     the set mode also assigns adds a class of blurred<br />
/ field is the value of the ID attribute of the input or textarea element<br />
/ April 13, 2008, Davin Granroth, granroth@gmail.com.<br />
*/<br />
function setSuggestedFormText(mode, field){<br />
var key = document.getElementById(field);<br />
var defaultText = key.title;<br />
if(mode == 'set'){<br />
if(key.value == '') {<br />
addClass(key, 'blurred');<br />
key.value = defaultText;<br />
}<br />
}<br />
if(mode == 'clear'){<br />
if(key.value == defaultText) {<br />
removeClass(key, 'blurred');<br />
key.value = '';<br />
}<br />
}<br />
}</p>
<p></code></p>
<p>This function takes two arguments: <code>mode</code> and <code>field</code>. The first, <code>mode</code> can be either of <var>set</var> or <var>clear</var>. The one puts in the suggested text from the title attribute of the element, and the other clears it out. Each checks to see if the value of the field has been edited, in which case it respects the user input.</p>
<p>The next step is to set up the function which triggers this function at the appropriate events. There are three events at which the function needs to be called: when the page loads, when focus is put on the field, and when focus is removed from the field. Here is the code for setUpSuggestedFormText.</p>
<p><code class="codeblock"><br />
/*<br />
/ field is the id of input or textarea field<br />
/ parent is the id of the containing form element<br />
*/<br />
function setUpSuggestedFormText(field, parent){<br />
if(document.getElementById(field)){<br />
// This will set the text on page load<br />
setSuggestedFormText('set', field);<br />
// These 2 events will toggle between the set and clear modes<br />
document.getElementById(field).onblur = function(){<br />
setSuggestedFormText('set', field);<br />
}<br />
document.getElementById(field).onfocus = function(){<br />
setSuggestedFormText('clear', field);<br />
}<br />
// Clear the text before sumitting the form.<br />
document.getElementById(parent).onsubmit = function(){<br />
setSuggestedFormText('clear', field);<br />
}<br />
}<br />
}</p>
<p></code></p>
<p>This setUpSuggestedFormText takes two arguments: the id of the field element and the id of its parent form. The id of the parent is used in the trigger for the form submission. I had considered using a parentNode property to find it, but depending on the markup in the form, it may be multiple parentNodes up. So, this is less code. However, if someone wants to write up the function to recursively walk up the parentNode tree to find the parent form&#8217;s id, I&#8217;d be happy to incorporate it.</p>
<p>The last step is to call the setUpSuggestedFormText once the DOM has loaded in the page. One slightly intrusive means of doing this is to put a Javascript setUp function just before the closing body tag. You can, of course, choose to use something like an addDOMLoadEvent (Google for that) function. Here is what the setUp function looks like in the Javascript.</p>
<p><code class="codeblock"><br />
function setUp(){<br />
setUpSuggestedFormText('to','msgForm');<br />
setUpSuggestedFormText('from','msgForm');<br />
}</p>
<p></code></p>
<p>You can <span class="mt-enclosure mt-enclosure-file"><a href="http://davingranroth.com/blog/documents/setSuggestedFormText-3.zip">download sample code</a></span> which uses an illustration of a message form with from, to, and message fields. The download is a ZIP file which contains an XHTML file, a CSS file, and a Javascript file.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.davingranroth.com/2008/04/revision-using-javascript-to-add-instructive-text-for-input-and-textarea-form-fields/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Javascript to add instructive text for input and textarea form fields</title>
		<link>http://blog.davingranroth.com/2008/01/using-javascript-to-add-instructive-text-for-input-and-textarea-form-fields/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=using-javascript-to-add-instructive-text-for-input-and-textarea-form-fields</link>
		<comments>http://blog.davingranroth.com/2008/01/using-javascript-to-add-instructive-text-for-input-and-textarea-form-fields/#comments</comments>
		<pubDate>Fri, 25 Jan 2008 00:35:38 +0000</pubDate>
		<dc:creator>Davin Granroth</dc:creator>
				<category><![CDATA[Web design and technology]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[forms]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://blog.davingranroth.com/?p=350</guid>
		<description><![CDATA[
 <a href="http://blog.davingranroth.com/2008/01/using-javascript-to-add-instructive-text-for-input-and-textarea-form-fields/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.davingranroth.com/blog/2008/04/revision-using-javascript-to-a.html">UPDATE 2008-04-13: This code has been refactored. Please view the updated posting.</a></p>
<p>Over the last year or so, I&#8217;ve worked on a number of websites where I wanted to add instructive text to form fields, but didn&#8217;t want that text to get in the way when a person actually tries to fill out the form. So, behavior-wise, the page would load with instructive (or suggested) text in the fields. It should have a class attribute that can be used to style it so it doesn&#8217;t look like a real value (grey and italic, for instance). When someone clicks on the field, the instructive text should go away and the class should go away so the default styling kicks in. When someone clicks off, the suggested text and class should pop back in, so long as the field is empty. The instructive text should come from the title attribute on the field (that made the most sense to me, given all the options).</p>
<p>So, here are a couple Javascript functions to do so.</p>
<p><code class="codeblock"><br />
function setSuggestedFormText(mode, field) {<br />
/*<br />
mode values must be one of: set, clear, or reset<br />
set is to check the value on page load<br />
clear is to clear the default value when someone clicks on the field<br />
reset is to fill in the default value when someone clicks off the field<br />
field is the value of the ID attribute of the input or textarea element<br />
Use .blurred and .sharpened selectors in your CSS file<br />
*/<br />
var key = document.getElementById(field);<br />
var defaultText = key.title;<br />
switch(mode) {<br />
case 'set':<br />
if(key.value == '') {<br />
key.value = defaultText;<br />
key.setAttribute('class', 'blurred');<br />
}<br />
break;</p>
<p>case 'clear':<br />
if(key.value == defaultText) {<br />
key.value = '';<br />
key.setAttribute('class', 'sharpened');<br />
}<br />
break;</p>
<p>case 'reset':<br />
if(key.value == '') {<br />
key.value = defaultText;<br />
key.setAttribute('class', 'blurred');<br />
}<br />
break;</p>
<p>default:<br />
break;<br />
}</p>
<p>}<br />
function setUpSuggestedFormText(field){<br />
setSuggestedFormText('set', field);<br />
var node = document.getElementById(field);<br />
node.onblur = function(){<br />
setSuggestedFormText('reset', field);<br />
}<br />
node.onfocus = function(){<br />
setSuggestedFormText('clear', field);<br />
}<br />
}</p>
<p></code></p>
<p>To use these functions, add them to your site&#8217;s Javascript library, and then call the following functions when the document is loaded. Google for adddomloadevent or you could probably use jQuery&#8217;s document.ready function. </p>
<p>Ok, usage. Let&#8217;s say you have an input field for an email address, like so:</p>
<p><code class="codeblock"><br />
&lt;input type="text" name="email"<br />
id="email" title="Your e-mail address" /&gt;</p>
<p></code></p>
<p>You would add the following javascript code to trigger the functions.</p>
<p><code class="codeblock"><br />
// Once the DOM is loaded, call this function<br />
setUpSuggestedFormText('email');</p>
<p></code></p>
<p>Feel free to use it. If you make an improvement, please let me know.</p>
<p>To see it in use, try the search form on this page. For now, the Javascript source is at <a href="http://davingranroth.com/blog/custom.js">http://davingranroth.com/blog/custom.js</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.davingranroth.com/2008/01/using-javascript-to-add-instructive-text-for-input-and-textarea-form-fields/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nephtali</title>
		<link>http://blog.davingranroth.com/2008/01/nephtali/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=nephtali</link>
		<comments>http://blog.davingranroth.com/2008/01/nephtali/#comments</comments>
		<pubDate>Thu, 24 Jan 2008 13:27:50 +0000</pubDate>
		<dc:creator>Davin Granroth</dc:creator>
				<category><![CDATA[Web design and technology]]></category>
		<category><![CDATA[Adam]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[frameworks]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://blog.davingranroth.com/?p=349</guid>
		<description><![CDATA[
 <a href="http://blog.davingranroth.com/2008/01/nephtali/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Oh! Nephtali!</p>
<p>Alright, so if you look up &#8220;Nephtali&#8221; on thinkbabynames.com, you see it listed as a variant of &#8220;Naftali.&#8221;</p>
<blockquote><p>The boy&#8217;s name Naftali \n(a)-fta-li, naf-tali\ is of Hebrew origin, and its meaning is &#8220;struggling&#8221;. Biblical: a son of Jacob and one of the ancestors of the 12 tribes of Israel.</p></blockquote>
<p>&#8220;Struggling.&#8221; Apt.</p>
<p>How many phone calls from Adam have I received in the last year that began, &#8220;With Nephtali, if you were to do [blah blah blah], which of these approaches would you like the best?&#8221;</p>
<p><em>Countless</em>. Every other day is a conservative estimate, considering that many days, there were many phone calls.</p>
<p>The man has been obsessively working on this &#8220;Nephtali.&#8221; Yesterday, in our ritual Nephtali conversation, he said, &#8220;So old man, it&#8217;s time to post this to your blog.&#8221;</p>
<p>After so many versions and so much work on Adam&#8217;s part, it&#8217;s time to break the silence.</p>
<h3>What is Nephtali?</h3>
<p>Well, I&#8217;ll give you my take on it, but for the practical details (and a download), go to <a href="http://nephtaliproject.com">nephtaliproject.com</a>.</p>
<p><strong>Nephtali is a framework for the development of data-driven websites.</strong> It uses PHP 5 and is object-oriented. It&#8217;s flexible, extensible, and plays nicely with other frameworks, like the Pear and Zend frameworks. Because of how it handles data, developers will tend to write more secure Web apps. It separates the presentation from the programming logic well, so that it is easy to use a tool such as Dreamweaver without worrying about messing up the behind-the-scenes programming. And, the API was written with a continual drive to make it user-friendly for programmers, while maintaining a value on security.</p>
<h3>My experience with Nephtali, thus far</h3>
<p>I&#8217;ve played with a couple iterations of Nephtali, and once getting oriented, I found I like it. (Granted, I&#8217;m biased having had so many discussions with Adam about it.)</p>
<p>Compared to CakePHP, Nephtali is easier to use. For instance, in CakePHP, or other Model-View-Controller frameworks (e.g., Ruby on Rails), database models are abstracted and then calls in the app rely on those abstractions. While there is a great benefit to this, I&#8217;ve found the abstractions themselves to be problematic. Nephtali can provide abstraction to fairly simple database actions (standard <abbr title="create, read, update, delete">CRUD</abbr> operations), but, gosh darn it, I like being able to jump in and write SQL. The reality for me as a developer is that database model abstraction causes me more grief than they are worth. Abstraction can slow me down, especially when the queries and relationships get tricky. Now, one of the big benefits to abstraction is that it can promote the <abbr title="Don&#8217;t Repeat Yourself">DRY</abbr> principle. Nephtali provides well for that, through implementing sub-classes, and I still have the direct, easy line to thinking about and working with the data in SQL.</p>
<h3>The future of Nephtali</h3>
<p>I could go on, but the proof for Nephtali will be in how many sites it is eventually used on, and how many other developers get their heads into it.</p>
<p>So, developers, <a href="http://nephtaliproject.com">check out Nephtali</a>. And if you have questions or suggestions, do not hesitate to dialogue with Adam about it. And tell him to post a screen-cast of building a basic app with Nephtali.</p>
<p>For now, I&#8217;m going to see if I can get Adam to smash a bottle of champagne over his development box in honor of this release. Congrats, Adam!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.davingranroth.com/2008/01/nephtali/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Can robots.txt prevent a dead page from being removed from a search engine&#8217;s index?</title>
		<link>http://blog.davingranroth.com/2008/01/can-robotstxt-prevent-a-dead-page-from-being-removed-from-a-search-engines-index/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=can-robotstxt-prevent-a-dead-page-from-being-removed-from-a-search-engines-index</link>
		<comments>http://blog.davingranroth.com/2008/01/can-robotstxt-prevent-a-dead-page-from-being-removed-from-a-search-engines-index/#comments</comments>
		<pubDate>Thu, 03 Jan 2008 14:52:48 +0000</pubDate>
		<dc:creator>Davin Granroth</dc:creator>
				<category><![CDATA[Web design and technology]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[SEO]]></category>

		<guid isPermaLink="false">http://blog.davingranroth.com/?p=343</guid>
		<description><![CDATA[
 <a href="http://blog.davingranroth.com/2008/01/can-robotstxt-prevent-a-dead-page-from-being-removed-from-a-search-engines-index/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><strong>Problem: Pages taken offline 4 months ago are still indexed by Google and Yahoo!</strong></p>
<p>In the course of work this week, we discovered that Yahoo! and Google still have record of a section of a website we removed nearly 4 months ago.</p>
<p>Surely the search engine robots had revisited the pages, repeatedly received 404-File Not Found errors, and proceeded to removed those pages from their indexes, right?</p>
<p>Apparently not. Here&#8217;s one explanation as to why.</p>
<p><strong>Context: Using robots.txt in the process of removing old pages and posting new ones</strong></p>
<p>I had also recently glanced at the robots.txt file for the domain in question, and noticed that there was a disallow rule applied to the pages that we had removed.</p>
<p>Four months ago, we released a new web service to replace one provided by these old pages. For a period of time, we kept both online with forwarders in place. During this time we added an entry to robots.txt to prevent spiders from indexing the old pages, and we encouraged indexing of the new pages by providing links to them.</p>
<p>Once we removed the old pages, we didn&#8217;t think to remove the entry from robots.txt. Afterall, the pages weren&#8217;t there, why would it matter?</p>
<p>Well, my revised theory holds that it does matter.</p>
<p><strong>Hypothesis: Excluding the robot with robots.txt stopped it from even checking that the page was there. So, with no confirmation that the page was gone, it didn&#8217;t tell the indexer to update the records.</strong></p>
<p>Here&#8217;s the scenario, from a search engine spider&#8217;s perspective.</p>
<p>(This model probably doesn&#8217;t technically match what&#8217;s going on in reality, but I hope it&#8217;s close enough to get some insight from.)</p>
<p>As a spider, I crawl links to pages, and when I find good pages (HTTP response of 200-OK), I read what textual data I can and send it back to the indexer to update our records.</p>
<p>However, if I try to get to a page, but the server tells me the page isn&#8217;t there, I send that as a note back to the indexer, and proceed to try to read the next page.</p>
<p>After receiving a few of these File Not Found messages over time about the same page, the indexer will remove that record from the index, as a matter of housekeeping.</p>
<p>Our problem may have been that we posted a robots.txt file which prevented the spiders from even trying to access these pages, and so when we had the pages removed, the spiders never had a chance to get the 404 error. So, they never communicated back to the indexer that there was a problem with the pages. So, the indexer never triggered its housekeeping activities and has left the pages referenced in its index.</p>
<p><strong>Moral of the story: Don&#8217;t screw with spiders.</strong></p>
<p>Had we left robots.txt well enough alone, the spiders would have found the bad links and soon enough the indexes would have been updated. Because we short-circuited their processes, we have preserved index reference to pages that have long since died.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.davingranroth.com/2008/01/can-robotstxt-prevent-a-dead-page-from-being-removed-from-a-search-engines-index/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XML file of shooting ranges in Michigan</title>
		<link>http://blog.davingranroth.com/2007/12/xml-file-of-shooting-ranges-in-michigan/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=xml-file-of-shooting-ranges-in-michigan</link>
		<comments>http://blog.davingranroth.com/2007/12/xml-file-of-shooting-ranges-in-michigan/#comments</comments>
		<pubDate>Wed, 19 Dec 2007 00:19:48 +0000</pubDate>
		<dc:creator>Davin Granroth</dc:creator>
				<category><![CDATA[Davin]]></category>
		<category><![CDATA[Web design and technology]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[ranges]]></category>
		<category><![CDATA[shooting]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://blog.davingranroth.com/?p=341</guid>
		<description><![CDATA[As another small step in this process of manipulating a data set to upload to Google Maps, I took the cleaned XHTML I had from a few days ago, and used TextWrangler to do some quick search and replaces on &#8230; <a href="http://blog.davingranroth.com/2007/12/xml-file-of-shooting-ranges-in-michigan/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>As another small step in this process of manipulating a data set to upload to Google Maps, I took the cleaned XHTML I had from a few days ago, and used <a title="TextWrangler is a *free and phenomenal* text editor. It is like BBEdit-lite." href="http://barebones.com/products/textwrangler/">TextWrangler</a> to do some quick search and replaces on the source code in order to produce this XML file.<br />
<span class="mt-enclosure mt-enclosure-file"><a href="http://blog.davingranroth.com/wp-content/uploads/2008/12/ranges-data.xml">ranges-data.xml</a></span></p>
<p>Next, I think, I&#8217;ll load this XML file into PHP using the simplexml features which will make it easy to run the data through a PHP-based GeoCoding processor that I&#8217;m sure I can dig up. The goal is to transcode the addresses of the ranges into latitude/longitude points, which seem to be required pieces of data for the KML file I&#8217;m trying to piece together.</p>
<p>I may at the same time output the whole thing into KML format, since I&#8217;ll be in there with the data nodes anyway.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.davingranroth.com/2007/12/xml-file-of-shooting-ranges-in-michigan/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

