<?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>Blog.ubrious &#187; Javascript</title>
	<atom:link href="http://blog.ubrio.us/category/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.ubrio.us</link>
	<description>An Ordinary Web Developer's Blog</description>
	<lastBuildDate>Thu, 19 Jan 2012 00:44:59 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>self clearing text input fields with javascript</title>
		<link>http://blog.ubrio.us/javascript/self-clearing-text-input-fields-with-javascript/</link>
		<comments>http://blog.ubrio.us/javascript/self-clearing-text-input-fields-with-javascript/#comments</comments>
		<pubDate>Wed, 23 Apr 2008 13:49:13 +0000</pubDate>
		<dc:creator>Rob Hurring</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[prototype]]></category>

		<guid isPermaLink="false">http://blog.ubrio.us/web/self-clearing-text-input-fields-with-javascript/</guid>
		<description><![CDATA[I found that I use a lot of input fields which need to display a simple message to the user like &#8220;type the molecular structure of didehydro-dimethylether onium cation&#8221; &#8212; and when they focus the box it needs to clear, and when they blur the box it needs to go back to that message. Theres [...]]]></description>
			<content:encoded><![CDATA[<p>I found that I use a lot of input fields which need to display a simple message to the user like &#8220;type the molecular structure of didehydro-dimethylether onium cation&#8221; &#8212; and when they focus the box it needs to clear, and when they blur the box it needs to go back to that message. Theres the sloppy way of doing it in the text box itself with the attribute callbacks &#8220;onfocus/blur&#8221; but thats annoying.  I decided to make a simple extension to the HTMLInputElement instead like a good boy.</p>
<p>Here is the input extension to make a text field (actually, _any_ input, but you can add that logic yourself:) ) self clearing:</p>
<h3>Requires <a href='http://www.prototypejs.org/' target='_blank' onclick="pageTracker._trackPageview('/outgoing/www.prototypejs.org/?referer=');">Prototype Javascript Library</a>!  <br/><small>I used v1.6 but I&#8217;m sure others will work fine.</small></h3>
<pre class="brush: jscript;">
// input_extensions.js

// extends HTMLInputElement to include a self-clearing method
// @author Rob Hurring
// @date 2008-04-23
// UPDATED: 12/02/08 -- thanks to Shawn for pointing out the IE flaw

var SelfClearingInput = Class.create();
SelfClearingInput.prototype = {
	initialize:function(element)
	{
		this.element = $(element);
		this.original_value = this.element.value
		Event.observe(this.element, 'focus', this.focus.bind(this));
		Event.observe(this.element, 'blur', this.blur.bind(this));
	},
	focus:function(e)
	{
		if(this.element.value == this.original_value)
			this.element.value = '';
	},
	blur:function(e)
	{
		if(this.element.value == '')
			this.element.value = this.original_value;
	}
};
</pre>
<p>when you want to use it, something like this can work:</p>
<pre class="brush: jscript;">
// In your javascript file somewhere
document.observe(&quot;dom:loaded&quot;, function()
{
	new SelfClearingInput('ID_OF_INPUT_BOX');
});
</pre>
<div class='help'>For more info check out the project page at <a href="http://github.com/robhurring/self_clearing_field" onclick="pageTracker._trackPageview('/outgoing/github.com/robhurring/self_clearing_field?referer=');">JavaScript Self Clearing Input @ GitHub</a></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.ubrio.us/javascript/self-clearing-text-input-fields-with-javascript/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Apocalypse 2.0 The day the web broke</title>
		<link>http://blog.ubrio.us/javascript/apocalypse-20-the-day-the-web-broke/</link>
		<comments>http://blog.ubrio.us/javascript/apocalypse-20-the-day-the-web-broke/#comments</comments>
		<pubDate>Tue, 05 Sep 2006 21:35:48 +0000</pubDate>
		<dc:creator>Rob Hurring</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://blog.ubrio.us/javascript/apocalypse-20-the-day-the-web-broke/</guid>
		<description><![CDATA[Found this article on Digg, and just thinking about this makes me cringe. If what he&#8217;s saying is true, which it most likely is, then my life is about to become a big pile of hate. Can&#8217;t we all just get along?
 Apocalypse 2.0 &#8211; the day the web broke by ZDNet&#8217;s Ryan Stewart &#8212; [...]]]></description>
			<content:encoded><![CDATA[<p>Found this article on Digg, and just thinking about this makes me cringe. If what he&#8217;s saying is true, which it most likely is, then my life is about to become a big pile of hate. Can&#8217;t we all just get along?</p>
<p><a href="http://blogs.zdnet.com/Stewart/?p=101" rel="bookmark" title="Permalink" onclick="pageTracker._trackPageview('/outgoing/blogs.zdnet.com/Stewart/?p=101&amp;referer=');"> Apocalypse 2.0 &#8211; the day the web broke</a> by <a href="http://zdnet.com" onclick="pageTracker._trackPageview('/outgoing/zdnet.com?referer=');">ZDNet</a>&#8217;s Ryan Stewart &#8212; On February 16th, 2005, Jesse James Garrett coined the term Ajax in an article titled &#8220;Ajax: A New Approach to Web Applications&#8221;. Days before that, on February 8th, the Google Blog announced something called Google Maps. Ajax was born and the web hasn&#8217;t been the same since. The combination of JavaScript, DHTML and CSS seemed to breathe a new kind of life into the web. All of a sudden you could program a series of hacks and your web page didn&#8217;t behave like a web page before. All that time you spent learning JavaScript? With Ajax, you were in demand again! People started saying things like &#8220;JavaScript Engineer&#8221; with a straight face.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ubrio.us/javascript/apocalypse-20-the-day-the-web-broke/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Wiki style auto link formatting through JS</title>
		<link>http://blog.ubrio.us/javascript/javascript-prototype-wikipedia-style-external-link-images/</link>
		<comments>http://blog.ubrio.us/javascript/javascript-prototype-wikipedia-style-external-link-images/#comments</comments>
		<pubDate>Tue, 25 Jul 2006 01:47:42 +0000</pubDate>
		<dc:creator>Rob Hurring</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://blog.ubrio.us/uncategorized/javascript-prototype-wikipedia-style-external-link-images/</guid>
		<description><![CDATA[This is a simple effect that looks pretty awesome and can definatly make your blogging life much easier. (how? because you will never have to type &#8220;target=_blank&#8221; again, thats how.)
Heres the JavaScript includes

src="/jslib/prototype.js"

src="ubrious.js?domain=blog.ubrio.us"

or

src="ubrious.js?domain=&#60;?=$_SERVER['SERVER_NAME']?&#62;"

And the JavaScript itself

Event.observe(window, 'load', function()
{
	domain = '';
	$A(document.getElementsByTagName("script")).findAll( function(s)
	{
		domain = s.src.match(/ubrious.js(?.*)?$/);
		if(domain)
			domain = domain[1].replace(/?domain=/, '');
	});
	$A(document.getElementsByTagName('a')).each(function(l)
	{
		if(l.target=="_blank" &#124;&#124; !l.href.match('/'+domain+'/') &#038;&#038; !l.href.match(/^javascript/))
		{
			// attach if outside of your [...]]]></description>
			<content:encoded><![CDATA[<p>This is a simple effect that looks pretty awesome and can definatly make your blogging life much easier. (how? because you will never have to type &#8220;target=_blank&#8221; again, thats how.)</p>
<p><strong>Heres the JavaScript includes</strong></p>
<pre>
src="/jslib/prototype.js"

src="ubrious.js?domain=blog.ubrio.us"

or

src="ubrious.js?domain=&lt;?=$_SERVER['SERVER_NAME']?&gt;"
</pre>
<p><strong>And the JavaScript itself</strong></p>
<pre>
Event.observe(window, 'load', function()
{
	domain = '';
	$A(document.getElementsByTagName("script")).findAll( function(s)
	{
		domain = s.src.match(/ubrious.js(?.*)?$/);
		if(domain)
			domain = domain[1].replace(/?domain=/, '');
	});
	$A(document.getElementsByTagName('a')).each(function(l)
	{
		if(l.target=="_blank" || !l.href.match('/'+domain+'/') &#038;&#038; !l.href.match(/^javascript/))
		{
			// attach if outside of your domain, and not a javascript link..
			Element.addClassName(l, 'aexternal');
			l.target="_blank";
		}
	});
});
</pre>
<p><strong>Finally, the link classes</strong></p>
<pre>
.aexternal{
	background: url(imgs/aout.gif) right no-repeat;
	padding-right: 12px;
	}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.ubrio.us/javascript/javascript-prototype-wikipedia-style-external-link-images/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

