<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>MLNTN</title>
	
	<link>http://mlntn.com</link>
	<description>Maniacal musings of a pixel perfectionist</description>
	<lastBuildDate>Wed, 19 Jan 2011 19:11:43 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/MellentineDesign" /><feedburner:info uri="mellentinedesign" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId>MellentineDesign</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><item>
		<title>HUMOR: jQuery LOLCAT plugin</title>
		<link>http://feedproxy.google.com/~r/MellentineDesign/~3/7BIHJnxjaiI/</link>
		<comments>http://mlntn.com/2011/01/19/humor-jquery-lolcat-plugin/#comments</comments>
		<pubDate>Wed, 19 Jan 2011 19:10:25 +0000</pubDate>
		<dc:creator>Jared</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[jquery plugins]]></category>

		<guid isPermaLink="false">http://mlntn.com/?p=172</guid>
		<description><![CDATA[I had an idea for a site easter egg recently where a user would enter some key combination and all of the text would be translated into LOLCAT.  As I usually do, I started off with a Google search for &#8220;jquery lolcat&#8221;. Nothing useful.
I search for &#8220;lolcat translator&#8221; and found better results, including a [...]]]></description>
			<content:encoded><![CDATA[<p>I had an idea for a site easter egg recently where a user would enter some key combination and all of the text would be translated into LOLCAT.  As I usually do, I started off with a Google search for &#8220;jquery lolcat&#8221;. Nothing useful.<span id="more-172"></span></p>
<p>I search for &#8220;lolcat translator&#8221; and found better results, including a <a href="http://search.cpan.org/~kcowgill/Acme-LOLCAT-0.0.5/" target="_blank" title="LOLCAT CPAN module">CPAN module</a>.  Reading through the code gave me an idea for how to implement a jQuery LOLCAT plugin of my own.</p>
<p>Check out the <a href="http://mlntn.com/demos/jquery-lolcat/">demo</a> or <a href="http://mlntn.com/downloads/jquery.lolcat.js">download the plugin</a>.</p>
<p>A few answers to some unasked questions:</p>
<ul>
<li>Yes, the translation table is extensible. Pass an object to the $.lolcat() call.</li>
<li>Yes, this should keep all bound event handlers, since only text nodes are replaced with translated text.</li>
<li>Yes, I spent way too much time on this.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://mlntn.com/2011/01/19/humor-jquery-lolcat-plugin/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://mlntn.com/2011/01/19/humor-jquery-lolcat-plugin/</feedburner:origLink></item>
		<item>
		<title>HUMOR: How to use the same code for PHP and Javascript</title>
		<link>http://feedproxy.google.com/~r/MellentineDesign/~3/UFShTnxwkzc/</link>
		<comments>http://mlntn.com/2010/12/02/humor-how-to-use-the-same-code-for-php-and-javascript/#comments</comments>
		<pubDate>Thu, 02 Dec 2010 17:14:13 +0000</pubDate>
		<dc:creator>Jared</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://mlntn.com/?p=164</guid>
		<description><![CDATA[I recently had to disable some forms if a certain case existed and I came up with a hilarious way to use the same code for PHP and Javascript. Sometimes, amusing myself is how I get through a day.
First the PHP:
unset&#40;$_POST&#41;;
Simple, right?
Now for the Javascript (with a little help from jQuery):
var $_POST = 'post';
function unset&#40;type&#41; [...]]]></description>
			<content:encoded><![CDATA[<p>I recently had to disable some forms if a certain case existed and I came up with a hilarious way to use the same code for PHP and Javascript. Sometimes, amusing myself is how I get through a day.<span id="more-164"></span></p>
<p>First the PHP:</p>
<div class="codecolorer-container php mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><a href="http://www.php.net/unset"><span style="color: #990000;">unset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p>Simple, right?</p>
<p>Now for the Javascript (with a little help from jQuery):</p>
<div class="codecolorer-container javascript mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #003366; font-weight: bold;">var</span> $_POST <span style="color: #339933;">=</span> <span style="color: #3366CC;">'post'</span><span style="color: #339933;">;</span><br />
<span style="color: #003366; font-weight: bold;">function</span> unset<span style="color: #009900;">&#40;</span>type<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'form[method='</span><span style="color: #339933;">+</span>type<span style="color: #339933;">+</span><span style="color: #3366CC;">']'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'submit'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
$<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; unset<span style="color: #009900;">&#40;</span>$_POST<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p>Okay, it takes a little more effort and &#8220;unset&#8221; is a horrible function name for what it&#8217;s doing. But it&#8217;s worth it, right? Right?!</p>
]]></content:encoded>
			<wfw:commentRss>http://mlntn.com/2010/12/02/humor-how-to-use-the-same-code-for-php-and-javascript/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://mlntn.com/2010/12/02/humor-how-to-use-the-same-code-for-php-and-javascript/</feedburner:origLink></item>
		<item>
		<title>2009 recap</title>
		<link>http://feedproxy.google.com/~r/MellentineDesign/~3/ExmsDpipPLA/</link>
		<comments>http://mlntn.com/2010/01/01/2009-recap/#comments</comments>
		<pubDate>Fri, 01 Jan 2010 16:25:28 +0000</pubDate>
		<dc:creator>Jared</dc:creator>
				<category><![CDATA[etc]]></category>

		<guid isPermaLink="false">http://mlntn.com/?p=138</guid>
		<description><![CDATA[Since 2009 has come to a close, I&#8217;d like to reflect on some of the cool stuff I&#8217;ve been able to work on over the past year.
In April and May, I spent some time working on database design for a complete rewrite of my company&#8217;s software.  The schema is very complex and presented lots [...]]]></description>
			<content:encoded><![CDATA[<p>Since 2009 has come to a close, I&#8217;d like to reflect on some of the cool stuff I&#8217;ve been able to work on over the past year.<span id="more-138"></span></p>
<p>In April and May, I spent some time working on database design for a complete rewrite of my company&#8217;s software.  The schema is very complex and presented lots of interesting challenges.</p>
<p>In May, I started building the system &#8211; with my coworkers &#8211; using the <a title="symfony framework" href="http://www.symfony-project.org/" target="_blank">symfony framework</a> and <a title="Doctrine ORM" href="http://www.doctrine-project.org/" target="_blank">Doctrine ORM</a>.  I tested out several other frameworks and ORM&#8217;s, but ultimately we decided on symfony and Doctrine.  The symfony framework is very mature and easily extensible.  Doctrine, on the other hand, is quirky and a little bloated.  It just so happens that symfony is built for Doctrine or Propel ORM and Doctrine seemed the lesser of two evils.</p>
<p>In October, I started building a ubiquitous chat component using XMPP for my company&#8217;s software.  The chat is based on <a title="Openfire XMPP server" href="http://www.igniterealtime.org/projects/openfire/" target="_blank">Openfire</a> and <a title="Strophe library" href="http://code.stanziq.com/strophe/" target="_blank">Strophe</a>.  The chat itself is similar to Facebook&#8217;s chat.</p>
<p>In November, I attended the first <a title="WordCamp Phoenix" href="http://phxwordcamp.com/" target="_blank">WordCamp Phoenix</a>.  Throughout the day, there were some good speakers (Jim Christian, John Hawkins, Brent Spore, Dave Moyer, Merlin Mann) and some that were awful (Lorelle VanFossen and Jayson Cote).  My friend&#8217;s sister-in-law (both attended WordCamp) knows Matt Mullenweg (the creator of WordPress), so we all had lunch together. It was a pretty cool experience overall.</p>
<p>Also in November, I put an online store together for a client using <a title="Magento e-Commerce Platform" href="http://www.magentocommerce.com/" target="_blank">Magento</a>.  I didn&#8217;t have much time to dive into it because the project had such a quick turnaround time, but I could do some pretty awesome things with it.  I&#8217;m looking for reasons to play around with it more.</p>
<p>I wrote a number of cool jQuery plugins in 2009:</p>
<ul>
<li><a href="/2009/03/09/javascript-jquery-undo-plugin/" title="Undoable: jQuery undo plugin">Undoable</a>: handles undo and redo</li>
<li>AJAXList: Create a very customizable autocomplete list via AJAX</li>
<li>Caret: Cursor selection getter and setter</li>
<li>FakeSelect: Creates a &lt;select&gt;-like dropdown menu from a &lt;ul&gt; element</li>
<li>Tristate: Creates a tri-state input (checked, unchecked, default) for forms</li>
<li><a href="/2009/12/30/jquery-ip-address-plugin/" title="jQuery IP address plugin">IP Address</a>: Creates an IP address input for forms</li>
</ul>
<p>I&#8217;m hoping 2010 is just as great as 2009 was.</p>
]]></content:encoded>
			<wfw:commentRss>http://mlntn.com/2010/01/01/2009-recap/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://mlntn.com/2010/01/01/2009-recap/</feedburner:origLink></item>
		<item>
		<title>jQuery IP address plugin</title>
		<link>http://feedproxy.google.com/~r/MellentineDesign/~3/N7PaNIeSp3s/</link>
		<comments>http://mlntn.com/2009/12/30/jquery-ip-address-plugin/#comments</comments>
		<pubDate>Wed, 30 Dec 2009 14:31:24 +0000</pubDate>
		<dc:creator>Jared</dc:creator>
				<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://mlntn.com/?p=113</guid>
		<description><![CDATA[It&#8217;s pretty tough to handle IP addresses in HTML forms. Sure, you can do have 4 separate inputs and have users tab between them.  You could setup one input and validate it on the server side.  You could even use a tool like Masked Input to force users to match a specific format.
But [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s pretty tough to handle IP addresses in HTML forms. Sure, you can do have 4 separate inputs and have users tab between them.  You could setup one input and validate it on the server side.  You could even use a tool like <a title="jQuery Masked Input plugin" href="http://digitalbush.com/projects/masked-input-plugin/" target="_blank">Masked Input</a> to force users to match a specific format.</p>
<p>But all of those solutions fall short in one way or another.<span id="more-113"></span></p>
<p>So I decided to write a jQuery plugin that would turn a plain old text input into an IP address form widget that operates like one you&#8217;d find in your operating system.</p>
<p>The plugin parses out existing text in the input (in case the user is editing an existing IP) and creates 4 new text inputs.  As the user types the IP address, the cursor jumps to the next box.  But if I left it there, it would be pretty lame, right?</p>
<p>The plugin also adds event handlers to the inputs to limit keys.  There are also event handlers that will allow right and left arrows to jump between inputs and backspace will continue across inputs as well.</p>
<p>I had to write another plugin to get the cursor handling working correctly, so it&#8217;s required for the IP address plugin.</p>
<p>As the user is typing, if all 4 IP octets have a value, the original IP address will be repopulated with the IP address from the widget.</p>
<p><a title="jQuery IP address plugin demo" href="http://mlntn.com/demos/jquery-ipaddress/">Check out the demo</a> or <a title="jQuery IP address plugin download" href="http://code.google.com/p/jquery-ip/source/browse/trunk" target="_blank">download from Google Code</a> (requires <a href="http://code.google.com/p/jquery-caret/source/browse/trunk" title="jQuery cursor position plugin" target="_blank">jquery.caret</a>, a cursor position plugin).</p>
]]></content:encoded>
			<wfw:commentRss>http://mlntn.com/2009/12/30/jquery-ip-address-plugin/feed/</wfw:commentRss>
		<slash:comments>32</slash:comments>
		<feedburner:origLink>http://mlntn.com/2009/12/30/jquery-ip-address-plugin/</feedburner:origLink></item>
		<item>
		<title>How to build a Google Chrome extension in 15 minutes</title>
		<link>http://feedproxy.google.com/~r/MellentineDesign/~3/0aHvpPVnSCI/</link>
		<comments>http://mlntn.com/2009/12/08/how-to-build-a-google-chrome-extension-in-15-minutes/#comments</comments>
		<pubDate>Wed, 09 Dec 2009 05:32:53 +0000</pubDate>
		<dc:creator>Jared</dc:creator>
				<category><![CDATA[etc]]></category>

		<guid isPermaLink="false">http://mlntn.com/?p=105</guid>
		<description><![CDATA[Google Chrome&#8217;s extension gallery opened December 8th and the race to create extensions is on.
I browsed through the gallery, looking for anything that might be useful to me and my normal browsing experience.  I found a couple good ones: Google Alerter, RSS Subscription Extension and Docs PDF/PowerPoint Viewer (by Google).
I searched for a Facebook [...]]]></description>
			<content:encoded><![CDATA[<p>Google Chrome&#8217;s extension gallery opened December 8th and the race to create extensions is on.</p>
<p>I browsed through the gallery, looking for anything that might be useful to me and my normal browsing experience.  I found a couple good ones: <a title="Google Chrome Extensions: Google Alerter" href="https://chrome.google.com/extensions/detail/ikefielkhonlbnjjfhcjmepanaeajkbh">Google Alerter</a>, <a title="Google Chrome Extensions: RSS Subscription Extension" href="https://chrome.google.com/extensions/detail/nlbjncdgjeocebhnmkbbbdekmmmcbfjd">RSS Subscription Extension</a> and <a title="Google Chrome Extensions: Docs PDF/PowerPoint Viewer (by Google)" href="https://chrome.google.com/extensions/detail/nnbmlagghjjcbdhgmkedmbmedengocbn">Docs PDF/PowerPoint Viewer (by Google)</a>.</p>
<p>I searched for a Facebook ad blocker, but the <a title="Google Chrome Extensions: Facebook Adblock" href="https://chrome.google.com/extensions/detail/bpkinlipdioelcoagofcbcmpbgedfcdg">one I found</a> only blocked profile ads &#8211; not very useful.  So I tried writing my own and found that it was much simpler than I expected.<span id="more-105"></span></p>
<p>There were really only two files that I needed to create: manifest.json (a <a title="Formats: Manifest Files - Google Chrome Extensions" href="http://code.google.com/chrome/extensions/manifest.html">manifest file</a> that tells Google Chrome important info about your extension) and facebook.css (a <a title="Content Scripts - Google Chrome Extensions" href="http://code.google.com/chrome/extensions/content_scripts.html">content script</a> that hides the ads using CSS, obviously).</p>
<p>The manifest.json file looks like this:</p>
<div class="codecolorer-container javascript mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;">&#123;</span><br />
&nbsp; <span style="color: #3366CC;">&quot;name&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Hide Facebook Ads&quot;</span><span style="color: #339933;">,</span><br />
&nbsp; <span style="color: #3366CC;">&quot;version&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;1.0&quot;</span><span style="color: #339933;">,</span><br />
&nbsp; <span style="color: #3366CC;">&quot;description&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Hides Facebook ads&quot;</span><span style="color: #339933;">,</span><br />
&nbsp; <span style="color: #3366CC;">&quot;content_scripts&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;matches&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">&quot;http://www.facebook.com/*&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;http://apps.facebook.com/*&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;css&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">&quot;facebook.css&quot;</span><span style="color: #009900;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; <span style="color: #009900;">&#93;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p>I used Chrome&#8217;s Developer Tools (Ctrl-Shift-I or Page menu &gt; Developer &gt; Developer Tools) to find good CSS rules for blocking the sponsored ads on the homepage, profile page and app pages.  I also had to fix the profile page, which broke when I hid the ad sidebar there.  Here&#8217;s what facebook.css looks like:</p>
<div class="codecolorer-container css mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="css codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #cc00cc;">#home_sponsor_nile</span><span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#sidebar_ads</span><span style="color: #00AA00;">,</span> <span style="color: #6666ff;">.module_ad</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span><br />
<span style="color: #6666ff;">.profile_bottom_container</span> <span style="color: #6666ff;">.right_column</span> <span style="color: #00AA00;">&#123;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">margin-right</span><span style="color: #00AA00;">:</span> <span style="color: #933;">180px</span><span style="color: #00AA00;">;</span><br />
<span style="color: #00AA00;">&#125;</span></div></div>
<p>After saving the two files to an empty directory, I opened chrome://extensions in Chrome.  Under &#8220;Developer mode&#8221;, I hit the Load unpacked extension&#8230; button and navigated to that directory.  Chrome added the plugin and I could refresh it if I needed to make a change to the CSS or manifest.json file.</p>
<p>After everything was tested and working, I packed the extension and was done.  Overall, I think the whole process took about 15 minutes, but most of that was looking at documentation.</p>
<p>Here&#8217;s the <a href="http://mlntn.com/wp-content/blogs.dir/4/files/2009/12/fbads.crx">extension</a>, if you want to play around with it.</p>
]]></content:encoded>
			<wfw:commentRss>http://mlntn.com/2009/12/08/how-to-build-a-google-chrome-extension-in-15-minutes/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		<feedburner:origLink>http://mlntn.com/2009/12/08/how-to-build-a-google-chrome-extension-in-15-minutes/</feedburner:origLink></item>
		<item>
		<title>jQuery undo plugin</title>
		<link>http://feedproxy.google.com/~r/MellentineDesign/~3/isx__nnf0vw/</link>
		<comments>http://mlntn.com/2009/03/09/javascript-jquery-undo-plugin/#comments</comments>
		<pubDate>Tue, 10 Mar 2009 02:14:57 +0000</pubDate>
		<dc:creator>Jared</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[jquery plugins]]></category>
		<category><![CDATA[undo]]></category>

		<guid isPermaLink="false">http://mlntn.com/?p=46</guid>
		<description><![CDATA[I got a crazy idea when I was working with some AJAX interfaces &#8211; a quick and painless jQuery undo plugin.
What does that mean?  I&#8217;m not entirely sure.
(Demo)
Here&#8217;s the goal&#8230;
I want to be easily able to add a function to the undo queue.  When I press the undo key combination, that function will run [...]]]></description>
			<content:encoded><![CDATA[<p>I got a crazy idea when I was working with some AJAX interfaces &#8211; a quick and painless jQuery undo plugin.</p>
<p>What does that mean?  I&#8217;m not entirely sure.<span id="more-46"></span></p>
<p>(<a href="http://design.mellentine.com/demos/jquery-undoable/">Demo</a>)</p>
<p>Here&#8217;s the goal&#8230;</p>
<p>I want to be easily able to add a function to the undo queue.  When I press the undo key combination, that function will run again and it will be placed in the redo queue:</p>
<div class="codecolorer-container javascript mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">undoable</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#sample'</span> <span style="color: #339933;">+</span> n<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">toggle</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p>This is really not ideal.  While some functions toggle correctly, not all do.</p>
<p>What I really is to be able to define a function for undo and a function for redo:</p>
<div class="codecolorer-container javascript mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">undoable</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#sample'</span> <span style="color: #339933;">+</span> n<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#sample'</span> <span style="color: #339933;">+</span> n<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">show</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p>I really think I can get away with both of them.</p>
<p><a href="http://design.mellentine.com/demos/jquery-undoable/">Check out the demo</a> and let me know what you think. (Hint: Open the Firebug console)</p>
]]></content:encoded>
			<wfw:commentRss>http://mlntn.com/2009/03/09/javascript-jquery-undo-plugin/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://mlntn.com/2009/03/09/javascript-jquery-undo-plugin/</feedburner:origLink></item>
		<item>
		<title>jQuery zoom event plugin</title>
		<link>http://feedproxy.google.com/~r/MellentineDesign/~3/fURlbGQxaw4/</link>
		<comments>http://mlntn.com/2008/12/11/javascript-jquery-zoom-event-plugin/#comments</comments>
		<pubDate>Thu, 11 Dec 2008 23:35:08 +0000</pubDate>
		<dc:creator>Jared</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jquery plugins]]></category>

		<guid isPermaLink="false">http://mlntn.com/?p=34</guid>
		<description><![CDATA[I don&#8217;t normally write code that I&#8217;m not ready to use, but I made an exception for this jQuery plugin.  It doesn&#8217;t really do all that I wanted it to do, but it&#8217;s good enough for a release.

Before I lose the ADD/ADHD folks: Demo.
The goal for this plugin was to create a event handler for [...]]]></description>
			<content:encoded><![CDATA[<p>I don&#8217;t normally write code that I&#8217;m not ready to use, but I made an exception for this jQuery plugin.  It doesn&#8217;t really do all that I wanted it to do, but it&#8217;s good enough for a release.<br />
<span id="more-34"></span><br />
Before I lose the ADD/ADHD folks: <a title="jQuery zoom() event demo" href="/demos/jquery-zoom/">Demo</a>.</p>
<p>The goal for this plugin was to create a event handler for text and page zooming in a browser window.  While this can&#8217;t be accomplished entirely without some better event support in the browsers, I can watch for keyboard and mouse shortcuts that result in zooming.</p>
<p>This plugin itself doesn&#8217;t care if you zoomed in or out.  It just runs the callback function when you zoom.  Maybe at a later point, I&#8217;ll add that feature.</p>
<p>Without any further ado, here&#8217;s the plugin code:</p>
<div class="codecolorer-container javascript mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">jQuery.<span style="color: #660066;">fn</span>.<span style="color: #660066;">zoom</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>fn<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; jQuery<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">keydown</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">switch</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">case</span> jQuery.<span style="color: #660066;">browser</span>.<span style="color: #660066;">mozilla</span> <span style="color: #339933;">||</span> jQuery.<span style="color: #660066;">browser</span>.<span style="color: #660066;">msie</span> <span style="color: #339933;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>e.<span style="color: #660066;">ctrlKey</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> <span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e.<span style="color: #660066;">which</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">187</span> <span style="color: #339933;">||</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e.<span style="color: #660066;">which</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">189</span> <span style="color: #339933;">||</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e.<span style="color: #660066;">which</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">107</span> <span style="color: #339933;">||</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e.<span style="color: #660066;">which</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">109</span> <span style="color: #339933;">||</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e.<span style="color: #660066;">which</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">96</span> &nbsp;<span style="color: #339933;">||</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e.<span style="color: #660066;">which</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">48</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> fn<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">case</span> jQuery.<span style="color: #660066;">browser</span>.<span style="color: #660066;">opera</span> <span style="color: #339933;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e.<span style="color: #660066;">which</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">43</span> <span style="color: #339933;">||</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e.<span style="color: #660066;">which</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">45</span> <span style="color: #339933;">||</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e.<span style="color: #660066;">which</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">42</span> <span style="color: #339933;">||</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#40;</span>e.<span style="color: #660066;">ctrlKey</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> e.<span style="color: #660066;">which</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">48</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#41;</span> fn<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">case</span> jQuery.<span style="color: #660066;">browser</span>.<span style="color: #660066;">safari</span> <span style="color: #339933;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>e.<span style="color: #660066;">metaKey</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> <span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e.<span style="color: #660066;">charCode</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">43</span> <span style="color: #339933;">||</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e.<span style="color: #660066;">charCode</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">45</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> fn<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; jQuery<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'mousewheel'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>e.<span style="color: #660066;">ctrlKey</span><span style="color: #009900;">&#41;</span> fn<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; jQuery<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'DOMMouseScroll'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>e.<span style="color: #660066;">ctrlKey</span><span style="color: #009900;">&#41;</span> fn<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></div></div>
<p>Because we&#8217;re dealing with browser implementations of keyboard shortcuts, I decided to use jQuery.browser (which uses navigator.useragent) to deal with the browsers individually.  Much to my surprise (and delight), Internet Explorer and Firefox handle zooming identically.</p>
<p>Lines 2 &#8211; 30 deal with zooming through keyboard shortcuts.  The character codes are as follows:<br />
<strong>42</strong>: * (numpad)<br />
<strong>43</strong>: + (numpad)<br />
<strong>45</strong>: &#8211; (numpad)<br />
<strong>48</strong>: 0 (numpad in FF and IE)<br />
<strong>96</strong>: 0<br />
<strong>107</strong>: + (numpad in FF and IE)<br />
<strong>109</strong>: &#8211; (numpad in FF and IE)<br />
<strong>187</strong>: +<br />
<strong>189</strong>: -</p>
<p>Lines 32-38 deal with scrollwheel zooming in Firefox and IE.  Opera doesn&#8217;t run the callback function for the scrollwheel when the CTRL key is pressed (which is how scrollwheel zooming is done in Opera).  Safari 2 (which is what I have) doesn&#8217;t support scrollwheel zooming at all.</p>
<p>Further testing needs to be done in Safari 3, but this plugin works pretty well as is.  Here&#8217;s how you&#8217;d use it:</p>
<div class="codecolorer-container javascript mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">jQuery<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">zoom</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'I zoomed'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p>Here&#8217;s the <a title="jQuery zoom() event plugin" href="/downloads/jquery.zoom.js">download</a> and the <a title="jQuery zoom() event demo" href="/demos/jquery-zoom/">demo</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://mlntn.com/2008/12/11/javascript-jquery-zoom-event-plugin/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		<feedburner:origLink>http://mlntn.com/2008/12/11/javascript-jquery-zoom-event-plugin/</feedburner:origLink></item>
		<item>
		<title>The start of a jQuery zoom event handler</title>
		<link>http://feedproxy.google.com/~r/MellentineDesign/~3/VxDRrG4UZmk/</link>
		<comments>http://mlntn.com/2008/12/11/javascript-the-start-of-a-jquery-zoom-event-handler/#comments</comments>
		<pubDate>Thu, 11 Dec 2008 05:40:31 +0000</pubDate>
		<dc:creator>Jared</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[events]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://mlntn.com/?p=31</guid>
		<description><![CDATA[After much research and very little code, I&#8217;ve come up with a basic start to a jQuery zoom event handler.  Don&#8217;t laugh.  This is very basic, but it handles zoom events based on keyboard shortcuts and fires the handler.

UPDATE: You can find the latest version of the plugin here.
jQuery.fn.zoom = function&#40;fn&#41; &#123;
&#160; &#160; jQuery&#40;document&#41;.keypress&#40;function&#40;e&#41;&#123;
&#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>After much research and very little code, I&#8217;ve come up with a basic start to a jQuery zoom event handler.  Don&#8217;t laugh.  This is very basic, but it handles zoom events based on keyboard shortcuts and fires the handler.<br />
<span id="more-31"></span></p>
<p><strong>UPDATE:</strong> You can find the latest version of the plugin <a href="http://design.mellentine.com/2008/12/11/javascript-jquery-zoom-event-plugin/">here</a>.</p>
<div class="codecolorer-container javascript mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">jQuery.<span style="color: #660066;">fn</span>.<span style="color: #660066;">zoom</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>fn<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; jQuery<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">keypress</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>e.<span style="color: #660066;">ctrlKey</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> <span style="color: #009900;">&#40;</span>e.<span style="color: #660066;">which</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">61</span> <span style="color: #339933;">||</span> e.<span style="color: #660066;">which</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">45</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> fn<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></div></div>
<p>You could then assign a handler like so:</p>
<div class="codecolorer-container javascript mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">jQuery<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">zoom</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'zoom, zoom'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p>So much more needs to be added to this and I&#8217;m not even sure I&#8217;m headed the right direction.  For example, I can address another way of zooming (CTRL-scrollwheel), but I doubt I can capture use of the menu in the browser.  Also, I could probably assign different keys to zoom.  I might have to come up with a different solution entirely.</p>
]]></content:encoded>
			<wfw:commentRss>http://mlntn.com/2008/12/11/javascript-the-start-of-a-jquery-zoom-event-handler/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://mlntn.com/2008/12/11/javascript-the-start-of-a-jquery-zoom-event-handler/</feedburner:origLink></item>
		<item>
		<title>Simple date conversion from SQL to readable</title>
		<link>http://feedproxy.google.com/~r/MellentineDesign/~3/AvB9ThxhYc0/</link>
		<comments>http://mlntn.com/2008/12/02/javascript-simple-date-conversion-from-sql-to-readable/#comments</comments>
		<pubDate>Wed, 03 Dec 2008 00:10:21 +0000</pubDate>
		<dc:creator>Jared</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[regular expressions]]></category>

		<guid isPermaLink="false">http://mlntn.com/?p=29</guid>
		<description><![CDATA[I needed a simple date converter function from SQL dates (YYYY-MM-DD) to something readable (M/D/YYYY).  So I wrote this little function.  Maybe someone else will have some use for it.
var makeSQLDatePretty = function&#40;d&#41; &#123;
&#160; return d.replace&#40;/([0-9]{4})-0?([0-9]{1,2})-0?([0-9]{1,2})/, '$2/$3/$1'&#41;;
&#125;;
Pass in a SQL date and the function trims leading zeros and returns a reformatted date.
var sqlDate = '2008-12-02';
alert&#40;makeSQLDatePretty&#40;sqlDate&#41;&#41;; [...]]]></description>
			<content:encoded><![CDATA[<p>I needed a simple date converter function from SQL dates (YYYY-MM-DD) to something readable (M/D/YYYY).  So I wrote this little function.  Maybe someone else will have some use for it.</p>
<div class="codecolorer-container javascript mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #003366; font-weight: bold;">var</span> makeSQLDatePretty <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>d<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; <span style="color: #000066; font-weight: bold;">return</span> d.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/([0-9]{4})-0?([0-9]{1,2})-0?([0-9]{1,2})/</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'$2/$3/$1'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></div></div>
<p>Pass in a SQL date and the function trims leading zeros and returns a reformatted date.</p>
<div class="codecolorer-container javascript mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #003366; font-weight: bold;">var</span> sqlDate <span style="color: #339933;">=</span> <span style="color: #3366CC;">'2008-12-02'</span><span style="color: #339933;">;</span><br />
<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>makeSQLDatePretty<span style="color: #009900;">&#40;</span>sqlDate<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// should alert '12/2/2008'</span></div></div>
<p>Crazy Europeans may want to change the replace regex with &#8216;$3/$2/$1&#8242;.</p>
]]></content:encoded>
			<wfw:commentRss>http://mlntn.com/2008/12/02/javascript-simple-date-conversion-from-sql-to-readable/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://mlntn.com/2008/12/02/javascript-simple-date-conversion-from-sql-to-readable/</feedburner:origLink></item>
		<item>
		<title>Smart, unobtrusive AJAX form submission with jQuery</title>
		<link>http://feedproxy.google.com/~r/MellentineDesign/~3/QSqVY-hqOCU/</link>
		<comments>http://mlntn.com/2008/09/22/javascript-smart-unobtrusive-ajax-form-submission-with-jquery/#comments</comments>
		<pubDate>Mon, 22 Sep 2008 23:44:22 +0000</pubDate>
		<dc:creator>Jared</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[jquery plugins]]></category>
		<category><![CDATA[mootools]]></category>

		<guid isPermaLink="false">http://mlntn.com/?p=19</guid>
		<description><![CDATA[A former coworker was telling me recently about MooTools and how the AJAX functions are so easy to use.  He sent me the following example:

function attachedToOnSubmitOfAForm&#40;&#41;&#123;
&#160; &#160; &#160; &#160; sp = $&#40;&#34;someForm&#34;&#41;;
&#160; &#160; &#160; &#160; sp.addClass&#40;'loader'&#41;;

&#160; &#160; &#160; &#160; sp.send&#40;&#123;
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; onComplete: function&#40;json&#41; &#123;
&#160; &#160; &#160; &#160; &#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>A former coworker was telling me recently about MooTools and how the AJAX functions are so easy to use.  He sent me the following example:<br />
<span id="more-19"></span></p>
<div class="codecolorer-container javascript mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #003366; font-weight: bold;">function</span> attachedToOnSubmitOfAForm<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; sp <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;someForm&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; sp.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'loader'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; sp.<span style="color: #660066;">send</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; onComplete<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>json<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ....<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; onFailure<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ....<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p>Great concept, right?  No need to tell it where to send the data or what fields to send, since the form already contains that info.  It&#8217;s mostly unobtrusive, so any browser that doesn&#8217;t have JS enabled would still be able to submit.</p>
<p>So my immediate response was, &#8220;Very cool.  I&#8217;m sure a jQuery plugin either exists or could be created pretty easily to handle that.&#8221;</p>
<p>I built the following plugin in maybe 30 minutes, and had it tested in another 15.</p>
<div class="codecolorer-container javascript mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>jQuery<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; jQuery.<span style="color: #660066;">fn</span>.<span style="color: #660066;">send</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>options<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> form <span style="color: #339933;">=</span> jQuery<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><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jQuery<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;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'submit'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jQuery.<span style="color: #660066;">ajax</span><span style="color: #009900;">&#40;</span>jQuery.<span style="color: #660066;">extend</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; type &nbsp; &nbsp; <span style="color: #339933;">:</span> form.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'method'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #3366CC;">'get'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; url &nbsp; &nbsp; &nbsp;<span style="color: #339933;">:</span> form.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'action'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> window.<span style="color: #660066;">location</span>.<span style="color: #660066;">href</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data &nbsp; &nbsp; <span style="color: #339933;">:</span> form.<span style="color: #660066;">serialize</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> options<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>jQuery<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p>There are some of you that are wondering, &#8220;Why is this necessary? I can write my own jQuery.ajax() code every time.&#8221;  Yep, and that&#8217;s part the problem I&#8217;m trying to solve. The plugin is a shortcut for most of the jQuery.ajax() code you&#8217;d normally write and it makes unobtrusive form submission dead simple:</p>
<div class="codecolorer-container javascript mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">jQuery<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'form'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">send</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; complete <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>data.<span style="color: #660066;">responseText</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p>The function takes one parameter, an object that extends the <a href="http://docs.jquery.com/Ajax/jQuery.ajax#options">jQuery.ajax method</a>.</p>
<p>Here&#8217;s a <a href="/demos/jquery-send">demo</a> and the <a href="/downloads/jquery.send.js">download</a>.</p>
<p><strong>2008-09-23</strong>: Updated <em>window.location</em> to <em>window.location.href</em> (Thanks Samori)</p>
]]></content:encoded>
			<wfw:commentRss>http://mlntn.com/2008/09/22/javascript-smart-unobtrusive-ajax-form-submission-with-jquery/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://mlntn.com/2008/09/22/javascript-smart-unobtrusive-ajax-form-submission-with-jquery/</feedburner:origLink></item>
	</channel>
</rss><!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->

