<?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>dingobytes &#187; Javascript</title>
	<atom:link href="http://www.dingobytes.com/category/javascript/feed" rel="self" type="application/rss+xml" />
	<link>http://www.dingobytes.com</link>
	<description>what your nephew can't make you</description>
	<lastBuildDate>Fri, 11 Jun 2010 03:26:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>My JavaScript Tool Kit</title>
		<link>http://www.dingobytes.com/javascript/my-javascript-tool-kit</link>
		<comments>http://www.dingobytes.com/javascript/my-javascript-tool-kit#comments</comments>
		<pubDate>Wed, 04 Mar 2009 00:21:19 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[best practice]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://www.dingobytes.com/?p=62</guid>
		<description><![CDATA[I have put together a “tool” kit of sorts to help anyone who is just starting out with scripting with javascript. I used javascript sparingly the first few years that I was scripting web applications and sites and it wasn&#8217;t until the last year that I really became infatuated with the scripting language. My understanding [...]]]></description>
			<content:encoded><![CDATA[<p>I have put together a “tool” kit of sorts to help anyone who is just starting out with scripting with javascript. I used javascript sparingly the first few years that I was scripting web applications and sites and it wasn&#8217;t until the last year that I really became infatuated with the scripting language.</p>
<p>My understanding of javascript has increased as I have scoured google.com looking for functions and frameworks to fulfill my page or project needs, but I still feel there is a lot more to learn. I have decided to create this list to help anyone who might just be starting out and needs some direction.<span id="more-62"></span></p>
<ol>
<li>Pick up a copy of “DOM Scripting: Web Design with JavaScript and the Document Object Model” by Jeremy Keith. This book is not easy enough to understand, but it also reminds new javascript users about graceful degradation. Before using any framework, I used many of the scripts in the book religiously. (find the book at http://www.friendsofed.com/book.html?isbn=9781590595336)</li>
<li>Use good web developer tools. Depending on your browser, make sure you are using web developer tools and checking for errors. Firebug is very popular for Firefox browser, but I still prefer the Web Developer tool bar. Microsoft offers a web developer tool bar for free download as well, but this does not have any javascript debugging included. You will need to enable javascript debugging in the IE browser and I would suggest downloading the Microsoft Debugging tool. (Firefox Web Developer: https://addons.mozilla.org/en-US/firefox/addon/60, Firefox Firebug: https://addons.mozilla.org/en-US/firefox/addon/1843 and Microsoft Script Debugger: http://www.microsoft.com/Downloads/details.aspx?familyid=2F465BE0-94FD-4569-B3C4-DFFDF19CCD99&amp;displaylang=en)</li>
<li>Never depend on javascript. Good mark up will always gracefully degrade so that the end product is accessible and usable.</li>
<li>Use the javascript validator at http://jslint.com. Douglas Crockford knows his javascript and his validator (even though it is strict) will help you write good script.</li>
<li>Once your javascript validates, you can minify your script using one of the many javascript compressor/minification tools available. I have used http://javascriptcompressor.com/ with the Base62 encode and shrink variables checked and it has worked well. Another that I just started using is Closure Compiler found here: http://code.google.com/closure/compiler/</li>
<li>Once you are comfortable with javascript, use a framework to speed development. There are several frameworks available such as Jquery, YUI, Prototype, Dojo, Mootools, etc. Find the framework that best suits your needs and learn to use it.</li>
</ol>
<p>I hope this toolkit will help you create accessible and usable applications. I might add to it as I think of more, but this is a great start (I know I wish I would have had it to start with).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dingobytes.com/javascript/my-javascript-tool-kit/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>showMessage</title>
		<link>http://www.dingobytes.com/tutorial/showmessage</link>
		<comments>http://www.dingobytes.com/tutorial/showmessage#comments</comments>
		<pubDate>Tue, 28 Oct 2008 03:47:16 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[message]]></category>
		<category><![CDATA[validation]]></category>

		<guid isPermaLink="false">http://www.dingobytes.com/?p=21</guid>
		<description><![CDATA[Having to mess with forms all the time, I was beginning to go crazy tweeking different messages. One for success, one for failure, one for help, etc. I decided to try to combine some css with some javascript to make a nice reusable piece to display my form messages. Here is the fruit of that [...]]]></description>
			<content:encoded><![CDATA[<p>Having to mess with forms all the time, I was beginning to go crazy tweeking different messages. One for success, one for failure, one for help, etc.</p>
<p>I decided to try to combine some css with some javascript to make a nice reusable piece to display my form messages. Here is the fruit of that labor.</p>
<p>The function is going to take three arguments. The first argument is a message and or list of messages. The second is the id of the node you would like to stick the message before. The last argument is a classname.</p>
<p><span id="more-21"></span></p>
<pre class="brush: javascript">
/*global document */
function showMessage(thismessage, location_id, classname) {
//first clear showmessage div
if (document.getElementById(&quot;showmessage&quot;)) {
var clearerror = document.getElementById(&quot;showmessage&quot;);
clearerror.parentNode.removeChild(clearerror);
}
</pre>
<p>The first part of the function will check to see if the div “showmessage” exists. If it does then it will remove it from the document.</p>
<pre class="brush: javascript">
// create an showmessage div
var location = document.getElementById(location_id);
</pre>
<p>We define the location so it can be used later. Below we create a new div and set the id attribute to showmessage. We then can style the div for each instance using the className. After that we create an unordered list.</p>
<p>With the list ready, the messages can then be put into an array. We will split the messages up in this example with a pipe &#8220;|&#8221;.  You can substitute your own delimiter.</p>
<pre class="brush: javascript">
var showmessagediv = document.createElement(&quot;div&quot;);
showmessagediv.setAttribute(&quot;id&quot;, &quot;showmessage&quot;);
showmessagediv.className = classname;
var showmessageul = document.createElement(&quot;ul&quot;);
showmessageul.setAttribute(&quot;id&quot;, classname + &quot;list&quot;);
var showmessage = [];
showmessage = thismessage.split(&quot;|&quot;);
var i;
for (i = 0; i &lt; showmessage.length; i++) {
var showmessageli = document.createElement(&quot;li&quot;);
var showmessagelitxt = document.createTextNode(showmessage[i]);
showmessageli.appendChild(showmessagelitxt);
showmessageul.appendChild(showmessageli);
}
showmessagediv.appendChild(showmessageul);
location.parentNode.insertBefore(showmessagediv, location);
// have to add this to display error until css corrected
}
</pre>
<p>Looping through the array, we create a new list element and insert the message. We append the message to the new list element and then append the list element to the unordered list element. When it is all done then we append the unordered list to the showmessage div. The last step of the function is to insert the new showmessage div right before the location_id.</p>
<p>Attached is the style I used with both the successful messages and the unsuccessfull images.</p>
<pre class="brush: css">
.errormsg {
clear: both;
display: block;
width: 90%;
color: #FFFFFF;
font-weight: bold;
background-color: #FF9D9D;
padding: 9px 10px 6px 40px;
margin: 10px 0;
border: 2px solid #FF0000;
}

.successmsg {
clear: both;
display: block;
width: 90%;
color: #333333;
font-weight: bold;
background-color: #9bc19b;
padding: 9px 10px 6px 40px;
margin: 10px 0;
border: 2px solid #039b03;
}

#errormsglist, #successmsglist {
margin-left: 0;
padding-left: 0;
list-style: none;
}

#errormsglist li, #successmsglist li{
padding-left: 20px;
background-repeat: no-repeat;
background-position: 0;
}

#errormsglist li { background-image: url(/icon/exclamation.png); }

#successmsglist li { background-image: url(/icon/accept.png); }
</pre>
<p>You can modify the CSS and change the class name to what ever you wish. The only think to remember is if you style the list, to append &#8220;list&#8221; to the style.</p>
<p><a href="http://www.dingobytes.com/wp-content/uploads/2008/11/showmessage.js">showMessage.js</a></p>
<p><a href="http://www.dingobytes.com/wp-content/uploads/2008/10/showmessage.css">showMessage.css<br />
</a></p>
<div id="attachment_28" class="wp-caption alignnone" style="width: 26px"><a href="http://www.dingobytes.com/wp-content/uploads/2008/10/exclamation.png"><img class="size-medium wp-image-28" title="exclamation.png" src="http://www.dingobytes.com/wp-content/uploads/2008/10/exclamation.png" alt="exclamation.png" width="16" height="16" /></a><p class="wp-caption-text">exclamation.png</p></div>
<div id="attachment_27" class="wp-caption alignnone" style="width: 26px"><a href="http://www.dingobytes.com/wp-content/uploads/2008/10/accept.png"><img class="size-medium wp-image-27" title="accept.png" src="http://www.dingobytes.com/wp-content/uploads/2008/10/accept.png" alt="accept.png" width="16" height="16" /></a><p class="wp-caption-text">accept.png</p></div>
<p><a href="http://www.dingobytes.com/wp-content/uploads/2008/10/showmessage.css"></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.dingobytes.com/tutorial/showmessage/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Lame Mouse Over Effect</title>
		<link>http://www.dingobytes.com/tutorial/lame-mouse-over-effect</link>
		<comments>http://www.dingobytes.com/tutorial/lame-mouse-over-effect#comments</comments>
		<pubDate>Thu, 03 Apr 2008 07:07:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[effect]]></category>
		<category><![CDATA[mouseover]]></category>

		<guid isPermaLink="false">http://www.dingobytes.com/?p=8</guid>
		<description><![CDATA[So at work today, I wanted to see if I could create a lame mouse over effect to let feel like they were highlighting a listing. I wanted to pop out the moused over listing on the page by putting a thin border around the moused over div and then change the background. I was [...]]]></description>
			<content:encoded><![CDATA[<p>So at work today, I wanted to see if I could create a lame mouse over effect to let feel like they were highlighting a listing.  I wanted to pop out the moused over listing on the page by putting a thin border around the moused over div and then change the background. I was able to create the effect with javascript and coldfusion very easily. Because I don&#8217;t host this site on a coldfusion server, I will just show the javascript with some rendered HTML.</p>
<p><span id="more-8"></span>To save some time, I will explain the javascript and how to call it. You can grab the css from the example page.</p>
<pre id="line149">
<pre class="brush: javascript">
&lt;script type=&quot;text/javascript&quot;&gt;
//&lt;![CDATA[
var listing = {

g:function(id) {
    return document.getElementById(id);
},

// function to change the background and border of listing on mouse over
highlight:function(id) {
    listing_el = listing.g(&quot;listing&quot; + id);
    if(id != 1) { //this is what to do for all divs other then first one
        id_above = id - 1;
        listing_above_el = listing.g(&quot;listing&quot; + id_above);
        listing_above_el.style.border = &quot;#fff 2px solid&quot;; //removes border on result above highlighted
        listing_el.style.backgroundColor = &quot;#fffae7&quot;;
        listing_el.style.border = &quot;#837b97&quot;;
    }
    else {
        listing_el.className = &quot;highlight_el&quot;;
        listing_el.style.backgroundColor = &quot;#fffae7&quot;;
        listing_el.style.border = &quot;#837b97&quot;;
    }
},

normal:function(id) {
    listing_el = listing.g(&quot;listing&quot; + id);
    if(id != 1) {
        id_above = id - 1;
        listing_above_el = listing.g(&quot;listing&quot; + id_above);
        listing_above_el.style.borderBottom = &quot;#cccccc 2px dotted&quot;; //restores border to result above highlighted
	listing_el.style.backgroundColor = &quot;#ffffff&quot;;
	listing_el.style.border = &quot;#ffffff 2px solid&quot;;
        listing_el.style.borderBottom = &quot;#cccccc 2px dotted&quot;;
    }
    else {
        listing_el.className = &quot;normal_el&quot;;
        listing_el.style.backgroundColor = &quot;#ffffff&quot;;
	listing_el.style.border = &quot;#ffffff 2px solid&quot;;
        listing_el.style.borderBottom = &quot;#cccccc 2px dotted&quot;;
    }
}
//]]&gt;
&lt;/script&gt;
</pre>
</pre>
<p>The HTML can be spit through some query or loop and is straight forward.</p>
<p><code>
<pre class="brush: html">
&lt;div id=&quot;listing1&quot; class=&quot;listing&quot; onmouseover=&quot;listing.highlight(&#039;1&#039;);&quot; onmouseout=&quot;listing.normal(&#039;1&#039;);&quot;&gt;
&lt;div id=&quot;listing_top&quot;&gt;
&lt;span class=&quot;left&quot;&gt;
&lt;a href=&quot;javascript:void(0);&quot; title=&quot;121 Initech Rd&quot;&gt;121 Initech Rd&lt;/a&gt;
&lt;/span&gt;
&lt;/div&gt;
&lt;div id=&quot;listing_left&quot;&gt;
&lt;a href=&quot;javascript:void(0);&quot; title=&quot;121 Initech Rd&quot;&gt;&lt;img src=&quot;images/inventory/thumbs/0/0/0/000976.jpg&quot; alt=&quot;121 Initech Rd&quot; class=&quot;displayed&quot; width=&quot;151&quot; /&gt;&lt;/a&gt;
2.00 bed 3.00 bath 1296 sqft&lt;br /&gt;
Lake Home&lt;br /&gt;
Listing: 08-1979
&lt;/div&gt;
&lt;div id=&quot;listing_right&quot;&gt;&lt;span class=&quot;large_price&quot;&gt;$198699&lt;/span&gt; One morning, when Gregor Samsa woke from troubled dreams, he found himself transformed in his bed into a horrible vermin. He lay on his armour-like back, and if he lifted his head a little he could see his brown belly, slightly domed and divided by arches into stiff sections. The bedding was hardly able to cover it and seemed ready to slide off any moment. His many legs, pitifully thin compared with the size of the rest of him, waved about helplessly as he looked. &quot;What&#039;s happened to me? &quot; he thought. It wasn&#039;t a dream.&lt;/div&gt;
&lt;div class=&quot;clear&quot;&gt;&lt;/div&gt;
&lt;/div&gt;&lt;/code&gt;&lt;/code&gt;

&lt;code&gt;&lt;div id=&quot;listing2&quot; class=&quot;listing&quot; onmouseover=&quot;listing.highlight(&#039;2&#039;);&quot; onmouseout=&quot;listing.normal(&#039;2&#039;);&quot;&gt;
&lt;div id=&quot;listing_top&quot;&gt;
&lt;span class=&quot;left&quot;&gt;
&lt;a href=&quot;javascript:void(0);&quot; title=&quot;121 Initech Rd&quot;&gt;121 Initech Rd&lt;/a&gt;
&lt;/span&gt;
&lt;/div&gt;
&lt;div id=&quot;listing_left&quot;&gt;
&lt;a href=&quot;javascript:void(0);&quot; title=&quot;121 Initech Rd&quot;&gt;&lt;img src=&quot;images/inventory/thumbs/0/0/0/000976.jpg&quot; alt=&quot;121 Initech Rd&quot; class=&quot;displayed&quot; width=&quot;151&quot; /&gt;&lt;/a&gt;
2.00 bed 3.00 bath 1296 sqft&lt;br /&gt;
Lake Home&lt;br /&gt;
Listing: 08-1979
&lt;/div&gt;
&lt;div id=&quot;listing_right&quot;&gt;&lt;span class=&quot;large_price&quot;&gt;$198699&lt;/span&gt; His room, a proper human room although a little too small, lay peacefully between its four familiar walls. A collection of textile samples lay spread out on the table - Samsa was a travelling salesman - and above it there hung a picture that he had recently cut out of an illustrated magazine and housed in a nice, gilded frame. It showed a lady fitted out with a fur hat and fur boa who sat upright, raising a heavy fur muff that covered the whole of her lower arm towards the viewer.&lt;/div&gt;
&lt;div class=&quot;clear&quot;&gt;&lt;/div&gt;
&lt;/div&gt;
</pre>
<p>This can be completed repeated and by dynamically changing the value <em>i</em> you can populate the results so that</p>
<p><code>[sourcecode language='html']<br />
&lt;div id="listing<em>i</em>" class="listing" onmouseover="listing.highlight('<em>i</em>');" onmouseout="listing.normal('<em>i</em>');"&gt;</code></p>
<p>You can see the <a title="finished product" href="http://www.dingobytes.com/example/results.html" target="_blank">finished product here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dingobytes.com/tutorial/lame-mouse-over-effect/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
