<?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>indiWiz.com &#187; javascript</title>
	<atom:link href="http://indiwiz.com/tag/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://indiwiz.com</link>
	<description>Subhash&#039;s Tech Log</description>
	<lastBuildDate>Sun, 29 Apr 2012 15:11:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Accessing RESTful WebServices with Prototype.js</title>
		<link>http://indiwiz.com/2009/07/22/accessing-restful-webservices-with-prototype-js/</link>
		<comments>http://indiwiz.com/2009/07/22/accessing-restful-webservices-with-prototype-js/#comments</comments>
		<pubDate>Wed, 22 Jul 2009 07:30:14 +0000</pubDate>
		<dc:creator>Subhash Chandran</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[rest]]></category>
		<category><![CDATA[webservice]]></category>

		<guid isPermaLink="false">http://indiwiz.com/?p=396</guid>
		<description><![CDATA[We can make Ajax requests using Prototype.js (version 1.6.0.3) thus: While working on this code, we found out that the method parameter accepted only GET or POST requests. When we give any other request type like DELETE or PUT, the Prototype.js library converted the request to POST. Arun Jeganath found this post where the same [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop --><!-- End Shareaholic LikeButtonSetTop --><p>We can make Ajax requests using <a href="http://www.prototypejs.org/">Prototype.js</a> (version 1.6.0.3) thus:</p>
<pre class="brush: jscript; title: ; notranslate">
var url = ...;
new Ajax.Request(
            url,
            {
               method:'DELETE',
               onComplete:function doMessage(response){
                   alert(response.status);
               }
            });
</pre>
<p>While working on this code, we found out that the <tt>method</tt> parameter accepted only GET or POST requests. When we give any other request type like DELETE or PUT, the Prototype.js library converted the request to POST.</p>
<p><a href="http://www.linkedin.com/in/arunjeganath">Arun Jeganath</a> found <a href="https://prototype.lighthouseapp.com/projects/8886/tickets/289-allow-put-delete-and-other-http-methods-on-ajax-requests">this post</a> where the same issue is discussed. The problem was solved when we commented these lines from the Prototype.js code:</p>
<pre>
      if (!['get', 'post'].include(this.method)) {
        //simulate other verbs over post
        params['_method'] = this.method;
        this.method = 'post';
      }
</pre>
<div class="shr-publisher-396"></div><!-- Start Shareaholic LikeButtonSetBottom --><!-- End Shareaholic LikeButtonSetBottom -->]]></content:encoded>
			<wfw:commentRss>http://indiwiz.com/2009/07/22/accessing-restful-webservices-with-prototype-js/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>37 Signals Launches Sprockets</title>
		<link>http://indiwiz.com/2009/02/20/37-signals-launches-sprockets/</link>
		<comments>http://indiwiz.com/2009/02/20/37-signals-launches-sprockets/#comments</comments>
		<pubDate>Fri, 20 Feb 2009 08:58:04 +0000</pubDate>
		<dc:creator>Subhash Chandran</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[news]]></category>

		<guid isPermaLink="false">http://indiwiz.com/?p=207</guid>
		<description><![CDATA[Sprockets (site) is described thus: Sprockets is a Ruby library that preprocesses and concatenates JavaScript source files. This is not a new idea, I have seen similar compiler in Liferay source for aggregating CSS files. Since this is sponsored by 37 Signals (creators or Ruby on Rails), Sprockets&#8217;s syntax can become a kind of standard. [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop --><!-- End Shareaholic LikeButtonSetTop --><p>Sprockets (<a href="http://getsprockets.org/">site</a>) is described thus: <i>Sprockets is a Ruby library that preprocesses and concatenates JavaScript source files</i>. This is not a new idea, I have seen similar compiler in <a href="http://www.liferay.com/">Liferay</a> source for aggregating CSS files. Since this is sponsored by <a href="http://www.37signals.com/">37 Signals</a> (creators or Ruby on Rails), Sprockets&#8217;s syntax can become a kind of standard. Already <a href="http://www.prototypejs.org/">Prototype</a> and <a href="http://script.aculo.us/">Script.aculo.us</a> JavaScript libraries (two OpenSource JavaScript libraries popular in RoR) comply to Sprockets&#8217;s syntax.</p>
<div class="shr-publisher-207"></div><!-- Start Shareaholic LikeButtonSetBottom --><!-- End Shareaholic LikeButtonSetBottom -->]]></content:encoded>
			<wfw:commentRss>http://indiwiz.com/2009/02/20/37-signals-launches-sprockets/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google CDN for popular JavaScript libraries</title>
		<link>http://indiwiz.com/2009/01/27/google-cdn-for-popular-javascript-libraries/</link>
		<comments>http://indiwiz.com/2009/01/27/google-cdn-for-popular-javascript-libraries/#comments</comments>
		<pubDate>Tue, 27 Jan 2009 14:35:10 +0000</pubDate>
		<dc:creator>Subhash Chandran</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://indiwiz.com/?p=184</guid>
		<description><![CDATA[Google is hosting versions of popular OpenSource JavaScript libraries (as a CDN&#8211;Content Delivery Network). The list of libraries include Prototype, jQuery, Scriptaculous, YUI and others. These can be directly linked to the Google URL. The advantages: Bandwidth saving: these files need not be hosted in local webservers, saving local bandwidth. Effective client side caching: if [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop --><!-- End Shareaholic LikeButtonSetTop --><p>Google is <a href="http://code.google.com/apis/ajaxlibs/">hosting versions of popular OpenSource JavaScript libraries</a> (as a <a href="http://en.wikipedia.org/wiki/Content_Delivery_Network">CDN&#8211;Content Delivery Network</a>). The list of libraries include <a href="http://www.prototypejs.org/">Prototype</a>, <a href="http://jquery.com/">jQuery</a>, <a href="http://script.aculo.us/">Scriptaculous</a>, <a href="http://developer.yahoo.com/yui/">YUI</a> and others. These can be directly linked to the Google URL. The advantages:</p>
<ul>
<li>Bandwidth saving: these files need not be hosted in local webservers, saving local bandwidth.</li>
<li>Effective client side caching: if a person visits 100 sites using Prototype library version 1.6.0.3, and if all these sites link to the Google CDN, then the script will be downloaded to the user&#8217;s system only once.</li>
</ul>
<p>Now the common fear among people: what if the URL changes? What happens when newer version of the libraries come up? Google&#8217;s promise (from the site):</p>
<p><i>Google works directly with the key stake holders for each library effort and accepts the latest stable versions as they are released. Once we host a release of a given library, we are committed to hosting that release indefinitely.</i></p>
<div class="shr-publisher-184"></div><!-- Start Shareaholic LikeButtonSetBottom --><!-- End Shareaholic LikeButtonSetBottom -->]]></content:encoded>
			<wfw:commentRss>http://indiwiz.com/2009/01/27/google-cdn-for-popular-javascript-libraries/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Feature Request: Script Exclusion in HTML</title>
		<link>http://indiwiz.com/2009/01/05/feature-request-script-exclusion-in-html/</link>
		<comments>http://indiwiz.com/2009/01/05/feature-request-script-exclusion-in-html/#comments</comments>
		<pubDate>Mon, 05 Jan 2009 10:44:26 +0000</pubDate>
		<dc:creator>Subhash Chandran</dc:creator>
				<category><![CDATA[Innovation]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[xhtml]]></category>

		<guid isPermaLink="false">http://indiwiz.com/?p=135</guid>
		<description><![CDATA[I am working currently in a portal project. From various datasources we collect information and publish as portlets. The current UI scenario requires us to use JavaScript libraries like prototype.js and jQuery. In both these libraries, $() has different meaning. So when we tie a particular portlet&#8217;s UI to prototype.js, and another to jQuery, we [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop --><!-- End Shareaholic LikeButtonSetTop --><p>I am working currently in a portal project. From various datasources we collect information and publish as portlets. The current UI scenario requires us to use JavaScript libraries like <a href="http://www.prototypejs.org/">prototype.js</a> and <a href="http://jquery.com/">jQuery</a>. In both these libraries, <tt>$()</tt> has different meaning. So when we tie a particular portlet&#8217;s UI to prototype.js, and another to jQuery, we cannot effectively place both of them in the same page.</p>
<p>If HTML/XHTML provides some kind of script exclusion so that scripts placed inside a particular scope do not reveal their functions and variables globally across the page, it is going to be helpful. For example:</p>
<pre>
&lt;script-package name=&quot;abc&quot;&gt;
  &lt;script src=&quot;prototype.js&quot; type=&quot;text/javascript&quot;/&gt;

  &lt;script type=&quot;text/javascript&quot;&gt;
    // use prototype specific code
  &lt;/script&gt;
&lt;/script-package&gt;

&lt;script-package name=&quot;xyz&quot;&gt;
  &lt;script src=&quot;jquery.js&quot; type=&quot;text/javascript&quot;/&gt;

  &lt;script type=&quot;text/javascript&quot;&gt;
    // use jQuery specific code
  &lt;/script&gt;
&lt;/script-package&gt;
</pre>
<p>In the rare case when a script needs to access some variable defined in different package, it can use some namespace mechanism. Any ideas?</p>
<div class="shr-publisher-135"></div><!-- Start Shareaholic LikeButtonSetBottom --><!-- End Shareaholic LikeButtonSetBottom -->]]></content:encoded>
			<wfw:commentRss>http://indiwiz.com/2009/01/05/feature-request-script-exclusion-in-html/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Search for the perfect Ajax auto-complete library</title>
		<link>http://indiwiz.com/2008/12/31/search-for-the-perfect-ajax-auto-complete/</link>
		<comments>http://indiwiz.com/2008/12/31/search-for-the-perfect-ajax-auto-complete/#comments</comments>
		<pubDate>Wed, 31 Dec 2008 06:47:25 +0000</pubDate>
		<dc:creator>Subhash Chandran</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[json]]></category>

		<guid isPermaLink="false">http://indiwiz.com/?p=121</guid>
		<description><![CDATA[Yesterday we (Krithika and myself) spent some time finding a perfect Ajax auto-complete solution for one of our internal projects. We wanted to have a tag search box with auto-complete functionality. We had created a front-end layer for our Java tagging API (developed by Arun) using RESTful interface. This exposed searched result in JSON. So [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop --><!-- End Shareaholic LikeButtonSetTop --><p>Yesterday we (Krithika and myself) spent some time finding a perfect Ajax auto-complete solution for one of our internal projects. We wanted to have a tag search box with auto-complete functionality. We had created a front-end layer for our Java tagging API (developed by Arun) using RESTful interface. This exposed searched result in JSON. So our need was for a Ajax library which provided auto-complete feature which satisfied following parameters:</p>
<ol>
<li>The code we need to incorporate for enabling auto-complete should be minimal.</li>
<li>Should not be flashy.</li>
<li>Should consume JSON content.</li>
</ol>
<p>This seemed to be a trivial task, but it took quite some time to find and finalize on <a href="http://www.beauscott.com/examples/autocomplete/doc/ns_examples.html">AutoComplete 1.2 by Beau Scott</a>. This script was simple to integrate, and did not require us to configure any sophisticated CSS. It allowed us to consume our RESTful service without any modification.</p>
<p>During our search, we were surprised to find how badly certain popular Ajax libraries implemented this oft-used functionality. The famous <a href="http://script.aculo.us/">Scriptaculous</a> library&#8217;s implementation has the implementation detailed here: <a href="http://github.com/madrobby/scriptaculous/wikis/ajax-autocompleter">http://github.com/madrobby/scriptaculous/wikis/ajax-autocompleter</a>. If you go through this document, you will see that the script requires the server to return data in this format:</p>
<pre>
&lt;ul&gt;
    &lt;li&gt;your mom&lt;/li&gt;
    &lt;li&gt;yodel&lt;/li&gt;
&lt;/ul&gt;
</pre>
<p>This is bad design. A server code returning data as HTML. This cannot be consumed effectively by other clients. The next one which we picked up was <a href="http://developer.yahoo.com/yui/autocomplete/">YUI Autocomplete</a>. The amount of configuration effort needed from our side scared us. We didn&#8217;t plunge deeper!</p>
<p>Another one which we tried was <a href="http://www.devbridge.com/projects/autocomplete/">DevBridge&#8217;s Auto Complete</a>. This looked simple to implement, and the look and feel was simplistic. But it had an issue: the call to the server-side code was passed as a query string (<tt>query=</tt>). We were using RESTful URL and we cannot modify our backend-code to comply to the requirements of the UI layer. But I did a little hack and made this script compliant to our requirement. But finally, we decided against using this patched-script because it had additional dependencies like images and CSS styles to be specified.</p>
<p>As said earlier, the script which matched all our requirements was <a href="http://www.beauscott.com/examples/autocomplete/doc/ns_examples.html">AutoComplete 1.2 by Beau Scott</a>.</p>
<p>The only worry for me from this exercise was the divide between the front-end developers and backend developers. Such a common functionality was not being addressed by popular frameworks without sacrificing functionality and addressing usability&#8211;and, more importantly, complying to established enterprise patterns like consuming data (like JSON and XML instead of HTML snippet) and support for RESTful URLs.</p>
<p>Hope 2009 annihilates this divide <img src='http://indiwiz.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<div class="shr-publisher-121"></div><!-- Start Shareaholic LikeButtonSetBottom --><!-- End Shareaholic LikeButtonSetBottom -->]]></content:encoded>
			<wfw:commentRss>http://indiwiz.com/2008/12/31/search-for-the-perfect-ajax-auto-complete/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JavaScript: Dynamically Creating and Manipulating DOM Elements</title>
		<link>http://indiwiz.com/2008/12/10/javascript-dynamically-creating-and-manipulating-dom-elements/</link>
		<comments>http://indiwiz.com/2008/12/10/javascript-dynamically-creating-and-manipulating-dom-elements/#comments</comments>
		<pubDate>Wed, 10 Dec 2008 09:24:49 +0000</pubDate>
		<dc:creator>Subhash Chandran</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://indiwiz.com/?p=57</guid>
		<description><![CDATA[I was pleasantly surprised to see that JavaScript now supports XML-DOM methods for manipulating JavaScript DOM trees. A quick look at the features: Init Before we proceed with the examples, the setup part. All the examples that follow assume the existence of this in the HTML page: Creating new element Let us assume the requirement [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop --><!-- End Shareaholic LikeButtonSetTop --><p>I was pleasantly surprised to see that JavaScript now supports XML-DOM methods for manipulating JavaScript DOM trees. A quick look at the features:</p>
<h3>Init</h3>
<p>Before we proceed with the examples, the setup part. All the examples that follow assume the existence of this in the HTML page:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;div id=&quot;placeholderId&quot;/&gt;
</pre>
<h3>Creating new element</h3>
<p>Let us assume the requirement of placing <tt>&lt;br/&gt;</tt> element inside the placeholder. The code:</p>
<pre class="brush: jscript; title: ; notranslate">
var e = document.getElementById('placeholderId');
var eBr = document.createElement('br');
e.appendChild(eBr);
</pre>
<h3>Adding attribute</h3>
<p>Suppose we want to add the attribute <tt>id=&quot;brId&quot;</tt>, we would write:</p>
<pre class="brush: jscript; title: ; notranslate">
eBr.setAttribute('id', 'brId');
</pre>
<h3>Deleting attribute</h3>
<pre class="brush: jscript; title: ; notranslate">
eBr.removeAttribute('id');
</pre>
<h3>Deleting element</h3>
<pre class="brush: jscript; title: ; notranslate">
var e = document.getElementById('brId');
var eParent = e.parentNode;
eParent.removeChild(e);
</pre>
<h3>Creating elements with text element</h3>
<p>Consider that we want to have the following paragraph element inside the <tt>placeholderId</tt> <tt>&lt;div&gt;</tt>:</p>
<pre>
&lt;p align="right"&gt;Hello World!&lt;/p&gt;
</pre>
<p>It can be achieved thus:</p>
<pre class="brush: jscript; title: ; notranslate">
var e = document.getElementById('placeholderId');
var ePara = document.createElement('p');
ePara.setAttribute('align', 'right');
var eTxt = document.createTextNode('Hello World!');
ePara.appendChild(eTxt);
e.appendChild(ePara);
</pre>
<p>Happy hacking with this info <img src='http://indiwiz.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<div class="shr-publisher-57"></div><!-- Start Shareaholic LikeButtonSetBottom --><!-- End Shareaholic LikeButtonSetBottom -->]]></content:encoded>
			<wfw:commentRss>http://indiwiz.com/2008/12/10/javascript-dynamically-creating-and-manipulating-dom-elements/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

