<?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>Sylvan Korvus &#187; geek</title>
	<atom:link href="http://www.korvus.com/blog/topics/geek/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.korvus.com</link>
	<description></description>
	<lastBuildDate>Fri, 25 Nov 2011 01:43:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>DailyZen in GeekTool</title>
		<link>http://www.korvus.com/blog/geek/dailyzen-in-geektool/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=dailyzen-in-geektool</link>
		<comments>http://www.korvus.com/blog/geek/dailyzen-in-geektool/#comments</comments>
		<pubDate>Sat, 06 Jun 2009 22:04:52 +0000</pubDate>
		<dc:creator>Sylvan</dc:creator>
				<category><![CDATA[geek]]></category>
		<category><![CDATA[Mac]]></category>

		<guid isPermaLink="false">http://www.korvus.com/?p=170</guid>
		<description><![CDATA[I have been playing with GeekTool the last few days. It&#8217;s a small app for Mac OS X (preferences pane, actually) that adds text and images directly to the desktop. It&#8217;s highly scriptable and customizable, with people adding anything from the date and time, to log files, to RSS feeds and live satellite photos. One [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-173" title="syldesk-zencropped-sm" src="http://www.korvus.com/kwp/wp-content/uploads/2009/06/syldesk-zencropped-sm.png" alt="syldesk-zencropped-sm" width="303" height="128" />I have been playing with <a href="http://projects.tynsoe.org/en/geektool/">GeekTool</a> the last few days. It&#8217;s a small app for Mac OS X (preferences pane, actually) that adds text and images directly to the desktop. It&#8217;s highly scriptable and customizable, with people adding anything from the date and time, to log files, to RSS feeds and live satellite photos.</p>
<p>One thing I&#8217;ve added to my own desktop, is the Zen poem posted daily on the website <a href="http://www.dailyzen.com/">DailyZen.com</a>. It took a little work to be able to do it, so I thought I&#8217;d post my script. <span id="more-170"></span>This is based  on the script to fetch a quote from Encarta as <a href="http://www.flickr.com/photos/barm/3297965686/#comment72157614210120597">posted on Flickr by barm</a>, so credit goes to him for getting me started.</p>
<p>This can all be pasted into GeekTool itself, or you can create a separate shell script <em>(eg. dailyzen.sh)</em>, which is what I&#8217;ve done, for easy editing. It&#8217;s a short one-liner, but there&#8217;s a lot going on:</p>
<p><code>curl -s http://www.dailyzen.com/ | sed -n &quot;/&lt;\!--Add Quote for correct day--&gt;/,/&lt;\/TD&gt;/p&quot;|sed -e &quot;s/&lt;[^&gt;]*&gt;//g&quot; |strings|fold -sw60</code></p>
<p><em>curl</em> of course is the Unix utility to fetch an URL, and grabs the contents of the front page of <a href="http://www.dailyzen.com/">http://www.dailyzen.com/</a>. <em>sed</em> then extracts the portion between the comment and the closing &lt;/TD&gt; tag, which contains the poem. The second <em>sed</em> command strips all HTML tags. I used <em>strings</em> to reliably get rid of some stray carriage returns, and finally <em>fold</em> wraps the poem to a nice width without breaking words, as GeekTool would do otherwise.</p>
<p>The script is straightforward to add to GeekTool, it&#8217;s simply a Shell command (either pasted in, or calling the dailyzen.sh file). I set the refresh time to 21600; 6 hours is enough to make sure it&#8217;s updated in the morning. I used Book Antiqua Italic 20pt for the text, white with 20% opacity.</p>
<p>And here&#8217;s the end result:</p>
<div id="attachment_168" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.korvus.com/kwp/wp-content/uploads/2009/06/syldesk-geektool.png" rel="lightbox[170]"><img class="size-medium wp-image-168 " title="Sylvan Korvus - GeekTool Desktop" src="http://www.korvus.com/kwp/wp-content/uploads/2009/06/syldesk-geektool-300x187.png" alt="Sylvan Korvus - GeekTool Desktop" width="300" height="187" /></a><p class="wp-caption-text">My GeekTool Desktop, with DailyZen quote</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.korvus.com/blog/geek/dailyzen-in-geektool/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Making the Tab Key work with JEditable Fields</title>
		<link>http://www.korvus.com/blog/geek/making-the-tab-key-work-with-jeditable-fields/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=making-the-tab-key-work-with-jeditable-fields</link>
		<comments>http://www.korvus.com/blog/geek/making-the-tab-key-work-with-jeditable-fields/#comments</comments>
		<pubDate>Sun, 24 May 2009 16:35:42 +0000</pubDate>
		<dc:creator>Sylvan</dc:creator>
				<category><![CDATA[geek]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://www.korvus.com/blog/news/making-the-tab-key-work-with-jeditable-fields/</guid>
		<description><![CDATA[Recently I was asked to solve a problem someone was having with JEditable. There were several fields on the page that existed as double-clickable text, which could then edited. The problem was, the tab key would not move between the fields. The first step of course was to build a simple test environment: a page [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I was asked to solve a problem someone was having with <a href="http://www.appelsiini.net/projects/jeditable">JEditable</a>. There were several fields on the page that existed as double-clickable text, which could then edited. The problem was, the tab key would not move between the fields.</p>
<p>The first step of course was to build a simple test environment: a page with several divs with ids such as “box1” “box2”  etc., <a href="http://jquery.com/">JQuery</a> and JEditable called, and JEditable configured to talk to a simple PHP script that simply echoes its input:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span> ?php <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$_REQUEST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;value&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p><span id="more-157"></span><br />
That was all straightforward enough, and replicated the basics of the client’s environment. The real trouble was the tab key functionality. Picking up a tab keypress is easy enough; with basic Javascript, or in JQuery:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.editbox'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'keydown'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>evt<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>evt.<span style="color: #660066;">keyCode</span><span style="color: #339933;">==</span><span style="color: #CC0000;">9</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #006600; font-style: italic;">//code</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>There were two primary problems:</p>
<ol>
<li>Moving the focus out of the existing field being edited.</li>
<li>Activating the next editable field.</li>
</ol>
<p>#1 took a fair amount of trial and error for me. JEditable creates a new input field inside the container element, and none of the JQuery selectors I was trying to use: children, sibling, etc. were working for me. Finally, I managed to get it this way:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;input&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #000066;">blur</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>I’ll be the first to admit that’s a little bit brute-force. If anyone has a more elegant way of selecting the created input in a JEditable element, please let me know!</p>
<p>Problem #2 evaded solution. I looked inside the JEditable code, and it is activated by an event; there was no function I could call directly, that I could see anyway, that would activate the next element. It took putting the problem aside for a few hours before it came to me.</p>
<p>JQuery nicely lets you create mouse events and other events. So the solution then became fairly obvious:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>nextBox<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">dblclick</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Where <em>nextBox</em> is the next box in line. <em>Note: JEditable normally takes a single click, so the “click()” function would be sufficient here. In this case, it’s configured for double-clicks.</em></p>
<p>It worked perfectly. Tab in one field would blur the current field, then activate the next field. Here’s the basic code, all together:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.editbox'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'keydown'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>evt<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>evt.<span style="color: #660066;">keyCode</span><span style="color: #339933;">==</span><span style="color: #CC0000;">9</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;input&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #000066;">blur</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #003366; font-weight: bold;">var</span> nextBox<span style="color: #339933;">=</span><span style="color: #3366CC;">''</span><span style="color: #339933;">;</span>
             <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;div.editbox&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">index</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;div.editbox&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">length</span><span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    nextBox<span style="color: #339933;">=</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;div.editbox:first&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>         <span style="color: #006600; font-style: italic;">//last box, go to first</span>
                <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
                    nextBox<span style="color: #339933;">=</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">next</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;div.editbox&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>    <span style="color: #006600; font-style: italic;">//Next box in line</span>
                <span style="color: #009900;">&#125;</span>
            $<span style="color: #009900;">&#40;</span>nextBox<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">dblclick</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  <span style="color: #006600; font-style: italic;">//Go to assigned next box</span>
            <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>           <span style="color: #006600; font-style: italic;">//Suppress normal tab</span>
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>I’ve omitted some very straightforward code to detect if shift is held down, and go up and wrap around to the bottom. But this should be sufficient to get anyone started with adding tab key functionality to their JEditable based forms.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.korvus.com/blog/geek/making-the-tab-key-work-with-jeditable-fields/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

