<?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>techrageo.us &#187; Javascript</title>
	<atom:link href="http://techrageo.us/taxonomy/categories/programming/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://techrageo.us</link>
	<description>insight on technology</description>
	<lastBuildDate>Sat, 22 Oct 2011 12:18:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>jQuery For Firebug</title>
		<link>http://techrageo.us/2008/03/05/jquery-for-firebug/</link>
		<comments>http://techrageo.us/2008/03/05/jquery-for-firebug/#comments</comments>
		<pubDate>Thu, 06 Mar 2008 01:00:43 +0000</pubDate>
		<dc:creator>bill</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[bookmarklet]]></category>
		<category><![CDATA[firebug]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://techrageo.us/2008/03/05/jquery-for-firebug/</guid>
		<description><![CDATA[Load jQuery in a Firebug session. When debugging or poking around in sites where jQuery is not already used, I had been pasting the following code into the multi-line FireBug console and hitting Run. This makes jQuery available for debugging, etc. j=document.createElement&#40;&#34;SCRIPT&#34;&#41;; j.src=&#34;http://code.jquery.com/jquery-latest.pack.js&#34;; document.getElementsByTagName&#40;&#34;HEAD&#34;&#41;&#91;0&#93;.appendChild&#40;j&#41;; If you use Firebug, this is a handy way to make [...]]]></description>
			<content:encoded><![CDATA[<h3>Load jQuery in a Firebug session.</h3>
<p>When debugging or poking around in sites where jQuery is not already used, I had been pasting the following code into the multi-line <a href="http://www.getfirebug.com/">FireBug</a> console and hitting Run. This makes jQuery available for debugging, etc.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">j<span style="color: #339933;">=</span>document.<span style="color: #660066;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;SCRIPT&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
j.<span style="color: #660066;">src</span><span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;http://code.jquery.com/jquery-latest.pack.js&quot;</span><span style="color: #339933;">;</span>
document.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;HEAD&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">appendChild</span><span style="color: #009900;">&#40;</span>j<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>If you use Firebug, this is a handy way to make it even <em>more</em> powerful.</p>
<p><strong>Make it a bookmarklet.</strong></p>
<p>Of course, that whole process got old fast, so I created a bookmarklet to do the same thing, but save me from having to paste and run it in Firebug.</p>
<p>Drag this link: <a href='javascript:void((function(){j=document.createElement("SCRIPT");j.src="http://code.jquery.com/jquery-latest.pack.js";document.getElementsByTagName("HEAD")[0].appendChild(j);})())'>Load jQuery</a> to your Firefox bookmark toolbar, then just click it to inject jQuery into a page.</p>
<p>The bookmarklet code:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">javascript<span style="color: #339933;">:</span><span style="color: #000066; font-weight: bold;">void</span><span style="color: #009900;">&#40;</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>j<span style="color: #339933;">=</span>document.<span style="color: #660066;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;SCRIPT&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> j.<span style="color: #660066;">src</span><span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;http://code.jquery.com/jquery-latest.pack.js&quot;</span><span style="color: #339933;">;</span> document.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;HEAD&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">appendChild</span><span style="color: #009900;">&#40;</span>j<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: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span></pre></div></div>

<p>And nicely formatted:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">javascript<span style="color: #339933;">:</span><span style="color: #000066; font-weight: bold;">void</span><span style="color: #009900;">&#40;</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>
  j<span style="color: #339933;">=</span>document.<span style="color: #660066;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;SCRIPT&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  j.<span style="color: #660066;">src</span><span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;http://code.jquery.com/jquery-latest.pack.js&quot;</span><span style="color: #339933;">;</span>
  document.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;HEAD&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">appendChild</span><span style="color: #009900;">&#40;</span>j<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: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span></pre></div></div>

<p>Then in Firebug, you can use jQuery selectors and so forth to debug the page. Obviously you&#8217;ll have to re-inject each time the page (or a new page) is loaded.</p>
<p><strong>Great, I&#8217;ve reinvented the wheel.</strong></p>
<p>Of course, a bit of searching revealed that John Resig himself posted a bookmarklet called <a href="http://ejohn.org/blog/hacking-digg-with-firebug-and-jquery/">jQuerify</a>&#8211;almost identical to this one&#8211;linked in <a href="http://ajaxian.com/archives/hacking-digg-with-firebug-and-jquery">this Ajaxian article</a>.</p>
<p>The bookmarklet envelopes are different, but both do a simple script injection into the DOM.</p>
]]></content:encoded>
			<wfw:commentRss>http://techrageo.us/2008/03/05/jquery-for-firebug/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Show Password Fields</title>
		<link>http://techrageo.us/2007/11/21/show-password-fields/</link>
		<comments>http://techrageo.us/2007/11/21/show-password-fields/#comments</comments>
		<pubDate>Wed, 21 Nov 2007 04:48:52 +0000</pubDate>
		<dc:creator>bill</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Bookmarklets]]></category>

		<guid isPermaLink="false">http://techrageo.us/2007/11/21/show-password-fields/</guid>
		<description><![CDATA[Update: had a case-sensitive bug in the code. Fixed now. A simple Javascript bookmarklet shows password field values. In form fields where a password is entered, it is usually obscured by asterisks or bullets to prevent someone from seeing what you type. This is a great feature but where a long password is being typed [...]]]></description>
			<content:encoded><![CDATA[<p>Update: had a case-sensitive bug in the code. Fixed now.</p>
<p><strong>A simple Javascript bookmarklet shows password field values.</strong></p>
<p>In form fields where a password is entered, it is usually obscured by asterisks or bullets to prevent someone from seeing what you type. This is a great feature but where a long password is being typed or a remembered password is filled in by the browser, you might want to actually see the actual password itself.</p>
<h3>Show Password Bookmarklet</h3>
<p>Here is a bookmarklet (a snippet of Javascript that can be pasted into the address bar of your web browser), that will show any passwords on a page that contain password form fields.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">javascript<span style="color: #339933;">:</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: #003366; font-weight: bold;">var</span> s<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #339933;">,</span>F<span style="color: #339933;">=</span>document.<span style="color: #660066;">forms</span><span style="color: #339933;">,</span>j<span style="color: #339933;">,</span>f<span style="color: #339933;">,</span>i<span style="color: #339933;">;</span>for <span style="color: #009900;">&#40;</span>j<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> j<span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>F.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> <span style="color: #339933;">++</span>j<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> f<span style="color: #339933;">=</span>F<span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>f.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> <span style="color: #339933;">++</span>i<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>f<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">type</span>.<span style="color: #660066;">toLowerCase</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot;password&quot;</span><span style="color: #009900;">&#41;</span> s <span style="color: #339933;">+=</span> f<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>s<span style="color: #009900;">&#41;</span> <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Password fields:<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #339933;">+</span> s<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;No password fields on this page.&quot;</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: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Just paste the above javascript into the address bar of your browser and press Enter, or create a bookmarklet link with the javascript as the URL. On this page you&#8217;ll see the password for the mock sign on form below.</p>
<table style="margin-bottom: 20px;">
<tbody>
<tr>
<td>User Name:</td>
<td>
<input type="text" value="myusername" /></td>
<td>Password:</td>
<td>
<input type="password" value="topsecret" /></td>
</tr>
</tbody>
</table>
<p><strong>This is nothing new.</strong></p>
<p>This or similar javascript has been around for a while. This particular one was on <a href="http://www.raymond.cc/blog/archives/2007/07/13/easily-show-the-contents-of-password-fields/">raymond.cc</a> (via <a href="http://www.fortysomething.ca/mt/etc/archives/007062.php">etc.</a>), but it needed to be fixed for some forms where fields have a null type property (an example is the sign on form for <a href="http://LinkedIn.com">LinkedIn</a>). The fix was adding <tt>f[i].type &amp;&amp;</tt> to the if statement inside the inner for loop.</p>
<h3>Formatted Javascript Code</h3>
<p>If you&#8217;re interested in what is happening to make this work the formatted code is below.</p>
<p>Essentially, the variable F is set to the collection of forms on the page, which is looped through, examining every input field in each form testing if it&#8217;s of type &#8220;password.&#8221; If it is a &#8220;password&#8221; field, its value is appended to the string variable s. Once all the input fields in all the forms on the page have been sniffed, the string value is displayed in an alert.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">javascript<span style="color: #339933;">:</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: #003366; font-weight: bold;">var</span> s<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #339933;">,</span> F<span style="color: #339933;">=</span>document.<span style="color: #660066;">forms</span><span style="color: #339933;">,</span>j<span style="color: #339933;">,</span>f<span style="color: #339933;">,</span>i<span style="color: #339933;">;</span>
  <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>j<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> j<span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>F.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> <span style="color: #339933;">++</span>j<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      f <span style="color: #339933;">=</span> F<span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
      <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>f.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> <span style="color: #339933;">++</span>i<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>f<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">type</span>.<span style="color: #660066;">toLowerCase</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot;password&quot;</span><span style="color: #009900;">&#41;</span> s <span style="color: #339933;">+=</span> f<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>s<span style="color: #009900;">&#41;</span> <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Password fields:<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #339933;">+</span> s<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;No password fields on this page.&quot;</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: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><strong>But Firefox already&#8230;</strong></p>
<p>And yes, we know Firefox will show you passwords in the clear with Tools/Options/Security/Show Passwords.</p>
<p>This javascript, however, is easier to access if you have created a bookmarklet for it, plus it works in other browsers.</p>
]]></content:encoded>
			<wfw:commentRss>http://techrageo.us/2007/11/21/show-password-fields/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>jQuery 1.2</title>
		<link>http://techrageo.us/2007/10/04/jquery-12/</link>
		<comments>http://techrageo.us/2007/10/04/jquery-12/#comments</comments>
		<pubDate>Thu, 04 Oct 2007 09:32:35 +0000</pubDate>
		<dc:creator>bill</dc:creator>
				<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://techrageo.us/2007/10/04/jquery-12/</guid>
		<description><![CDATA[Major Updates To jQuery John Resig and the jQuery team have been busy releasing jQuery 1.2 and a bugfix version 1.2.1. jQuery Version 1.2 Version 1.2 is a major update to the popular Javascript library. Many new features were added and a few were removed, so updating existing code may be required to use the [...]]]></description>
			<content:encoded><![CDATA[<h3>Major Updates To jQuery</h3>
<p>John Resig and the jQuery team have been busy releasing jQuery 1.2 and a bugfix  version 1.2.1.</p>
<h3>jQuery Version 1.2</h3>
<p>Version 1.2 is a major update to the popular Javascript library. Many new features were added and a few were removed, so updating existing code may be required to use the new release.</p>
<p><strong>Features Removed</strong></p>
<p>The jQuery team tries to keep the library as small as possible. Unfortunately that means some things have been deprecated or moved into plugins.</p>
<p>A backwards compatibility plugin is available to assist or delay any changes needed to use the new version.</p>
<p>Several XPath selector features were removed, including Descendant (ex. $(&#8220;div//p&#8221;) ), Child (ex. $(&#8220;div/p&#8221;) ), Parent (ex. $(&#8220;p/../div&#8221;) ), Contains Predicate (ex. $(&#8220;div[p]&#8220;) ), and Attribute (ex. $(&#8220;a[@href]&#8220;) ). It is recommended that instead of these selectors, the corresponding CSS or other selectors be used. Or use the <a href="http://jquery.com/plugins/project/xpath">XPath Compatibility Plugin</a>.</p>
<p>The parametized clone() method (ex. $(&#8220;div&#8221;).clone(false) ) has been deprecated. .clone() is still supported, but instead of using the false argument, use .clone().empty() instead.</p>
<p>DOM Traversal methods .eq(), .lt(), .gt(), and .contains() have been deprecated in favor of using .slice() and .filter(). <strong>Note that 1.2.1 brings back .eq().</strong></p>
<p>The Ajax methods .loadIfModifed() and .getIfModifed() are deprecated. You should use the $.ajax() method with the &#8220;ifModified:true&#8221; option instead. Also, $.ajaxTimeout is now deprecated in favor of $.ajaxSetup(). .evalScripts() has been removed as it is no longer necessary; all scripts in HTML strings are automatically evaluated when injected into the document.</p>
<p><strong>Features Added</strong></p>
<p>Now for the good stuff.</p>
<p>Besides the new XPath Compatibility Plugin mentioned above, the core now supports :has(selector), :header, and :animated.</p>
<p>New DOM traversal methods include .map(), .prevAll() and .nextAll(), .slice(), .hasClass(), .andSelf(), and .contents().</p>
<p>New DOM manipulation methods include .wrapInner() and .wrapAll(), .replaceWith() and .replaceAll(), and .clone(true) Event Cloning.</p>
<p>New .offset(), .height() and .width() CSS methods were added.</p>
<p>Ajax support was improved with support for partial .load(), Cross-Domain getScript(), JSONP, and disabling caching. Also .serialize() has been reworked.</p>
<p>New effects features support .stop(), % and em animations, color animations, relative animations, queue control, the :animated selector, and custom animation types with the step Function.</p>
<p>Namespaced Events and .triggerHandler() are also new.</p>
<p><strong>jQuery.UI</strong></p>
<p><a href="http://ui.jquery.com/">jQuery now has its own UI</a>, including draggables, droppables, resizables, shadows, sliders, sortables, tabs, accordians, selectables, trees, and modals.</p>
<p>Well, it has a few bugs, but it really is nice. And, of course, they&#8217;re hard at work squashing the bugs as fast as possible.</p>
<h3>jQuery Version 1.2.1</h3>
<p>A bugfix release on September 16th <a href="http://dev.jquery.com/report/17">fixes some bugs</a> and adjusts the API in two places.</p>
<p>Due to overwhelming demand, .eq() has returned in version 1.2.1. Also, a problem with the relative animation API has been fixed.</p>
<h3>Excellent Upgrade</h3>
<p>This is a major step forward for jQuery. The loss of XPath and a few features in the core is a slightly bitter pill, but plugins help with this. The additional features are great, and the new UI library is welcome.</p>
]]></content:encoded>
			<wfw:commentRss>http://techrageo.us/2007/10/04/jquery-12/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>jQuery 1.1.4 Released</title>
		<link>http://techrageo.us/2007/08/25/jquery-114-released/</link>
		<comments>http://techrageo.us/2007/08/25/jquery-114-released/#comments</comments>
		<pubDate>Sat, 25 Aug 2007 18:37:01 +0000</pubDate>
		<dc:creator>bill</dc:creator>
				<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://techrageo.us/2007/08/25/jquery-114-released/</guid>
		<description><![CDATA[John Resig and the jQuery team have released jQuery 1.1.4. This release addresses bugs, improves performance, adds some functionality, and deprecates some functionality in anticipation of changes upcoming in jQuery version 1.2. Both standard and packed .js files are available at code.jquery.com. jQuery Bugfixes This latest release addresses 53 problem tickets (including those fixed in [...]]]></description>
			<content:encoded><![CDATA[<p>John Resig and the jQuery team have <a href="http://jquery.com/blog/2007/08/24/jquery-114-faster-more-tests-ready-for-12/">released jQuery 1.1.4</a>.</p>
<p>This release addresses bugs, improves performance, adds some functionality, and deprecates some functionality in anticipation of changes upcoming in jQuery version 1.2.</p>
<p>Both <a href="http://code.jquery.com/jquery-1.1.4.js">standard</a> and <a href="http://code.jquery.com/jquery-1.1.4.pack.js">packed</a> .js files are available at code.jquery.com.</p>
<h3>jQuery Bugfixes</h3>
<p>This latest release addresses 53 problem tickets (including those fixed in the 1.1.3.1 emergency release), improving computed styles in Safari, HTML script evaluation, and Ajax settings issues.</p>
<h3>jQuery Library Improvements</h3>
<p>Besides bugfixes, you can now rename jQuery. This allows multiple instances of jQuery to be included, side-by-side. Further, it allows you to use jQuery within the namespace of another library, such as the Yahoo! UI toolkit.</p>
<p>The new release also includes speed improvements over version 1.1.3 in id and element selectors, and with each() operations.</p>
<h3>jQuery New Features</h3>
<p>jQuery version 1.1.4 introduces some new functionality as well.</p>
<p>.slice() allows you to grab a &#8220;slice&#8221; of a selector result vector, and operates like the Javascript array slice method.</p>
<p>:has() allows you to further qualify a selector, as in $(&#8220;a:has(img)&#8221;) to select all anchors that contain an image element.</p>
<p>Deep .extend() allows objects to be merged without overwriting internal objects.</p>
<h3>Deprecations</h3>
<p>In preparation for jQuery 1.2, some items are deprecated in version 1.1.4.</p>
<p>Some XPath selectors are being dropped. An XPath plugin is being introduced with 1.2, and in the meantime CSS selector formats must suffice. For example, instead of using the XPath child selector $(&#8220;div/p&#8221;), you now use the CSS selector $(&#8220;div > p&#8221;).</p>
<p>The parameterized .clone() method is now deprecated.</p>
<p>DOM traversal methods .eq(), .lt(), and .gt() are deprecated, replaced by the new .slice() method.</p>
<p>Ajax methods .loadIfmodified() and .getIfModified() are deprecated and replaced by the long form .ajax() method. .ajaxTimeout() is deprecated as the long-form .ajaxSetup() will suffice. .evalScripts() is no longer needed since all scripts are evaluated are now automatically evaluated upon injection.</p>
]]></content:encoded>
			<wfw:commentRss>http://techrageo.us/2007/08/25/jquery-114-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery Makes Ajax Easy, Part 1</title>
		<link>http://techrageo.us/2007/08/03/jquery-makes-ajax-easy-part-1/</link>
		<comments>http://techrageo.us/2007/08/03/jquery-makes-ajax-easy-part-1/#comments</comments>
		<pubDate>Fri, 03 Aug 2007 04:35:36 +0000</pubDate>
		<dc:creator>bill</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://techrageo.us/2007/08/03/jquery-makes-ajax-easy-part-1/</guid>
		<description><![CDATA[jQuery Ajax jQuery, John Resig&#8217;s Javascript library, makes Ajax easy for beginners and professionals alike. This article dives into using the various jQuery Ajax methods. Ajax Basics Asynchronous JavaScript and XML, or Ajax, has become a catch-all term for client-initiated communications with a server. Specifically, Ajax usually refers to requests sent from a web browser [...]]]></description>
			<content:encoded><![CDATA[<h3>jQuery Ajax</h3>
<p><a href="http://jquery.com"><br />
jQuery</a>, John Resig&#8217;s Javascript library, makes Ajax easy for beginners and professionals alike. This article dives into using the various jQuery Ajax methods.</p>
<h3>Ajax Basics</h3>
<p><a href="http://en.wikipedia.org/wiki/Ajax_(programming)">Asynchronous JavaScript and XML</a>, or <strong>Ajax</strong>, has become a catch-all term for client-initiated communications with a server. Specifically, Ajax usually refers to requests sent from a web browser to a server. It is even used to refer to non-XML communications, such as <a href="http://microformats.org/wiki/rest/ahah">Asynchronous HTML and HTTP</a> &#8212; <strong>AHAH</strong>. The rationale being that the first H in AHAH really means XHTML. I think someone just wanted another clever-sounding acronym; it really should be AJAH since it still uses Javascript. But I digress.</p>
<p>Simply put, Ajax allows you to execute a POST or GET request from the browser back to your server to fetch data, save data, execute a method, or what have you, without requiring a refresh of the web page.</p>
<h3>jQuery Ajax Methods</h3>
<p>jQuery provides several methods to assist with Ajax programming: load, get, post, and ajax.</p>
<p><strong>load()</strong> takes a url, parameters, and a callback function. It executes a GET request of the URL and inserts the returned data into the DOM at a location you select. The parameters and callback function are optional. A typical usage would be something like <tt>$("address").load( url, {name:"John",id:"100"}, function(){ alert("Ajax call complete.");})</tt>.</p>
<p><strong>get()</strong> takes a url, parameters, and a callback function. It executes a GET request of the URL and returns the XMLHttpRequest. The parameters and callback function are optional. A typical usage would be something like <tt>$.get( url, {name:"John",id:"100"}, function(data){ $("address").html( data ); alert("Ajax call complete.");})</tt>.</p>
<p><strong>post()</strong> takes a url, parameters, and a callback function. It sends a POST request to the URL and returns the XMLHttpRequest. The parameters and callback function are optional. A typical usage would be something like <tt>$.post( url, {name:"John",id:"100"}, function(data){ $("address").html( data ); alert("Ajax call complete.");})</tt>.</p>
<p><strong>ajax()</strong> takes a set of request properties specified in key-value pairs. It sends the specified request and returns the XMLHttpRequest. The ajax() method is complex but offers much more control over the request than any of the other methods. A typical usage would be something like <tt>$.ajax({ type:"GET", url:url, datatype:"html", data:{name:"John",id:"100"}, complete:function( data ) { $("address").html( data ); alert( "Ajax call complete.")}})</tt>.</p>
<h3>Get Data From A URL</h3>
<p>This example is taken from the <a title="Introduction To jQuery Programming" href="http://techrageo.us/2007/07/05/jquery-introduction/">jQuery Introduction</a> posted here about a month ago. Technically, this is AJAH, since we&#8217;re not fetching XML, but the technique is the same.</p>
<p><strong>We need a proxy to fetch data from another domain.</strong></p>
<p>In the diagram below, you can see that the web page in your browser needs to fetch from the same domain from which it was loaded, in this case techrageo.us. From there it can go anywhere. In this example we&#8217;re fetching from Yahoo.com.</p>
<p><img alt="Ajax needs a URL proxy" src="/images/ajax.gif"/></p>
<p>Ajax is usually limited to connections back to the same domain from which the web page was loaded. To fetch data from another domain, such as from the Yahoo quote server, we need to create a simple URL proxy. The PHP code is below. Basically it takes a URL, fetches it with curl, and returns the output.</p>
<p>Note: due to server restrictions, the curl_exec string below had to be tweaked to get it into this article. Just remove the spaces and you&#8217;re good to go.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">// don't cache this page</span>
<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Cache-Control: no-cache&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">function</span> geturl<span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$ch</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_init</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$timeout</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">5</span><span style="color: #339933;">;</span>
  <span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_URL<span style="color: #339933;">,</span> <span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_RETURNTRANSFER<span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_CONNECTTIMEOUT<span style="color: #339933;">,</span> <span style="color: #000088;">$timeout</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #666666; font-style: italic;">// make this curl_exec, no spaces</span>
  <span style="color: #000088;">$results</span> <span style="color: #339933;">=</span> c u r l _ e x e c <span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #990000;">curl_close</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">return</span> <span style="color: #000088;">$results</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #666666; font-style: italic;">// get the specified url from the querystring</span>
<span style="color: #000088;">$theurl</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;url&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// decode it</span>
<span style="color: #000088;">$theurl</span> <span style="color: #339933;">=</span> <span style="color: #990000;">urldecode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$theurl</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// decode forgets the ampersand</span>
<span style="color: #000088;">$theurl</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;&amp;#038;&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;&amp;&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$theurl</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// fetch the url</span>
<span style="color: #000088;">$v</span> <span style="color: #339933;">=</span> geturl<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$theurl</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// spit out the results</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$v</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Enter a stock ticker symbol, such as IBM or SBUX, and click Submit. When you do the span with id=&#8221;lasttrade&#8221; is loaded with data returned from geturl.php?http://finance.yahoo.com/d/quotes.csv?f=l1&#038;s=IBM (assuming you entered IBM).</p>
<p><em>Update: Yahoo has changed their quote URLs to something like this http://download.finance.yahoo.com/d/quotes.csv?f=l1&#038;s=IBM </em></p>
<form id="stockform">
Ticker Symbol:<br />
<input id="sym" name="sym" type="text" size="10"/>
<input type="submit"/></form>
<p>Last Trade: <span id="lasttrade"></span></p>
<p><strong>We&#8217;re using .load() for this simple example.</strong></p>
<p>The jQuery code is below. As you can see an anonymous function is attached to the submit handler of the form with an id of stockform. The function gets the value of the input field with an id of sym, then appends it to the URL of the Yahoo csv quote server with format specified to return the last trade price. That URL is then escaped and appended to geturl.php?url=, which is a simple PHP proxy that resides here at <a href="http://techrageo.us">techrageo.us</a>. The submit handler function then returns false to prevent the browser from trying to continue submitting the form.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// wait till the DOM is loaded</span>
$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</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: #006600; font-style: italic;">// attach a submit handler to the form</span>
  $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;form#stockform&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">submit</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: #006600; font-style: italic;">// get the ticker symbol and build URL</span>
    <span style="color: #003366; font-weight: bold;">var</span> sym <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;input#sym&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #003366; font-weight: bold;">var</span> yurl <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;http://download.finance.yahoo.com/d/quotes.csv?f=l1&amp;s=&quot;</span><span style="color: #339933;">+</span>sym<span style="color: #339933;">;</span>
        <span style="color: #006600; font-style: italic;">//old: &quot;http://finance.yahoo.com/d/quotes.csv?f=l1&amp;s=&quot;+sym;</span>
    <span style="color: #003366; font-weight: bold;">var</span> furl <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;geturl.php&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #006600; font-style: italic;">// load last trade price from Yahoo and</span>
    <span style="color: #006600; font-style: italic;">// stick it in the #lasttrade span</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;span#lasttrade&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">load</span><span style="color: #009900;">&#40;</span> furl<span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>url<span style="color: #339933;">:</span>escape<span style="color: #009900;">&#40;</span>yurl<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</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>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><strong>Now let&#8217;s modify the example to use $.get().</strong></p>
<p>jQuery&#8217;s $.get() method can be used to send a GET request. For example, the example above can be written as follows.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// wait till the DOM is loaded</span>
$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</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: #006600; font-style: italic;">// attach a submit handler to the form</span>
  $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;form#stockform&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">submit</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: #006600; font-style: italic;">// get the ticker symbol and build URL</span>
    <span style="color: #003366; font-weight: bold;">var</span> sym <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;input#sym&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #003366; font-weight: bold;">var</span> yurl <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;http://download.finance.yahoo.com/d/quotes.csv?f=l1&amp;s=&quot;</span><span style="color: #339933;">+</span>sym<span style="color: #339933;">;</span>
        <span style="color: #006600; font-style: italic;">//old: &quot;http://finance.yahoo.com/d/quotes.csv?f=l1&amp;s=&quot;+sym;</span>
    <span style="color: #003366; font-weight: bold;">var</span> furl <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;/code/geturl.php&quot;</span><span style="color: #339933;">;</span>
    $.<span style="color: #660066;">get</span><span style="color: #009900;">&#40;</span> furl<span style="color: #339933;">,</span>
      <span style="color: #009900;">&#123;</span>url<span style="color: #339933;">:</span>escape<span style="color: #009900;">&#40;</span>yurl<span style="color: #009900;">&#41;</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>data<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;span#lasttrade&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span> data <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>
    <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>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><strong>Now let&#8217;s modify the example to use $.ajax() for more control.</strong></p>
<p>jQuery&#8217;s $.ajax() method can also be used to send a GET request. For example, the example above can be written as follows.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// wait till the DOM is loaded</span>
$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</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: #006600; font-style: italic;">// attach a submit handler to the form</span>
  $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;form#stockform&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">submit</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: #006600; font-style: italic;">// get the ticker symbol and build URL</span>
    <span style="color: #003366; font-weight: bold;">var</span> sym <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;input#sym&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #003366; font-weight: bold;">var</span> yurl <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;http://download.finance.yahoo.com/d/quotes.csv?f=l1&amp;s=&quot;</span><span style="color: #339933;">+</span>sym<span style="color: #339933;">;</span>
        <span style="color: #006600; font-style: italic;">//old: &quot;http://finance.yahoo.com/d/quotes.csv?f=l1&amp;s=&quot;+sym;</span>
    <span style="color: #003366; font-weight: bold;">var</span> furl <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;/code/geturl.php&quot;</span><span style="color: #339933;">;</span>
    $.<span style="color: #660066;">ajax</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
      url<span style="color: #339933;">:</span>furl<span style="color: #339933;">,</span>
      data<span style="color: #339933;">:</span><span style="color: #009900;">&#123;</span> url<span style="color: #339933;">:</span>escape<span style="color: #009900;">&#40;</span>yurl<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
      dataType<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;html&quot;</span><span style="color: #339933;">,</span>
      success<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: #009900;">&#40;</span><span style="color: #3366CC;">&quot;span#lasttrade&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span> data <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
      error<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>xhr<span style="color: #339933;">,</span>err<span style="color: #339933;">,</span>e<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;Error: &quot;</span> <span style="color: #339933;">+</span> err <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// $.ajax()</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> <span style="color: #006600; font-style: italic;">// .submit()</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>In part 2 we&#8217;ll look at POST requests and other dataTypes.</p>
<p><script>
$(document).ready(function()
{
//  $("form#stockform").submit(function(){
//    var sym = $("input#sym").val();
//    var yurl = "http://finance.yahoo.com/d/quotes.csv?f=l1&#038;s="+sym;
//    var furl = "http://techrageo.us/code/geturl.php?url=" + escape(yurl);
//    $("span#lasttrade").load( furl );
//    return false;
//  });
//  $("form#stockform").submit(function(){
//    var sym = $("input#sym").val();
//    var yurl = "http://finance.yahoo.com/d/quotes.csv?f=l1&#038;s="+sym;
//    var furl = "/code/geturl.php";
//    $.get( furl,
//      {url:escape(yurl)},
//      function(data){
//        $("span#lasttrade").html( data );
//      });
//    return false;
//  });
  $("form#stockform").submit(function(){
    // get the ticker symbol and build URL
    var sym = $("input#sym").val();
    var yurl = "http://download.finance.yahoo.com/d/quotes.csv?f=l1&#038;s="+sym;
        //old: "http://finance.yahoo.com/d/quotes.csv?f=l1&#038;s="+sym;
    var furl = "/code/geturl.php";
    $.ajax({
      url:furl,
      data:{ url:escape(yurl) },
      dataType:"html",
      success:function(data){ $("span#lasttrade").html( data );},
      error:function(xhr,err,e){ alert( "Error: " + err ); }
    }); // $.ajax()
    return false;
  }); // .submit()
});
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://techrageo.us/2007/08/03/jquery-makes-ajax-easy-part-1/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
		<item>
		<title>jQuery Introduction</title>
		<link>http://techrageo.us/2007/07/05/jquery-introduction/</link>
		<comments>http://techrageo.us/2007/07/05/jquery-introduction/#comments</comments>
		<pubDate>Thu, 05 Jul 2007 10:32:58 +0000</pubDate>
		<dc:creator>bill</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://techrageo.us/2007/07/05/jquery-introduction/</guid>
		<description><![CDATA[Javascript Frameworks Abound Do we really need another Javascript framework? There&#8217;s the Dojo Toolkit. It&#8217;s mature and includes the kitchen sink. Then there&#8217;s Prototype. It&#8217;s wildly popular and several popular UI layers are built on top of it, including script.aculo.us, Rico, and others. Of course, you can&#8217;t leave out mootools. It&#8217;s UI library, moo.fx, can [...]]]></description>
			<content:encoded><![CDATA[<div id="jqueryintro">
<h3>Javascript Frameworks Abound</h3>
<p><strong>Do we really need another Javascript framework?</strong></p>
<p>There&#8217;s the <a href="http://dojotoolkit.org/">Dojo Toolkit</a>. It&#8217;s mature and includes the kitchen sink. Then there&#8217;s <a href="http://www.prototypejs.org/">Prototype</a>. It&#8217;s wildly popular and several popular UI layers are built on top of it, including <a href="http://script.aculo.us/">script.aculo.us</a>, <a href="http://openrico.org/">Rico</a>, and others. Of course, you can&#8217;t leave out <a href="http://mootools.net/">mootools</a>. It&#8217;s UI library, <a href="http://moofx.mad4milk.net/">moo.fx</a>, can also sit on top of Prototype if you so desire. There&#8217;s <a href="http://developer.yahoo.com/yui/">Y!UI, the Yahoo! User Interface library</a>. And we&#8217;ve got <a href="http://extjs.com/">ExtJs</a>, a robust interface framework that can leverage Y!UI, Prototype, or jQuery.</p>
<h3>jQuery</h3>
<p>Which brings us to&#8230; <a href="http://jquery.com">jQuery</a>. Yep, it is yet another Javascript framework (YAJF). jQuery, though, is arguably the fastest and the most elegant of the lot. It supports CSS3, browser detection, method chaining, plugins, Ajax (gotta have that to be cool), flexible selectors, and basic UI effects. All in under 20K.</p>
<h4>Simple July 4th jQuery Demo</h4>
<p>Okay, so by way of introduction, here&#8217;s a simple little jQuery demonstration.</p>
<p><a id="redwhiteblue" href="#">Click this link to turn this article red white and blue and get the lyrics to &#8220;God Bless America,&#8221; then click again to return to normal.</a></p>
<p class="Godblessamerica" style="display:none;border:2px solid #aaa;padding:1em;">
God Bless America,<br />
Land that I love.<br />
Stand beside her, and guide her<br />
Thru the night with a light from above.<br />
From the mountains, to the prairies,<br />
To the oceans, white with foam<br />
God bless America, My home sweet home.
</p>
<p>The code is below, and is doing this: to the anchor tag (&#8220;a&#8221;) with an id of &#8220;redwhiteblue&#8221;, toggle between two functions on each click event; the first function loops through all the paragraph elements within divs of class &#8220;entry&#8221; and assigns a css color style based on the index mod 3 (iteratively assign from an array of red, white, and blue); the second function simply assigns a css color style of black to all paragraphs within divs of class &#8220;entry&#8221;; both functions return false to short-circuit the link.</p>
<p><em><strong>Update:</strong> The commented section below is replaced by the three lines that follow it, suggested by jQuery&#8217;s creator, John Resig (thanks, John). What I was doing with a clumsy <code>for</code> loop, iterating through each paragraph I selected with a cobbled-together XPath, is better done with the <code>each</code> method, applying a simple function along the selected vector. It goes to show just how slick the library really is.</em></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">  <span style="color: #003366; font-weight: bold;">var</span> rwb<span style="color: #339933;">=</span>Array<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#f00&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;#aaa&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;#00f&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;a#redwhiteblue&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">toggle</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;">&quot;p.Godblessamerica&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">slideDown</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">300</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">//    for(i=0;i&lt;$(&quot;div#jqueryintro p&quot;).length;i++){</span>
<span style="color: #006600; font-style: italic;">//      $(&quot;div#jqueryintro p:nth(&quot; + i + &quot;)&quot;).css({color:rwb[i % 3]});</span>
<span style="color: #006600; font-style: italic;">//    } return false;</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;div#jqueryintro p&quot;</span><span style="color: #009900;">&#41;</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>i<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
      $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>color<span style="color: #339933;">:</span>rwb<span style="color: #009900;">&#91;</span>i <span style="color: #339933;">%</span> <span style="color: #CC0000;">3</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#125;</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> <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: #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;">&quot;p.Godblessamerica&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">slideUp</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">300</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;div#jqueryintro p&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>color<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;#000&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</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></pre></div></div>

<h3>More jQuery Demos</h3>
<p>Here are a few other little demos I fiddled up along the way.</p>
<h4>Toggle Red Demo</h4>
<p><a class="togglered" href="#">Click this link to toggle the following paragraph between black and red text.</a></p>
<p class="redtarget">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Duis adipiscing purus eu elit. Quisque feugiat malesuada lectus. Suspendisse potenti. Donec viverra, nisi et lobortis sollicitudin, erat quam condimentum sapien, at volutpat ipsum neque tristique lorem.
</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">   $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;a.togglered&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">toggle</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;">&quot;p.redtarget&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>color<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;#AA0000&quot;</span><span style="color: #009900;">&#125;</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;">&quot;p.redtarget&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>color<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;#000&quot;</span><span style="color: #009900;">&#125;</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></pre></div></div>

<h4>Toggle Visibility</h4>
<p>Okay <a class="intro" href="#">click this link</a> to reveal a DIV with some text. Then, click again to re-hide the text.</p>
<div class="introtarget" style="display:none;background-color:#eee;color:#37a;padding:.8em;margin-bottom:1em;border:1px solid #777;">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Duis adipiscing purus eu elit. Quisque feugiat malesuada lectus. Suspendisse potenti. Donec viverra, nisi et lobortis sollicitudin, erat quam condimentum sapien, at volutpat ipsum neque tristique lorem.
</div>
<p>That&#8217;s a toggle tacked onto the DIV. Here&#8217;s the code to make that happen.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">  $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;a.intro&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</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;">&quot;div.introtarget&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">toggle</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">100</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>return <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></pre></div></div>

<p>Translated into English, that means &#8220;select <code>A</code> tags of class <code>intro</code>, then handle click events by executing a function that finds divs of class introtarget and attach a toggle of speed 100 to them; then return false.&#8221;</p>
<h4>Get Stock Quote With Ajax</h4>
<p>Of course, jQuery supports Ajax. Here&#8217;s a simple demo that calls a PHP file that merely takes the URL passed in, fetches it, then echos the results.</p>
<p>The jQuery Javascript code takes the output (in this case just a number), and sticks it into the lasttrade span.</p>
<form id="stockform">Ticker Symbol:<br />
<input id="sym" name="sym" type="text" size="10"/>
<input type="submit"/></form>
<p>Last Trade: <span id="lasttrade"></span></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">  $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;form#stockform&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">submit</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: #003366; font-weight: bold;">var</span> sym <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;input#sym&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #003366; font-weight: bold;">var</span> yurl <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;http://finance.yahoo.com/d/quotes.csv?&quot;</span> <span style="color: #339933;">+</span>
       <span style="color: #3366CC;">&quot;f=l1&amp;s=&quot;</span><span style="color: #339933;">+</span>sym<span style="color: #339933;">;</span>
    <span style="color: #003366; font-weight: bold;">var</span> furl <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;geturl.php?url=&quot;</span> <span style="color: #339933;">+</span> escape<span style="color: #009900;">&#40;</span>yurl<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;span#lasttrade&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">load</span><span style="color: #009900;">&#40;</span> furl <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</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></pre></div></div>

<h3>Shortest jQuery Tutorial Ever</h3>
<p>Hey! Learn jQuery now. Here&#8217;s what you do to get your feet wet with jQuery.</p>
<ol>
<li>Start with a basic HTML file.

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">html</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>Here is <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;clickme&quot;</span>&gt;</span>a link<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span>.<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;lorem&quot;</span>&gt;</span>Lorem ipsum dolor sit amet,
    consectetuer adipiscing elit.<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>This text is here to stay.<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;lorem&quot;</span>&gt;</span>Phasellus luctus. Suspendisse nisi
  	neque, feugiat eget, ullamcorper at, feugiat ut,
  	tellus.<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">html</span>&gt;</span></pre></div></div>

</li>
<li>Link in the jQuery library. You can do this by referencing the code at code.jquery.com or by downloading jquery.js and linking to it.
<p>Below I&#8217;m linking to the packed version of jQuery 1.1.3.1 (the latest at the time of this update).</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span></span>
<span style="color: #009900;">    <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://code.jquery.com/jquery-1.1.3.1.pack.js&quot;</span><span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">head</span>&gt;</span></pre></div></div>

</li>
<li>Add the standard jQuery document ready state handler function. This is a pattern used for most jQuery work, wherein your jQuery code resides.

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script<span style="color: #339933;">&gt;</span>
$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</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: #006600; font-style: italic;">// your code here</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>

</li>
<li>Flesh it out with some jQuery scripting. See above for examples; the code snippets in the examples can be dropped into the ready function, provided you add the proper elements to the HTML as well.

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script<span style="color: #339933;">&gt;</span>
$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</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;">&quot;a#clickme&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</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;">&quot;p.lorem&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">toggle</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">100</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>return <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>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>

</li>
</ol>
<h3>Update and Wrapping Up</h3>
<p>Since publishing this article I&#8217;ve made a few updates. First was to incorporate John Resig&#8217;s suggestion for the July 4th demo. Using <code>each</code> had crossed my mind but I was looking at it wrong and ended up patching an XPath together to get what I wanted.</p>
<p>The second update was to add some additional comments to the <strong>Shortest jQuery Tutorial Ever</strong> section.</p>
<p>And last, I incorporated <a href="http://jquery.com/blog/2007/07/05/jquery-1131/">today&#8217;s update to jQuery itself, now at version 1.1.3.1</a>. Interestingly enough, though the tutorial had you link in version 1.1.3, I had been loading an older (pre-1.1.3) version on this site and was a little disappointed that the demos were a little sluggish. Linking to 1.1.3.1 provided a significant and very noticeable boost to performance. They said <a href="http://jquery.com/blog/2007/07/01/jquery-113-800-faster-still-20kb/">1.1.3 was 800% faster than 1.1.2</a>, and I mostly believed them &#8212; but come on, everyone claims they&#8217;re latest release of whatever is 800% faster. It&#8217;s like marketing boilerplate. I think they make rubber stamps that say that. But I can vouch that the latest release of jQuery is at least, technically speaking, a whole bunch faster.</p>
</div>
<p> <!-- jquery introduction --></p>
<p><script>
$(document).ready(function()
{
   $("a.togglered").toggle(function(){
     $("p.redtarget").css({color:"#AA0000"});
   },function(){
     $("p.redtarget").css({color:"#000"});
   });
  $("a.intro").click( function() {
    $("div.introtarget").toggle(100);return false;
  });
  $("form#stockform").submit(function(){
    var sym = $("input#sym").val();
    var yurl = "http://finance.yahoo.com/d/quotes.csv?f=l1&#038;s="+sym;
    var furl = "http://techrageo.us/code/geturl.php?url=" + escape(yurl);
    $("span#lasttrade").load( furl );
    return false;
  });
  var rwb=Array("#f00","#aaa","#00f");
  $("a#redwhiteblue").toggle( function() {
    $("p.Godblessamerica").slideDown(300);
    $("div#jqueryintro p").each(function(i){
      $(this).css({color:rwb[i % 3]});
    }); return false;
  },
  function(){
    $("p.Godblessamerica").slideUp(300);
    $("div#jqueryintro p").css({color:"#000"});
    return false;
  });
});
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://techrageo.us/2007/07/05/jquery-introduction/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Ajax Tutorials</title>
		<link>http://techrageo.us/2006/05/04/ajax-tutorials/</link>
		<comments>http://techrageo.us/2006/05/04/ajax-tutorials/#comments</comments>
		<pubDate>Thu, 04 May 2006 10:37:59 +0000</pubDate>
		<dc:creator>bill</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://techrageo.us/2006/05/04/ajax-tutorials/</guid>
		<description><![CDATA[Another top-tutorial list. Top 20 Ajax Tutorials. Via digg.]]></description>
			<content:encoded><![CDATA[<p>Another top-tutorial list. <a href="http://121space.com/index.php?showtopic=1875">Top 20 Ajax Tutorials</a>. Via <a href="http://digg.com/programming/Top_20_AJAX_Tutorials">digg</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://techrageo.us/2006/05/04/ajax-tutorials/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google Maps for WordPress &#8211; GooMaps</title>
		<link>http://techrageo.us/2005/08/16/google-maps-api-and-wordpress/</link>
		<comments>http://techrageo.us/2005/08/16/google-maps-api-and-wordpress/#comments</comments>
		<pubDate>Tue, 16 Aug 2005 15:13:12 +0000</pubDate>
		<dc:creator>bill</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Mapping]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://techrageo.us/?p=42</guid>
		<description><![CDATA[Google Maps Update (8 Mar 2009): Updated again to fix the constants broken by a change made by Google. Thanks to brian, who left a comment asking about the maps not working. Update (30 Jan 2007): Updated again to make a link in the popup actually open a new window. Did this by embedding a [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Google Maps</strong></p>
<p><em>Update (8 Mar 2009):  Updated again to fix the constants broken by a change made by Google. Thanks to brian, who left a comment asking about the maps not working.</em></p>
<p><em>Update (30 Jan 2007):  Updated again to make a link in the popup actually open a new window. Did this by embedding a javascript OnClick handler in the html attribute of the marker element in the xml file.</em></p>
<p><em>Update (6 Sept 2005): I&#8217;ve updated the XML file goomap1.xml again, this time to include a link around &#8216;IBM&#8217;. Note that the anchor tag must specify a target so the link doesn&#8217;t open inside the IFRAME, and of course angle-brackets must again be XML encoded.</em></p>
<p><em>Update (1 Sept 2005): I&#8217;ve updated the XML file goomap1.xml to include a break (&lt;br/&gt;) between IBM and Dev in the info popup HTML. It must be XML encoded to obscure the angle-brackets from the XML parser.</em></p>
<p>Sites like <a href="http://www.mapquest.com">MapQuest</a> and <a href="http://www.mapblast.com">MapBlast</a> served our mapping needs first, but <a href="http://maps.google.com">Google Maps</a> started the second revolution in online mapping. Click and drag to pan  in realtime. Zoom in and out just as quickly. Click a button to get satellite  imagery instead of a map. Now they offer a hybrid mode with streets and labels  overlaid on top of the satellite imagery. It&#8217;s all very cool.</p>
<p>Google Maps has <a href="http://www.google.com/apis/maps/">a mapping API</a> with which you can build and use your own maps, complete  with custom markers, animation, popup information bubbles, and the works.</p>
<p>So to build maps you simply sign up for a <a href="http://www.google.com/apis/maps/signup.html">Google Maps API Key</a>, reference a Google-provided script in the HTML head element, and embed a div and some simple Javascript in your HTML, and you&#8217;re off to the races.</p>
<p><strong>Google Maps and WordPress</strong></p>
<p>Of course, it&#8217;d occasionally be nice to embed a custom Google Map in a WordPress post. Detailing recent travel, geo-tagged photos, whatever.</p>
<p><em>Problems Embedding Google Maps in <a href="http://wordpress.org/">WordPress</a> Posts</em></p>
<p>The first problem that arises when trying to include a map within a WordPress post is this: complex inline Javascript is essentially rendered useless. But you <em>can</em> call a function. So we can offload the Javascript functionality to a file, reference it, then call the function to build the map.</p>
<p>However, a second problem shows up. Google Map API Keys are good for one directory on a  server only, so the API key would only work for the root or wp-content, or another static location.</p>
<p><em>The Solution</em></p>
<p>The solution is four-fold</p>
<ol>
<li>Move your Google Maps Javascript to a .js file, or simply download and use <a href="http://techrageo.us/wp-content/GooMaps.js"><em>GooMaps.js</em></a>.</li>
<li>Move the map data to an XML file. <a href="http://techrageo.us/wp-content/goomap1.xml"><em>goomap1.xml</em></a></li>
<li>Call the Javascript function from a standalone HTML file. <a href="http://techrageo.us/wp-content/goomap1.html"><em>goomap1.html</em></a></li>
<li>Embed the HTML file in an IFRAME within your WordPress post.</li>
</ol>
<p>&lt;br /&gt; Sorry. If you&#8217;re seeing this, your browser doesn&#8217;t support IFRAMEs. You should upgrade to a more current browser.&lt;br /&gt; Simple as that. Mostly.</p>
<p>In the example to the right, a hybrid style map is centered around IBM in Austin, TX. Two custom icons and shadows are placed on the manufacturing plant on the West side of Burnet Rd. and the development buildings across the street.</p>
<p>This was created with an IFRAME tag embedded in this post, along with uploaded XML and HTML files, goomap1.xml and goomap1.html, to describe the map data and the IFRAME HTML, respectively. The IFRAME code also includes the Google Maps Javascript and some custom Javascript code.</p>
<p>Let&#8217;s get into those steps in more detail.</p>
<p>Step 1 &#8212; <strong>GooMaps.js &#8211; Google Maps Javascript File</strong></p>
<p>You&#8217;re going to want to put code similar to the following in a Javascript file. Let&#8217;s call it <a href="http://techrageo.us/wp-content/GooMaps.js"><em>GooMaps.js</em></a>.</p>
<p>It supports the following features:</p>
<ul>
<li>You can specify the center, the zoom, the map type (&#8220;Map&#8221;, &#8220;Satellite&#8221;, and &#8220;Hybrid&#8221;) and the base URL for icon files. Use the markers tag.</li>
<li>Include a list of markers, specifying the latitude, longitude, html caption, icon and shadow icon, and their sizes. Use the marker tag.</li>
</ul>
<p>You can <a href="http://techrageo.us/wp-content/GooMaps.js">download</a> and use this if you wish. No warrenties, use at your own risk, I&#8217;m not liable, an so on. Feel free to use it but I&#8217;d appreciate a back link.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// Function: createMarker</span>
<span style="color: #006600; font-style: italic;">// Creates a GMarker at a given point with a given icon</span>
<span style="color: #006600; font-style: italic;">//  Then adds a &quot;click&quot; event listener that pops up</span>
<span style="color: #006600; font-style: italic;">//  some caption (HTML formatted)</span>
<span style="color: #006600; font-style: italic;">// Modified from Google Maps API Reference</span>
<span style="color: #006600; font-style: italic;">// Added support for specifying icons and html captions</span>
<span style="color: #003366; font-weight: bold;">function</span> createMarker<span style="color: #009900;">&#40;</span>point<span style="color: #339933;">,</span> icon<span style="color: #339933;">,</span> html<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #003366; font-weight: bold;">var</span> marker <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> GMarker<span style="color: #009900;">&#40;</span>point<span style="color: #339933;">,</span> icon<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  GEvent.<span style="color: #660066;">addListener</span><span style="color: #009900;">&#40;</span>marker<span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;click&quot;</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>
    marker.<span style="color: #660066;">openInfoWindowHtml</span><span style="color: #009900;">&#40;</span>html<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>
  <span style="color: #000066; font-weight: bold;">return</span> marker<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #006600; font-style: italic;">// Function: GooMapXml</span>
<span style="color: #006600; font-style: italic;">// Reads an xml file, the name of which is specified</span>
<span style="color: #006600; font-style: italic;">//  in an attribute of a span with the id mapinfo.</span>
<span style="color: #003366; font-weight: bold;">function</span> GooMapXml<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  <span style="color: #006600; font-style: italic;">// Find mapinfo span and get name attribute</span>
  <span style="color: #003366; font-weight: bold;">var</span> mapinfo <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'mapinfo'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">getAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'name'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #006600; font-style: italic;">// Create GXmlHttp object to fetch XML document</span>
  <span style="color: #003366; font-weight: bold;">var</span> request <span style="color: #339933;">=</span> GXmlHttp.<span style="color: #660066;">create</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #006600; font-style: italic;">// Open the connection to the XML file</span>
  request.<span style="color: #000066;">open</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;GET&quot;</span><span style="color: #339933;">,</span> mapinfo<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #006600; font-style: italic;">// Describe a function to handle the completed request</span>
  request.<span style="color: #660066;">onreadystatechange</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;">if</span> <span style="color: #009900;">&#40;</span>request.<span style="color: #660066;">readyState</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">4</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #006600; font-style: italic;">// Get XML file contents</span>
      <span style="color: #003366; font-weight: bold;">var</span> xmlDoc <span style="color: #339933;">=</span> request.<span style="color: #660066;">responseXML</span><span style="color: #339933;">;</span>
      <span style="color: #006600; font-style: italic;">// Get markers element</span>
      <span style="color: #003366; font-weight: bold;">var</span> markers <span style="color: #339933;">=</span> xmlDoc.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;markers&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #006600; font-style: italic;">// Get iconbase attribute</span>
      iconbase <span style="color: #339933;">=</span> markers<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">getAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;iconbase&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #006600; font-style: italic;">// Set default maptypes array</span>
      maptypes <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span>G_SATELLITE_MAP<span style="color: #339933;">,</span>G_HYBRID_MAP<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
      <span style="color: #006600; font-style: italic;">// If maptype attribute is present get it and set accordingly</span>
      <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> markers<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">getAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;maptype&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #003366; font-weight: bold;">null</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        mt <span style="color: #339933;">=</span> markers<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">getAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;maptype&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">substring</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span><span style="color: #CC0000;">3</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">toUpperCase</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">switch</span><span style="color: #009900;">&#40;</span> mt <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
          <span style="color: #000066; font-weight: bold;">case</span> <span style="color: #3366CC;">&quot;SAT&quot;</span> <span style="color: #339933;">:</span>
            maptypes <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span>G_SATELLITE_MAP<span style="color: #339933;">,</span>G_HYBRID_MAP<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
          <span style="color: #000066; font-weight: bold;">case</span> <span style="color: #3366CC;">&quot;HYB&quot;</span> <span style="color: #339933;">:</span>
            maptypes <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span>G_HYBRID_MAP<span style="color: #339933;">,</span>G_SATELLITE_MAP<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
      <span style="color: #009900;">&#125;</span>
      <span style="color: #006600; font-style: italic;">// Get map div from HTML doc</span>
      <span style="color: #003366; font-weight: bold;">var</span> map <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> GMap<span style="color: #009900;">&#40;</span>document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;map&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>maptypes<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #006600; font-style: italic;">// Add small google map controls</span>
      map.<span style="color: #660066;">addControl</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">new</span> GSmallMapControl<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #006600; font-style: italic;">// Add map type buttons</span>
      map.<span style="color: #660066;">addControl</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">new</span> GMapTypeControl<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #006600; font-style: italic;">// Create point for center (get x,y from attributes of markers element)</span>
      <span style="color: #003366; font-weight: bold;">var</span> cpt <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> GPoint<span style="color: #009900;">&#40;</span>
                    parseFloat<span style="color: #009900;">&#40;</span>markers<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">getAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;centerx&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                    parseFloat<span style="color: #009900;">&#40;</span>markers<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">getAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;centery&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #006600; font-style: italic;">// Center and zoom map (zoom specified in attribute of markers element)</span>
      map.<span style="color: #660066;">centerAndZoom</span><span style="color: #009900;">&#40;</span>cpt<span style="color: #339933;">,</span> parseInt<span style="color: #009900;">&#40;</span>markers<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">getAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;zoom&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #006600; font-style: italic;">// Get marker element vector</span>
      <span style="color: #003366; font-weight: bold;">var</span> markerlist <span style="color: #339933;">=</span> xmlDoc.<span style="color: #660066;">documentElement</span>.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;marker&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #006600; font-style: italic;">// Loop through marker elements</span>
      <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> markerlist.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #006600; font-style: italic;">// Create points based on lat, lng attributes</span>
        <span style="color: #003366; font-weight: bold;">var</span> point <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> GPoint<span style="color: #009900;">&#40;</span>
                        parseFloat<span style="color: #009900;">&#40;</span>markerlist<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">getAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;lng&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                        parseFloat<span style="color: #009900;">&#40;</span>markerlist<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">getAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;lat&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #006600; font-style: italic;">// Create icon</span>
        <span style="color: #003366; font-weight: bold;">var</span> icon <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> GIcon<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #006600; font-style: italic;">// Set image and shadow from iconbase and icon/iconsh attributes</span>
        icon.<span style="color: #660066;">image</span> <span style="color: #339933;">=</span> iconbase <span style="color: #339933;">+</span> markerlist<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">getAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;icon&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        icon.<span style="color: #660066;">shadow</span> <span style="color: #339933;">=</span> iconbase <span style="color: #339933;">+</span> markerlist<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">getAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;iconsh&quot;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #006600; font-style: italic;">// Set icon and shadow sizes from attributes</span>
        icon.<span style="color: #660066;">iconSize</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> GSize<span style="color: #009900;">&#40;</span>
          parseInt<span style="color: #009900;">&#40;</span>markerlist<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">getAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;iconszx&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
          parseInt<span style="color: #009900;">&#40;</span>markerlist<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">getAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;iconszy&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        icon.<span style="color: #660066;">shadowSize</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> GSize<span style="color: #009900;">&#40;</span>
          parseInt<span style="color: #009900;">&#40;</span>markerlist<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">getAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;iconshszx&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
          parseInt<span style="color: #009900;">&#40;</span>markerlist<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">getAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;iconshszy&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #006600; font-style: italic;">// Set icon anchor</span>
        icon.<span style="color: #660066;">iconAnchor</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> GPoint<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #006600; font-style: italic;">// Set icon window anchor</span>
        icon.<span style="color: #660066;">infoWindowAnchor</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> GPoint<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">5</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #006600; font-style: italic;">// Call createMarker w/ point, icon and html from attribute</span>
        <span style="color: #003366; font-weight: bold;">var</span> marker <span style="color: #339933;">=</span> createMarker<span style="color: #009900;">&#40;</span> point<span style="color: #339933;">,</span> icon<span style="color: #339933;">,</span>
          markerlist<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">getAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;html&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #006600; font-style: italic;">// Add marker overlay to map</span>
        map.<span style="color: #660066;">addOverlay</span><span style="color: #009900;">&#40;</span>marker<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #006600; font-style: italic;">// Send request to get XML file</span>
  request.<span style="color: #660066;">send</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Step 2 &#8212; <strong>XML Map Data</strong></p>
<p>Next, build an XML file containing enough data to describe the map.</p>
<p><em>Update #1: I&#8217;ve updated this to include a break (&lt;br/&gt;) between IBM and Dev in the info popup HTML. It must be XML encoded to obscure the angle-brackets from the XML parser.</em></p>
<p><em>Update #2: I&#8217;ve updated this to include an anchor around IBM in the info popup HTML.</em></p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">&nbsp;</pre></div></div>

<p>Step 3 &#8212; <strong>HTML Google Map File</strong></p>
<p>You need a file in a static location to embed the API functions provided by Google. Otherwise you&#8217;ll get a popup complaining that your API key is for a different URL. Make sure you replace [**your api key**] in the code below with your Google Maps API Key.</p>
<p>This HTML file is simply the contents of the IFRAME you&#8217;ll be embedding in your WordPress post.</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">&nbsp;
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://maps.google.com/maps?file=api&amp;amp;v=1&amp;amp;key=[**your api key**]&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;</span><span style="color: #808080; font-style: italic;">&lt;!--mce:0--&gt;</span><span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://techrageo.us/wp-content/GooMap.js&quot;</span>&gt;</span><span style="color: #808080; font-style: italic;">&lt;!--mce:1--&gt;</span><span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;</span><span style="color: #808080; font-style: italic;">&lt;!--mce:2--&gt;</span><span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span></pre></div></div>

<p>Step 4 &#8212; <strong>Embedding Google Map in Your WordPress Post</strong></p>
<p>Finally, when you get to the point where you want to embed the map, simply include the following in your post.</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">Sorry. If you're seeing this, your browser doesn't support IFRAMEs.
You should upgrade to a more current browser.</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://techrageo.us/2005/08/16/google-maps-api-and-wordpress/feed/</wfw:commentRss>
		<slash:comments>65</slash:comments>
		</item>
		<item>
		<title>Creating a Drag and Drop Schedule For Your Web Application</title>
		<link>http://techrageo.us/2005/08/09/creating-a-drag-and-drop-schedule-for-your-web-application/</link>
		<comments>http://techrageo.us/2005/08/09/creating-a-drag-and-drop-schedule-for-your-web-application/#comments</comments>
		<pubDate>Tue, 09 Aug 2005 19:14:29 +0000</pubDate>
		<dc:creator>grant</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Web design]]></category>

		<guid isPermaLink="false">http://techrageo.us/?p=40</guid>
		<description><![CDATA[If you are creating a web application and you need to have the ability to schedule resources (people, machines, Precious Moments figurines, etc) it can sometimes be a cumbersome task. With this drag and drop schedule you won&#8217;t have to worry about the end user making typos in an html form and causing more trouble [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://techrageo.us/wp-content/schedule_normal_big.jpg"><img align="right" src="http://techrageo.us/wp-content/schedule_normal_small.jpg" style="border: thin solid black;" /></a></p>
<p>If you are creating a web application and you need to have the ability to schedule resources (people, machines, Precious Moments figurines, etc) it can sometimes be a cumbersome task.  With this drag and drop schedule you won&#8217;t have to worry about the end user making typos in an html form and causing more trouble for you later.</p>
<p>Let&#8217;s start off by putting the obvious header information along with some javascript variables that we will use later:</p>
<blockquote style="border: thin solid black; background-color: #ffffee;"><p>
&lt;!DOCTYPE html PUBLIC &#8220;-//W3C//DTD XHTML 1.0 Transitional//EN&#8221; &#8220;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#8221;&gt;<br />
&lt;html&gt;<br />
  &lt;head&gt;<br />
    &lt;title&gt;Test Schedule&lt;/title&gt;<br />
    &lt;script&gt;<br />
      var moving_object = &#8220;&#8221;;<br />
      var mX, mY, devX, devY;<br />
      var set_to_grid = true;<br />
      var lock_x_axis = false;<br />
      var lock_y_axis = false;<br />
      var gridX = 10;<br />
      var gridY = 10;
</p></blockquote>
<p>Next, while still in the script tag we need a function that will keep track of our mouse movements so that we know when the user is dragging an object.<br />
This function will also be responsible for moving the floating schedule objects and should be able to restrict the movement of the floating objects so that they only move horizontally or vertically (depending on your schedule type).<br />
Another nice feature would be to lock the floater to an invisible grid so that placing your object in the correct spot is easier.</p>
<blockquote style="border: thin solid black; background-color: #ffffee;"><p>
      function setCoords( e )<br />
      {<br />
        &nbsp;if( document.all )<br />
        &nbsp;{<br />
          &nbsp;&nbsp;mX = event.clientX;<br />
          &nbsp;&nbsp;mY = event.clientY;<br />
        &nbsp;}<br />
        &nbsp;else<br />
        &nbsp;{<br />
          &nbsp;&nbsp;mX = e.pageX;<br />
          &nbsp;&nbsp;mY = e.pageY;<br />
        &nbsp;}<br />
        &nbsp;if( moving_object )<br />
        &nbsp;{<br />
          &nbsp;&nbsp;if( moving_object != &#8220;&#8221; )<br />
          &nbsp;&nbsp;{<br />
            &nbsp;&nbsp;&nbsp;if( set_to_grid )<br />
            &nbsp;&nbsp;&nbsp;{<br />
              &nbsp;&nbsp;&nbsp;&nbsp;useY = parseInt( (mY &#8211; devY) / gridY) * gridY;<br />
              &nbsp;&nbsp;&nbsp;&nbsp;useX = parseInt( (mX &#8211; devX) / gridX) * gridX;<br />
            &nbsp;&nbsp;&nbsp;}<br />
            &nbsp;&nbsp;&nbsp;else<br />
            &nbsp;&nbsp;&nbsp;{<br />
              &nbsp;&nbsp;&nbsp;&nbsp;useY = mY &#8211; devY;<br />
              &nbsp;&nbsp;&nbsp;&nbsp;useX = mX &#8211; devX;<br />
            &nbsp;&nbsp;&nbsp;}<br />
            &nbsp;&nbsp;&nbsp;if( lock_y_axis == false )<br />
            &nbsp;&nbsp;&nbsp;{<br />
              &nbsp;&nbsp;&nbsp;&nbsp;document.getElementById(moving_object).style.top = useY + &#8220;px&#8221;;<br />
            &nbsp;&nbsp;&nbsp;}</p>
<p>            &nbsp;&nbsp;&nbsp;if( lock_x_axis == false )<br />
            &nbsp;&nbsp;&nbsp;{<br />
              &nbsp;&nbsp;&nbsp;&nbsp;document.getElementById(moving_object).style.left = useX + &#8220;px&#8221;;<br />
            &nbsp;&nbsp;&nbsp;}<br />
          &nbsp;&nbsp;}<br />
        &nbsp;}<br />
      }
</p></blockquote>
<p>We also need a function that is called when we click on the floating object that tells the <b>setCoords()</b> function some basic information, like which object is moving and if it should lock the movement in any way.<br />
This function should also bring the floating object above the rest of the objects on the page.</p>
<blockquote style="border: thin solid black; background-color: #ffffee;"><p>
      function setMover( object_id , lock_y, lock_x, use_grid )<br />
      {<br />
        &nbsp;moving_object = object_id;<br />
        &nbsp;set_to_grid = use_grid;<br />
        &nbsp;lock_x_axis = lock_x;<br />
        &nbsp;lock_y_axis = lock_y;</p>
<p>        &nbsp;if( object_id != &#8220;&#8221; )<br />
        &nbsp;{<br />
          &nbsp;&nbsp;devY = mY &#8211; parseInt( document.getElementById( moving_object ).style.top );<br />
          &nbsp;&nbsp;devX = mX &#8211; parseInt( document.getElementById( moving_object ).style.left );<br />
          &nbsp;&nbsp;document.getElementById( moving_object ).style.zIndex=99;<br />
        &nbsp;}<br />
      }
</p></blockquote>
<p>Lastly, we need a function that is called when the user &#8220;let&#8217;s go&#8221; of the floating (i.e. they dropped it).  This function basically undoes everything that <b>setMover()</b> does and moves the floating object back down with the rest of the objects.</p>
<p>If you want to get really fancy you can update a database from this function, which comes in handy if you want to automatically save the new position of your floater.  To do this just create an invisible iframe document with a form in it.  Update the form from within this function and use the form&#8217;s submit() function to send the new coordinates to the database.</p>
<blockquote style="border: thin solid black; background-color: #ffffee;"><p>
      function unSetMover( object_id )<br />
      {<br />
        &nbsp;moving_object = &#8220;&#8221;;<br />
        &nbsp;lock_x_axis = false;<br />
        &nbsp;lock_y_axis = false;<br />
        &nbsp;if( object_id != &#8220;&#8221; )<br />
        &nbsp;{<br />
          &nbsp;&nbsp;document.getElementById( object_id ).style.zIndex=10;<br />
        &nbsp;}<br />
        &nbsp;//Something like this might help you update the database:<br />
        &nbsp;//frames['hidden_iframe'].document.editform.x_coord.value = mX;<br />
        &nbsp;//frames['hidden_iframe'].document.editform.y_coord.value = mY;<br />
        &nbsp;//frames['hidden_iframe'].document.editform.submit();<br />
      }<br />
    &lt;/script&gt;<br />
  &lt;/head&gt;
</p></blockquote>
<p>The next thing our page needs is some style.  We need a class for our floater objects, for consistancy. Most of this is just fluff, the &#8216;position&#8217; is the only essential part.</p>
<blockquote style="border: thin solid black; background-color: #ffffee;"><p>
  &lt;style&gt;<br />
    .floater<br />
    {<br />
      &nbsp;z-index: 10;<br />
      &nbsp;text-align: center;<br />
      &nbsp;position: absolute;<br />
      &nbsp;border: thin solid black;<br />
    }
</p></blockquote>
<p><img align="right" src='http://techrageo.us/wp-content/schedule_transparent.jpg' alt='Transparent Hovering' style="border: thin solid black;" /><br />
It would be nice if our &#8216;floater&#8217; class did something to highlight itself when the mouse was floating over it.  It would also be nice if it became semi-transparent while it was moving over the other objects so we could see what was underneath it.   <em>(This is all fluff&#8230;you can leave this out if you want to)</em></p>
<blockquote style="border: thin solid black; background-color: #ffffee;"><p>
    .floater:hover<br />
    {<br />
      &nbsp;opacity: .75;<br />
      &nbsp;filter: alpha( opacity = 75 );<br />
      &nbsp;border: thin dashed blue;<br />
    }
</p></blockquote>
<p>The last part of the style is just to setup the background and x/y axis so that it resembles a schedule.</p>
<blockquote style="border: thin solid black; background-color: #ffffee;"><p>
    body<br />
    {<br />
      &nbsp;background-image: url(&#8216;images/background_time_grid.gif&#8217;);<br />
    }</p>
<p>    .axis-background, .row-background<br />
    {<br />
      &nbsp;opacity: .35;<br />
      &nbsp;filter: alpha(opacity=35);<br />
      &nbsp;position: absolute;<br />
    }<br />
    .axis-background<br />
    {<br />
      &nbsp;background-color: #aaaadd;<br />
    }<br />
    .row-background<br />
    {<br />
      &nbsp;background-color: #ddddaa;<br />
    }<br />
    .axis-label<br />
    {<br />
      &nbsp;background-color: #ffffee;<br />
      &nbsp;position: absolute;<br />
      &nbsp;text-align: center;<br />
      &nbsp;font-size: 90%;<br />
      &nbsp;border: thin solid black;<br />
    }<br />
  &lt;/style&gt;
</p></blockquote>
<p>When declaring the &#8216;body&#8217; element we need to make sure that it runs the <b>setCoords()</b> function each time the mouse moves, so we will know where the pointer is if we are moving an floating object.</p>
<blockquote style="border: thin solid black; background-color: #ffffee;"><p>
  &lt;body onMouseMove=&#8221;setCoords(event);&#8221;&gt;
</p></blockquote>
<p>Next, we are going to create a nice background for our x and y axis.</p>
<blockquote style="border: thin solid black; background-color: #ffffee;"><p>
    &lt;div class=&#8221;axis-background&#8221; style=&#8221;top: 0px; left: 0px; height: 50px; width: 100%;&#8221;&gt;&amp;nbsp;&lt;/div&gt;<br />
    &lt;div class=&#8221;axis-background&#8221; style=&#8221;top: 50px; left: 0px; height: 100%; width: 100px;&#8221;&gt;&amp;nbsp;&lt;/div&gt;
</p></blockquote>
<p>Now let&#8217;s put some times along the top of the page on the x-axis.  You&#8217;ll probably want generate these out of a database, but to show you how it is done we will just use static html.</p>
<blockquote style="border: thin solid black; background-color: #ffffee;"><p>
    &lt;div class=&#8221;axis-label&#8221; style=&#8221;top: 5px; left: 70px; width: 60px;&#8221;&gt;8:00AM&lt;/div&gt;<br />
    &lt;div class=&#8221;axis-label&#8221; style=&#8221;top: 5px; left: 170px; width: 60px;&#8221;&gt;9:00AM&lt;/div&gt;<br />
    &lt;div class=&#8221;axis-label&#8221; style=&#8221;top: 5px; left: 270px; width: 60px;&#8221;&gt;10:00AM&lt;/div&gt;<br />
    &lt;div class=&#8221;axis-label&#8221; style=&#8221;top: 5px; left: 370px; width: 60px;&#8221;&gt;11:00AM&lt;/div&gt;<br />
    &lt;div class=&#8221;axis-label&#8221; style=&#8221;top: 5px; left: 470px; width: 60px;&#8221;&gt;12:00AM&lt;/div&gt;<br />
    &lt;div class=&#8221;axis-label&#8221; style=&#8221;top: 5px; left: 570px; width: 60px;&#8221;&gt;1:00AM&lt;/div&gt;<br />
    &lt;div class=&#8221;axis-label&#8221; style=&#8221;top: 5px; left: 670px; width: 60px;&#8221;&gt;2:00AM&lt;/div&gt;<br />
    &lt;div class=&#8221;axis-label&#8221; style=&#8221;top: 5px; left: 770px; width: 60px;&#8221;&gt;3:00AM&lt;/div&gt;<br />
    &lt;div class=&#8221;axis-label&#8221; style=&#8221;top: 5px; left: 870px; width: 60px;&#8221;&gt;4:00AM&lt;/div&gt;
</p></blockquote>
<p>We need to create the y-axis labels now.  Again, you&#8217;ll probably generate these values from a database but for our example we&#8217;ll just use assume we are scheduling &#8220;work stations&#8221;.</p>
<blockquote style="border: thin solid black; background-color: #ffffee;"><p>
    &lt;div class=&#8221;axis-label&#8221; style=&#8221;top: 60px; left: 5px; width: 90px;&#8221;&gt;Work Station 1&lt;/div&gt;<br />
    &lt;div class=&#8221;row-background&#8221; style=&#8221;top: 160px; left: 100px; height: 100px; width: 100%;&#8221;&gt;&amp;nbsp;&lt;/div&gt;<br />
    &lt;div class=&#8221;axis-label&#8221; style=&#8221;top: 160px; left: 5px; width: 90px;&#8221;&gt;Work Station 2&lt;/div&gt;<br />
    &lt;div class=&#8221;axis-label&#8221; style=&#8221;top: 260px; left: 5px; width: 90px;&#8221;&gt;Work Station 3&lt;/div&gt;<br />
    &lt;div class=&#8221;row-background&#8221; style=&#8221;top: 360px; left: 100px; height: 100px; width: 100%;&#8221;&gt;&amp;nbsp;&lt;/div&gt;<br />
    &lt;div class=&#8221;axis-label&#8221; style=&#8221;top: 360px; left: 5px; width: 90px;&#8221;&gt;Work Station 4&lt;/div&gt;
</p></blockquote>
<p>Finally (at last!) we can create the actual floating objects.  We are going to make these all a different color (and all pastel at that).  These you would definitely want to generate from a database&#8230;else the purpose of this article is probably lost on you.  Our object needs to run the <b>setMover()</b> function when it is clicked and it needs to run the <b>unSetMover()</b> function when that click is released (when it is &#8216;dropped&#8217;).  If you are scheduling people you can even put a thumbnail image in these floaters so that the end user will really feel at home&#8211;pushing around his/her co-workers.</p>
<p>You&#8217;ll notice that the third floater does not restrict the movement at all, the user can move it up, down, left and right.  This should give you an idea of how movements can be done.</p>
<blockquote style="border: thin solid black; background-color: #ffffee;">
<p>    &lt;div id=&#8221;floater1&#8243; class=&#8221;floater&#8221; style=&#8221;background-color:#cccccc; top: 50px; left: 100px; width: 100px&#8221; onmousedown=&#8221; setMover( &#8216;floater1&#8242;, true, false, true );&#8221; onmouseup=&#8221; unSetMover( &#8216;floater1&#8242; );&#8221; &gt;Order 1991-01A&lt;br /&gt;&lt;hr&gt;&lt;small&gt;Shearer, Grant&lt;/small&gt;&lt;/div&gt;</p>
<p>    &lt;div id=&#8221;floater2&#8243; class=&#8221;floater&#8221; style=&#8221;background-color:#ffccff; top: 50px; left: 200px; width: 80px&#8221; onmousedown=&#8221; setMover( &#8216;floater2&#8242;, true, false, true );&#8221; onmouseup=&#8221; unSetMover( &#8216;floater2&#8242; );&#8221; &gt;Order 2491-01A&lt;br /&gt;&lt;hr&gt;&lt;small&gt;Dummy, Test&lt;/small&gt;&lt;/div&gt;</p>
<p>    &lt;div id=&#8221;floater3&#8243; class=&#8221;floater&#8221; style=&#8221;background-color:#ccccff; top: 50px; left: 280px; width: 120px&#8221; onmousedown=&#8221; setMover( &#8216;floater3&#8242;, false, false, false );&#8221; onmouseup=&#8221; unSetMover( &#8216;floater3&#8242; );&#8221; &gt;Order 1431-01A&lt;br /&gt;&lt;hr&gt;&lt;small&gt;Smith, Bob&lt;/small&gt;&lt;/div&gt;</p>
<p>    &lt;div id=&#8221;floater4&#8243; class=&#8221;floater&#8221; style=&#8221;background-color:#ccffcc; top: 50px; left: 400px; width: 70px&#8221; onmousedown=&#8221; setMover( &#8216;floater4&#8242;, true, false, true );&#8221; onmouseup=&#8221; unSetMover( &#8216;floater4&#8242; );&#8221; &gt;Order 2236-09A&lt;br /&gt;&lt;hr&gt;&lt;small&gt;Springer, Jerry&lt;/small&gt;&lt;/div&gt;</p>
<p>    &lt;div id=&#8221;floater5&#8243; class=&#8221;floater&#8221; style=&#8221;background-color:#ffcccc; top: 50px; left: 470px; width: 110px&#8221; onmousedown=&#8221; setMover( &#8216;floater5&#8242;, true, false, true );&#8221; onmouseup=&#8221; unSetMover( &#8216;floater5&#8242; );&#8221; &gt;Order 3507-00&lt;br /&gt;&lt;hr&gt;&lt;small&gt;Simpleton Sr, Gary&lt;/small&gt;&lt;/div&gt;</p>
<p>    &lt;div id=&#8221;floater6&#8243; class=&#8221;floater&#8221; style=&#8221;background-color:#ffffcc; top: 50px; left: 580px; width: 170px&#8221; onmousedown=&#8221; setMover( &#8216;floater6&#8242;, true, false, true );&#8221; onmouseup=&#8221; unSetMover( &#8216;floater6&#8242; );&#8221; &gt;Order 3567-00&lt;br /&gt;&lt;hr&gt;&lt;small&gt;Simpleton Jr, Gary&lt;/small&gt;&lt;/div&gt;</p>
<p>    &lt;div id=&#8221;floater7&#8243; class=&#8221;floater&#8221; style=&#8221;background-color:#ccffff; top: 50px; left: 750px; width: 90px&#8221; onmousedown=&#8221; setMover( &#8216;floater7&#8242;, true, false, true );&#8221; onmouseup=&#8221; unSetMover( &#8216;floater7&#8242; );&#8221; &gt;Order 3337-00&lt;br /&gt;&lt;hr&gt;&lt;small&gt;Jingleheimer, Jerry&lt;/small&gt;&lt;/div&gt;</p>
<p>    &lt;div id=&#8221;floater8&#8243; class=&#8221;floater&#8221; style=&#8221;background-color:#ffcccc; top: 150px; left: 100px; width: 110px&#8221; onmousedown=&#8221; setMover( &#8216;floater8&#8242;, true, false, true );&#8221; onmouseup=&#8221; unSetMover( &#8216;floater8&#8242; );&#8221; &gt;Order 5507-00&lt;br /&gt;&lt;hr&gt;&lt;small&gt;Simpleton Sr, Gary&lt;/small&gt;&lt;/div&gt;</p>
<p>    &lt;div id=&#8221;floater9&#8243; class=&#8221;floater&#8221; style=&#8221;background-color:#ffffcc; top: 150px; left: 210px; width: 170px&#8221; onmousedown=&#8221; setMover( &#8216;floater9&#8242;, true, false, true );&#8221; onmouseup=&#8221; unSetMover( &#8216;floater9&#8242; );&#8221; &gt;Order 8456-00&lt;br /&gt;&lt;hr&gt;&lt;small&gt;Simpleton Jr, Gary&lt;/small&gt;&lt;/div&gt;</p>
<p>    &lt;div id=&#8221;floater10&#8243; class=&#8221;floater&#8221; style=&#8221;background-color:#ccffff; top: 150px; left: 380px; width: 90px&#8221; onmousedown=&#8221; setMover( &#8216;floater10&#8242;, true, false, true );&#8221; onmouseup=&#8221; unSetMover( &#8216;floater10&#8242; );&#8221; &gt;Order 4321-00&lt;br /&gt;&lt;hr&gt;&lt;small&gt;Jingleheimer, Jerry&lt;/small&gt;&lt;/div&gt;
   </p></blockquote>
<p>   The ending.  The iframe and it&#8217;s contents are only needed if you plan on updating your database every time the user &#8220;drops&#8221; one of the floating objects.</p>
<blockquote style="border: thin solid black; background-color: #ffffee;"><p>
  &lt;iframe name=&#8221;hidden_iframe&#8221; style=&#8221;visibility: hidden;&#8221;&gt;<br />
 		&lt;form name=&#8221;editform&#8221; method=&#8221;post&#8221; action=&#8221;myupdatepage.php&#8221;&gt;<br />
 		 &lt;input type=&#8221;hidden&#8221; name=&#8221;x_coord&#8221; /&gt;<br />
 		 &lt;input type=&#8221;hidden&#8221; name=&#8221;y_coord&#8221; /&gt;<br />
    &lt;/form><br />
  &lt;/iframe&gt;<br />
  &lt;/body&gt;<br />
&lt;/html&gt;
</p></blockquote>
<p><center><a href="http://techrageo.us/wp-content/code/schedule.html"><b>See it in action</b></a></center><br />
(To use the code, just click on &#8220;See it in action&#8221; and save the page from there)</p>
<p><small style="color: #992222;">Some of the css used in the code above does not work in all browsers.  The opacity property, for instance, does not appear to work in Internet Explorer.  YMMV.</small></p>
]]></content:encoded>
			<wfw:commentRss>http://techrageo.us/2005/08/09/creating-a-drag-and-drop-schedule-for-your-web-application/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>del.icio.us Javascript Linkrolls</title>
		<link>http://techrageo.us/2005/08/05/delicious-javascript-linkrolls/</link>
		<comments>http://techrageo.us/2005/08/05/delicious-javascript-linkrolls/#comments</comments>
		<pubDate>Fri, 05 Aug 2005 20:40:33 +0000</pubDate>
		<dc:creator>bill</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Web design]]></category>

		<guid isPermaLink="false">http://techrageo.us/?p=37</guid>
		<description><![CDATA[del.icio.us now provides linkrolls via javascript. All you have to do to use it is copy the following script to your editor (it&#8217;s all one line, so remove any line breaks): &#60;script type="text/javascript"src="http://del.icio.us/feeds/js/techrageo.us/tech?tags;extended;count=14;title=my%20del.icio.us;bullet=%C2%BB;icon;sort=alpha"&#62;&#60;/script&#62; Then adjust the querystring to your needs as follows Modify &#8220;techrageo.us&#8221; to whoever&#8217;s del.icio.us links you want to monitor Modify &#8220;tech&#8221; to [...]]]></description>
			<content:encoded><![CDATA[<p>del.icio.us now provides <a href="http://del.icio.us/doc/feeds/js/">linkrolls via javascript</a>.<br />
<blockquote><script type="text/javascript" src="http://del.icio.us/feeds/js/techrageo.us?bullet=%C2%BB"></script>
</p></blockquote>
<p>All you have to do to use it is copy the following script to your editor (it&#8217;s all one line, so remove any line breaks):</p>
<blockquote><p>
<code>&lt;script type="text/javascript"<br />src="http://del.icio.us/feeds/js/techrageo.us/tech?tags;<br />extended;count=14;title=my%20del.icio.us;<br />bullet=%C2%BB;icon;sort=alpha"&gt;&lt;/script&gt;<br />
</code>
</p></blockquote>
<p>Then adjust the querystring to your needs as follows</p>
<ul>
<li>Modify &#8220;techrageo.us&#8221; to whoever&#8217;s del.icio.us links you want to monitor</li>
<li>Modify &#8220;tech&#8221; to filter by a certain tag, combine them with &#8220;+&#8221; as in &#8220;tech+diy&#8221;, or remove the &#8220;/tech&#8221; altogether to not filter by tags.</li>
<li><strong>extended</strong> &#8212; include &#8220;extended&#8221; if you want to see the extended text for each link</li>
<li><strong>tags</strong> &#8212; include &#8220;tags&#8221; if you want to see the tags for each link</li>
<li><strong>count</strong> &#8212; include &#8220;count&#8221; if you want some number of links displayed besides the default (20, I believe)</li>
<li><strong>title</strong> &#8212; include &#8220;title&#8221; if you want del.icio.us to add a title, or simply remove the title portion of the querystring</li>
<li><strong>bullet</strong> &#8212; include &#8220;bullet&#8221; and set it to a character if you want a bullet displayed before each link</li>
<li><strong>icon</strong> &#8212; include &#8220;icon&#8221; if you want the del.icio.us icon to appear, or remove it for no icon.</li>
<li><strong>sort</strong> &#8212; include &#8220;sort=alpha&#8221; if you want the links to be sorted alphabetically. If the <em>sort</em> key is not included, the default is to list the links chronologically.</li>
<li>Drop the resulting script into your web code where you want the links to appear</li>
<li>del.icio.us delivers the link feed inline</li>
</ul>
<p>Kind of snazzy.</p>
]]></content:encoded>
			<wfw:commentRss>http://techrageo.us/2005/08/05/delicious-javascript-linkrolls/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

