<?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>Intelligrape  Groovy &#38; Grails Blogs &#187; javascript</title>
	<atom:link href="http://www.intelligrape.com/blog/tag/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.intelligrape.com/blog</link>
	<description></description>
	<lastBuildDate>Thu, 02 Feb 2012 07:48:06 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<image>
			<title>Intelligrape  Groovy &amp; Grails Blogs</title>
			<url>http://www.intelligrape.com/blog/wp-content/uploads/2011/05/favicon2.ico</url>
			<link>http://www.intelligrape.com/blog</link>
			<width></width>
			<height></height>
			<description></description>
		</image>		<item>
		<title>Getting started with extJS</title>
		<link>http://www.intelligrape.com/blog/2011/04/14/getting-started-with-extjs/</link>
		<comments>http://www.intelligrape.com/blog/2011/04/14/getting-started-with-extjs/#comments</comments>
		<pubDate>Thu, 14 Apr 2011 16:11:06 +0000</pubDate>
		<dc:creator>Anuj Aneja</dc:creator>
				<category><![CDATA[Grails]]></category>
		<category><![CDATA[extjs]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.intelligrape.com/blog/?p=3642</guid>
		<description><![CDATA[Ext.JS JavaScript Framework a cross-browser JavaScript library for building rich internet applications. It is built for developing high performance, customizable UI widgets and features a well designed, documented and extensible Component model. It is available in both Commercial and Open Source licenses are available.
Step  1:
First download the source css and js from here
Step 2:
Include [...]]]></description>
			<content:encoded><![CDATA[<p>Ext.JS JavaScript Framework a cross-browser JavaScript library for building rich internet applications. It is built for developing high performance, customizable UI widgets and features a well designed, documented and extensible Component model. It is available in both Commercial and Open Source licenses are available.</p>
<p><strong>Step  1:</strong><br />
First download the source css and js from <a href="http://www.sencha.com/products/extjs/">here</a></p>
<p><strong>Step 2:</strong><br />
Include the following css and js as</p>
<pre class="brush: xml;">
&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;../../resources/css/ext-all.css&quot; /&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;../../adapter/ext/ext-base.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;../../ext-all.js&quot;&gt;&lt;/script&gt;
</pre>
<p>Now start writing the code in script tag or make js file.<br />
jQuery and extJS comparisions:</p>
<p><strong>Document is ready</strong></p>
<pre class="brush: xml;">
//document is raedy in jQuery
&lt;script type=&quot;text/javascript&quot;&gt;
$(document).ready(function() {
  // do stuff when DOM is ready
});
&lt;/script&gt;

//in extJS
&lt;script type=&quot;text/javascript&quot;&gt;
Ext.onReady(function() {
  // do stuff when DOM is ready
});
&lt;/script&gt;
</pre>
<p><strong>Selecting elements</strong></p>
<pre class="brush: xml;">
// Selecting by ID in jQuery
var myDiv = $(&quot;#element-id&quot;);
// Selecting by ID in Extjs
var myDiv = Ext.get('element-id');
// Perform some action on it
// Add a class
myDiv.addClass('my-class');
// Set the width 100 px,
// true is for applying default animation on change
myDiv.setWidth(100, true);
// Retrive some information of the element
// Get the elements box info as object {x, y, width, height}
var box = myDiv.getBox();

extJS:

// Select elements with CSS Selector
var imgs = Ext.select(&quot;#my-div div.member img&quot;);
// or select directly from an existing element
var members = Ext.get('my-div');
var imgs = members.select('div.member img');
// Now, any Ext.Element actions can be performed on all the elements in this collection
</pre>
<p><strong>Dom scripting</strong></p>
<pre class="brush: xml;">
var el1 = Ext.get(&quot;my-1st-div&quot;);
var el2 = Ext.get(&quot;my-2nd-div&quot;);
// Appending elements
el1.appendChild(&quot;A new paragraph&quot;).appendTo(el2)
// Replcing, removing
var el3 = Ext.get(&quot;my-3rd-div&quot;);
Ext.get(&quot;my-4th-div&quot;).replace(el3).insertAfter(el2);
el2.remove()
</pre>
<p><strong>Events</strong></p>
<pre class="brush: xml;">
// Binding an event in jQuery
$(&quot;.btn&quot;).click(function() {
// Do something on button click
});

// Binding an event in Extjs
Ext.select('.btn').on('click', function() {
// Do something on button click
});
</pre>
<p><strong>Ajax</strong></p>
<pre class="brush: xml;">
// Basic request in jQuery
$.ajax({
type: &quot;POST&quot;,
url: url,
data: { x: 'y },
success: function(msg){
alert( &quot;Data Saved: &quot; + msg );
}
});

// Basic request in Ext
Ext.Ajax.request({
url: url,
params: { x: 'abc' },
success: function(msg){
alert( &quot;Data Saved: &quot; + msg );
}
});
</pre>
<p>Here, I have listed the basic difference between jQuery and extJS for complete reference refer <strong><a href="http://dev.sencha.com/deploy/dev/docs/">extJs API docs</a></strong><br />
hope it helps you guys <img src='http://www.intelligrape.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Anuj Aneja<br />
Intelligrape Software</p>
]]></content:encoded>
			<wfw:commentRss>http://www.intelligrape.com/blog/2011/04/14/getting-started-with-extjs/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Using Google Analytics for tracking Multiple Steps of a Webflow</title>
		<link>http://www.intelligrape.com/blog/2011/02/28/using-google-analytics-for-tracking-multiple-steps-of-a-webflow/</link>
		<comments>http://www.intelligrape.com/blog/2011/02/28/using-google-analytics-for-tracking-multiple-steps-of-a-webflow/#comments</comments>
		<pubDate>Mon, 28 Feb 2011 08:35:23 +0000</pubDate>
		<dc:creator>Vivek Krishna</dc:creator>
				<category><![CDATA[Google Web Tools]]></category>
		<category><![CDATA[Javascript/Ajax/JQuery]]></category>
		<category><![CDATA[google analytics]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.intelligrape.com/blog/?p=3166</guid>
		<description><![CDATA[In one of our projects, we are using a webflow for an order wizard. We needed to track the number of users converting a draft to a confirmed order using Google Analytics. This would have been simple if the URLs were different for each step. However, that is not the way webflows work and a [...]]]></description>
			<content:encoded><![CDATA[<p>In one of our projects, we are using a webflow for an order wizard. We needed to track the number of users converting a draft to a confirmed order using Google Analytics. This would have been simple if the URLs were different for each step. However, that is not the way webflows work and a similar URL is generated for multiple steps. After some searching around, we found that we could call a trackPageView method in Google Analytics API and set a name for the page being tracked. This could be done using</p>
<pre class="brush: jscript;">
&lt;script type=&quot;text/javascript&quot;&gt;
    try {
        var pageTracker = _gat._getTracker(&quot;&lt;ANALYTICS-KEY&gt;&quot;);
        pageTracker._trackPageview(&quot;/enterDetails.html&quot;);
    } catch(err) {
    }
&lt;/script&gt;
</pre>
<p>Replacing &#8220;/enterDetails.html&#8221; in each page with the corresponding step name did the trick. However, this is an old version of the Google Analytics API. Our application uses a newer version of the JavaScript code provided by Google.</p>
<p>In this, we had to use Virtual Page Tracking, which is a method explained in the <a href="http://code.google.com/apis/analytics/docs/tracking/asyncMigrationExamples.html" target="_blank">Google Analytics API Docs</a> under the section, Virtual Page Views. We had to write something like</p>
<pre class="brush: jscript;">

&lt;script type=&quot;text/javascript&quot;&gt;
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'ANALYTICS-KEY']);
_gaq.push(['_trackPageview', '/enterDetails.html']);
(function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
&lt;/script&gt;
</pre>
<p>For usage on grails, we used a template, which takes in the pageName and uses /${controllerName}/${actionName}/${pageName} to  generate the virtual page name which is tracked. Now we are successfully tracking the conversions.</p>
<p>Hope this helps.</p>
<p>Vivek</p>
<p>http://in.linkedin.com/in/svivekkrishna</p>
]]></content:encoded>
			<wfw:commentRss>http://www.intelligrape.com/blog/2011/02/28/using-google-analytics-for-tracking-multiple-steps-of-a-webflow/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>File Uploading using plupload plugin of jquery.</title>
		<link>http://www.intelligrape.com/blog/2011/02/14/file-uploading-using-plupload-plugin-of-jquery/</link>
		<comments>http://www.intelligrape.com/blog/2011/02/14/file-uploading-using-plupload-plugin-of-jquery/#comments</comments>
		<pubDate>Mon, 14 Feb 2011 12:50:10 +0000</pubDate>
		<dc:creator>Anuj Aneja</dc:creator>
				<category><![CDATA[Grails]]></category>
		<category><![CDATA[Javascript/Ajax/JQuery]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://www.intelligrape.com/blog/?p=2798</guid>
		<description><![CDATA[In my grails project i was having the requirement of having multiple file uploading, but in current implementation there was the problem of button being not loaded in Internet Explorer.For that i found plupload very cool to implement this. It has very cool feature of drag and drop and support for almost all browser. Actually [...]]]></description>
			<content:encoded><![CDATA[<p>In my grails project i was having the requirement of having multiple file uploading, but in current implementation there was the problem of button being not loaded in Internet Explorer.For that i found plupload very cool to implement this. It has very cool feature of drag and drop and support for almost all browser. Actually what it does is based on the browser, get the Runtime of the browser.For Documentation, js and css refer <a href="http://www.plupload.com/index.php">link</a></p>
<p>In gsp we need to include the js of pluplaod api as shown below:</p>
<pre class="brush: jscript;">
&lt;link rel=&quot;stylesheet&quot; href=&quot;${resource(dir: 'css/plupload/css', file: 'plupload.queue.css')}&quot; type=&quot;text/css&quot; media=&quot;screen&quot;&gt;
&lt;link rel=&quot;stylesheet&quot; href=&quot;${resource(dir: 'css/plupload/css', file: 'jquery.ui.plupload.css')}&quot; type=&quot;text/css&quot; media=&quot;screen&quot;&gt;
&lt;g:set var=&quot;fileExtension&quot; value=&quot;${new FileExtension()}&quot;&gt;&lt;/g:set&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://www.google.com/jsapi&quot;&gt;&lt;/script&gt;
&lt;p:javascript src='jquery-1.3.2'/&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;${resource(dir: &quot;js/plupload&quot;, file: &quot;gears_init.js&quot;)}&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;${resource(dir: &quot;js/plupload&quot;, file: &quot;browserplus-min.js&quot;)}&quot;&gt;&lt;/script&gt;
&lt;!-- Load source versions of the plupload script files --&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;${resource(dir: &quot;js/plupload&quot;, file: &quot;plupload.js&quot;)}&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;${resource(dir: &quot;js/plupload&quot;, file: &quot;plupload.gears.js&quot;)}&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;${resource(dir: &quot;js/plupload&quot;, file: &quot;plupload.silverlight.js&quot;)}&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;${resource(dir: &quot;js/plupload&quot;, file: &quot;plupload.flash.js&quot;)}&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;${resource(dir: &quot;js/plupload&quot;, file: &quot;plupload.browserplus.js&quot;)}&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;${resource(dir: &quot;js/plupload&quot;, file: &quot;plupload.html5.js&quot;)}&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;${resource(dir: &quot;js/plupload&quot;, file: &quot;jquery.plupload.queue.js&quot;)}&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
    var button = '${buttonId}';
&lt;/script&gt;
</pre>
<p>Now we need to write script to load and bind the plupload plugin shown below:</p>
<pre class="brush: jscript;">
	&lt;script type=&quot;text/javascript&quot;&gt;
    var runtimesList;
    if (navigator.userAgent.indexOf(&quot;Firefox&quot;)!=-1){
        runtimesList='silverlight,browserplus,html4,gears,flash,html5';
    }else{
        runtimesList='html5,silverlight,browserplus,html4,gears,flash';
    }
    $(function() {
        var uploader = new plupload.Uploader({
            runtimes : runtimesList,
            browse_button : 'pickfiles',
            url : url,
            flash_swf_url : '${resource(dir: &quot;js/plupload&quot;, file: &quot;plupload.flash.swf&quot;)}',
            silverlight_xap_url : '${resource(dir: &quot;js/plupload&quot;, file: &quot;plupload.silverlight.xap&quot;)}',
            filters : [
                {title : &quot;Image files&quot;, extensions : &quot;gif,png&quot;},
                {title : &quot;Zip files&quot;, extensions : &quot;zip&quot;}
            ]
        });

        uploader.bind('Init', function(up, params) {
        });

        uploader.bind('FilesAdded', function(up, files) {
            $.each(files, function(i, file) {
                $('#filelist').append('&lt;div id=&quot;' + file.id + '&quot;&gt;&lt;span class=&quot;mcentd9d&quot; style=&quot;font-size:12px; color:green;&quot;&gt;File: ' + file.name + ' uploaded successfully!(' + plupload.formatSize(file.size) + ')&lt;b&gt;&lt;/b&gt;&lt;\/span&gt;' + '&lt;/div&gt;');
            });
        });

        uploader.bind('UploadFile', function(up, file) {

        });

        uploader.bind('UploadProgress', function(up, file) {
            $('#' + file.id + &quot; b&quot;).html(file.percent + &quot;%&quot;);
        });

        uploader.bind('QueueChanged', function(up) {
            $('#uploadfiles').click();
        });

        uploader.bind('FileUploaded', function(up) {

        });
        uploader.bind('Error', function(up) {
            alert('Error in uploading file');
        });

        $('#uploadfiles').click(function(e) {
            uploader.start();
            e.preventDefault();
        });
        uploader.init();
    });

&lt;/script&gt;
	&lt;div class=&quot;attachment&quot;&gt;
               &lt;div id=&quot;filelist&quot;&gt;&lt;/div&gt;
                      &lt;a href=&quot;#&quot; class=&quot;plupload_button plupload_add&quot; id=&quot;pickfiles&quot; style=&quot;position: relative; z-index: 0; &quot;&gt;Select File&lt;/a&gt;
                      &lt;input type='hidden' id=&quot;uploadfiles&quot;/&gt;
          &lt;/div&gt;
</pre>
<p>Now we need to handle the saving part of the file,for each file uploaded in Queue there is separate call to<br />
the action.It saves the file to the filePath specified.</p>
<pre class="brush: java;">
def saveAttachment={
      def files = request.getFileMap()
      def file=files.get(&quot;file&quot;)
      String fileName = file.getOriginalFilename()
      byte[] data=file.getBytes()
      File dir=new File(filePath)//some path...
      if(!dir.exists()){
         dir.mkdirs()
      }
      File actualFile=new File(filePath, fileName)
      actualFile.withOutputStream {out -&gt;
             out.write data
      }
}
</pre>
<p>Disclaimer: As in some cases you might want to can the upload of all the files as there is a different call to action of you can save there files in session, but session for this plupload is different from current user session so you will have to make your own session handling for that!!!</p>
<p>Note:The total length of files upload and and total uploaded differs in case IE and Firefox. The comments and any suggestions are welcomed.</p>
<p>Hope it help you guys! Cheer! <img src='http://www.intelligrape.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Anuj Aneja</p>
<p>http://www.Intelligrape.com</p>
]]></content:encoded>
			<wfw:commentRss>http://www.intelligrape.com/blog/2011/02/14/file-uploading-using-plupload-plugin-of-jquery/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>JQGrid Expanding SubGrid on page load</title>
		<link>http://www.intelligrape.com/blog/2011/02/13/jqgrid-expanding-subgrid-on-page-load/</link>
		<comments>http://www.intelligrape.com/blog/2011/02/13/jqgrid-expanding-subgrid-on-page-load/#comments</comments>
		<pubDate>Sun, 13 Feb 2011 14:08:34 +0000</pubDate>
		<dc:creator>Tarun Pareek</dc:creator>
				<category><![CDATA[Javascript/Ajax/JQuery]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[JQuery JQGrid Plugin]]></category>

		<guid isPermaLink="false">http://www.intelligrape.com/blog/?p=2784</guid>
		<description><![CDATA[Hi,
&#160;
Recently guys, i faced problem while expanding the JQGrid SubGrid onLoad of the page.
&#160;
Initially, i used the following code on gridComplete Event of JQGrid, Using the code given below, i am only able to expand grid but without data populated in subgrid.


gridComplete: function&#40;&#41; &#123;
            [...]]]></description>
			<content:encoded><![CDATA[<p>Hi,<br />
&nbsp;<br />
Recently guys, i faced problem while expanding the JQGrid SubGrid onLoad of the page.<br />
&nbsp;<br />
Initially, i used the following code on gridComplete Event of JQGrid, Using the code given below, i am only able to expand grid but without data populated in subgrid.<br />
<br/></p>

<div class="wp_syntax"><div class="code"><pre class="groovy">gridComplete: function<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                var rowIds <span style="color: #66cc66;">=</span> $<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;#testTable&quot;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">getDataIDs</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
                $.<span style="color: #663399;">each</span><span style="color: #66cc66;">&#40;</span>rowIds, function <span style="color: #66cc66;">&#40;</span>index, rowId<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                        $<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;#testTable&quot;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">expandSubGridRow</span><span style="color: #66cc66;">&#40;</span>rowId<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>                   
                <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
            <span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>After trying different ways, and many efforts i came up with this <strong>solution</strong> and it worked for me.<br />
Solution to above problem given below :<br />
<br/></p>

<div class="wp_syntax"><div class="code"><pre class="groovy">gridComplete: function<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                var timeOut <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">50</span><span style="color: #66cc66;">;</span>
                var rowIds <span style="color: #66cc66;">=</span> $<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;#testTable&quot;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">getDataIDs</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
                $.<span style="color: #663399;">each</span><span style="color: #66cc66;">&#40;</span>rowIds, function <span style="color: #66cc66;">&#40;</span>index, rowId<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                    setTimeout<span style="color: #66cc66;">&#40;</span>function<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                        $<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;#testTable&quot;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">expandSubGridRow</span><span style="color: #66cc66;">&#40;</span>rowId<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
                    <span style="color: #66cc66;">&#125;</span>, timeOut<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
                    timeOut <span style="color: #66cc66;">=</span> timeOut + <span style="color: #cc66cc;">200</span><span style="color: #66cc66;">;</span>
                <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
            <span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>It worked for me. Hope it help you too.<br />
<br/></p>
<p>Thanks &#038; regards,<br />
Tarun Pareek<br />
<a href="http://in.linkedin.com/in/tarunpareek">LinkedIn</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.intelligrape.com/blog/2011/02/13/jqgrid-expanding-subgrid-on-page-load/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Sharing Session Information between Wordpress and Grails using Cookies and base64 encoding</title>
		<link>http://www.intelligrape.com/blog/2010/08/03/sharing-session-information-between-wordpress-and-grails-using-cookies-and-base64-encoding/</link>
		<comments>http://www.intelligrape.com/blog/2010/08/03/sharing-session-information-between-wordpress-and-grails-using-cookies-and-base64-encoding/#comments</comments>
		<pubDate>Tue, 03 Aug 2010 10:20:49 +0000</pubDate>
		<dc:creator>Vivek Krishna</dc:creator>
				<category><![CDATA[Grails]]></category>
		<category><![CDATA[Javascript/Ajax/JQuery]]></category>
		<category><![CDATA[base64 encoding]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery plugins]]></category>

		<guid isPermaLink="false">http://www.intelligrape.com/blog/?p=1426</guid>
		<description><![CDATA[A scenario arose in one of our projects that we had to share some information between the grails application (which was taking care of dynamic content) and wordpress (which was used to maintain the static pages about the application). The information was the logged in user&#8217;s name so that we could display that on the [...]]]></description>
			<content:encoded><![CDATA[<p>A scenario arose in one of our projects that we had to share some information between the grails application (which was taking care of dynamic content) and wordpress (which was used to maintain the static pages about the application). The information was the logged in user&#8217;s name so that we could display that on the header. After giving it some thought, we decided that setting a cookie with the logged in user&#8217;s name from the grails application and then reading it from the wordpress application using javascript was one way of doing so.</p>
<p>This was achieved by setting the cookie with code on grails side as</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="groovy">Cookie cookie <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Cookie<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'userNameCookie'</span>, fullname<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
cookie.<span style="color: #006600;">setVersion</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">-1</span><span style="color: #66cc66;">&#41;</span>  <span style="color: #808080; font-style: italic;">// unknown version bypasses quoting logic</span>
cookie.<span style="color: #006600;">path</span> <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">&quot;/&quot;</span>
cookie.<span style="color: #006600;">maxAge</span> <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">30</span> <span style="color: #66cc66;">*</span> <span style="color: #cc66cc;">60</span> <span style="color: #66cc66;">*</span> <span style="color: #cc66cc;">60</span><span style="color: #66cc66;">;</span> <span style="color: #808080; font-style: italic;">//30 minutes life</span>
response.<span style="color: #006600;">addCookie</span><span style="color: #66cc66;">&#40;</span>cookie<span style="color: #66cc66;">&#41;</span></pre></div></div>

</blockquote>
<p>There is an excellent <a href="http://plugins.jquery.com/project/cookie">jQuery cookie plugin</a> to read cookies using javascript. All that needs to be done is include the javascript file and call the method given below to get the value from it</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="groovy">jQuery.<span style="color: #006600;">cookie</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'userNameCookie'</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

</blockquote>
<p>However, there was an issue with this approach. The usernames could have unicode characters like ä, ö etc. The cookie was not getting set from the grails application and threw an Exception because the unicode characters weren&#8217;t escaped. The exception also suggested that we could use decodeBase64(). But since it was due to encode, we decided to convert the fullname to bytes, encode it to base64, call the toString() method and then set the value. What we did was to change the cookie value to from grails</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="groovy">Cookie cookie <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Cookie<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'usercookie'</span>, fullname.<span style="color: #006600;">bytes</span>.<span style="color: #FFCC33;">encodeBase64</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span></pre></div></div>

</blockquote>
<p>In order to decode this base64 encoded string on the client side, we used the <a href="http://plugins.jquery.com/project/base64">jQuery Base 64 Functions plugin</a>. This can be used to decode a base64 encoded string as</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="groovy">jQuery.<span style="color: #006600;">base64Decode</span><span style="color: #66cc66;">&#40;</span>jQuery.<span style="color: #006600;">cookie</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'userNameCookie'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span></pre></div></div>

</blockquote>
<p>This worked like a charm.</p>
<p>Hope this helps</p>
<p>Vivek</p>
<p>http://in.linkedin.com/in/svivekkrishna</p>
<p>vivek[at]intelligrape.com</p>
]]></content:encoded>
			<wfw:commentRss>http://www.intelligrape.com/blog/2010/08/03/sharing-session-information-between-wordpress-and-grails-using-cookies-and-base64-encoding/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery Alert Message without using traditional javascript alert-box.</title>
		<link>http://www.intelligrape.com/blog/2010/06/14/jquery-alert-message-without-using-traditional-javascript-alert-box/</link>
		<comments>http://www.intelligrape.com/blog/2010/06/14/jquery-alert-message-without-using-traditional-javascript-alert-box/#comments</comments>
		<pubDate>Mon, 14 Jun 2010 16:50:30 +0000</pubDate>
		<dc:creator>Salil</dc:creator>
				<category><![CDATA[HTML-UI-CSS]]></category>
		<category><![CDATA[Javascript/Ajax/JQuery]]></category>
		<category><![CDATA[custom alert messages]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://www.intelligrape.com/blog/?p=1093</guid>
		<description><![CDATA[This post might help you if you want to display alert messages without using tradition javascript (irritating) alert.
To achieve this you need jQuery for your frontend UI.
Below is the javascript method (code snapshot) which displays your message for 5 seconds. And then fades out automatically.


function displayAlertMessage&#40;message&#41; &#123;
var timeOut = 5
jQuery&#40;'#messageBox'&#41;.text&#40;message&#41;.fadeIn&#40;&#41;
jQuery&#40;'#messageBox'&#41;.css&#40;&#34;display&#34;, &#34;block&#34;&#41;
setTimeout&#40;function&#40;&#41; &#123;
jQuery&#40;'#messageBox'&#41;.fadeOut&#40;&#41;
jQuery&#40;'#messageBox'&#41;.css&#40;&#34;display&#34;, &#34;none&#34;&#41;
&#125;, timeOut * [...]]]></description>
			<content:encoded><![CDATA[<p>This post might help you if you want to display alert messages without using tradition javascript (irritating) alert.<br />
To achieve this you need jQuery for your frontend UI.</p>
<p>Below is the javascript method (code snapshot) which displays your message for 5 seconds. And then fades out automatically.</p>
<blockquote>

<div class="wp_syntax"><div class="code"><pre class="javascript"><span style="color: #003366; font-weight: bold;">function</span> displayAlertMessage<span style="color: #009900;">&#40;</span>message<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #003366; font-weight: bold;">var</span> timeOut <span style="color: #339933;">=</span> <span style="color: #CC0000;">5</span>
jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#messageBox'</span><span style="color: #009900;">&#41;</span>.<span style="color: #006600;">text</span><span style="color: #009900;">&#40;</span>message<span style="color: #009900;">&#41;</span>.<span style="color: #006600;">fadeIn</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#messageBox'</span><span style="color: #009900;">&#41;</span>.<span style="color: #006600;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;display&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;block&quot;</span><span style="color: #009900;">&#41;</span>
setTimeout<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>
jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#messageBox'</span><span style="color: #009900;">&#41;</span>.<span style="color: #006600;">fadeOut</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#messageBox'</span><span style="color: #009900;">&#41;</span>.<span style="color: #006600;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;display&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;none&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> timeOut <span style="color: #339933;">*</span> <span style="color: #CC0000;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

</blockquote>
<p>messageBox is id of your div tag where you want to display the Alert Message.<br />
timeOut is number of seconds you want to hold message on screen.<br />
That&#8217;s it. So simple and quite comfortable from a user&#8217;s perspective Isn&#8217;t it? <img src='http://www.intelligrape.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Cheers!!<br />
Salil Kalia</p>
<p>﻿</p>
]]></content:encoded>
			<wfw:commentRss>http://www.intelligrape.com/blog/2010/06/14/jquery-alert-message-without-using-traditional-javascript-alert-box/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Tracking Image Clicks using Google Analytics</title>
		<link>http://www.intelligrape.com/blog/2010/02/25/tracking-image-clicks-using-google-analytics/</link>
		<comments>http://www.intelligrape.com/blog/2010/02/25/tracking-image-clicks-using-google-analytics/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 16:26:56 +0000</pubDate>
		<dc:creator>Vivek Krishna</dc:creator>
				<category><![CDATA[Javascript/Ajax/JQuery]]></category>
		<category><![CDATA[google analytics]]></category>
		<category><![CDATA[image tracking]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.intelligrape.com/blog/?p=410</guid>
		<description><![CDATA[In one of the projects, it was required to track the number of times an image (which linked to another page) was clicked using Google Analytics. We found a very informative article here. It talks about tracking external links and file downloads. This wasn&#8217;t exactly our purpose, but the javascript downloaded from there acted as [...]]]></description>
			<content:encoded><![CDATA[<p>In one of the projects, it was required to track the number of times an image (which linked to another page) was clicked using Google Analytics. We found a very informative article <a href="http://www.goodwebpractices.com/roi/track-downloads-in-google-analytics-automatically.html" target="_blank">here</a>. It talks about tracking external links and file downloads. This wasn&#8217;t exactly our purpose, but the <a href="http://www.goodwebpractices.com/downloads/gatag.js" target="_blank">javascript</a> downloaded from there acted as a very good starting point.</p>
<p>What we did was to add a code block like this after line no. 13 of the javascript code from the link given above.</p>
<blockquote>
<div class="code">

<div class="wp_syntax"><div class="code"><pre class="javascript"><span style="color: #003366; font-weight: bold;">var</span> imgs <span style="color: #339933;">=</span> document.<span style="color: #006600;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;img&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</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> l<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> l <span style="color: #339933;">&lt;</span>imgs.<span style="color: #006600;">length</span><span style="color: #339933;">;</span> l<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
       <span style="color: #000066; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
               <span style="color: #003366; font-weight: bold;">var</span> path <span style="color: #339933;">=</span> imgs<span style="color: #009900;">&#91;</span>l<span style="color: #009900;">&#93;</span>.<span style="color: #006600;">getAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'src'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
               <span style="color: #003366; font-weight: bold;">var</span> isDoc <span style="color: #339933;">=</span> path.<span style="color: #006600;">match</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/\.(?:jpg|png|gif|svg)($|\&amp;|\?)/</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
               startListening<span style="color: #009900;">&#40;</span>imgs<span style="color: #009900;">&#91;</span>l<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;click&quot;</span><span style="color: #339933;">,</span> trackImageClicks<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
       <span style="color: #009900;">&#125;</span>
       <span style="color: #000066; font-weight: bold;">catch</span><span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
           <span style="color: #000066; font-weight: bold;">continue</span><span style="color: #339933;">;</span>
       <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span></pre></div></div>

</div>
</blockquote>
<p>And a method before the Analytics script provided by Google for the site</p>
<blockquote>
<div class="code">

<div class="wp_syntax"><div class="code"><pre class="javascript"><span style="color: #003366; font-weight: bold;">function</span> trackImageClicks<span style="color: #009900;">&#40;</span>evnt<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> e <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>evnt.<span style="color: #006600;">srcElement</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">?</span> evnt.<span style="color: #006600;">srcElement</span> <span style="color: #339933;">:</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">;</span>
    <span style="color: #003366; font-weight: bold;">var</span> lnk <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>e.<span style="color: #006600;">getAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;src&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006600;">charAt</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot;/&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">?</span> e.<span style="color: #006600;">getAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;src&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;/&quot;</span> <span style="color: #339933;">+</span> e.<span style="color: #006600;">getAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;src&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span><span style="color: #009900;">&#40;</span>pageTracker<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot;object&quot;</span><span style="color: #009900;">&#41;</span> pageTracker._trackPageview<span style="color: #009900;">&#40;</span>lnk<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span>e.<span style="color: #006600;">tagName</span> <span style="color: #339933;">!=</span> <span style="color: #3366CC;">&quot;A&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        e <span style="color: #339933;">=</span> e.<span style="color: #006600;">parentNode</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
     lnk <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>e.<span style="color: #006600;">pathname</span>.<span style="color: #006600;">charAt</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot;/&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">?</span> e.<span style="color: #006600;">pathname</span> <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;/&quot;</span> <span style="color: #339933;">+</span> e.<span style="color: #006600;">pathname</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>e.<span style="color: #006600;">search</span> <span style="color: #339933;">&amp;&amp;</span> e.<span style="color: #006600;">pathname</span>.<span style="color: #006600;">indexOf</span><span style="color: #009900;">&#40;</span>e.<span style="color: #006600;">search</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">-1</span><span style="color: #009900;">&#41;</span> lnk <span style="color: #339933;">+=</span> e.<span style="color: #006600;">search</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>e.<span style="color: #006600;">hostname</span> <span style="color: #339933;">!=</span> location.<span style="color: #006600;">host</span><span style="color: #009900;">&#41;</span> lnk <span style="color: #339933;">=</span> e.<span style="color: #006600;">hostname</span> <span style="color: #339933;">+</span> lnk<span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span><span style="color: #009900;">&#40;</span>pageTracker<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot;object&quot;</span><span style="color: #009900;">&#41;</span> pageTracker._trackPageview<span style="color: #009900;">&#40;</span>lnk<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

</div>
</blockquote>
<p>Now, the clicks on each image were getting tracked. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.intelligrape.com/blog/2010/02/25/tracking-image-clicks-using-google-analytics/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Identify merchant provider from the given credit card no.</title>
		<link>http://www.intelligrape.com/blog/2009/11/04/identify-merchant-provider-from-the-given-credit-card-no/</link>
		<comments>http://www.intelligrape.com/blog/2009/11/04/identify-merchant-provider-from-the-given-credit-card-no/#comments</comments>
		<pubDate>Tue, 03 Nov 2009 19:17:25 +0000</pubDate>
		<dc:creator>Amit Jain</dc:creator>
				<category><![CDATA[Javascript/Ajax/JQuery]]></category>
		<category><![CDATA[credit card identification]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[javascript validation]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[merchant provider]]></category>

		<guid isPermaLink="false">http://www.intelligrape.com/blog/?p=277</guid>
		<description><![CDATA[Hi Friends,
I was working on the financial application, where the user doesn&#8217;t want to select merchant provider while feeding in credit card details and yet we needed to know the merchant provider. Following is the code that helped:




function getMerchantProvider(cardNo){                 [...]]]></description>
			<content:encoded><![CDATA[<p>Hi Friends,</p>
<p>I was working on the financial application, where the user doesn&#8217;t want to select merchant provider while feeding in credit card details and yet we needed to know the merchant provider. Following is the code that helped:</p>
<blockquote>
<div class="wp_syntax">
<div class="code">
<pre class="javascript">
function getMerchantProvider(cardNo){                      //cardNo is the credit card number
    var cards = new Array();
    cards [0] = {cardName: "Visa",prefixes: "4"};
    cards [1] = {cardName: "Mastercard", prefixes: "51,52,53,54,55"};
    cards [2] = {cardName: "DinersClub", prefixes: "300,301,302,303,304,305,36,38,55"};
    cards [3] = {cardName: "CarteBlanche", prefixes: "300,301,302,303,304,305,36,38"};
    cards [4] = {cardName: "American Express", prefixes: "34,37"};
    cards [5] = {cardName: "Discovery",  prefixes: "6011,650"};
    cards [6] = {cardName: "JCB", prefixes: "3,1800,2131"};
    cards [7] = {cardName: "enRoute", prefixes: "2014,2149"};
    cards [8] = {cardName: "Solo", prefixes: "6334, 6767"};
    cards [9] = {cardName: "Switch", prefixes: "4903,4905,4911,4936,564182,633110,6333,6759"};
    cards [10] = {cardName: "Maestro", prefixes: "5020,6"};
    cards [11] = {cardName: "VisaElectron", prefixes: "417500,4917,4913"};
    var prefix
    var cardType

    for(cardType=0; cardType&lt;cards.length; cardType++){
        prefix = cards[cardType].prefixes.split(",");
        for (i=0; i&lt;prefix.length; i++) {
             var exp = new RegExp ("^" + prefix[i]);
             if (exp.test (cardNo))
                  return cards[cardType].cardName;      
       }
    }
     return "Invalid";       
}
</pre>
</div>
</div>
</blockquote>
<p>The above function returns merchant provider name if matching pattern is found and Invalid if not. Please make a note, this function doesn&#8217;t validates the credit card no.</p>
<p>For the credit card number validation I used jquery extended validation plugin for credit card, which also needed to know the merchant provider for validation so this code helped. Extended credit card validation plugin can be found at <a href="http://www.ihwy.com/labs/jquery-validate-credit-card-extension.aspx">http://www.ihwy.com/labs/jquery-validate-credit-card-extension.aspx</a></p>
<p>Thanks!</p>
<p>~~Amit Jain~~<br />
<a href="mailto:amit@intelligrape.com">amit@intelligrape.com</a><br />
IntelliGrape Softwares</p>
]]></content:encoded>
			<wfw:commentRss>http://www.intelligrape.com/blog/2009/11/04/identify-merchant-provider-from-the-given-credit-card-no/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ajax Request Progress Indicator</title>
		<link>http://www.intelligrape.com/blog/2009/10/12/ajax-request-progress-indicator/</link>
		<comments>http://www.intelligrape.com/blog/2009/10/12/ajax-request-progress-indicator/#comments</comments>
		<pubDate>Mon, 12 Oct 2009 11:41:02 +0000</pubDate>
		<dc:creator>Bhagwat Kumar</dc:creator>
				<category><![CDATA[Javascript/Ajax/JQuery]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[prototype library]]></category>

		<guid isPermaLink="false">http://www.intelligrape.com/blog/?p=251</guid>
		<description><![CDATA[In my current project, I used ajax to fetch data from the server to provide Desktop Application like Experience. I wanted to automatically show an indicator when an AJAX request is ongoing, and hide it when there is no such request. So I found the following solution for both the Prototype library and the JQuery [...]]]></description>
			<content:encoded><![CDATA[<p>In my current project, I used ajax to fetch data from the server to provide Desktop Application like Experience. I wanted to automatically show an indicator when an AJAX request is ongoing, and hide it when there is no such request. So I found the following solution for both the Prototype library and the JQuery library.</p>
<p>Make sure the following HTML is included on every page where AJAX requests are made. (Place it in body of the main layout so that you do not have to repeat this HTML on each page.</p>
<blockquote>
<div class="code">

<div class="wp_syntax"><div class="code"><pre>&lt;span id=&quot;ajax_spinner&quot; style=&quot;display:none<SEMI>position:absolute<SEMI> top:50%<SEMI> left:50%<SEMI> z-index:3000<SEMI>&quot;&gt;
       &lt;-- Design Busy indicator here --&gt;
       &lt;img src=&quot;/yoursite/images/spinner.gif&quot;/&gt;
&lt;/span&gt;</pre></div></div>

</div>
</blockquote>
<p>Make sure the following javascript code has been executed before any AJAX request is made. (Move this to a js file and include it in Heading part of the main layout).</p>
<blockquote>
<div class="code">

<div class="wp_syntax"><div class="code"><pre class="javascript"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #009966; font-style: italic;">/*
  Registering responders for prototype library.
  (If you are not using  prototype library then there is no need of the next statement.)
*/</span>
&nbsp;
Ajax.<span style="color: #006600;">Responders</span>.<span style="color: #006600;">register</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
          onCreate<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>
              jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#ajax_spinner&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006600;">show</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
          onComplete<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>
              jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#ajax_spinner&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006600;">hide</span><span style="color: #009900;">&#40;</span><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>
&nbsp;
<span style="color: #009966; font-style: italic;">/*
   Registering responders for jQuery AJAX calls.
*/</span>
&nbsp;
jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#ajax_spinner&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006600;">ajaxStart</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>
              jQuery<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #006600;">show</span><span style="color: #009900;">&#40;</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>
jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#ajax_spinner&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006600;">ajaxStop</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>
              jQuery<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #006600;">hide</span><span style="color: #009900;">&#40;</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>
&nbsp;
<span style="color: #006600; font-style: italic;">/*
    Note : If you are not using jQuery you can show/hide the div
         using javascript(e.g. document.getElementById) to do the same
*/</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>

</div>
</blockquote>
<p>The above trick worked for me and hope it works for you guys too.</p>
<p>Helpful links :-<br />
<a class="alignleft" href="http://www.prototypejs.org/api/ajax/responders" target="_blank"> http://www.prototypejs.org/api/ajax/responders</a><br />
<a class="alignleft" href="http://docs.jquery.com/Ajax/jQuery.ajax" target="_blank">http://docs.jquery.com/Ajax/jQuery.ajax</a><br />
<a class="alignleft" href="http://blogs.aarohan.biz/2009/05/26/get-started-with-jquery-ajax-and-json-in-your-perl-web-applications" target="_blank">http://blogs.aarohan.biz/2009/05/26/get-started-with-jquery-ajax-and-json-in-your-perl-web-applications</a> (Thanks to Amit)</p>
<p> ~~~~Bhagwat Kumar~~~<br />
bhagwat@intelligrape.com</p>
]]></content:encoded>
			<wfw:commentRss>http://www.intelligrape.com/blog/2009/10/12/ajax-request-progress-indicator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Add hotkeys to the web application</title>
		<link>http://www.intelligrape.com/blog/2009/09/28/add-hotkeys-to-web-application/</link>
		<comments>http://www.intelligrape.com/blog/2009/09/28/add-hotkeys-to-web-application/#comments</comments>
		<pubDate>Mon, 28 Sep 2009 17:25:33 +0000</pubDate>
		<dc:creator>Amit Jain</dc:creator>
				<category><![CDATA[Javascript/Ajax/JQuery]]></category>
		<category><![CDATA[hotkeys]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[keyboard shortcuts]]></category>

		<guid isPermaLink="false">http://www.intelligrape.com/blog/?p=247</guid>
		<description><![CDATA[Add hotkeys to your web application using javascript and its keydown event. ]]></description>
			<content:encoded><![CDATA[<p>Let us have a look at the simple javascript code, that can be used to add hotkeys to our web application. I tried using jquery hotkeys plugin and two more plugins, but they didn&#8217;t work for me.</p>
<p>So I ended up handling the keydown event of my own.</p>
<blockquote>
<div class="wp_syntax">
<div class="code">
<pre class="groovy">var isAlt = false;
document.onkeyup = function(e) {
    if (e.which == 18) //18 is the keycode for 'Alt'
	isAlt = false;
}
document.onkeydown = function(e) {
    if (e.which == 18)
	 isAlt = true;
    else if (e.which == 69 &amp;&amp; isAlt == true) { //69 is the keycode for 'e'
        function1(); 	 // executed when alt+e is pressed
        return false;
    } else if (e.which == 71 &amp;&amp; isAlt == true) {
        function2(); 	 // executed when alt+g is pressed
        return false;
    }
    ...
}</pre>
</div>
</div>
</blockquote>
<p>Hope this helped.</p>
<p>Cheers!<br />
~~Amit Jain~~<br />
amit@intelligrape.com<br />
IntelliGrape Softwares</p>
]]></content:encoded>
			<wfw:commentRss>http://www.intelligrape.com/blog/2009/09/28/add-hotkeys-to-web-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

