<?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"
	>

<channel>
	<title>spudly.shuoink.com</title>
	<atom:link href="http://spudly.shuoink.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://spudly.shuoink.com</link>
	<description>the best way to predict the future is to implement it</description>
	<pubDate>Thu, 21 Feb 2008 15:14:33 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
	<language>en</language>
			<item>
		<title>Using the XML DOM Without Writing 15,0000 Lines of Code</title>
		<link>http://spudly.shuoink.com/2008/02/20/using-the-xml-dom-without-writing-150000-lines-of-code/</link>
		<comments>http://spudly.shuoink.com/2008/02/20/using-the-xml-dom-without-writing-150000-lines-of-code/#comments</comments>
		<pubDate>Thu, 21 Feb 2008 05:17:09 +0000</pubDate>
		<dc:creator>spudly</dc:creator>
		
		<category><![CDATA[JavaScript]]></category>

		<category><![CDATA[appendChild]]></category>

		<category><![CDATA[child node]]></category>

		<category><![CDATA[createElement]]></category>

		<category><![CDATA[createTextNode]]></category>

		<category><![CDATA[document]]></category>

		<category><![CDATA[html]]></category>

		<category><![CDATA[html dom]]></category>

		<category><![CDATA[insertAfter]]></category>

		<category><![CDATA[insertBefore]]></category>

		<category><![CDATA[xml]]></category>

		<category><![CDATA[xml dom]]></category>

		<guid isPermaLink="false">http://spudly.shuoink.com/2008/02/20/using-the-xml-dom-without-writing-150000-lines-of-code/</guid>
		<description><![CDATA[I&#8217;m a pretty big fan of using the XML DOM rather than innerHTML, simply because it seems to me to be better programming style. I hate hate hate, however, that it takes 15 lines of code to create one node. Today, I came up with an idea to solve the problem. I created a wrapper [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m a pretty big fan of using the XML DOM rather than innerHTML, simply because it seems to me to be better programming style. I hate hate hate, however, that it takes 15 lines of code to create one node. Today, I came up with an idea to solve the problem. I created a wrapper function for document.createElement() that takes either a string or an object literal as an argument. Then, based on the data in this argument, I create the needed element(s). Here&#8217;s a simple example that creates a text node:</p>
<pre name="code" class="javascript:nocontrols:nogutter">
var node = createElements("Hello World!");
document.body.appendChild(node);</pre>
<p>Ok, so the above example is pretty useless, but what if you wanted to make that text into a link. the createElements() function allows us to pass an object literal with four items: tag, attributes, style, and children. &#8220;Tag&#8221; is, of course, the type of HTMLElement you want to create. &#8220;Attributes&#8221; is another object literal containing the attributes for the html tag (src, href, etc&#8230;). &#8220;Style&#8221; is an object literal containing the style attributes you want applied to the element, and last but certainly not least, &#8220;children&#8221; allows you to nest elements. It is an array of either strings or object literals, just like the ones you would pass into this function. Each of these children will be recursively created and appended to the main element. Here&#8217;s an example that creates a link to google:</p>
<pre name="code" class="javascript:nocontrols:nogutter">
var node = createElements({
	 tag: "a",
	 attributes: {
		href: "http://www.google.com"
	 },
	 style {
	    textDecoration: "none"
	 },
	 children: [ "Click Here!" ]
});
document.body.appendChild(node);</pre>
<p>And here&#8217;s a more complex example that really shows off the nesting power of this javascript function:</p>
<pre name="code" class="javascript:nocontrols:nogutter">
var node = createElements({
   tag: "div",
   attributes: {
	  id: "google_link"
   },
   children: [
	  {
		 tag: "a",
		 attributes: {
			href: "http://www.google.com"
		 },
		 style: {
			textDecoration: "none",
			fontWeight: "bold"
		 },
		 children: [
			{
			   tag: "img",
			   attributes: {
				  src: "http://www.google.com/intl/en_ALL/images/logo.gif",
				  alt: "Google!",
				  title: "Google!",
				  border: "0"
			   },
			   style: {
				  width: "200px",
				  height: "200px"
			   }
			},
			{
			   tag: "br"
			},
			"Click here to go to Google!"
		 ]

	  }
   ]
});
document.body.appendChild(node);</pre>
<p>The above example creates the following code:</p>
<pre name="code" class="javascript:nocontrols:nogutter">
&lt;div id="google_link"&gt;
	&lt;a style="text-decoration: none; font-weight: bold;" href="http://www.google.com"&gt;
		&lt;img style="width: 200px; height: 200px;" title="Google!" alt="Google!" src="http://www.google.com/intl/en_ALL/images/logo.gif" border="0"&gt;
		&lt;br /&gt;
		Click here to go to Google!
	&lt;/a&gt;
&lt;/div&gt;</pre>
<p>As you can see, it&#8217;s quite a bit easier to use than typing mynode.setAttribute 20 times. Here&#8217;s the source code:</p>
<pre name="code" class="javascript:nocontrols">
function createElements( args ) {
   var el;

   if( typeof(args) == "string" ) {

      el = document.createTextNode(args);

   } else if ( typeof(args) == "object" ) {

      el = document.createElement( args.tag );

      if ( args.attributes ) {
         for ( i in args.attributes ) {
            el.setAttribute(i, args.attributes[i]);
         }
      }
      if ( args.style ) {
         for ( i in args.style ) {
            el.style[i] = args.style[i];
         }
      }
      if ( args.children ) {
         for ( var i = 0; i &lt; args.children.length; i++ ) {
            el.appendChild( createElements( args.children[i] ) );
         }
      }

   }
   return el;
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://spudly.shuoink.com/2008/02/20/using-the-xml-dom-without-writing-150000-lines-of-code/feed/</wfw:commentRss>
		</item>
		<item>
		<title>PHP Error Log Parser</title>
		<link>http://spudly.shuoink.com/2008/02/17/php-error-log-parser/</link>
		<comments>http://spudly.shuoink.com/2008/02/17/php-error-log-parser/#comments</comments>
		<pubDate>Sun, 17 Feb 2008 15:15:34 +0000</pubDate>
		<dc:creator>spudly</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[code]]></category>

		<category><![CDATA[error log]]></category>

		<category><![CDATA[error log parser]]></category>

		<category><![CDATA[filter]]></category>

		<category><![CDATA[grouped by request]]></category>

		<category><![CDATA[parse error log]]></category>

		<category><![CDATA[regex]]></category>

		<category><![CDATA[regular expression]]></category>

		<category><![CDATA[source]]></category>

		<category><![CDATA[source code]]></category>

		<guid isPermaLink="false">http://spudly.shuoink.com/2008/02/17/php-error-log-parser/</guid>
		<description><![CDATA[So about a month ago I got pretty tired of looking at this:
[17-Feb-2008 07:33:52] PHP Parse error:  syntax error, unexpected T_FUNCTION, expecting &#8216;(&#8217; in C:\www\forms\validate.php on line 10
[17-Feb-2008 07:33:54] PHP Parse error:  syntax error, unexpected T_FUNCTION, expecting &#8216;(&#8217; in C:\www\forms\validate.php on line 10
[17-Feb-2008 07:34:08] PHP Fatal error:  Call to undefined function send_email() [...]]]></description>
			<content:encoded><![CDATA[<p>So about a month ago I got pretty tired of looking at this:</p>
<pre>[17-Feb-2008 07:33:52] PHP Parse error:  syntax error, unexpected T_FUNCTION, expecting &#8216;(&#8217; in C:\www\forms\validate.php on line 10
[17-Feb-2008 07:33:54] PHP Parse error:  syntax error, unexpected T_FUNCTION, expecting &#8216;(&#8217; in C:\www\forms\validate.php on line 10
[17-Feb-2008 07:34:08] PHP Fatal error:  Call to undefined function send_email() in C:\www\forms\email.php on line 32
[17-Feb-2008 07:34:39] PHP Parse error:  syntax error, unexpected T_STRING, expecting T_FUNCTION in C:\www\lib\User.php on line 379
[17-Feb-2008 07:34:55] PHP Parse error:  syntax error, unexpected $end in C:\www\login\login.php on line 134</pre>
<p>The PHP error log (or any error log for that matter) is really hard on the eyes. So, I decided to write an error log parser that would make things a little prettier. And here it is:</p>
<p align="center"><a href="http://spudly.shuoink.com/wp-content/uploads/2008/02/errors.jpg" title="Error Log Parser"><img src="http://spudly.shuoink.com/wp-content/uploads/2008/02/errors.thumbnail.jpg" alt="Error Log Parser" border="0" /></a>  <a href="http://spudly.shuoink.com/wp-content/uploads/2008/02/errors2.jpg" title="Error Log Parser - Source View"><img src="http://spudly.shuoink.com/wp-content/uploads/2008/02/errors2.thumbnail.jpg" alt="Error Log Parser - Source View" border="0" /></a></p>
<p>Features:</p>
<ul>
<li>Displays last $n errors (specified by user)</li>
<li>Filter errors by regex</li>
<li>PHP Built-In Function names link directly to their documentation on php.net</li>
<li>Line numbers and script names are clickable. Click the line number to view the source code for the offending code. The code will be displayed, with the selected line highlighted.</li>
<li>Errors grouped by request</li>
</ul>
<p>The parser is actually separated into 4 files.</p>
<ul>
<li>errors.php - the actual parser</li>
<li>errors.html.php - the &#8216;normal view&#8217; template</li>
<li>errors.source.html.php - the &#8217;source code view&#8217; template</li>
<li>errors.css - the css for the above templates</li>
</ul>
<p>Also, it is currently setup to use the template engine I uploaded a few days ago. If you don&#8217;t like that, it&#8217;s pretty easy to change. If you know your way around php (which I expect you do if you&#8217;re looking at the error logs), you can manipulate the parser and templates to work without my engine in about 5 mins.</p>
<p>Also, you can forego the templates completely and use the parser for your own purposes. Whatever you want.</p>
<p>Enjoy!</p>
<p align="center"><a href="/files/errors.zip">Download Now</a></p>
]]></content:encoded>
			<wfw:commentRss>http://spudly.shuoink.com/2008/02/17/php-error-log-parser/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Steal These Buttons! - CSS Sprite Style</title>
		<link>http://spudly.shuoink.com/2008/02/13/steal-these-buttons-css-sprite-style/</link>
		<comments>http://spudly.shuoink.com/2008/02/13/steal-these-buttons-css-sprite-style/#comments</comments>
		<pubDate>Thu, 14 Feb 2008 03:58:25 +0000</pubDate>
		<dc:creator>spudly</dc:creator>
		
		<category><![CDATA[CSS]]></category>

		<category><![CDATA[apache]]></category>

		<category><![CDATA[css sprite]]></category>

		<category><![CDATA[css2]]></category>

		<category><![CDATA[firefox]]></category>

		<category><![CDATA[html]]></category>

		<category><![CDATA[ie]]></category>

		<category><![CDATA[internet explorer]]></category>

		<category><![CDATA[linux]]></category>

		<category><![CDATA[mathml]]></category>

		<category><![CDATA[mysql]]></category>

		<category><![CDATA[opera]]></category>

		<category><![CDATA[perl]]></category>

		<category><![CDATA[PHP]]></category>

		<category><![CDATA[rss]]></category>

		<category><![CDATA[safari]]></category>

		<category><![CDATA[sprite]]></category>

		<category><![CDATA[stb]]></category>

		<category><![CDATA[steal these buttons]]></category>

		<category><![CDATA[stylesheet]]></category>

		<category><![CDATA[svg]]></category>

		<category><![CDATA[windows]]></category>

		<category><![CDATA[xhtml]]></category>

		<guid isPermaLink="false">http://spudly.shuoink.com/2008/02/13/steal-these-buttons-css-sprite-style/</guid>
		<description><![CDATA[We&#8217;ve all seen these buttons floating around the internet. Every other website you see uses them, proclaiming their standard compliance. They&#8217;re called &#8220;steal these buttons&#8221; and there are a number of websites where you can download them.
Here&#8217;s my set, in the form of a CSS Sprite. In case you don&#8217;t know what that is, a [...]]]></description>
			<content:encoded><![CDATA[<p>We&#8217;ve all seen these buttons floating around the internet. Every other website you see uses them, proclaiming their standard compliance. They&#8217;re called &#8220;steal these buttons&#8221; and there are a number of websites where you can download them.</p>
<p>Here&#8217;s my set, in the form of a CSS Sprite. In case you don&#8217;t know what that is, a css sprite is one image that gets split into many images using cascading style sheets. This way you load one big image instead of 50 small images, thus dramatically reducing the number of requests made by the web browser, which makes the page load much faster.</p>
<p>Here it is / Here they are:</p>
<style type="text/css">    .stb { float: left; } </style>
<link href="/lib/stb/stb.css" rel="stylesheet" type="text/css" /><a href="http://jigsaw.w3.org/css-validator/" class="stb stbCss"></a><a href="http://jigsaw.w3.org/css-validator/" class="stb stbCss2"></a><a href="http://validator.w3.org/check?uri=referer" class="stb stbHtml"></a><a href="http://validator.w3.org/check?uri=referer" class="stb stbHtml3"></a><a href="http://validator.w3.org/check?uri=referer" class="stb stbHtml3_2"></a><a href="http://validator.w3.org/check?uri=referer" class="stb stbHtml4"></a><a href="http://validator.w3.org/check?uri=referer" class="stb stbHtml4_01"></a><a href="http://validator.w3.org/check?uri=referer" class="stb stbHtml5"></a><a href="http://validator.w3.org/check?uri=referer" class="stb stbXhtml"></a><a href="http://validator.w3.org/check?uri=referer" class="stb stbXhtml1_1"></a><a href="http://validator.w3.org/check?uri=referer" class="stb stbXhtml2"></a><a href="http://validator.w3.org/check?uri=referer" class="stb stbMathml2_0"></a><a href="http://validator.w3.org/check?uri=referer" class="stb stbSvg1_0"></a><a href="http://www.getfirefox.com/" class="stb stbFirefox"></a><a href="http://www.opera.com/" class="stb stbOpera"></a><a href="http://www.microsoft.com/" class="stb stbIe4"></a><a href="http://www.microsoft.com/" class="stb stbIe5"></a><a href="http://www.microsoft.com/" class="stb stbIe5_5"></a><a href="http://www.microsoft.com/" class="stb stbIe6"></a><a href="http://www.microsoft.com/" class="stb stbIe7"></a><a href="http://www.apple.com/safari/" class="stb stbSafari"></a><a href="http://www.microsoft.com/" class="stb stbWindows"></a><a href="http://www.linux.org/" class="stb stbLinux"></a><a href="http://www.apache.org/" class="stb stbApache"></a><a href="http://www.mysql.com/" class="stb stbMysql"></a><a href="http://www.mysql.com/" class="stb stbMysql4"></a><a href="http://www.mysql.com/" class="stb stbMysql5"></a><a href="http://www.php.net/" class="stb stbPhp"></a><a href="http://www.php.net/" class="stb stbPhp4"></a><a href="http://www.php.net/" class="stb stbPhp5"></a><a href="http://www.perl.org/" class="stb stbPerl"></a><a href="http://www.perl.org/" class="stb stbPerl4"></a><a href="http://www.perl.org/" class="stb stbPerl5"></a><a href="http://www.perl.org/" class="stb stbPerl6"></a><a href="http://validator.w3.org/feed/check.cgi?url=myURL" class="stb stbRss1_0"></a><a href="http://validator.w3.org/feed/check.cgi?url=myURL" class="stb stbRss2_0"></a><a href="http://validator.w3.org/feed/check.cgi?url=myURL" class="stb stbRss3_0"></a>
<p style="clear: left">And here&#8217;s how you use it:</p>
<p>First, include the stylesheet.</p>
<pre name="code" class="css:nocontrols:nogutter">
   &lt;link href="stb.css" rel="stylesheet" type="text/css" /&gt;</pre>
<p>Second, add the image to the page. You do so by adding a link. Examples for each is contained in the test.html file included in the zip file.</p>
<pre name="code" class="css:nocontrols:nogutter">
   &lt;a href="http://jigsaw.w3.org/css-validator/" class="stb stbCss"&gt;&lt;/a&gt;</pre>
<p style="text-align: center"> <a href="/files/stb.zip">Download Now</a></p>
]]></content:encoded>
			<wfw:commentRss>http://spudly.shuoink.com/2008/02/13/steal-these-buttons-css-sprite-style/feed/</wfw:commentRss>
		</item>
		<item>
		<title>PHP Template Engine</title>
		<link>http://spudly.shuoink.com/2008/02/09/php-template-engine/</link>
		<comments>http://spudly.shuoink.com/2008/02/09/php-template-engine/#comments</comments>
		<pubDate>Sat, 09 Feb 2008 16:05:14 +0000</pubDate>
		<dc:creator>spudly</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[cache]]></category>

		<category><![CDATA[cached]]></category>

		<category><![CDATA[object oriented]]></category>

		<category><![CDATA[oo]]></category>

		<category><![CDATA[perldoc]]></category>

		<category><![CDATA[perlpod]]></category>

		<category><![CDATA[smarty]]></category>

		<category><![CDATA[template]]></category>

		<category><![CDATA[template toolkit]]></category>

		<category><![CDATA[templates]]></category>

		<guid isPermaLink="false">http://spudly.shuoink.com/2008/02/09/php-template-engine/</guid>
		<description><![CDATA[I&#8217;ve been looking for a good PHP template engine for quite a while now, but I haven&#8217;t been able to find one that I feel good about. In my bout of frustration, I made my own. Mine, however, is based on normal php tags, rather than creating my own new template language. Thus, you can [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been looking for a good PHP template engine for quite a while now, but I haven&#8217;t been able to find one that I feel good about. In my bout of frustration, I made my own. Mine, however, is based on normal php tags, rather than creating my own new template language. Thus, you can use real php functions within the template to format the data that is displayed. It&#8217;s also object oriented and supports caching.</p>
<p>Here&#8217;s a simple example:</p>
<p>PHP File:</p>
<pre name="code" class="php:nocontrols">
&lt;?php
   require('template.php');
   $template = new Template("./templates/");
   $template-&gt;setVars(array(
      "title" =&gt; "My Web Page",
      "hello" =&gt; "Hello World!"
   ));
   echo $template-&gt;process( "helloworld.html.php" );
?&gt;</pre>
<p>Template (HTML) File:</p>
<pre name="code" class="html:nocontrols">
&lt;html&gt;
   &lt;head&gt;
      &lt;title&gt;&lt;?php echo $title; ?&gt;&lt;/title&gt;
   &lt;/head&gt;
   &lt;body&gt;
      &lt;p&gt;
         &lt;?php echo $hello; ?&gt;
      &lt;/p&gt;
   &lt;/body&gt;
&lt;/html&gt;</pre>
<p><a href="/files/Template.zip">Download Now!</a></p>
<p>Note: This is still somewhat a work in progress. On my todo list is 1) improve cache handling (based on request headers), and 2) redocument the source with phpdoc instead of perldoc.</p>
]]></content:encoded>
			<wfw:commentRss>http://spudly.shuoink.com/2008/02/09/php-template-engine/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Pointers / References in JavaScript: a hack</title>
		<link>http://spudly.shuoink.com/2007/12/27/pointers-references-in-javascript-a-hack/</link>
		<comments>http://spudly.shuoink.com/2007/12/27/pointers-references-in-javascript-a-hack/#comments</comments>
		<pubDate>Thu, 27 Dec 2007 16:49:24 +0000</pubDate>
		<dc:creator>spudly</dc:creator>
		
		<category><![CDATA[JavaScript]]></category>

		<category><![CDATA[anonymous function]]></category>

		<category><![CDATA[Functions]]></category>

		<category><![CDATA[getter]]></category>

		<category><![CDATA[pass by]]></category>

		<category><![CDATA[pointer]]></category>

		<category><![CDATA[pointers]]></category>

		<category><![CDATA[reference]]></category>

		<category><![CDATA[references]]></category>

		<category><![CDATA[reference_to]]></category>

		<category><![CDATA[setInterval]]></category>

		<category><![CDATA[variable]]></category>

		<guid isPermaLink="false">http://spudly.shuoink.com/2007/12/27/pointers-references-in-javascript-a-hack/</guid>
		<description><![CDATA[I prefer to call them references, but some people call them pointers. Regardless of what you call them, any experienced programmer knows that references sometimes come in handy.
In JavaScript, objects and functions are already passed by reference (as long as you don&#8217;t use parenthesis after the function name). Unfortunately, there is no way to force [...]]]></description>
			<content:encoded><![CDATA[<p>I prefer to call them references, but some people call them pointers. Regardless of what you call them, any experienced programmer knows that references sometimes come in handy.</p>
<p>In JavaScript, objects and functions are already passed by reference (as long as you don&#8217;t use parenthesis after the function name). Unfortunately, there is no way to force other variable types to be passed by reference instead of by value.</p>
<p>Because I thought this was rediculous, I&#8217;ve created a javascript function that can be used to get a reference / pointer to a variable. Here it is:</p>
<pre name="code" class="javascript:nocontrols">
function reference_to( object, property ) {
   return function() {
      return object[property];
   }
}</pre>
<p>Essentially, this function returns a getter function. So, instead of a value you have an anonymous function that retrieves the value for you. To use it, call reference_to with the object as the first argument and the variable name as the second (in string form). For example:</p>
<pre name="code" class="javascript:nocontrols:nogutter">reference_to(node, "className");</pre>
<p>If the variable you&#8217;re trying to point to is not contained in an object (it&#8217;s a global variable), use window as the object, like this:</p>
<pre name="code" class="javascript:nocontrols:nogutter">var myVar = "blah";
reference_to(window, "myVar");</pre>
<p>Here&#8217;s a working, more in-depth example:</p>
<pre name="code" class="javascript:nocontrols:nogutter">
<script type="text/javascript">   
   function foo( getter ) {
      function bar() {
        alert( getter() );
      }
      window.setInterval( bar, 10000 );
   }
</script>
<form>
<input name="mytext" type="text" />
<input value="start" onclick="foo( reference_to(this.form.mytext,'value') );" type="button" />
</form>
</pre>
<p style="text-align: center">    <a href="/examples/reference_to.html">See this example in action.</a><br />(tested in IE7, Opera9, Firefox2, and Safari3)</p>
<p>This creates a text box and a start button. The start button has an onclick attribute which starts this script. When you click on the start button, the reference_to function is called with two arguments. The first argument is the object that contains the variable to point to, and the second argument is the name of the variable. In this case, we&#8217;re passing in the input box and &#8220;value&#8221;, which will get the text inside of the input box.</p>
<p>The reference_to function returns an anonymous getter function, which is then passed to the foo() function as the only argument. The foo function creates a scoped function named bar which alerts the current value of the text box by calling alert( getter() ) where getter is the anonymous getter function. Next, foo() tells the web browser to call bar() every 10 seconds with window.setInterval.</p>
<p>In other words&#8230; after you click start, an alert box will pop up every 10 seconds to tell you what text is currently contained in the input box.</p>
]]></content:encoded>
			<wfw:commentRss>http://spudly.shuoink.com/2007/12/27/pointers-references-in-javascript-a-hack/feed/</wfw:commentRss>
		</item>
		<item>
		<title>my version of the popular addEvent()</title>
		<link>http://spudly.shuoink.com/2007/12/08/my-version-of-the-popular-addevent/</link>
		<comments>http://spudly.shuoink.com/2007/12/08/my-version-of-the-popular-addevent/#comments</comments>
		<pubDate>Sat, 08 Dec 2007 17:35:25 +0000</pubDate>
		<dc:creator>spudly</dc:creator>
		
		<category><![CDATA[JavaScript]]></category>

		<category><![CDATA[addEvent]]></category>

		<category><![CDATA[event]]></category>

		<category><![CDATA[event handler]]></category>

		<category><![CDATA[event listener]]></category>

		<category><![CDATA[event_listener]]></category>

		<category><![CDATA[event_listener.add]]></category>

		<category><![CDATA[event_listener.remove]]></category>

		<category><![CDATA[handler]]></category>

		<category><![CDATA[listener]]></category>

		<category><![CDATA[onclick]]></category>

		<category><![CDATA[onload]]></category>

		<category><![CDATA[onmouseover]]></category>

		<category><![CDATA[onunload]]></category>

		<category><![CDATA[removeEvent]]></category>

		<category><![CDATA[unubtrusive javascript]]></category>

		<guid isPermaLink="false">http://spudly.shuoink.com/2007/12/08/my-version-of-the-popular-addevent/</guid>
		<description><![CDATA[Ok, so here is my version of the popular addEvent() javascript function.
usage:
event_listener.add( object, event_type, function );
Example:
function init() {
   alert("the page is fully loaded");
}
event_listener.add(window,"onload", init);
-OR -

event_listener.add(window, "onload", function init() {
   alert("the page is fully loaded");
});
Then you can also remove events as well. Remove them in the same manner you created them. Like [...]]]></description>
			<content:encoded><![CDATA[<p>Ok, so here is my version of the popular addEvent() javascript function.</p>
<p>usage:</p>
<pre name="code" class="javascript:nocontrols:nogutter">event_listener.add( object, event_type, function );</pre>
<p>Example:</p>
<pre name="code" class="javascript:nocontrols:nogutter">function init() {
   alert("the page is fully loaded");
}
event_listener.add(window,"onload", init);</pre>
<p>-OR -</p>
<pre name="code" class="javascript:nocontrols:nogutter">
event_listener.add(window, "onload", function init() {
   alert("the page is fully loaded");
});</pre>
<p>Then you can also remove events as well. Remove them in the same manner you created them. Like this:</p>
<pre name="code" class="javascript:nocontrols:nogutter">event_listener.remove( object, event_type, function );</pre>
<p>Example:</p>
<pre name="code" class="javascript:nocontrols:nogutter">function init() {
   alert("the page is fully loaded");
}
event_listener.remove(window,"onload", init);</pre>
<p>-OR -</p>
<pre name="code" class="javascript:nocontrols:nogutter">
event_listener.remove(window, "onload", function init() {
   alert("the page is fully loaded");
});</pre>
<p><span id="more-3"></span></p>
<p>Ok, so here&#8217;s the code:</p>
<pre name="code" class="javascript:nocontrols">var event_listener = {
   add: function(node, event_type, function_reference) {
      node = $(node);
      // if this is the first time an event has been added
      // to this node, setup the event handling system
      if(
         typeof node[event_type] != &#8216;function&#8217; ||
         typeof node[event_type+'_num'] == &#8216;undefined&#8217;
      ) {
         node[ event_type + '_num' ] = 0;
         if( typeof node[event_type] == &#8220;function&#8221; ) {
            node[event_type + 0] = node[event_type];
            node[event_type + '_num']++;
         }
         // setup the actual event listener (onclick, onmouseover, etc&#8230;)
         node[event_type] = function(e){
            e = (e) ? e : window.event;
            var return_value = true;
            for(var i = 0; i &lt; node[event_type + '_num']; i++) {
               if( node[event_type + i](e) === false) {
                  return_value = false;
               }
            }
            return return_value;
         }
      }
      // prevent duplicates - return if the function is already there
      for(var i = 0; i &lt; node[event_type + '_num']; i++) {
         if( node[event_type + i] == function_reference ) {
            return false;
         }
      }
      node[ event_type + node[ event_type + '_num' ] ] = function_reference;
      node[ event_type + '_num' ]++;
      return true;
   },
   remove: function(node, event_type, func) {
      node = $(node);

      // if the node is not setup for the event handling system, do nothing
      if(
         typeof node[event_type] != &#8216;function&#8217; ||
         typeof node[event_type + '_num'] == &#8216;undefined&#8217; ||
         node[event_type + '_num'] == 0
      ) {
         return false;
      }

      // loop through functions. once target function is found, remove it. shift
      // subsequent functions up one number (kindof like Array.splice(i,1); )
      var found = false;
      for( var i = 0; i &lt; node[event_type + '_num']; i++ ){
         if( !found ) {
            found = node[event_type+i] == func ||
            node[event_type+i].toString == func.toString;
         }
         if( found &amp;&amp; ( i + 1 ) &lt; node[event_type + '_num'] ) {
            node[ event_type + i] = node[event_type + ( i + 1 )];
         }
      }

      if(found) {
         node[event_type + '_num']&#8211;;
         return true;
      }

   }
};</pre>
<p>Inspired by and/or based on the following:<br />
<a href="http://barney.gonzaga.edu/%7Eamoore1/php/addEvent/">Aaron Moore&#8217;s addEvent()</a><br />
<a href="http://www.dustindiaz.com/rock-solid-addevent/">Dustin Diaz&#8217;s addEvent()</a></p>
]]></content:encoded>
			<wfw:commentRss>http://spudly.shuoink.com/2007/12/08/my-version-of-the-popular-addevent/feed/</wfw:commentRss>
		</item>
		<item>
		<title>more class functions&#8230;</title>
		<link>http://spudly.shuoink.com/2007/12/06/more-class-functions/</link>
		<comments>http://spudly.shuoink.com/2007/12/06/more-class-functions/#comments</comments>
		<pubDate>Fri, 07 Dec 2007 02:35:14 +0000</pubDate>
		<dc:creator>spudly</dc:creator>
		
		<category><![CDATA[JavaScript]]></category>

		<category><![CDATA[addClass]]></category>

		<category><![CDATA[array]]></category>

		<category><![CDATA[class]]></category>

		<category><![CDATA[className]]></category>

		<category><![CDATA[hasClass]]></category>

		<category><![CDATA[removeClass]]></category>

		<guid isPermaLink="false">http://spudly.shuoink.com/2007/12/06/more-class-functions/</guid>
		<description><![CDATA[Update: changed from Object.prototype.hasClass(className) to simply hasClass(element, className) for cross-browser compatibility
Ok&#8230; nothing to revolutionary here. This has been done before lots of times. I&#8217;ve written two new functions to go along with my hasClass() javascript function.
First is addClass(), which simply adds a class to an object, while preserving the existing classes. Here it is:
function addClass( [...]]]></description>
			<content:encoded><![CDATA[<p>Update: changed from Object.prototype.hasClass(className) to simply hasClass(element, className) for cross-browser compatibility</p>
<p>Ok&#8230; nothing to revolutionary here. This has been done before lots of times. I&#8217;ve written two new functions to go along with my hasClass() javascript function.</p>
<p>First is addClass(), which simply adds a class to an object, while preserving the existing classes. Here it is:</p>
<pre name="code" class="javascript:nocontrols">function addClass( /*HTMLElement:*/node, /*String:*/className ) {
   if( !hasClass(node, className) ) {
      node.className = node.className + (node.className ? " " : "") + className;
      return true;
   }
   return false;
};</pre>
<p>Use it like this:</p>
<pre name="code" class="javascript:nogutter:nocontrols">addClass(myNode, "myclass");</pre>
<p>Next is the removeClass function, which removes a css class from an object. Here it is:</p>
<pre name="code" class="javascript:nocontrols">function removeClass( /*HTMLElement:*/node, /*String:*/className ) {
   if( hasClass(node, className ) {
      node.className = (' '+node.className+' ').replace(' '+className+' ',' ').replace(/^ | $/,'');
      return true;
   }
   return false;
}</pre>
<p>And here&#8217;s how you use removeClass():</p>
<pre name="code" class="javascript:nogutter:nocontrols">removeClass(myNode, "myclass");</pre>
<p>Like I said, nothing revolutionary, but here they are.</p>
]]></content:encoded>
			<wfw:commentRss>http://spudly.shuoink.com/2007/12/06/more-class-functions/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Object.hasClass()</title>
		<link>http://spudly.shuoink.com/2007/12/01/objecthasclass/</link>
		<comments>http://spudly.shuoink.com/2007/12/01/objecthasclass/#comments</comments>
		<pubDate>Sun, 02 Dec 2007 04:31:46 +0000</pubDate>
		<dc:creator>spudly</dc:creator>
		
		<category><![CDATA[JavaScript]]></category>

		<category><![CDATA[class]]></category>

		<category><![CDATA[function]]></category>

		<category><![CDATA[getElementsByClass]]></category>

		<category><![CDATA[getElementsWhere]]></category>

		<category><![CDATA[hasClass object]]></category>

		<guid isPermaLink="false">http://spudly.shuoink.com/2007/12/01/objecthasclass/</guid>
		<description><![CDATA[Update: For compatibility, Object.hasClass(className) is being changed to simply hasClass(node, className).
Inspired by the dojo toolkit, this function checks to see if a given class is assigned to a node. Simply run it like this:
var my_node = document.getElementsById("mydiv");
if( hasClass(my_node, "myclass") ) {
   // ...do something
}
Enough talk; here&#8217;s the code:
function hasClass( /*HTMLElement:*/node, /*String:*/value ) {
	return [...]]]></description>
			<content:encoded><![CDATA[<p>Update: For compatibility, Object.hasClass(className) is being changed to simply hasClass(node, className).</p>
<p>Inspired by the dojo toolkit, this function checks to see if a given class is assigned to a node. Simply run it like this:</p>
<pre name="code" class="javascript:nocontrols:nogutter">var my_node = document.getElementsById("mydiv");
if( hasClass(my_node, "myclass") ) {
   // ...do something
}</pre>
<p>Enough talk; here&#8217;s the code:</p>
<pre name="code" class="javascript:nocontrols">function hasClass( /*HTMLElement:*/node, /*String:*/value ) {
	return (" "+node.className+" ").match(" "+value+" ") ? true : false;
};</pre>
<p>It works like this. Since the class attribute has multiple values separated by spaces, you simply add a space to the beginning and one to the end. Then add spaces to the beginning of the value. Then if the value string is contained within the class string, the element has the class.</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://spudly.shuoink.com/2007/12/01/objecthasclass/feed/</wfw:commentRss>
		</item>
		<item>
		<title>the ultimate getElementsBy*: Object.getElementsWhere()</title>
		<link>http://spudly.shuoink.com/2007/12/01/the-ultimate-getelementsby-objectgetelementswhere/</link>
		<comments>http://spudly.shuoink.com/2007/12/01/the-ultimate-getelementsby-objectgetelementswhere/#comments</comments>
		<pubDate>Sun, 02 Dec 2007 04:14:13 +0000</pubDate>
		<dc:creator>spudly</dc:creator>
		
		<category><![CDATA[JavaScript]]></category>

		<category><![CDATA[array]]></category>

		<category><![CDATA[comparison]]></category>

		<category><![CDATA[eval]]></category>

		<category><![CDATA[evaluation]]></category>

		<category><![CDATA[getElementsBy]]></category>

		<category><![CDATA[getElementsByAny]]></category>

		<category><![CDATA[getElementsByClass]]></category>

		<category><![CDATA[getElementsByClassName]]></category>

		<category><![CDATA[getElementsById(regex)]]></category>

		<category><![CDATA[getElementsByTagName]]></category>

		<category><![CDATA[getElementsWhere]]></category>

		<category><![CDATA[HTMLElement]]></category>

		<category><![CDATA[object]]></category>

		<category><![CDATA[operator]]></category>

		<category><![CDATA[push]]></category>

		<guid isPermaLink="false">http://spudly.shuoink.com/2007/12/01/the-ultimate-getelementsby-objectgetelementswhere/</guid>
		<description><![CDATA[Update: for compatibility, Object.getElementsWhere(&#8221;condition&#8221;) is being changed to getElementsWhere(node, condition) where node is the node to search in.
I&#8217;ve looked a lot lately at the getElementsByClass() function and other getElementsBy functions, but they all seemed rather inadequate to me.
I rewrote the function about three times before I figured out what to do. What I really wanted [...]]]></description>
			<content:encoded><![CDATA[<p>Update: for compatibility, Object.getElementsWhere(&#8221;condition&#8221;) is being changed to getElementsWhere(node, condition) where node is the node to search in.</p>
<p>I&#8217;ve looked a lot lately at the getElementsByClass() function and other getElementsBy functions, but they all seemed rather inadequate to me.</p>
<p>I rewrote the function about three times before I figured out what to do. What I really wanted was a function that could perform a custom comparison on a property of an html element. What I finally came up with was a function that could take a comparison as a string and execute it on each element within the object you run it for. For example:</p>
<p>The following code will get all elements inside of the mydiv element that have a width less than 100:</p>
<pre name="code" class="javascript:nocontrols:nogutter">getElementsWhere(mydiv "width &lt; 100" );</pre>
<p>The combinations you can choose are endless. Use any comparison operator you want! You can also run functions that belong to the object on the value before it is compared. For example, if you need to compare the css width of a node, do this:</p>
<p>For numeric style attributes, do something like this:</p>
<pre name="code" class="javascript:nocontrols:nogutter">getElementsWhere( document, "style.width.replace('px','') &gt; 100" );</pre>
<p>The idea that sparked all this was my desire for a getElementsById(regex) function. Hence, you can also perform regular expressions on the value of the objects, like this:</p>
<pre name="code" class="javascript:nocontrols:nogutter">getElementsWhere(document "id.match( /^image_/ )");</pre>
<p>In fact, you can perform any of the functions that apply to the variable type of the element&#8217;s attribute you specify.<br />
<span id="more-4"></span><br />
Here&#8217;s the code:</p>
<pre name="code" class="javascript:nocontrols">function getElementsWhere( /*HTMLElement:*/node, /*String:*/comparison) {
   var found = [];
   var all = node.getElementsByTagName(&#8221;*&#8221;);
   for( var i = 0; i &lt; all.length; i++ ) {
      if( eval( &#8220;all[i].&#8221; + comparison ) ) {
         found.push( all[i] );
      }
   }
   return found;
};</pre>
<p>And here&#8217;s how it works&#8230;</p>
<p>First, create two arrays. The found array starts out empty and will contain each element who&#8217;s attribute matches the comparison. The all array contains every html element on the page.</p>
<pre name="code" class="javascript:nocontrols:nogutter">   var found = [];
   var all = node.getElementsByTagName(&#8221;*&#8221;);</pre>
<p>Then we loop through each array element in the &#8216;all&#8217; array:</p>
<pre name="code" class="javascript:nocontrols:nogutter">   for( var i = 0; i &lt; all.length; i++ ) {</pre>
<p>Below, we perform the comparison. It&#8217;s really quite simple. Since the comparison was passed in as a string, we simply use eval to run it as part of the code. So if comparison is &#8220;width == 100&#8243;, then the code below really is equivalent to: if( all[i].width == 100 )</p>
<pre name="code" class="javascript:nocontrols:nogutter">      if( eval( "all[i].&#8221; + comparison ) ) {</pre>
<p>If the comparison evaluated to true, push the element onto the found array:</p>
<pre name="code" class="javascript:nocontrols:nogutter">         found.push( all[i] );</pre>
<p>Then return the found array to the caller:</p>
<pre name="code" class="javascript:nocontrols:nogutter">   return found;</pre>
<p>Well, I hope you like it!</p>
]]></content:encoded>
			<wfw:commentRss>http://spudly.shuoink.com/2007/12/01/the-ultimate-getelementsby-objectgetelementswhere/feed/</wfw:commentRss>
		</item>
		<item>
		<title>alert(&#8217;Hello world!&#8217;);</title>
		<link>http://spudly.shuoink.com/2007/11/29/hello-world/</link>
		<comments>http://spudly.shuoink.com/2007/11/29/hello-world/#comments</comments>
		<pubDate>Thu, 29 Nov 2007 19:27:15 +0000</pubDate>
		<dc:creator>spudly</dc:creator>
		
		<category><![CDATA[General]]></category>

		<category><![CDATA[blog]]></category>

		<category><![CDATA[function]]></category>

		<category><![CDATA[hello world]]></category>

		<category><![CDATA[JavaScript]]></category>

		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://spudly.shuoink.com/?p=1</guid>
		<description><![CDATA[So here&#8217;s my new blog - dedicated to sharing and explaining the functions that I write in javascript, php, and others &#8230;
]]></description>
			<content:encoded><![CDATA[<p>So here&#8217;s my new blog - dedicated to sharing and explaining the functions that I write in javascript, php, and others &#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://spudly.shuoink.com/2007/11/29/hello-world/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
