<?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>Jasongraphix &#187; Code</title>
	<atom:link href="http://jasongraphix.com/journal/category/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://jasongraphix.com</link>
	<description>A journal of art, thoughts, and projects by Jason Beaird.</description>
	<lastBuildDate>Mon, 13 Feb 2012 15:07:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Process of Sublimination</title>
		<link>http://jasongraphix.com/journal/process-of-sublimination/</link>
		<comments>http://jasongraphix.com/journal/process-of-sublimination/#comments</comments>
		<pubDate>Sun, 12 Feb 2012 03:05:54 +0000</pubDate>
		<dc:creator>Jason Beaird</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[editor]]></category>
		<category><![CDATA[macvim]]></category>
		<category><![CDATA[sublimetext]]></category>
		<category><![CDATA[text]]></category>
		<category><![CDATA[textmate]]></category>

		<guid isPermaLink="false">http://jasongraphix.com/?p=1595</guid>
		<description><![CDATA[This post turned out a bit longer than I intended. To summarize, I've tried several text editors out over the last few months and recently fell in geeky love with <a href="http://www.sublimetext.com/" rel="external">Sublime Text 2</a>. It's a truly amazing new text editor that's available for OSX, Linux &#38; Windows. Now, on with the story.
In the Beginning... I believe it was the Summer of 2005 when I tried out <a href="http://macromates.com/" rel="external">TextMate</a> for the first time. After a few minutes of playing with it's project drawer, tabs, regex find, snippets and column select features I was <a href="http://bukk.it/yay.gif" rel="external">very happy</a>. No more bloated applications from a certain software suite or sub-par minimalist editors. TextMate was a simple, innovative, powerful tool that helped me write a lot of code with very few distractions...]]></description>
			<content:encoded><![CDATA[<p>This post turned out a bit longer than I intended. To summarize, I&#8217;ve tried several text editors out over the last few months and recently fell in geeky love with <a href="http://www.sublimetext.com/" rel="external">Sublime Text 2</a>. It&#8217;s a truly amazing new text editor that&#8217;s available for OSX, Linux &amp; Windows. Now, on with the story.</p>
<h3>In the Beginning</h3>
<div class="imgleftxsm alignc"><img src="/static/uploads/Sublimination-TextMate1.png" alt="TextMate Icon" />TextMate</div>
<p>I believe it was the Summer of 2005 when I tried out <a href="http://macromates.com/" rel="external">TextMate</a> for the first time. After a few minutes of playing with it&#8217;s project drawer, tabs, regex find, snippets and column select features I was <a href="http://bukk.it/yay.gif" rel="external">very happy</a>. No more bloated applications from a certain software suite or sub-par minimalist editors. TextMate was a simple, innovative, powerful tool that helped me write a lot of code with very few distractions. I kept TextMate by my side for over 6 years and through 3 different jobs &#8211; yes, with 3 separate seat licenses.</p>
<p>Over that time though, TextMate started to grow stale. I never really used all of it&#8217;s advanced features but new features simply stopped flowing. In 2008, rumors started circulating about an eminent v2.0 release with loads of new features, bugfixes and stability improvements. I was pretty excited. Months passed. Then a year. Then another. Before I knew it, the end of 2011 was approaching and I decided it was time to try something new.</p>
<h3>Enter MacVim</h3>
<div class="imgrightxsm alignc"><img src="/static/uploads/Sublimination-MacVim.png" alt="MacVim Icon" />MacVim</div>
<p>Every once in a while I have to make changes to remote files over SSH. I consider myself fairly command line competent but trying to edit anything with <a href="http://en.wikipedia.org/wiki/Vim_%28text_editor%29" rel="external">vim</a> on a server usually means I first have to open a <a href="http://www.tuxfiles.org/linuxhelp/vimcheat.html" rel="external">cheat sheet</a> of basic commands. I&#8217;ve heard a few people say that switching to <a href="http://code.google.com/p/macvim/" rel="external">MacVim</a>, the GUI OSX version of the ubiquitous Unix text editor, greatly improved their efficiency. Switching seemed like an easy way to kill two nerdy birds with one stone, so in September, I dove in.</p>
<p>If you&#8217;ve ever met a hardcore Vim user, they&#8217;ll tell you that the only way to really get fast is to ditch your mouse. It sounds crazy, but the shortcuts in Vim allow you to jump around a line, page or even a project tree like a ninja. Using your mouse, they&#8217;ll tell you, wastes time and shows weakness. Ok, so they won&#8217;t tell you it shows weakness, but that&#8217;s what they <em>really</em> think. I gave MacVim about a week. I spent the majority of that week staring at a printed copy of commands and trying to avoid touching my mouse. I wanted to embrace Vim but by Friday I was back to happily (and much more efficiently) clicking around TextMate again. MacVim is a great editor, it just didn&#8217;t work out so well for me. On the bright side, I&#8217;m a lot more comfortable editing files on a remote server.</p>
<h3>TextMate Two Point Oh No!</h3>
<div class="imgleftxsm alignc"><img src="/static/uploads/Sublimination-TextMate2.png" alt="TextMate2 Icon" />TextMate2</div>
<p>A month or two after my failed attempt to switch to MacVim, something unexpected happened. TextMate finally released an alpha of <a href="http://blog.macromates.com/2011/textmate-2-0-alpha/" rel="external">version 2</a>. I was ecstatic about features like split view and multiple carets so I installed it immediately. The application chrome looked a little fresher and David Lanham&#8217;s new <a href="http://dribbble.com/shots/351365-Textmate-2" rel="external">flower icon</a> was a nice touch, but overall the update was pretty ho-hum. I would be fine with ho-hum, but there were some major annoying issues &#8211; like buggy selection highlighting on large blocks of text and the lack of a &#8220;Replace &amp; Find&#8221; button &#8211; that really prevented me from fully adopting it.</p>
<h3>Sublime Text &#8211; Two Point Oh Yea!</h3>
<div class="imgrightxsm alignc"><img src="/static/uploads/Sublimination-SublimeText2.png" alt="SublimeText2 Icon" />SublimeText2</div>
<p>Having switched from TextMate to MacVim back to TextMate to TextMate 2 and back to TextMate again, I wasn&#8217;t too keen on wasting my time with another text editor. Stale as it may have been, TextMate 1.5 did everything I needed it to, or so I thought. After seeing a few <a href="https://twitter.com/#!/justinsane98/status/164071354604339200" rel="external">exuberant</a> <a href="https://twitter.com/#!/justinsane98/status/164073139083554816" rel="external">tweets</a> from my friend Justin though, I decided to check it out. The design of the <a href="http://www.sublimetext.com" rel="external">Sublime Text homepage</a> didn&#8217;t give me much confidence but after reading through some of the features of <a href="http://www.sublimetext.com/2" rel="external">Sublime Text 2</a>, I downloaded it and started working on some front-end code.</p>
<p>It only took a few minutes of playing with the mini map sidebar, speedy search tools &amp; multi-select features and I was sold. Sublime Text 2 has all the features I love most about TextMate 1.5 and a better implementation of the TextMate 2.0 features I was most looking forward to. At $59, a license is about the same price as TextMate&#8217;s. Unlike TextMate though, you can try Sublime Text out indefinitely. The fact that it&#8217;s available for Mac, Linux and Windows means I&#8217;ll never have to find an alternative if I need to work on a different OS and with an active plugin community behind it, it&#8217;ll always be getting better. Maybe I&#8217;m a bit too excited but I&#8217;m glad to find another text editor that I immediately feel like sticking with&#8230;maybe even for the next 6 years.</p>
<p>If you decide to try it out, be sure to read the <a href="http://net.tutsplus.com/tutorials/tools-and-tips/sublime-text-2-tips-and-tricks/" rel="external">Sublime Text 2 Tips and Tricks</a> post on Nettuts+. Another helpful (&amp; equally hilarious) read is @filipminev&#8217;s <a href="http://1p1e1.tumblr.com/post/14262857223/9-reasons-you-must-install-sublime-text-2-code-like-a" rel="external">9 reasons you must install Sublime Text 2</a> post.</p>
]]></content:encoded>
			<wfw:commentRss>http://jasongraphix.com/journal/process-of-sublimination/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>View Multiple Link BGs</title>
		<link>http://jasongraphix.com/journal/view-multiple-link-bgs/</link>
		<comments>http://jasongraphix.com/journal/view-multiple-link-bgs/#comments</comments>
		<pubDate>Thu, 11 Feb 2010 15:14:51 +0000</pubDate>
		<dc:creator>Jason Beaird</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Background]]></category>
		<category><![CDATA[background image]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[firefox extension]]></category>
		<category><![CDATA[firefox extensions]]></category>
		<category><![CDATA[multiple backgrounds]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://jasongraphix.com/?p=873</guid>
		<description><![CDATA[Have you ever right-clicked on a website graphic in Firefox expecting to find that handy &#8220;View Background Image&#8221; context menu item only to realize it wasn&#8217;t there because the element you right-clicked on was a link? No? Well it happens to me all the time. A little over a year ago I made a little [...]]]></description>
			<content:encoded><![CDATA[<p><img alt="View Link Background Image" src="http://static.jasongraphix.com/uploads/viewlinkbgimag.png" width="293" height="269" class="floatright border" />Have you ever right-clicked on a website graphic in Firefox expecting to find that handy &#8220;View Background Image&#8221; context menu item only to realize it wasn&#8217;t there because the element you right-clicked on was a link? No? Well it happens to me all the time. A little over a year ago I made a <a href="http://www.jasongraphix.com/downloads/linkbackimage/" rel="external">little Firefox extension</a> to add that functionality for links. </p>
<p>Ever since Firefox 3.6 came out though, my little extension has been broken. I had no idea why until I dug into the JavaScript and discovered that Firefox was returning the CSS background image URL as <code>url("imageurl")</code> instead of <code>url(imageurl)</code>. Stripping the double quotes was an easy fix but I also knew that FF 3.6 supported <a href="http://snook.ca/archives/html_and_css/multiple-bg-css-gradients" rel="external">multiple backgrounds</a>. Out of curiosity I set up a little html link styled with 2 background images and to my surprise <code>getPropertyValue("background-image")</code> returned <code>url("imageurl1"), url("imageurl2")</code>. Sweet! A few more lines of JavaScript and not only did the extension work again, but <em>it works on links with multiple background images</em>!</p>
<p><a href="http://www.jasongraphix.com/downloads/linkbackimage/" rel="external">Grab v1.8 of View Link Background Image</a></p>
<h4>Now for the sad part&#8230;</h4>
<p>As I was experimenting with multiple background image support in Firefox 3.6, I discovered that the &#8220;View Background Image&#8221; context menu item is now missing when you right-click on elements that have multiple backgrounds. While the extension update adds the ability to see all the backgrounds applied to a link, Firefox itself lacks the ability to do the same for other elements. I&#8217;m sure I can take care of that with another extension update. For now though, I&#8217;m just happy to say it works again.</p>
]]></content:encoded>
			<wfw:commentRss>http://jasongraphix.com/journal/view-multiple-link-bgs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mobile Directory</title>
		<link>http://jasongraphix.com/journal/mobile-directory/</link>
		<comments>http://jasongraphix.com/journal/mobile-directory/#comments</comments>
		<pubDate>Fri, 03 Jul 2009 17:07:25 +0000</pubDate>
		<dc:creator>Jason Beaird</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[directiry]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://jasongraphix.com/?p=508</guid>
		<description><![CDATA[Here at Cyberwoven, everybody has a little sheet of paper on their desk that lists all of the office phone extensions. That little sheet of paper is useful, but very limited in the amount of information it can convey. Many of us in the office have iPhones, so I thought it might be fun to [...]]]></description>
			<content:encoded><![CDATA[<p><script type="text/javascript">
// <![CDATA[ 
document.domain="jasongraphix.com"; 
// ]]&gt;</script><object type="text/html" width="350" height="480" data="http://www.jasongraphix.com/sandbox/directory/" style="float:right; border:5px solid #1f1e36; margin:0 -100px 10px 10px;"></object>Here at Cyberwoven, everybody has a little sheet of paper on their desk that lists all of the office phone extensions. That little sheet of paper is useful, but very limited in the amount of information it can convey. Many of us in the office have iPhones, so I thought it might be fun to create a simple mobile directory page. </p>
<p>Over the course of a lunch break I created a webpage with a simple list that showed exactly what the extension sheet had on it, making each <code>&lt;li&gt;</code> expand on click to show more contact information: cell number, email, twitter, website, instant messenger, etc. This webpage was similar to any other wepage really except that it was a little narrower and contained 2 extra lines of meta data in the header:</p>
<p><code>&lt;meta name="apple-mobile-web-app-capable" content="yes" /&gt;</code><br />
<br />
<code>&lt;meta name="viewport" content="width=device-width, height=device-height, user-scalable=no"/&gt;</code></p>
<p>I learned about the first meta tag from <a href="http://daringfireball.net/linked/2008/10/03/fullscreen-iphone-web-apps" rel="external">a short post</a> on Daring Fireball a while back. It&#8217;s just a simple tag that loads pages added to your home screen as a standalone app; without the standard Safari chrome. The viewport meta tag just defines some rules for the display of the page. By setting the width and height to device-width and device-height, I&#8217;m just forcing the page to fit to the viewport whether it&#8217;s in portrait or landscape mode. Setting user-scalable to &#8220;no&#8221; just prevents the user from zooming in or out, which is acceptable since I&#8217;m designing the content to fit the screen. You can learn more about these meta tags (and a lot of other great iPhone mobile app tips) from the <a href="http://developer.apple.com/safari/library/documentation/AppleApplications/Reference/SafariHTMLRef/Introduction.html">HTML section</a> of Apple&#8217;s Safari Reference Library</a>.</p>
<p>As I mentioned above, those two meta tags are really the only iPhone specific bits in this simple web application. The rest is just plain ole&#8217; HTML, CSS and jQuery with a smidge of PHP just to handle some variables and authentication. Rather than explaining all that I&#8217;ll just let you grab the demo. Feel free to use this as is or modify it to your heart&#8217;s content. I used an HTML file to store the directory data, but this example could easily be modified to pull from an XML file or from a database.</p>
<p><strong><a href="/sandbox/directory/mobiledirectory.zip">Download Mobile Directory Demo</a> &#8211; Zip (28KB)</strong><br />
<a href="/sandbox/directory/" rel="external">View the Demo</a> (password is &#8220;stapler&#8221;)</p>
]]></content:encoded>
			<wfw:commentRss>http://jasongraphix.com/journal/mobile-directory/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Link Background Image</title>
		<link>http://jasongraphix.com/journal/link-background-image/</link>
		<comments>http://jasongraphix.com/journal/link-background-image/#comments</comments>
		<pubDate>Wed, 05 Nov 2008 19:32:32 +0000</pubDate>
		<dc:creator>Jason Beaird</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[background image]]></category>
		<category><![CDATA[background image on link]]></category>
		<category><![CDATA[firefox extension]]></category>
		<category><![CDATA[linkbackimage]]></category>
		<category><![CDATA[view background image]]></category>

		<guid isPermaLink="false">http://beta.jasongraphix.com/journal/link-background-image/</guid>
		<description><![CDATA[Update 2/11/2010: Added support for Multiple Background Images Over a year ago I posted about the lack of a View Background Image option in Firefox when right-clicking on links. As a web designer, I use that context menu item on a regular basis, so for it to not be there for links seemed like a [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Update 2/11/2010:</strong> <a href="http://jasongraphix.com/journal/view-multiple-link-bgs/">Added support for Multiple Background Images</a></p>
<p>Over a year ago I <a href="/archive/2007/07/view_background">posted</a> about the lack of a <strong>View Background Image</strong> option in Firefox when right-clicking on links.  As a web designer, I use that context menu item on a regular basis, so for it to not be there for links seemed like a glaring omission.</p>
<p>To my surprise, a <a target="_blank" title="James Booker" href="http://www.jamesbooker.co.uk/">very kind volunteer</a> came to the rescue with a head-start on an extension and an invitation to improve on it.  The problem was that his simple extension did exactly what I wanted it to.  When you right-clicked on a link, there was a &#8220;View Background Image&#8221; item that, when you clicked on it, linked to the CSS background-image of that element.</p>
<p>I didn&#8217;t feel the need to improve on James&#8217; extension until it stopped working in Firefox3. Yes, there are many other ways of discovering the background-image of an element in Firefox (specifically through <a title="You need this extension." target="_blank" href="https://addons.mozilla.org/en-US/firefox/addon/1843">Firebug</a> and the <a title="You need this extension too..." target="_blank" href="https://addons.mozilla.org/en-US/firefox/addon/60">Web Developer Toolbar</a>) but I wanted my context menu item back, so I dove into the extensions folder and added the following functionality:</p>
<ul>
<li>It checks for a background image on the link you right-clicked on.</li>
<li>If it&#8230;
<ul>
<li>Finds an image: You get a &#8220;View Link Background Image&#8221; context menu item.</li>
<li>Doesn&#8217;t find an image, but finds one on its immediate parent: You get a &#8220;View Parent Background Image&#8221; context menu item.</li>
<li>Finds no image on the link or its immediate parent: You get a disabled &#8220;View Link Background Image&#8221; context menu item.</li>
</ul>
</li>
</ul>
<p>While it doesn&#8217;t seem like a mission-critical extension, I&#8217;ve started relying on it for my day-to-day work and thought you might find it useful as well.</p>
<p>So without further ado, you can <strong><a href="/downloads/linkbackimage/">download the extension here</a></strong>.</p>
]]></content:encoded>
			<wfw:commentRss>http://jasongraphix.com/journal/link-background-image/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Date-Ahh</title>
		<link>http://jasongraphix.com/journal/date-ahh/</link>
		<comments>http://jasongraphix.com/journal/date-ahh/#comments</comments>
		<pubDate>Sat, 16 Aug 2008 02:30:35 +0000</pubDate>
		<dc:creator>Jason Beaird</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[color]]></category>
		<category><![CDATA[data visualization]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[play]]></category>
		<category><![CDATA[random]]></category>

		<guid isPermaLink="false">http://beta.jasongraphix.com/journal/date-ahh/</guid>
		<description><![CDATA[This is really random, but any date written out in mmddyy format could be used as a unique hexadecimal RGB color code. Today&#8217;s date for instance could be represented as #081508. Because of the linear and cyclical nature of time, I thought it would be interesting to see what a series of dates would look [...]]]></description>
			<content:encoded><![CDATA[<p>This is really random, but any date written out in mmddyy format could be used as a unique hexadecimal RGB color code.  Today&#8217;s date for instance could be represented as <span style="color:#081508;">#081508</span>.  Because of the linear and cyclical nature of time, I thought it would be interesting to see what a series of dates would look like represented by blocks colored with the hex code for each day.</p>
<p>This was surprisingly easy to do in php:</p>
<pre lang="php">
$first_date = "2008-01-01";
$end_date = "2009-12-31";
$alpha = strtotime($first_date);
$omega = strtotime($end_date);
while($alpha &lt;= $omega){
$ufirst = strtotime("+1 day", $alpha);
$formatted = date("m/d/Y", $alpha);
$color = date("mdy", $alpha);
echo '&lt;div class="day" style="background-color:#'.$color.'" title="'.$formatted.'"&lt;&amp;nbsp;&lt;/div&gt;';
}
</pre>
<p>I made a little <a href="/sandbox/colorfuldates/">demo page</a> where you can see what any year (between 1970 and 2037 &#8211; the boundaries of php strtotime) looks like. I also made another page the just shows the <a href="/sandbox/colorfuldates/10.php">last 10 years</a>.</p>
<p><img src="http://static.jasongraphix.com/uploads/dateahh.png" class="border" width="420" height="830" alt="Dateahh!" /></p>
<p>I chose to show 10 years so that I&#8217;d get a little bit of the 90s in there, which obviously produce a much brighter blue color.  If I were able to render 100 years this way, it would be a very subtle gradient from the dark greens all the way to that bright blue you see at the top.  Yea, it&#8217;s mostly useless, but I thought it was an interesting way to visualize data.</p>
]]></content:encoded>
			<wfw:commentRss>http://jasongraphix.com/journal/date-ahh/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Textbox Hints</title>
		<link>http://jasongraphix.com/journal/textbox-hints/</link>
		<comments>http://jasongraphix.com/journal/textbox-hints/#comments</comments>
		<pubDate>Thu, 31 Jan 2008 20:14:58 +0000</pubDate>
		<dc:creator>Jason Beaird</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[password box]]></category>
		<category><![CDATA[textbox]]></category>
		<category><![CDATA[textbox hints]]></category>
		<category><![CDATA[textbox value]]></category>
		<category><![CDATA[type="password"]]></category>

		<guid isPermaLink="false">http://beta.jasongraphix.com/journal/textbox-hints/</guid>
		<description><![CDATA[Update 6/4/09: I just wrote a new blog post about using the title attribute as the hint text. The method described below is still practical for some forms, but using the title text is a more practical and widely-applicable method of providing textbox hints. Check out the new post. There are typically only two types [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Update 6/4/09:</strong> I just wrote a new blog post about using the title attribute as the hint text. The method described below is still practical for some forms, but using the title text is a more practical and widely-applicable method of providing textbox hints. Check out <a href="http://jasongraphix.com/journal/title-based-textbox-hints/">the new post.</a></p>
<p>There are typically only two types of forms that tend to get squeezed into tight quarters in page layouts: login, and search. For this reason, web designers are often tempted to save space by hiding the labels on these forms and assuming that a user will intuitively know what to type into each textbox.  With a simple search form, this is logical because you have a textbox next to a button that says &#8220;Search&#8221;, &#8220;Go&#8221;, or perhaps &#8220;I&#8217;m feeling Lucky&#8221;. Login forms are a little trickier.  For most of us, seeing two text boxes and a &#8220;login&#8221; button is all we need to play McGyver, but the average user often needs those &#8220;Username:&#8221; and &#8220;Password:&#8221; labels to know what to enter.</p>
<p>A common solution to this problem is to use javascript to show and hide &#8220;hints&#8221;. This is one of those tasks that has a dozen different (perfectly acceptable) methods, and everyone tends to stand behind their choice as boldly as they do their favorite presidential candidate. I&#8217;ve tried a few of these methods, but because I tend to do it a bit differently, I thought I&#8217;d share.</p>
<p>Most of the solutions out there either insert a value into the textbox or they move around a label.  Inserting a value into a textbox is the most obvious/common solution and has its pros and cons, but the deal breaker is the fact that a value inserted into a password box will still display as dots/asterisks. As far as I know, you can&#8217;t dynamically change the type of an input from <code>password</code> to <code>text</code>, so that solution is out.  Moving around a label tag is something I first read about on the ALA article: <a href="http://www.alistapart.com/articles/makingcompactformsmoreaccessible">Making Compact Forms More Accessible</a>. It&#8217;s an ingenious idea really, but:</p>
<ol>
<li>I usually only need to make compact login forms, so it doesn&#8217;t have to be portable across other types of forms.</li>
<li>The area for the form typically won&#8217;t accommodate leaving the labels in place for users without javascript.</li>
<li>Occasionally I like to use a different font for the login box hints to make it jive with a home page design.</li>
</ol>
<p>With those things in mind, I decided to try using a background image for on the textbox instead of the label.  Also, I tend to incorporate jQuery into most projects lately, so it made sense for me to write it in that &#8211; although it could just as easily be rewritten as straight Javascript if necessary.</p>
<p><strong><a href="/sandbox/textboxhints/">Check out the working demo.</a></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://jasongraphix.com/journal/textbox-hints/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>View Background Image</title>
		<link>http://jasongraphix.com/journal/view-background-image/</link>
		<comments>http://jasongraphix.com/journal/view-background-image/#comments</comments>
		<pubDate>Mon, 30 Jul 2007 18:32:12 +0000</pubDate>
		<dc:creator>Jason Beaird</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[background image]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[firefox extensions]]></category>
		<category><![CDATA[link background]]></category>
		<category><![CDATA[view background image]]></category>

		<guid isPermaLink="false">http://beta.jasongraphix.com/journal/view-background-image/</guid>
		<description><![CDATA[Update 11/5/2008: There&#8217;s now an extension for this! Of all the context menus in Firefox, my second most-clicked item (behind View Page Source) is View Background Image. This stock functionality is one of the many reason I still prefer to use Firefox over Safari, even though Safari&#8217;s rendering is notably faster. The problem I have [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Update 11/5/2008:</strong> <a href="http://jasongraphix.com/journal/link-background-image/">There&#8217;s now an extension for this!</a></p>
<p><img alt="View Background Image of a Link" src="http://static.jasongraphix.com/uploads/view-background-image.jpg" width="216" height="375" align="right" class="border" /></p>
<p>Of all the context menus in Firefox, my second most-clicked item (behind <em>View Page Source</em>) is <em>View Background Image</em>. This stock functionality is one of the many reason I still prefer to use Firefox over Safari, even though Safari&#8217;s rendering is notably faster. The problem I have with <em>View Background Image</em> though is that the image I want to view is often associated with a link element. When you right-click on a link though, this menu item is sadly missing.</p>
<p>The only alternative I&#8217;ve found, short of digging around in the page source and CSS, involves the <a href="https://addons.mozilla.org/en-US/firefox/addon/60">Web Developer Toolbar</a>.  If you have this extension installed, you can click on <em>Images &raquo; View Image Information</em> to see a list of all background images that are associated with the page you are viewing. That usually does the trick, but it would be much more ideal if there were an extension that just makes <em>View Background Image</em> work on links.  After all of my searching and discussions with friends and coworkers I&#8217;ve concluded that there is no extension out there that can make this happen.  I&#8217;ve never made a Firefox extension before, but I have toyed around with Javascript/XUL and could probably figure it out if I get desperate enough.  Before I attempt this though, I figured I&#8217;d ask, &#8220;What do you do when you want to see the background image of a link?&#8221;</p>
]]></content:encoded>
			<wfw:commentRss>http://jasongraphix.com/journal/view-background-image/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Sorting Time Strings</title>
		<link>http://jasongraphix.com/journal/sorting-time-strings/</link>
		<comments>http://jasongraphix.com/journal/sorting-time-strings/#comments</comments>
		<pubDate>Mon, 11 Dec 2006 21:40:26 +0000</pubDate>
		<dc:creator>Jason Beaird</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[am]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[order by]]></category>
		<category><![CDATA[pm]]></category>
		<category><![CDATA[sorting time]]></category>
		<category><![CDATA[sorting time strings]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://beta.jasongraphix.com/journal/sorting-time-strings/</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p>OK, so I&#8217;m working on a MySQL database of tour reservations that has time values stored as strings in an AM/PM time format.  The hour portion of the value does not contain a leading 0, so &#8220;6:00 AM&#8221;, &#8220;11:35 AM&#8221;, &#8220;4:45 PM&#8221; are all possible values. I&#8217;ve written a query to pull a sorted list of the unique tour times from the database that looks something like this:</p>
<pre>
SELECT DISTINCT reservation_time,
FROM reservations
WHERE DATEDIFF(reservation_date, '2006-12-11')=0
AND is_canceled=0
ORDER BY SUBSTRING(reservation_time, -2),
CAST(SUBSTRING_INDEX(reservation_time,':',1 ) AS UNSIGNED),
CAST(SUBSTRING(reservation_time,-5, 2) AS UNSIGNED);
</pre>
<p>My problem is what follows the <code>ORDER BY</code> statement.  I&#8217;m sorting the list of time values 3 times: first by the last 2 digits of the time (AM or PM), then by the hour, then by the minutes.  I can&#8217;t use SUBSTRING( reservation_time, 2 ) to get the hour value because some have one digit and some have 2.  This also means I have to get the minutes by counting from the right side instead of from the left. My question, to all my SQL fluent friends out there is whether or not this is the best way to get this data. Ordering the data 3 times seems a bit inefficient, but then I&#8217;m no SQL wizard.</p>
]]></content:encoded>
			<wfw:commentRss>http://jasongraphix.com/journal/sorting-time-strings/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>ActiveX Update Woes</title>
		<link>http://jasongraphix.com/journal/activex-update-woes/</link>
		<comments>http://jasongraphix.com/journal/activex-update-woes/#comments</comments>
		<pubDate>Wed, 05 Apr 2006 21:42:11 +0000</pubDate>
		<dc:creator>Jason Beaird</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[activeX]]></category>
		<category><![CDATA[activex update]]></category>
		<category><![CDATA[eolas]]></category>
		<category><![CDATA[ie6]]></category>
		<category><![CDATA[infringement]]></category>
		<category><![CDATA[internet explorer]]></category>
		<category><![CDATA[microsoft]]></category>

		<guid isPermaLink="false">http://beta.jasongraphix.com/journal/activex-update-woes/</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p>Are all of your client sites April 11th Compliant?  I&#8217;ve spent much of my day so far going through client websites (many of which <a href="http://www.ericksonmarketing.com" title="Erickson Marketing Studio, LLC">we</a> didn&#8217;t even build) looking for instances of applet, object and embed tags (mostly flash) to make sure they won&#8217;t break on April 11th.  On that day, Microsoft will be releasing a security update for IE containing a particularly annoying <a href="http://support.microsoft.com/kb/912945">ActiveX update</a>.  Any ActiveX control that a user interacts with will now need to be activated.  For instance, if you have a flash movie or multimedia object and a user clicks on it, they will get a nice message like this:</p>
<div align="center"><img src="http://static.jasongraphix.com/uploads/activexactivation.gif" width="350" height="213" alt="ActiveX Activation" /></div>
</p>
<p>One way of avoiding this annoying activation routine is to call your objects via an external script file.  Fortunately we&#8217;ve been doing this at work with our flash files for quite a while using Geoff Stearns&#8217; <a href="http://blog.deconcept.com/flashobject/">FlashObject</a>.  By using FlashObject, swf files will not require activation and users will be able to interact with the flash just as if they never got that silly ActiveX update.</p>
<p>So why is all this happening and who should we blame?  You guessed it. Micro$oft:</p>
<blockquote><p>A jury in 2003 found that Microsoft&#8217;s Internet Explorer browser infringed on a patent owned by Eolas and the University of California. The software vendor was ordered to pay $521 million in damages. Microsoft has vowed to fight the ruling, but so far has been unsuccessful in getting the patent invalidated. &#8211; <a href="http://www.toptechnews.com/story.xhtml?story_id=13200003C9IO">Click here to read the full story at Top Tech News</a></p></blockquote>
<p>Thank you Microsoft! To read more about making your sites April 11th compliant, visit the msdn page: <a href="http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/overview/activating_activex.asp">Activating ActiveX Controls</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://jasongraphix.com/journal/activex-update-woes/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>nearestSentence Function</title>
		<link>http://jasongraphix.com/journal/nearestsentence-function/</link>
		<comments>http://jasongraphix.com/journal/nearestsentence-function/#comments</comments>
		<pubDate>Mon, 20 Mar 2006 17:33:15 +0000</pubDate>
		<dc:creator>Jason Beaird</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[crop string]]></category>
		<category><![CDATA[last sentence]]></category>
		<category><![CDATA[nearest sentence]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://beta.jasongraphix.com/journal/nearestsentence-function/</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p>I wanted to be able to take a string of text, a blog entry in this case, and crop it down to the nearest sentence to a given maximum length value.  I am sure this function exists in php, but I couldn&#8217;t find it so I wrote my own and figured some of you might find this handy:</p>
<pre>
function nearestSentence($s) {
//Max length of string before
//looking for last sentence.
$maxL = 350;

//Strip html tags and convert
//html entities (like &amp;)
//to single characters before counting.
$toCount = strip_tags(html_entity_decode($s));

//Crop the string down to the max length.
if (strlen($toCount) <= $maxL) {
$s2 = $s;
} else {
$s2 = substr($toCount, 0, $maxL);
}
//Look for position of the last ., ?, or !
$lastPunct = max(strrpos($s2, '.'), strrpos($s2, '?'), strrpos($s2, '!'));
//Crop the string again down to the nearest punctuation.
$s3 = substr($s2, 0, $lastPunct+1);
//Return string with html entites re-inserted.
return htmlentities($s3);
}
</pre>
<p>So, if you had some text like:</p>
<blockquote><div>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat? Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis! At vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla?</div>
</blockquote>
<p>Then, you would get:</p>
<blockquote><div>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat?</div>
</blockquote>
<p>If you have some flexibility for the length of your blurb, I think this looks a lot better than just cropping your string down to a particular length and adding... but maybe that's just me.</p>
]]></content:encoded>
			<wfw:commentRss>http://jasongraphix.com/journal/nearestsentence-function/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

