<?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>Abhi&#039;s Weblog &#187; Web Development</title>
	<atom:link href="http://abhinavsingh.com/blog/category/web-development/feed/" rel="self" type="application/rss+xml" />
	<link>http://abhinavsingh.com/blog</link>
	<description>PHP, Memcached, XMPP and Web Development</description>
	<lastBuildDate>Mon, 27 Feb 2012 09:12:57 +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>Setting Nginx, PHP Fastcgi and XCache on a new Ubuntu</title>
		<link>http://abhinavsingh.com/blog/2010/04/setting-nginx-php-fastcgi-and-xcache-on-a-new-ubuntu/</link>
		<comments>http://abhinavsingh.com/blog/2010/04/setting-nginx-php-fastcgi-and-xcache-on-a-new-ubuntu/#comments</comments>
		<pubDate>Thu, 29 Apr 2010 13:38:04 +0000</pubDate>
		<dc:creator>Abhinav Singh</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[XCache]]></category>

		<guid isPermaLink="false">http://abhinavsingh.com/blog/?p=592</guid>
		<description><![CDATA[Recently, because of a mandatory VPS move I had an opportunity to migrate all my sites from apache to nginx. My old box was in a messy state and setting up a new box from scratch was always going to be fun. Here in this post, I will walk you through all the steps that [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2010%2F04%2Fsetting-nginx-php-fastcgi-and-xcache-on-a-new-ubuntu%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2010%2F04%2Fsetting-nginx-php-fastcgi-and-xcache-on-a-new-ubuntu%2F&amp;source=imoracle&amp;style=normal&amp;service=bit.ly&amp;service_api=R_f027b5a79a20a49b713f16282f1e0857&amp;hashtags=nginx,PHP,Ubuntu,XCache&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Recently, because of a mandatory VPS move I had an opportunity to migrate all my sites from apache to nginx. My old box was in a messy state and setting up a new box from scratch was always going to be fun. Here in this post, I will walk you through all the steps that helped me migrate seamlessly. Specially, how did I setup the new box ensuring zero downtime on the sites.</p>
<p><strong style="font-size:18px;"><u>Ensuring zero downtime while migration:</u></strong><br />
By the time I will pin up various pieces on my new vps box, I didn&#8217;t want my site visitors to see an under-maintenance page. To ensure zero downtime, I usually follow these steps:</p>
<ul>
<li>Setup the new vps with nginx, php-fastcgi, etc as described later in the post</li>
<li>To verify the setup on new vps, edit the local host file depending upon your operating system
<pre class="php" name="code">/private/etc/hosts (mac)
/etc/hosts (ubuntu)
C:\Windows\System32\drivers\etc\hosts (windows)
</pre>
<p>Go ahead and add the following host entry:</p>
<pre class="php" name="code">99.198.122.216 abhinavsingh.com</pre>
<p>where, 99.198.122.216 is my new vps ip address and abhinavsingh.com is a vhost configured to handle by nginx on my new vps</li>
<li>Now, whenever I visit http://abhinavsingh.com in my browser, my local machine will point it to my new vps box. However, all other visitors will still be served by apache on old vps.</li>
<li>After verifying the setup, I simply remove previously added host setting on my local box and update the DNS settings for my site at godaddy.</li>
</ul>
<p>To start with, just add up the required host setting on your local system.</p>
<p><strong style="font-size:18px;"><u>Installing Nginx and configuring vhosts:</u></strong><br />
Follow these steps to install nginx webserver:</p>
<ul>
<li>Update and upgrade apt-get and install nginx
<pre class="php" name="code">sudo apt-get update
sudo apt-get upgrade
sudo apt-get install nginx</pre>
</li>
<li>Configure vhost for nginx by creating a file <code>/etc/nginx/sites-available/mysite.com</code> as follows:
<pre class="php" name="code">server {
        listen   80;
        server_name  mysite.com;
        access_log  /var/log/nginx/mysite.access.log;

        root   /var/www/mysite;
        index  index.php index.html index.htm;

        location / {
        }
}</pre>
</li>
<li>Enable vhost by creating a symlink as follows:
<pre class="php" name="code">cd /etc/nginx/sites-enabled
ln -s /etc/nginx/sites-available/mysite.com mysite.com
sudo /etc/init.d/nginx restart</pre>
</li>
<li>Assuming you have configured your local host file correctly, try visiting http://mysite.com and your browser will take it to the new vps</li>
</ul>
<p><strong style="font-size:18px;"><u>Setting up php-fastcgi and xcache:</u></strong><br />
Here are the steps to configure php-fastcgi and how to ensure php-fastcgi is up and running even after system reboot. We will also configure xcache for better performance.</p>
<ul>
<li>sudo apt-get install php5-cgi php5-cli php5-xcache</li>
<li>Download <a href="http://gist.github.com/383557">php-fastcgi default config</a> and place it at <code>/etc/default/php-fastcgi</code></li>
<li>Download <a href="http://gist.github.com/383550">php-fastcgi init.d script</a> and place it at <code>/etc/init.d/php-fastcgi</code></li>
<li>Add php-fastcgi init.d as startup script
<pre class="php" name="code">update-rc.d -f php-fastcgi defaults</pre>
</li>
<li>Update following fields inside <code>/etc/php5/conf.d/xcache.ini</code>:
<pre class="php" name="code">xcache.admin.user = "admin"
xcache.admin.pass = "pass"
xcache.size  =  128M
xcache.count = 4</pre>
<p> xcache.count should ideally be equal to <code>cat /proc/cpuinfo |grep -c processor</code></li>
<li>Setup xcache admin interface:
<pre class="php" name="code">cd /var/www
ln -s /usr/share/xcache/admin xcache</pre>
</li>
<li>Update <code>/etc/php5/cgi/php.ini</code> as per your requirements and start php-fastcgi process
<pre class="php" name="code">sudo /etc/init.d/php-fastcgi start</pre>
</li>
<li>Visit xcache admin panel http://vps_ip_address/xcache</li>
</ul>
<p><strong style="font-size:18px"><u>Stitching php-fastcgi and nginx vhosts:</u></strong><br />
Now lets enable php for vhosts configured with nginx:</p>
<ul>
<li>Download <a href="http://gist.github.com/383588">nginx fastcgi param</a> config file and place it at <code>/etc/nginx/fastcgi.conf</code></li>
<li>Update /etc/nginx/sites-available/mysite.com with following config:
<pre class="php" name="code">location ~ \.php$ {
                fastcgi_pass    127.0.0.1:9000;
                fastcgi_index   index.php;
                fastcgi_param   SCRIPT_FILENAME /var/www/mysite$fastcgi_script_name;
                include         /etc/nginx/fastcgi.conf;
        }
</pre>
</li>
<li>Restart nginx and we are done</li>
</ul>
<p>Here we complete the vps setup and vhost configurations. Verify the new vps setup and once satisfied update site&#8217;s DNS settings. Another challenge involving migration from apache to nginx includes rewriting apache .htaccess rewrite rules for nginx. However, I will keep that for another post.</p>
<script type="text/javascript">var wordpress_toolbar_urls = ["http:\/\/api.tweetmeme.com\/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2010%2F04%2Fsetting-nginx-php-fastcgi-and-xcache-on-a-new-ubuntu%2F","http:\/\/gist.github.com\/383557","http:\/\/gist.github.com\/383550","http:\/\/gist.github.com\/383588"];var wordpress_toolbar_url = "http://abhinavsingh.com/blog/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "oinw";var wordpress_toolbar_hash = "aHR0cDovL2FiaGluYXZzaW5naC5jb20vYmxvZy8yMDEwLzA0L3NldHRpbmctbmdpbngtcGhwLWZhc3RjZ2ktYW5kLXhjYWNoZS1vbi1hLW5ldy11YnVudHUvPHdwdGI%2BU2V0dGluZyBOZ2lueCwgUEhQIEZhc3RjZ2kgYW5kIFhDYWNoZSBvbiBhIG5ldyBVYnVudHU8d3B0Yj5odHRwOi8vYWJoaW5hdnNpbmdoLmNvbS9ibG9nPHdwdGI%2BQWJoaSYjMDM5O3MgV2VibG9n";</script><ul class="related_post"><li><a href="http://abhinavsingh.com/blog/2009/01/memcached-and-n-things-you-can-do-with-it/" title="Memcached and &quot;N&quot; things you can do with it &#8211; Part 1">Memcached and &quot;N&quot; things you can do with it &#8211; Part 1</a> (19)</li><li><a href="http://abhinavsingh.com/blog/2008/07/how-to-get-started-with-web-development/" title="How to get started with web development?">How to get started with web development?</a> (9)</li><li><a href="http://abhinavsingh.com/blog/2008/05/how-to-configure-ubuntu-and-lamp-on-windows/" title="How to configure Ubuntu and LAMP on Windows">How to configure Ubuntu and LAMP on Windows</a> (4)</li><li><a href="http://abhinavsingh.com/blog/2010/08/php-code-setup-and-demo-of-jaxl-boshchat-application/" title="PHP Code, Setup and Demo of Jaxl boshchat application">PHP Code, Setup and Demo of Jaxl boshchat application</a> (80)</li><li><a href="http://abhinavsingh.com/blog/2010/08/releasing-jaxl-2-0-object-oriented-xmpp-framework-in-php/" title="Releasing Jaxl 2.0 &#8211; Object oriented XMPP framework in PHP">Releasing Jaxl 2.0 &#8211; Object oriented XMPP framework in PHP</a> (6)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://abhinavsingh.com/blog/2010/04/setting-nginx-php-fastcgi-and-xcache-on-a-new-ubuntu/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Making cross-sub-domain ajax (XHR) requests using mod_proxy and iframes</title>
		<link>http://abhinavsingh.com/blog/2009/11/making-cross-sub-domain-ajax-xhr-requests-using-mod_proxy-and-iframes/</link>
		<comments>http://abhinavsingh.com/blog/2009/11/making-cross-sub-domain-ajax-xhr-requests-using-mod_proxy-and-iframes/#comments</comments>
		<pubDate>Sun, 29 Nov 2009 15:27:59 +0000</pubDate>
		<dc:creator>Abhinav Singh</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[iframe]]></category>
		<category><![CDATA[mod_proxy]]></category>

		<guid isPermaLink="false">http://abhinavsingh.com/blog/?p=556</guid>
		<description><![CDATA[One of the restrictions imposed by all browser side programming languages is that one cannot make cross-domain ajax requests. This restriction comes because of the same origin policy and even sub-domain ajax calls are not allowed. In this blog post, I will demo two methods of making cross-sub-domain ajax requests. First demo will use mod_proxy [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2009%2F11%2Fmaking-cross-sub-domain-ajax-xhr-requests-using-mod_proxy-and-iframes%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2009%2F11%2Fmaking-cross-sub-domain-ajax-xhr-requests-using-mod_proxy-and-iframes%2F&amp;source=imoracle&amp;style=normal&amp;service=bit.ly&amp;service_api=R_f027b5a79a20a49b713f16282f1e0857&amp;hashtags=Ajax,Apache,iframe,mod_proxy&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>One of the restrictions imposed by all browser side programming languages is that one cannot make cross-domain ajax requests. This restriction comes because of the <a href="http://en.wikipedia.org/wiki/Same_origin_policy">same origin policy</a> and even sub-domain ajax calls are not allowed. In this blog post, I will demo two methods of making cross-sub-domain ajax requests. First demo will use <a href="http://httpd.apache.org/docs/2.0/mod/mod_proxy.html">mod_proxy</a> module of Apache. While the second demo will use iframe and javascript tricks for making sub-domain ajax requests.</p>
<p><strong style="font-size:18px;"><u>Using mod_proxy for cross-domain ajax requests</u></strong><br />
By enabling mod_proxy module of apache2, we can configure apache in <a href="http://en.wikipedia.org/wiki/Reverse_proxy">reverse proxy</a> mode. In reverse proxy mode, apache2 appears be like an ordinary web server to the browser. However depending upon the proxy rules defined, apache2 can make cross-domain request and serve data back to the browser.</p>
<p><a href="http://abhinavsingh.com/webdemos/crossdomainajax/mod-proxy-example.php">Demo Link</a> for Cross Domain Ajax using Apache mod_proxy</p>
<p>In this demo, I will make cross-domain request to <a href="http://gtalkbots.com/reverse-proxy-data.php">http://gtalkbots.com/reverse-proxy-data.php</a>. To make this cross-domain request successful, I have configured apache2 as shown below:</p>
<ol>
<li>Enable mod_proxy module.
<pre class="php" name="code">$ a2enmod proxy
$ a2enmod proxy_http
$ a2enmod proxy_connect</pre>
</li>
<li>Add the following lines to httpd.conf:
<pre class="php" name="code">$ cat /private/etc/apache2/httpd.conf | grep mod_proxy

LoadModule proxy_module libexec/apache2/mod_proxy.so
LoadModule proxy_connect_module libexec/apache2/mod_proxy_connect.so
LoadModule proxy_http_module libexec/apache2/mod_proxy_http.so</pre>
</li>
<li>Create a file reverse-proxy.conf and add the following config:
<pre class="php" name="code">$ cat /private/etc/apache2/other/reverse-proxy.conf

ProxyRequests Off

&lt;Proxy *&gt;
Order deny,allow
Deny from all
Allow from .abhinavsingh.com
&lt;/Proxy&gt;

ProxyPass /webdemos/crossdomainajax/reverse-proxy-get.php http://gtalkbots.com/reverse-proxy-data.php
ProxyPassReverse /webdemos/crossdomainajax/reverse-proxy-get.php http://gtalkbots.com/reverse-proxy-data.php</pre>
</li>
</ol>
<p>In brief, when Apache sees an incoming ajax request to <code>/webdemos/crossdomainajax/reverse-proxy-get.php</code> , it simply proxy pass it to <code>http://gtalkbots.com/reverse-proxy-data.php</code> and return back the response. The whole process is hidden from the users on the demo page.</p>
<p><strong style="font-size:18px;"><u>Using iframes for cross-domain ajax requests</u></strong><br />
Another method of achieving sub-domain ajax requests is by using iframes. However, javascript does not allow communication between two frames if they don&#8217;t have same <code>document.domain</code>. The simplest of the hacks to make this communication possible is to set <code>document.domain</code> of the iframe same as that of the parent frame.</p>
<p><a href="http://abhinavsingh.com/webdemos/crossdomainajax/iframe-example.php">Demo Link</a> for Sub-Domain Ajax using iFrames</p>
<p>In this demo, I will make a sub-domain request to <a href="http://img1.abhinavsingh.com/iframe-data.php">http://img1.abhinavsingh.com/iframe-data.php</a>. To make this possible, I load an iframe with <code>src="http://img1.abhinavsingh.com/iframe-demo.php"</code> and set <code>document.domain="abhinavsingh.com";</code> for the iframe.</p>
<p><strong><u>iframe-demo.php</u></strong></p>
<pre class="php" name="code">&lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript"&gt;
	jQuery(function($) {
		function getTimestamp() {
			$.get(ajax_url,
				{},
				function(data) {
					$('#iframe_ajax_data', top.document).html('Server time received through iframe ajax: '+data);
				}
			);
		}

		document.domain = "abhinavsingh.com";
		$('#link', top.document).click(function() {
			getTimestamp();
		});
	});
&lt;/script&gt;
</pre>
<p>In brief, <code>iframe-demo.php</code> sets an <code>onclick</code> event on <code>$('#link' top.document)</code> , which makes a sub-domain ajax request to <a href="http://img1.abhinavsingh.com/iframe-data.php">http://img1.abhinavsingh.com/iframe-data.php</a></p>
<p>Enjoy!</p>
<script type="text/javascript">var wordpress_toolbar_urls = ["http:\/\/api.tweetmeme.com\/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2009%2F11%2Fmaking-cross-sub-domain-ajax-xhr-requests-using-mod_proxy-and-iframes%2F","http:\/\/en.wikipedia.org\/wiki\/Same_origin_policy","http:\/\/httpd.apache.org\/docs\/2.0\/mod\/mod_proxy.html","http:\/\/en.wikipedia.org\/wiki\/Reverse_proxy","http:\/\/abhinavsingh.com\/webdemos\/crossdomainajax\/mod-proxy-example.php","http:\/\/gtalkbots.com\/reverse-proxy-data.php","http:\/\/abhinavsingh.com\/webdemos\/crossdomainajax\/iframe-example.php","http:\/\/img1.abhinavsingh.com\/iframe-data.php","http:\/\/img1.abhinavsingh.com\/iframe-data.php"];var wordpress_toolbar_url = "http://abhinavsingh.com/blog/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "oinw";var wordpress_toolbar_hash = "aHR0cDovL2FiaGluYXZzaW5naC5jb20vYmxvZy8yMDA5LzExL21ha2luZy1jcm9zcy1zdWItZG9tYWluLWFqYXgteGhyLXJlcXVlc3RzLXVzaW5nLW1vZF9wcm94eS1hbmQtaWZyYW1lcy88d3B0Yj5NYWtpbmcgY3Jvc3Mtc3ViLWRvbWFpbiBhamF4IChYSFIpIHJlcXVlc3RzIHVzaW5nIG1vZF9wcm94eSBhbmQgaWZyYW1lczx3cHRiPmh0dHA6Ly9hYmhpbmF2c2luZ2guY29tL2Jsb2c8d3B0Yj5BYmhpJiMwMzk7cyBXZWJsb2c%3D";</script><ul class="related_post"><li><a href="http://abhinavsingh.com/blog/2008/11/how-does-php-echos-a-hello-world-behind-the-scene/" title="How does PHP echo&#039;s a &quot;Hello World&quot;? &#8211; Behind the scene">How does PHP echo&#039;s a &quot;Hello World&quot;? &#8211; Behind the scene</a> (16)</li><li><a href="http://abhinavsingh.com/blog/2008/08/how-to-make-faster-websites-and-enhance-your-site-user-experience-part-1/" title="How to make faster websites and enhance your site user experience &#8211; Part 1">How to make faster websites and enhance your site user experience &#8211; Part 1</a> (26)</li><li><a href="http://abhinavsingh.com/blog/2008/07/how-to-get-started-with-web-development/" title="How to get started with web development?">How to get started with web development?</a> (9)</li><li><a href="http://abhinavsingh.com/blog/2008/06/caching-problem-with-ie-with-ajax-a-solution/" title="Caching problem in IE with Ajax : A Solution">Caching problem in IE with Ajax : A Solution</a> (18)</li><li><a href="http://abhinavsingh.com/blog/2008/05/gmail-type-attachment-how-to-make-one/" title="Gmail Type Attachment &#8211; How to make one?">Gmail Type Attachment &#8211; How to make one?</a> (21)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://abhinavsingh.com/blog/2009/11/making-cross-sub-domain-ajax-xhr-requests-using-mod_proxy-and-iframes/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>Introducing jSlider: A Content Slider plugin for JQuery</title>
		<link>http://abhinavsingh.com/blog/2009/08/introducing-jslider-a-content-slider-plugin-for-jquery/</link>
		<comments>http://abhinavsingh.com/blog/2009/08/introducing-jslider-a-content-slider-plugin-for-jquery/#comments</comments>
		<pubDate>Thu, 27 Aug 2009 13:32:14 +0000</pubDate>
		<dc:creator>Abhinav Singh</dc:creator>
				<category><![CDATA[Open Source Projects]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Demo]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jslider]]></category>
		<category><![CDATA[Open Source]]></category>

		<guid isPermaLink="false">http://abhinavsingh.com/blog/?p=524</guid>
		<description><![CDATA[jSlider is a light weight JQuery plugin for content sliding. By content we mean everything: HTML code, Images, Advertisements etc etc. jSlider allows to put our content in simple &#60;div&#62;&#8216;s, and then it automatically generates a content slider for you, which one can customize using various options provided. Screenshot Below is a screen shot of [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2009%2F08%2Fintroducing-jslider-a-content-slider-plugin-for-jquery%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2009%2F08%2Fintroducing-jslider-a-content-slider-plugin-for-jquery%2F&amp;source=imoracle&amp;style=normal&amp;service=bit.ly&amp;service_api=R_f027b5a79a20a49b713f16282f1e0857&amp;hashtags=Demo,javascript,jslider,Open+Source&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><a href="http://code.google.com/p/jslider">jSlider</a> is a light weight <a href="http://jquery.com/">JQuery</a> plugin for content sliding. By content we mean everything: HTML code, Images, Advertisements etc etc. jSlider allows to put our content in simple <code>&lt;div&gt;</code>&#8216;s, and then it automatically generates a content slider for you, which one can customize using various options provided.</p>
<p><strong style="font-size:18px;"><u>Screenshot</u></strong><br />
Below is a screen shot of a content slider using jSlider:<br />
<a href="http://abhinavsingh.com/webdemos/jslider" style="text-decoration:none"><br />
<img src="http://abhinavsingh.com/blog/wp-content/uploads/2009/08/jSlider.png" alt="jSlider" title="jSlider" width="614" height="229" class="aligncenter size-full wp-image-525" style="border:0px none;"/><br />
</a></p>
<p><strong style="font-size:18px;"><u>Download and Demo</u></strong><br />
jSlider is hosted at google code. Use the following links for demo and downloads:</p>
<ul>
<li><a href="http://code.google.com/p/jslider">Download</a> the source code.</li>
<li>Click for a <a href="http://abhinavsingh.com/webdemos/jslider">demo</a> of jSlider</li>
</ul>
<p><strong style="font-size:18px;"><u>Using jslider.jquery.js</u></strong><br />
Below is a sample html code which will be processed by jslider:</p>
<p><strong>Sample input to jslider</strong></p>
<pre name="code" class="php">
    &lt;div id="jslider"&gt;
      &lt;div&gt;
        &lt;input type="hidden" value="Title for Content 1"/&gt;
        &lt;div&gt;
          HTML Content # 1
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;div&gt;
        &lt;input type="hidden" value="Title for Content 2"/&gt;
        &lt;div&gt;
          HTML Content # 2
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;div&gt;
        &lt;input type="hidden" value="Title for Content 3"/&gt;
        &lt;div&gt;
          HTML Content # 3
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;div&gt;
        &lt;input type="hidden" value="Title for Content 4"/&gt;
        &lt;div&gt;
          HTML Content # 4
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;div&gt;
        &lt;input type="hidden" value="Title for Content 5"/&gt;
        &lt;div&gt;
          HTML Content # 5
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
</pre>
<p>One must preserve the div structure as given in the example above. The hidden input values will be taken as heading for that block of content. If you want to have no heading or a common heading, fill this hidden input field appropriately.</p>
<p><strong>Sample output from jslider</strong></p>
<pre class="php" name="code">  &lt;div id="jslider"&gt;
    &lt;div class="slider"&gt;
      &lt;h2&gt;Title for Content 1&lt;/h2&gt;
      &lt;ul&gt;
        &lt;li class="selected"&gt;1&lt;/li&gt;
        &lt;li&gt;2&lt;/li&gt;
        &lt;li&gt;3&lt;/li&gt;
        &lt;li&gt;4&lt;/li&gt;
        &lt;li&gt;5&lt;/li&gt;
      &lt;/ul&gt;
    &lt;/div&gt;
    &lt;div class="content"&gt;
      &lt;div class="block"&gt;
        &lt;input type="hidden" value="Title for Content 1"/&gt;
        HTML Content # 1
      &lt;/div&gt;
      &lt;div class="block"&gt;
        &lt;input type="hidden" value="Title for Content 2"/&gt;
        HTML Content # 2
      &lt;/div&gt;
      &lt;div class="block"&gt;
        &lt;input type="hidden" value="Title for Content 3"/&gt;
        HTML Content # 3
      &lt;/div&gt;
      &lt;div class="block"&gt;
        &lt;input type="hidden" value="Title for Content 4"/&gt;
        HTML Content # 4
      &lt;/div&gt;
      &lt;div class="block"&gt;
        &lt;input type="hidden" value="Title for Content 5"/&gt;
        HTML Content # 5
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;</pre>
<p><strong style="font-size:18px;"><u>Customizing jslider.jquery.js</u></strong><br />
jSlider provides following options for customization:</p>
<ol>
<li><u>width</u>: Width of jslider div above, defaults to &#8217;610px&#8217;</li>
<li><u>height</u>: Height of jslider div above, defaults to &#8217;225px&#8217;</li>
<li><u>slider_height</u>: Height of slider div above (navigation bar), defaults to &#8217;24px&#8217;</li>
<li><u>content_height</u>: Height of content div above, defaults to &#8217;180px&#8217;</li>
<li><u>block_width</u>: Width of block div inside content div&#8217;s above, defaults to &#8217;590px&#8217;</li>
<li><u>block_padding</u>: Padding of block div inside content div&#8217;s above, defaults to &#8217;10px&#8217;</li>
<li><u>animation_time</u>: Time taken by 1 slide of content, defaults to 300 msec</li>
<li><u>animation_type</u>: Animation type, defaults to &#8216;linear&#8217;. Other option is &#8216;swing&#8217;</li>
</ol>
<p>Rest of the options like various padding etc can be controlled using the css properties. <a href="http://abhinavsingh.com/webdemos/jslider">View demo</a> for more implementation details. This is my first jquery plugin and I am only 2 weeks old in jquery. If you find any bug or need any enhancement, you are most welcome.</p>
<script type="text/javascript">var wordpress_toolbar_urls = ["http:\/\/api.tweetmeme.com\/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2009%2F08%2Fintroducing-jslider-a-content-slider-plugin-for-jquery%2F","http:\/\/code.google.com\/p\/jslider","http:\/\/jquery.com\/","http:\/\/abhinavsingh.com\/webdemos\/jslider","http:\/\/code.google.com\/p\/jslider","http:\/\/abhinavsingh.com\/webdemos\/jslider","http:\/\/abhinavsingh.com\/webdemos\/jslider"];var wordpress_toolbar_url = "http://abhinavsingh.com/blog/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "oinw";var wordpress_toolbar_hash = "aHR0cDovL2FiaGluYXZzaW5naC5jb20vYmxvZy8yMDA5LzA4L2ludHJvZHVjaW5nLWpzbGlkZXItYS1jb250ZW50LXNsaWRlci1wbHVnaW4tZm9yLWpxdWVyeS88d3B0Yj5JbnRyb2R1Y2luZyBqU2xpZGVyOiBBIENvbnRlbnQgU2xpZGVyIHBsdWdpbiBmb3IgSlF1ZXJ5PHdwdGI%2BaHR0cDovL2FiaGluYXZzaW5naC5jb20vYmxvZzx3cHRiPkFiaGkmIzAzOTtzIFdlYmxvZw%3D%3D";</script><ul class="related_post"><li><a href="http://abhinavsingh.com/blog/2009/07/facebook-type-image-rotation-and-more-using-php-and-javascript/" title="Facebook type image rotation and more using PHP and Javascript">Facebook type image rotation and more using PHP and Javascript</a> (27)</li><li><a href="http://abhinavsingh.com/blog/2009/06/seo-analyzer-v-12-adding-support-for-bing-along-with-google-and-yahoo/" title="SEO Analyzer v 1.2 &#8211; Adding support for Bing along with Google and Yahoo">SEO Analyzer v 1.2 &#8211; Adding support for Bing along with Google and Yahoo</a> (24)</li><li><a href="http://abhinavsingh.com/blog/2009/08/fixed-js-solution-to-ie6-positionfixed-bug/" title="fixed.js &#8211; Solution to IE6 &quot;position:fixed&quot; Bug">fixed.js &#8211; Solution to IE6 &quot;position:fixed&quot; Bug</a> (4)</li><li><a href="http://abhinavsingh.com/blog/2009/07/xml-parsing-in-php-xpath-way-the-best-i-know-so-far/" title="XML Parsing in PHP, XPATH way &#8211; The best I know so far">XML Parsing in PHP, XPATH way &#8211; The best I know so far</a> (32)</li><li><a href="http://abhinavsingh.com/blog/2009/04/seo-analyzer-version-11-whats-new/" title="SEO Analyzer &#8211; Version 1.1 &#8211; What&#039;s New?">SEO Analyzer &#8211; Version 1.1 &#8211; What&#039;s New?</a> (4)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://abhinavsingh.com/blog/2009/08/introducing-jslider-a-content-slider-plugin-for-jquery/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>fixed.js &#8211; Solution to IE6 &quot;position:fixed&quot; Bug</title>
		<link>http://abhinavsingh.com/blog/2009/08/fixed-js-solution-to-ie6-positionfixed-bug/</link>
		<comments>http://abhinavsingh.com/blog/2009/08/fixed-js-solution-to-ie6-positionfixed-bug/#comments</comments>
		<pubDate>Sat, 15 Aug 2009 15:10:04 +0000</pubDate>
		<dc:creator>Abhinav Singh</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[fixed.js]]></category>
		<category><![CDATA[IE6]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Open Source]]></category>

		<guid isPermaLink="false">http://abhinavsingh.com/blog/?p=521</guid>
		<description><![CDATA[IE6 has been a bane for all frontend developers for years. An element can be positioned relative to the browser window using the style position:fixed, it does not move when the page is scrolled. You can do nice layout things (e.g. facebook chat bar) with this in most modern browsers but not for IE6 in [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2009%2F08%2Ffixed-js-solution-to-ie6-positionfixed-bug%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2009%2F08%2Ffixed-js-solution-to-ie6-positionfixed-bug%2F&amp;source=imoracle&amp;style=normal&amp;service=bit.ly&amp;service_api=R_f027b5a79a20a49b713f16282f1e0857&amp;hashtags=fixed.js,IE6,javascript,Open+Source&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>IE6 has been a bane for all frontend developers for years. An element can be positioned relative to the browser window using the style <code>position:fixed</code>, it does not move when the page is scrolled. You can do nice layout things (e.g. facebook chat bar) with this in most modern browsers but not for IE6 in windows until you use <code>fixed.js</code></p>
<p><strong style="font-size:18px;"><u>Sample Code for Facebook Type Chat Bar</u></strong></p>
<pre name="code" class="php">&lt;html&gt;
  &lt;head&gt;
    &lt;style type="text/css"&gt;
      body {
        margin:0px;
        padding:0px;
        height:1600px;
        position:relative;
      }
      #shoutbox {
        position:fixed;
        background-color:#F2F2F2;
        border-top:1px solid #CCCCCC;
        bottom:0px;
        left:0px;
        width:100%;
        height:25px;
      }
    &lt;/style&gt;
    &lt;script type="text/javascript" src="fixed.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;div id="shoutbox"&gt;
      &lt;!-- Our Shoutbox --&gt;
    &lt;/div&gt;
  &lt;/body&gt;
&lt;/html&gt;
</pre>
<p>The above code will show you a bar at the bottom of the page, which remains fixed at the bottom even if you scroll the page.</p>
<p><strong style="font-size:18px;"><u>How does fixed.js help me?</u></strong></p>
<ol>
<li>fixed.js is smart enough to invoke only if the browser is IE6 on Windows machine. This is achieved by these two lines of code in fixed.js.
<pre class="javascript" name="code">/*@cc_on
@if (@_win32 &#038;&#038; @_jscript_version>4)</pre>
</li>
<li>It specifically tells IE6 how to render elements with <code>position:fixed</code> attributes. Which are otherwise ignored by IE6.</li>
<li>For remaining browsers, fixed.js go to sleep silently. Doesn&#8217;t do any processing.</li>
</ol>
<p><strong style="font-size:18px;"><u>Download fixed.js</u></strong><br />
fixed.js is developed and maintained at <a href="http://www.doxdesk.com/software/js/fixed.html">doxdesk.com</a>. Click here to <a href="http://www.doxdesk.com/file/software/js/fixed.js">download fixed.js</a></p>
<p>Happy Coding!</p>
<script type="text/javascript">var wordpress_toolbar_urls = ["http:\/\/api.tweetmeme.com\/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2009%2F08%2Ffixed-js-solution-to-ie6-positionfixed-bug%2F","http:\/\/www.doxdesk.com\/software\/js\/fixed.html","http:\/\/www.doxdesk.com\/file\/software\/js\/fixed.js"];var wordpress_toolbar_url = "http://abhinavsingh.com/blog/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "oinw";var wordpress_toolbar_hash = "aHR0cDovL2FiaGluYXZzaW5naC5jb20vYmxvZy8yMDA5LzA4L2ZpeGVkLWpzLXNvbHV0aW9uLXRvLWllNi1wb3NpdGlvbmZpeGVkLWJ1Zy88d3B0Yj5maXhlZC5qcyAmIzgyMTE7IFNvbHV0aW9uIHRvIElFNiAmcXVvdDtwb3NpdGlvbjpmaXhlZCZxdW90OyBCdWc8d3B0Yj5odHRwOi8vYWJoaW5hdnNpbmdoLmNvbS9ibG9nPHdwdGI%2BQWJoaSYjMDM5O3MgV2VibG9n";</script><ul class="related_post"><li><a href="http://abhinavsingh.com/blog/2009/08/introducing-jslider-a-content-slider-plugin-for-jquery/" title="Introducing jSlider: A Content Slider plugin for JQuery">Introducing jSlider: A Content Slider plugin for JQuery</a> (6)</li><li><a href="http://abhinavsingh.com/blog/2009/07/facebook-type-image-rotation-and-more-using-php-and-javascript/" title="Facebook type image rotation and more using PHP and Javascript">Facebook type image rotation and more using PHP and Javascript</a> (27)</li><li><a href="http://abhinavsingh.com/blog/2009/06/seo-analyzer-v-12-adding-support-for-bing-along-with-google-and-yahoo/" title="SEO Analyzer v 1.2 &#8211; Adding support for Bing along with Google and Yahoo">SEO Analyzer v 1.2 &#8211; Adding support for Bing along with Google and Yahoo</a> (24)</li><li><a href="http://abhinavsingh.com/blog/2010/08/releasing-jaxl-2-0-object-oriented-xmpp-framework-in-php/" title="Releasing Jaxl 2.0 &#8211; Object oriented XMPP framework in PHP">Releasing Jaxl 2.0 &#8211; Object oriented XMPP framework in PHP</a> (6)</li><li><a href="http://abhinavsingh.com/blog/2010/02/wordpress-toolbar-v-2-2-custom-toolbar-url-support-for-wpmu-and-bug-fixes/" title="Wordpress Toolbar v 2.2 : Custom toolbar url,  Support for WPMU and bug fixes">Wordpress Toolbar v 2.2 : Custom toolbar url,  Support for WPMU and bug fixes</a> (38)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://abhinavsingh.com/blog/2009/08/fixed-js-solution-to-ie6-positionfixed-bug/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Getting started with Autotools &#8211; GNU Build System on Debian</title>
		<link>http://abhinavsingh.com/blog/2009/08/getting-started-with-autotools-gnu-build-system-on-debian/</link>
		<comments>http://abhinavsingh.com/blog/2009/08/getting-started-with-autotools-gnu-build-system-on-debian/#comments</comments>
		<pubDate>Sun, 02 Aug 2009 09:28:35 +0000</pubDate>
		<dc:creator>Abhinav Singh</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Autoconf]]></category>
		<category><![CDATA[Automake]]></category>
		<category><![CDATA[Autotools]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[GNU]]></category>
		<category><![CDATA[Open Source]]></category>

		<guid isPermaLink="false">http://abhinavsingh.com/blog/?p=512</guid>
		<description><![CDATA[If you eat and drink open source, chances are high that you might have downloaded an open source project code, only to see files like: aclocal.m4, configure.ac, Makefile.am, Makefile.in and what not. You might have also used commands like ./configure, make etc but what are these files? Does they really belong to the project you [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2009%2F08%2Fgetting-started-with-autotools-gnu-build-system-on-debian%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2009%2F08%2Fgetting-started-with-autotools-gnu-build-system-on-debian%2F&amp;source=imoracle&amp;style=normal&amp;service=bit.ly&amp;service_api=R_f027b5a79a20a49b713f16282f1e0857&amp;hashtags=Autoconf,Automake,Autotools,Debian,GNU,Open+Source&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><img src="http://abhinavsingh.com/blog/wp-content/uploads/2009/08/The_GNU_logo-300x293.png" alt="The_GNU_logo" title="The_GNU_logo" style="float:left;width:140px;margin-right:10px;"/><br />
If you eat and drink open source, chances are high that you might have downloaded an open source project code, only to see files like: <code>aclocal.m4</code>, <code>configure.ac</code>, <code>Makefile.am</code>, <code>Makefile.in</code> and what not. You might have also used commands like <code>./configure</code>, <code>make</code> etc but what are these files? Does they really belong to the project you download? Do I need to understand them? In this blog post I look forward to answer all your question, as well as introduce you to not so popular <a href="http://en.wikipedia.org/wiki/GNU_build_system">Autotools</a> &#8211; A GNU Build System.</p>
<p><strong style="font-size:18px"><u>Setting up Autotools on Debian?</u></strong><br />
Before we go ahead and understand what Autotools is, we will try building a HelloWorld package. Lets get started by setting up Autotools on debian machine.</p>
<ul>
<li>apt-get install build-essential</li>
<li>gcc &#8211;version (verifying install)</li>
<li>g++ &#8211;version (verifying install)</li>
<li>apt-get install automake autoconf</li>
</ul>
<p>You have your environment ready. Lets start packaging the HelloWorld package.</p>
<p><strong style="font-size:18px"><u>Hello World Source Code</u></strong><br />
<a href="http://abhinavsingh.googlecode.com/files/autotools-helloworld-1.0.tar.gz">Download full source code from here</a></p>
<p>We will need to create 5 files for our basic HelloWorld package. Start by creating a directory structure like this:<br />
&#8211; <strong>HelloWorld</strong><br />
&nbsp;&nbsp;&nbsp;&nbsp;&#8211; configure.ac<br />
&nbsp;&nbsp;&nbsp;&nbsp;&#8211; Makefile.am<br />
&nbsp;&nbsp;&nbsp;&nbsp;&#8211; README<br />
&nbsp;&nbsp;&nbsp;&nbsp;&#8211; <strong>src</strong><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8211; Makefile.am<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8211; helloworld.c</p>
<p><strong><u>src/helloworld.c</u></strong></p>
<pre name="code" class="c">#include &lt;config.h&gt;
#include &lt;stdio.h&gt;

int main (void) {
    puts ("Hello World!");
    puts ("This is " PACKAGE_STRING ".");
    return 0;
}
</pre>
<p>Note we don&#8217;t have a <code>config.h</code> file but still we include it here. In actual <code>config.h</code> will be autogenerated by the autotools, when we build the package. Similarly, <code>PACKAGE_STRING</code> will be a pre-defined variable inside <code>config.h</code>.</p>
<p><strong><u>src/Makefile.am</u></strong></p>
<pre name="code" class="c">bin_PROGRAMS = helloworld
hello_SOURCES = helloworld.c</pre>
<p>Here we tell the build system to generate a binary named <code>helloworld</code> using the sources defined below i.e. <code>helloworld.c</code></p>
<p><strong><u>Makefile.am</u></strong></p>
<pre name="code" class="c">SUBDIRS=src
dist_doc_DATA=README</pre>
<p>Here we give information about the various sub-directory. For a bigger project you might have a <code>man</code> directory, <code>data</code> directory etc. Also we tell the build to package <code>README</code> file with the build.</p>
<p><strong><u>README</u></strong></p>
<pre name="code" class="c">This is a demonstration HelloWorld package for GNU Automake.
Type `info Automake' to read the Automake manual.</pre>
<p><strong><u>configure.ac</u></strong></p>
<pre name="code" class="c">AC_INIT([helloworld], [1.0], [emailid@provider.com])
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
AC_PROG_CC
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([
 Makefile
 src/Makefile
])
AC_OUTPUT
</pre>
<p>Don&#8217;t leave the post on seeing the above file. We will go through each and every one of them. <code>configure.ac</code> contains a series of <a href="http://en.wikipedia.org/wiki/M4_(computer_language)">M4 macros</a> that will expand to some shell code to finally generate the <code>configure</code> script. Autotools have utilities like <code>automake</code> and <code>autoconf</code> (details below) which read this file to generate intermediate and final build files. The variables starting with AC_ are Autoconf macros and those starting with AM_ are Automake macros.</p>
<ol>
<li>AC_INIT: Initializes autoconf. It takes 3 input parameters: Name of the package, Version of the package and Contact address for bug reports</li>
<li>AM_INIT_AUTOMAKE: Initializes automake. It can take a number of available input parameters. <code>-Wall</code> <code>-Werror</code> specifically tells automake to turn on all warnings and report them as error. While development we will keep error reporting turned on. <code>foreign</code> tells automake that this package doesn&#8217;t follow GNU standard. As per GNU standards we should also distribute files like <code>ChangeLog</code>, <code>AUTHORS</code> and at this stage we don&#8217;t want automake to complaint about them.</li>
<li>AC_PROG_CC: This line tells <code>configure</code> script to search available C compilers and define variable <code>CC</code> with its name. Later on many intermediate files will use this variable <code>CC</code> for building binary files.</li>
<li>AC_CONFIG_HEADERS: It tells the <code>configure</code> script to generate a <code>config.h</code> file which is pre-included by <code>helloworld.c</code>. Generated <code>config.h</code> will have content like this:
<pre name="code" class="c">/* config.h.  Generated from config.h.in by configure.  */
/* config.h.in.  Generated from configure.ac by autoheader.  */

/* Name of package */
#define PACKAGE "helloworld"

/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "emailid@provider.com"

/* Define to the full name of this package. */
#define PACKAGE_NAME "helloworld"</pre>
</li>
<li>AC_CONFIG_FILES: This tells <code>configure</code> script list of files from which it should generate it&#8217;s *.in templates. This variable is also used by <code>automake</code> utility to know list of <code>Makefile.am</code> it should process. (Note: Each directory should have a Makefile.am file and as you keep adding new directories keep adding them to AC_CONFIG_FILES, else build will not consider your new directories while building packages.</li>
<li>AC_OUTPUT: It is a closing command that actually produces the part of the script in charge of creating the files registered with AC_CONFIG_HEADERS and AC_CONFIG_FILES.</li>
</ol>
<p><strong style="font-size:18px"><u>Building a Hello World package for distribution</u></strong><br />
Lets create our first package for distribution.</p>
<ol>
<li>cd path/to/helloworld/directory: Migrate to the project directory</li>
<li>autoreconf &#8211;install: This command initiates the build system. You should see something like this as output:
<pre name="code" class="c">configure.ac:2: installing `./missing'
configure.ac:2: installing `./install-sh'
src/Makefile.am: installing `./depcomp'
</pre>
<p>Also if you scan through the <code>HelloWorld</code> directory, you will find a lot of new files being generated by the build system. Particularly you will see a <code>Makefile.in</code> being generated for each <code>Makefile.am</code>. Apart from these files of interest are <code>configure</code> and <code>config.h.in</code>.</li>
<li>./configure: It utilizes *.in files generated by the previous step to build the <code>Makefile</code>, <code>src/Makefile</code> and <code>config.h</code>. You should see something like this on your console:
<pre name="code" class="c">checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking for gcc... gcc
</pre>
</li>
<li>make</li>
<li>src/helloworld: This will output this on the console.
<pre name="code" class="c">Hello World!
This is helloworld 1.0.</pre>
</li>
<li>make distcheck: This utility finally creates the helloworld-1.0.tar.gz package for distribution. You should see this on your console on running this utility:
<pre name="code" class="c">================================================
helloworld-1.0 archives ready for distribution:
helloworld-1.0.tar.gz
================================================</pre>
</li>
</ol>
<p><strong style="font-size:18px"><u>Installing distributed HelloWorld package</u></strong></p>
<ol>
<li>Copy the generated package into your temp directory and then issue the following commands</li>
<li>tar -xzvf helloworld-1.0.tar.gz</li>
<li>cd helloworld-1.0</li>
<li>./configure</li>
<li>make</li>
<li>make install</li>
</ol>
<p><code>make install</code> will copy the <code>helloworld</code> binary into the <code>/usr/local/bin</code> directory. Try running <code>helloworld</code> from command line and you should see a similar output, as we saw above while building the package. Further it also copies the <code>README</code> file under <code>/usr/local/share/doc/helloworld</code> directory. If your built package includes the <code>man</code> directory, it gets copied to <code>/usr/local/share/man</code> automatically.</p>
<p><strong style="font-size:18px"><u>What is Autotools?</u></strong><br />
Autotools is a build system developed by GNU which helps you distribute your source code across various Unix systems. The files you are wondering about are auto generated by the Autotools.</p>
<p>Autotools is a combination of several utilities made available by GNU, including:</p>
<ol>
<li>Autoconf</li>
<li>Automake</li>
</ol>
<p>There are many others which can be listed above, but for this blog post we will restrict ourselves to Automake and Autoconf only.</p>
<p><strong><u>Autoconf</u></strong><br />
autoconf process files like <code>configure.in</code> to generate a <code>configure</code> script. When we run the <code>configure</code> script, it reads other template files like <code>Makefile.in</code> to generate a final output file, in this case <code>Makefile</code></p>
<p><strong><u>Automake</u></strong><br />
It reads all <code>Makefile.am</code> and generate corresponding <code>Makefile.in</code>, used by the <code>configure</code> script as described above.</p>
<p>Happy Packaging!</p>
<script type="text/javascript">var wordpress_toolbar_urls = ["http:\/\/api.tweetmeme.com\/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2009%2F08%2Fgetting-started-with-autotools-gnu-build-system-on-debian%2F","http:\/\/en.wikipedia.org\/wiki\/GNU_build_system","http:\/\/abhinavsingh.googlecode.com\/files\/autotools-helloworld-1.0.tar.gz","http:\/\/en.wikipedia.org\/wiki\/M4_(computer_language)"];var wordpress_toolbar_url = "http://abhinavsingh.com/blog/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "oinw";var wordpress_toolbar_hash = "aHR0cDovL2FiaGluYXZzaW5naC5jb20vYmxvZy8yMDA5LzA4L2dldHRpbmctc3RhcnRlZC13aXRoLWF1dG90b29scy1nbnUtYnVpbGQtc3lzdGVtLW9uLWRlYmlhbi88d3B0Yj5HZXR0aW5nIHN0YXJ0ZWQgd2l0aCBBdXRvdG9vbHMgJiM4MjExOyBHTlUgQnVpbGQgU3lzdGVtIG9uIERlYmlhbjx3cHRiPmh0dHA6Ly9hYmhpbmF2c2luZ2guY29tL2Jsb2c8d3B0Yj5BYmhpJiMwMzk7cyBXZWJsb2c%3D";</script><ul class="related_post"><li><a href="http://abhinavsingh.com/blog/2010/08/releasing-jaxl-2-0-object-oriented-xmpp-framework-in-php/" title="Releasing Jaxl 2.0 &#8211; Object oriented XMPP framework in PHP">Releasing Jaxl 2.0 &#8211; Object oriented XMPP framework in PHP</a> (6)</li><li><a href="http://abhinavsingh.com/blog/2010/02/wordpress-toolbar-v-2-2-custom-toolbar-url-support-for-wpmu-and-bug-fixes/" title="Wordpress Toolbar v 2.2 : Custom toolbar url,  Support for WPMU and bug fixes">Wordpress Toolbar v 2.2 : Custom toolbar url,  Support for WPMU and bug fixes</a> (38)</li><li><a href="http://abhinavsingh.com/blog/2009/09/5-exciting-gaming-bots-you-can-create-using-jaxl-jabber-xmpp-library-in-php/" title="5 exciting (gaming) bots you can create using Jaxl (Jabber XMPP Library) in PHP">5 exciting (gaming) bots you can create using Jaxl (Jabber XMPP Library) in PHP</a> (23)</li><li><a href="http://abhinavsingh.com/blog/2009/08/introducing-jslider-a-content-slider-plugin-for-jquery/" title="Introducing jSlider: A Content Slider plugin for JQuery">Introducing jSlider: A Content Slider plugin for JQuery</a> (6)</li><li><a href="http://abhinavsingh.com/blog/2009/08/building-a-custom-php-framework-with-a-custom-template-caching-engine-using-output-control-functions/" title="Building a Custom PHP Framework with a custom template caching engine using Output Control functions">Building a Custom PHP Framework with a custom template caching engine using Output Control functions</a> (10)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://abhinavsingh.com/blog/2009/08/getting-started-with-autotools-gnu-build-system-on-debian/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Getting started with Openlaszlo &#8211; Framework for developing flash apps</title>
		<link>http://abhinavsingh.com/blog/2009/07/getting-started-with-openlaszlo-framework-for-developing-flash-apps/</link>
		<comments>http://abhinavsingh.com/blog/2009/07/getting-started-with-openlaszlo-framework-for-developing-flash-apps/#comments</comments>
		<pubDate>Tue, 14 Jul 2009 20:47:45 +0000</pubDate>
		<dc:creator>Abhinav Singh</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[OpenLaszlo]]></category>

		<guid isPermaLink="false">http://abhinavsingh.com/blog/?p=503</guid>
		<description><![CDATA[Openlaszlo is an open source framework which simplifies development of flash applications. Openlaszlo allows you to code your flash apps using xml style laszlo code, and thereafter you can compile your code to output a .swf file for production usage. I first came around openlaszlo while I was developing Alterplayer &#8211; open source flash mp3 [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2009%2F07%2Fgetting-started-with-openlaszlo-framework-for-developing-flash-apps%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2009%2F07%2Fgetting-started-with-openlaszlo-framework-for-developing-flash-apps%2F&amp;source=imoracle&amp;style=normal&amp;service=bit.ly&amp;service_api=R_f027b5a79a20a49b713f16282f1e0857&amp;hashtags=Open+Source,OpenLaszlo&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><a href="http://openlaszlo.org">Openlaszlo</a> is an open source framework which simplifies development of flash applications. Openlaszlo allows you to code your flash apps using xml style laszlo code, and thereafter you can compile your code to output a .swf file for production usage. I first came around openlaszlo while I was developing <a href="http://code.google.com/p/alterplayer">Alterplayer</a> &#8211; open source flash mp3 player.</p>
<p>In this post I will demonstrate:</p>
<ul>
<li>Getting started with Openlaszlo &#8211; Setting up your dev enviornment</li>
<li>Hello World! in Openlaszlo</li>
<li>Upcoming tutorials</li>
</ul>
<p><strong style="font-size:18px"><u>Setting up Openlaszlo development environment</u></strong></p>
<ol>
<li>Download the latest openlaszlo release 4.4 from <a href="http://openlaszlo.org/download">http://openlaszlo.org/download</a> or alternatively download directly from <a href="http://download.openlaszlo.org/4.4.0/openlaszlo-4.4.0-windows-dev-install.exe">http://download.openlaszlo.org/4.4.0/openlaszlo-4.4.0-windows-dev-install.exe</a></li>
<li>Double click and install the setup. For me on WinXP, it installs in the following location. <strong>C:\Program Files\OpenLaszlo Server 4.4.0</strong></li>
<li>Upon installation tomcat server will start automatically. If it doesn&#8217;t, click the following file to start the tomcat server. <strong>C:\Program Files\OpenLaszlo Server 4.4.0\Server\lps-4.4.0\lps\utils\startTomcat.bat</strong></li>
<li>At any point in time when you want to stop the tomcat server, click the <strong>stopTomcat.bat</strong> file lying in the same folder.</li>
<li>Browse to the following location on your firefox, to see the opening welcome screen <a href="http://127.0.0.1:8080/lps-4.4.0/laszlo-explorer/index.jsp">http://127.0.0.1:8080/lps-4.4.0/laszlo-explorer/index.jsp</a></li>
<li>Create a folder inside <strong>C:\Program Files\OpenLaszlo Server 4.4.0\Server\lps-4.4.0</strong>, called <strong>Workspace</strong>. We will do all our development in this directory.</li>
<li>Create a folder called <strong>HelloWorld</strong> inside Workspace. We will start developing our first project straight away</li>
</ol>
<p><strong style="font-size:18px"><u>Hello World! in OpenLaszlo</u></strong><br />
Like in any other language and framework, we will learn how to write a Hello World! program.</p>
<ol>
<li>Create a file <strong>helloworld.lzx</strong> inside the Hello World folder</li>
<li>
<pre name="code" class="xml"><canvas debug="true">
  <text id="helloworld">Hello World!</text>
</canvas></pre>
</li>
<li>Browse to the following location on your browser: <a href="http://127.0.0.1:8080/lps-4.4.0/Workspace/HelloWorld/helloworld.lzx">http://127.0.0.1:8080/lps-4.4.0/Workspace/HelloWorld/helloworld.lzx</a></li>
<li>Did you see HelloWorld! ? Bingo</li>
</ol>
<p><strong style="font-size:18px"><u>Hello World! Explained</u></strong></p>
<ol>
<li>Each and every openlaszlo code file have an extension .lzx</li>
<li>Each and every laszlo code is wrapped inside <em>&lt;canvas&gt;&lt;/canvas&gt; </em>tag</li>
<li><em>&lt;text&gt;&lt;/text&gt;</em> is a class used for non-editable text fields. Here it will simply display Hello World! on the browser.</li>
</ol>
<p><strong style="font-size:18px"><u>Debugging in Openlaszlo</u></strong><br />
One of the strong feature which comes packaged with openlaszlo, is it&#8217;s support for debugging. When you visited the above link in your browser, along with Helllo World! text you must have seen a debugger window too. Mainly because we had <em>&lt;canvas debug=&#8221;true&#8221;&gt;</em>, debug true in our code.</p>
<p>If you might have noticed, I have given an id to out <em>&lt;text&gt;&lt;/text&gt;</em> node. Lets see how can we make use of it while debugging. Suppose you didn&#8217;t get what you really wanted out of your code, for instance suppose you mistyped Hello World! as Helo World!. Simply go ahead and type the element id in the debugger window.</p>
<p>For instance here I will type in the id of the element i want to inspect i.e. <strong>id=&#8221;helloworld&#8221;</strong>. As I press enter, debugger shows me all the details about my element of interest.<br />
<img src="http://abhinavsingh.com/blog/wp-content/uploads/2009/07/getting_started_with_openlaszlo.jpg" alt="getting_started_with_openlaszlo" title="getting_started_with_openlaszlo" width="600" height="420" class="alignleft size-full wp-image-505" /></p>
<p>Another thing you can do from within the code is, print out your debug logs on the debugger screen. For instance modify the above code as follows and refresh your app on the browser:</p>
<pre name="code" class="xml"><canvas debug="true">
  <text id="helloworld">
    Hello World!
  </text>
  <script>
    Debug.write("I just printed a Hello World!");
  </script>
</canvas></pre>
<p>Above code will simply throw a string &#8220;<strong>I just printed a Hello World!</strong>&#8221; on the debugger string. In you application you can ever throw a variable value for debugging purpose.</p>
<p><strong style="font-size:18px"><u>Upcoming tutorial</u></strong><br />
In the next tutorials on openlaszlo, I will explain:</p>
<ol>
<li>How to create an <a href="http://code.google.com/p/alterplayer">alterplayer</a> out of openlaszlo. Meanwhile I would like you to go through my previous post on openlaszlo: <a href="http://abhinavsingh.com/blog/2008/10/how-to-create-a-single-button-flash-audio-player-using-openlaszlo/">How to create a single button flash audio player using Openlaszlo?</a></li>
<li>How to build an <a href="http://abhinavsingh.com/imoracle/">imoracle video player</a> out of openlaszlo.</li>
</ol>
<p>Both the projects will be opensource under GNU General Public License v3.</p>
<p>Also you may want to visit the following reference on openlaszlo official site:<br />
<a href="http://www.openlaszlo.org/lps3/docs/reference/">http://www.openlaszlo.org/lps3/docs/reference/</a></p>
<script type="text/javascript">var wordpress_toolbar_urls = ["http:\/\/api.tweetmeme.com\/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2009%2F07%2Fgetting-started-with-openlaszlo-framework-for-developing-flash-apps%2F","http:\/\/openlaszlo.org","http:\/\/code.google.com\/p\/alterplayer","http:\/\/openlaszlo.org\/download","http:\/\/download.openlaszlo.org\/4.4.0\/openlaszlo-4.4.0-windows-dev-install.exe","http:\/\/127.0.0.1:8080\/lps-4.4.0\/laszlo-explorer\/index.jsp","http:\/\/127.0.0.1:8080\/lps-4.4.0\/Workspace\/HelloWorld\/helloworld.lzx","http:\/\/code.google.com\/p\/alterplayer","http:\/\/abhinavsingh.com\/imoracle\/","http:\/\/www.openlaszlo.org\/lps3\/docs\/reference\/"];var wordpress_toolbar_url = "http://abhinavsingh.com/blog/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "oinw";var wordpress_toolbar_hash = "aHR0cDovL2FiaGluYXZzaW5naC5jb20vYmxvZy8yMDA5LzA3L2dldHRpbmctc3RhcnRlZC13aXRoLW9wZW5sYXN6bG8tZnJhbWV3b3JrLWZvci1kZXZlbG9waW5nLWZsYXNoLWFwcHMvPHdwdGI%2BR2V0dGluZyBzdGFydGVkIHdpdGggT3Blbmxhc3psbyAmIzgyMTE7IEZyYW1ld29yayBmb3IgZGV2ZWxvcGluZyBmbGFzaCBhcHBzPHdwdGI%2BaHR0cDovL2FiaGluYXZzaW5naC5jb20vYmxvZzx3cHRiPkFiaGkmIzAzOTtzIFdlYmxvZw%3D%3D";</script><ul class="related_post"><li><a href="http://abhinavsingh.com/blog/2010/08/releasing-jaxl-2-0-object-oriented-xmpp-framework-in-php/" title="Releasing Jaxl 2.0 &#8211; Object oriented XMPP framework in PHP">Releasing Jaxl 2.0 &#8211; Object oriented XMPP framework in PHP</a> (6)</li><li><a href="http://abhinavsingh.com/blog/2010/02/wordpress-toolbar-v-2-2-custom-toolbar-url-support-for-wpmu-and-bug-fixes/" title="Wordpress Toolbar v 2.2 : Custom toolbar url,  Support for WPMU and bug fixes">Wordpress Toolbar v 2.2 : Custom toolbar url,  Support for WPMU and bug fixes</a> (38)</li><li><a href="http://abhinavsingh.com/blog/2009/09/5-exciting-gaming-bots-you-can-create-using-jaxl-jabber-xmpp-library-in-php/" title="5 exciting (gaming) bots you can create using Jaxl (Jabber XMPP Library) in PHP">5 exciting (gaming) bots you can create using Jaxl (Jabber XMPP Library) in PHP</a> (23)</li><li><a href="http://abhinavsingh.com/blog/2009/08/introducing-jslider-a-content-slider-plugin-for-jquery/" title="Introducing jSlider: A Content Slider plugin for JQuery">Introducing jSlider: A Content Slider plugin for JQuery</a> (6)</li><li><a href="http://abhinavsingh.com/blog/2009/08/building-a-custom-php-framework-with-a-custom-template-caching-engine-using-output-control-functions/" title="Building a Custom PHP Framework with a custom template caching engine using Output Control functions">Building a Custom PHP Framework with a custom template caching engine using Output Control functions</a> (10)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://abhinavsingh.com/blog/2009/07/getting-started-with-openlaszlo-framework-for-developing-flash-apps/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Toggle : A Javascript game, anyone up for the challenge?</title>
		<link>http://abhinavsingh.com/blog/2009/06/toggle-a-javascript-game-anyone-up-for-the-challenge/</link>
		<comments>http://abhinavsingh.com/blog/2009/06/toggle-a-javascript-game-anyone-up-for-the-challenge/#comments</comments>
		<pubDate>Sun, 21 Jun 2009 10:24:09 +0000</pubDate>
		<dc:creator>Abhinav Singh</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Online Games]]></category>

		<guid isPermaLink="false">http://abhinavsingh.com/blog/?p=438</guid>
		<description><![CDATA[This weekend I came across a game made using java applets. Initially looked like its possible to solve it, but slowly we realized that there might be no solution to this game. Finally I decided to clone it using javascript and see if you can solve the same. Toggle PS: Tested on all browsers except [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2009%2F06%2Ftoggle-a-javascript-game-anyone-up-for-the-challenge%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2009%2F06%2Ftoggle-a-javascript-game-anyone-up-for-the-challenge%2F&amp;source=imoracle&amp;style=normal&amp;service=bit.ly&amp;service_api=R_f027b5a79a20a49b713f16282f1e0857&amp;hashtags=javascript,Online+Games&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>This weekend I came across a game made using java applets. Initially looked like its possible to solve it, but slowly we realized that there might be no solution to this game. Finally I decided to clone it using javascript and see if you can solve the same.</p>
<div style="font-weight:bold; font-size:32px; color:#000000; margin-left:270px; margin-top:10px;">Toggle</div>
<div id="container" style="position:relative; height:300px; margin-top:5px; margin-left:200px;"></div>
<p><strong style="color:#AA0000">PS: Tested on all browsers except IE</strong></p>
<p><strong><u>Modes:</u></strong><br />
I included a custom mode in this game. Original game had only the classic mode.</p>
<ul>
<li><u>Classic Mode:</u> When you click a square in classic mode, that clicked square and all neighbourhood squares toggle their colors (excluding diagonal neighbours).</li>
<li><u>Custom Mode:</u> In custom mode, when you click a square, the clicked square and all neighbourhood squares toggle their colors (including diagonal neighbours).</li>
</ul>
<p><strong><u>Rules:</u></strong></p>
<ul>
<li>Destination is to fill all the squares with black color.</li>
<li>Ideally game should be played in a single mode only. However I have provided an option where you can switch modes in between the game. So you are free to either play it in a single mode throughout, or switch modes as and when you feel is the requirement</li>
<li>If you are finally able to make it, click view history, copy the steps you followed to conquer this game and post it as a comment to this blog post</li>
</ul>
<p><strong style="font-size:26px;"><u>Source Code:</u></strong><br />
The source code consists of toggle.js and toggle.css. Find below the source code, and towards the end, find how to embed the same on your page/blog.</p>
<p><strong><u>toggle.css</u></strong></p>
<pre class="css" name="code">/*

  Script: toggle.css
  Author: Abhinav Singh mailsforabhinav[at]gmail[dot]com
  Website: http://abhinavsingh.com
  Code license: GNU General Public License v3

*/
.box {
  border:1px solid #000000;
  cursor:pointer;
}
.boxColored {
  border:1px solid #FFFFFF;
  background: #000000;
  cursor:pointer;
}
</pre>
<p><strong><u>toggle.js</u></strong></p>
<pre class="javascript" name="code">/*

  Script: toggle.js
  Author: Abhinav Singh mailsforabhinav[at]gmail[dot]com
  Website: http://abhinavsingh.com
  Code license: GNU General Public License v3

*/
Array.prototype.unique = function(b) {
  var a = [], i, l = this.length;
  for(i=0; i&lt;l; i++) {
    if(a.indexOf(this[i], 0, b) &lt; 0) { a.push(this[i]); }
  }
  return a;
};
var $ = {
  html: '',
  cid: 'container',
  xBoxes: 5,
  yBoxes: 5,
  boxWidth: 50,
  boxHeight: 50,
  version: 'classic',
  history: Array(),
  init: function() {
    var tmp = '';
    for(var i=0;i&lt;this.yBoxes;i++) {
      for(var j=0;j&lt;this.xBoxes;j++) {
        tmp += '&lt;div onclick="$.toggle(this)" name="box" id="box-'+i+'-'+j+'" style="position:absolute; left:'+(j*this.boxWidth)+'px; top:'+(i*this.boxHeight)+'px; height:'+this.boxHeight+'px; width:'+this.boxWidth+'px" class="box"&gt;';
        tmp += '&lt;/div&gt;';
      }
    }
    tmp += '&lt;div style="position:absolute; top:'+((this.yBoxes*this.boxHeight)+5)+'px; left:0px;"&gt;';
    tmp += '  &lt;b style="float:left"&gt;Version:&lt;/b&gt; ';
    tmp += '  &lt;select style="float:left" id="version" onchange="$.version = this.options[this.selectedIndex].value;"&gt;';
    tmp += '    &lt;option value="classic"&gt;Classic&lt;/option&gt;';
    tmp += '    &lt;option value="custom"&gt;Custom&lt;/option&gt;';
    tmp += '  &lt;/select&gt;';
    tmp += '  &lt;div style="float:left; padding-left:20px; text-decoration:underline; cursor:pointer;" onclick="alert($.history.unique())"&gt;View History&lt;/div&gt;';
    tmp += '&lt;/div&gt;';
    document.getElementById(this.cid).innerHTML = tmp;
  },
  toggle: function(t) {
    this.history.push((t.id.toString()).replace('box-',''));
    id = t.id; ids = id.split("-");
    xid = parseInt(ids[1]); yid = parseInt(ids[2]);

    for(var l=xid-1; l&lt;=xid+1; l++) {
      for(var m=yid-1; m&lt;=yid+1; m++) {
        if(l&gt;=0 &#038;&#038; l&lt;this.xBoxes &#038;&#038; m&gt;=0 &#038;&#038; m&lt;this.yBoxes) {
          if(this.version == "classic") {
            if((l == xid-1 &#038;&#038; m == yid-1) || (l == xid+1 &#038;&#038; m == yid-1) || (l == xid-1 &#038;&#038; m == yid+1) || (l == xid+1 &#038;&#038; m == yid+1)) {

            }
            else {
              var boxid = document.getElementById('box-'+l+'-'+m);
              if(boxid.className == "box") boxid.className = "boxColored";
              else if(boxid.className == "boxColored") boxid.className = "box";
            }
          }
          if(this.version == "custom") {
            var boxid = document.getElementById('box-'+l+'-'+m);
            if(boxid.className == "box") boxid.className = "boxColored";
            else if(boxid.className == "boxColored") boxid.className = "box";
          }
        }
      }
    }
  }
}
$.init();</pre>
<p><strong><u>How to embed toggle on my page/blog?</u></strong></p>
<ul>
<li>Simply copy the js and css files from above or download them from here: <a href="http://abhinavsingh.com/toggle/toggle.js">toggle.js</a>, <a href="http://abhinavsingh.com/toggle/toggle.css">toggle.css</a></li>
<li>Include the two on your page/blog. toggle.js automatically calls up <strong>$.init()</strong> on load. $.init() method will look for a div with id <strong>$.cid</strong> on you page, and populate the game in the same div. Hence make sure you have a div with id $.cid on the page.</li>
<li><strong>$.xBoxes</strong>, <strong>$.yBoxes</strong>, <strong>$.boxWidth</strong>, <strong>$.boxHeight</strong> are a few tunable parameters you may want to play with</li>
</ul>
<link rel="stylesheet" href="http://abhinavsingh.com/webdemos/toggle/toggle.css" type="text/css"/>
<script type="text/javascript" src="http://abhinavsingh.com/webdemos/toggle/toggle.js"></script><br />
Happy Toggling!</p>
<script type="text/javascript">var wordpress_toolbar_urls = ["http:\/\/api.tweetmeme.com\/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2009%2F06%2Ftoggle-a-javascript-game-anyone-up-for-the-challenge%2F","http:\/\/abhinavsingh.com\/toggle\/toggle.js","http:\/\/abhinavsingh.com\/toggle\/toggle.css"];var wordpress_toolbar_url = "http://abhinavsingh.com/blog/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "oinw";var wordpress_toolbar_hash = "aHR0cDovL2FiaGluYXZzaW5naC5jb20vYmxvZy8yMDA5LzA2L3RvZ2dsZS1hLWphdmFzY3JpcHQtZ2FtZS1hbnlvbmUtdXAtZm9yLXRoZS1jaGFsbGVuZ2UvPHdwdGI%2BVG9nZ2xlIDogQSBKYXZhc2NyaXB0IGdhbWUsIGFueW9uZSB1cCBmb3IgdGhlIGNoYWxsZW5nZT88d3B0Yj5odHRwOi8vYWJoaW5hdnNpbmdoLmNvbS9ibG9nPHdwdGI%2BQWJoaSYjMDM5O3MgV2VibG9n";</script><ul class="related_post"><li><a href="http://abhinavsingh.com/blog/2009/08/introducing-jslider-a-content-slider-plugin-for-jquery/" title="Introducing jSlider: A Content Slider plugin for JQuery">Introducing jSlider: A Content Slider plugin for JQuery</a> (6)</li><li><a href="http://abhinavsingh.com/blog/2009/08/fixed-js-solution-to-ie6-positionfixed-bug/" title="fixed.js &#8211; Solution to IE6 &quot;position:fixed&quot; Bug">fixed.js &#8211; Solution to IE6 &quot;position:fixed&quot; Bug</a> (4)</li><li><a href="http://abhinavsingh.com/blog/2009/07/facebook-type-image-rotation-and-more-using-php-and-javascript/" title="Facebook type image rotation and more using PHP and Javascript">Facebook type image rotation and more using PHP and Javascript</a> (27)</li><li><a href="http://abhinavsingh.com/blog/2009/06/seo-analyzer-v-12-adding-support-for-bing-along-with-google-and-yahoo/" title="SEO Analyzer v 1.2 &#8211; Adding support for Bing along with Google and Yahoo">SEO Analyzer v 1.2 &#8211; Adding support for Bing along with Google and Yahoo</a> (24)</li><li><a href="http://abhinavsingh.com/blog/2009/04/getting-google-page-rank-using-javascript-for-adobe-air-apps/" title="Getting Google Page Rank using Javascript &#8211; For Adobe AIR Apps">Getting Google Page Rank using Javascript &#8211; For Adobe AIR Apps</a> (2)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://abhinavsingh.com/blog/2009/06/toggle-a-javascript-game-anyone-up-for-the-challenge/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>Konami Code on Facebook : How to implement it on your site</title>
		<link>http://abhinavsingh.com/blog/2009/05/konami-code-on-facebook-how-to-implement-it-on-your-site/</link>
		<comments>http://abhinavsingh.com/blog/2009/05/konami-code-on-facebook-how-to-implement-it-on-your-site/#comments</comments>
		<pubDate>Tue, 19 May 2009 17:46:59 +0000</pubDate>
		<dc:creator>Abhinav Singh</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[cheat code]]></category>
		<category><![CDATA[Facebook]]></category>
		<category><![CDATA[Konami Code]]></category>
		<category><![CDATA[lens flare]]></category>
		<category><![CDATA[Video Game]]></category>

		<guid isPermaLink="false">http://abhinavsingh.com/blog/?p=359</guid>
		<description><![CDATA[Yesterday while chatting with friends, I discovered an unusual thing on facebook. Unusual because I didn&#8217;t see any sense in what I saw back then. The process to discover this unusual thing is as follows: How to view lens flare on facebook 1. Login to facebook.com 2. Click once anywhere on your home page 3. [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2009%2F05%2Fkonami-code-on-facebook-how-to-implement-it-on-your-site%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2009%2F05%2Fkonami-code-on-facebook-how-to-implement-it-on-your-site%2F&amp;source=imoracle&amp;style=normal&amp;service=bit.ly&amp;service_api=R_f027b5a79a20a49b713f16282f1e0857&amp;hashtags=cheat+code,Facebook,Konami+Code,lens+flare,Video+Game&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Yesterday while chatting with friends, I discovered an unusual thing on <a href="http://facebook.com">facebook</a>. Unusual because I didn&#8217;t see any sense in what I saw back then. The process to discover this unusual thing is as follows:</p>
<p><strong style="font-size:18px;">How to view lens flare on facebook</strong><br />
1. Login to facebook.com<br />
2. Click once anywhere on your home page<br />
3. Click the following sequence of characters using your keyboard<br />
4. <strong>Up</strong>, <strong>Up</strong>, <strong>Down</strong>, <strong>Down</strong>, <strong>Left</strong>, <strong>Right</strong>, <strong>Left</strong>, <strong>Right</strong>, <strong>B</strong>, <strong>A</strong>, <strong>Enter Key</strong><br />
5. Click again on the page or try to scroll the page up or down</p>
<p>If everything is done correctly you will see something like this:<br />
<img src="http://abhinavsingh.com/blog/wp-content/uploads/2009/05/lensflare-1024x619.jpg" alt="lensflare on facebook" title="lensflare on facebook" width="650" class="alignleft size-large wp-image-360" style="padding:3px;border:1px solid #CCCCCC;"/></p>
<p>On more investigation I found out this unusual thing is nothing but &#8220;<a href="http://en.wikipedia.org/wiki/Konami_Code">Konami Code</a>&#8220;, which is a cheat code that appears in many Konami video games. The Konami code was introduced to many gamers in the 1988 NES version of <strong>Contra</strong>. Due to the game&#8217;s intense difficulty, many Contra players became reliant on the cheat code, which increased the player&#8217;s lives from 3 to 30 (9 to 90 including continues), to finish the game. The game&#8217;s popularity, combined with the near-necessity of using the code, made it renowned to an entire generation of video game players. This led to the code being used in countless games, and even mentioned across popular culture.</p>
<p>Once the cheat code is entered, facebook extends it to enable <a href="http://en.wikipedia.org/wiki/Lens_flare">Lens Flare</a> on all the pages you visit thereafter. You can use the below code, to enable-disable komani code on your site, and thereafter extend it to anything you want to:</p>
<pre class="html" name="code">
  &lt;head&gt;
    <script type="text/javascript">
      var $ = {
        enabled: false,
        tmp: Array(),
        _konamiCode: Array(65,66,39,37,39,37,40,40,38,38),
        init: function() {
          this.tmp = Array(65,66,39,37,39,37,40,40,38,38);
        },
        konamiCode: function(e) {
          if(!this.enabled) {
            var t = this.tmp.pop();
            if((e.keyCode-t) == 0) {
              if(this.tmp.length == 0) {
                this.enabled = true;
              }
            }
            else {
              this.init();
            }
          }
          else {
            this.action();
          }
        },
        // Change the action() function to whatever you want to
        action: function() {
          alert("Konami Code Activated");
        }
      }
    </script>
  &lt;/head&gt;
  &lt;body onload="$.init()" onkeydown="$.konamiCode(event)"&gt;
  &lt;/body&gt;</pre>
<p>Try out once on facebook and then come back to grab it for your site.<br />
Enjoy!</p>
<div id="paidTxtLinkAds">Discover the best php solutions with <a href="http://www.testking.org">testkings</a> online <a href="http://www.testking.org/640-553.htm">testking 640-553</a> web development course and join <a href="http://www.testking.org/SY0-201.htm">testking SY0-201</a> php classes for guaranteed learning.</div>
<script type="text/javascript">var wordpress_toolbar_urls = ["http:\/\/api.tweetmeme.com\/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2009%2F05%2Fkonami-code-on-facebook-how-to-implement-it-on-your-site%2F","http:\/\/facebook.com","http:\/\/en.wikipedia.org\/wiki\/Konami_Code","http:\/\/en.wikipedia.org\/wiki\/Lens_flare","http:\/\/www.testking.org","http:\/\/www.testking.org\/640-553.htm","http:\/\/www.testking.org\/SY0-201.htm"];var wordpress_toolbar_url = "http://abhinavsingh.com/blog/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "oinw";var wordpress_toolbar_hash = "aHR0cDovL2FiaGluYXZzaW5naC5jb20vYmxvZy8yMDA5LzA1L2tvbmFtaS1jb2RlLW9uLWZhY2Vib29rLWhvdy10by1pbXBsZW1lbnQtaXQtb24teW91ci1zaXRlLzx3cHRiPktvbmFtaSBDb2RlIG9uIEZhY2Vib29rIDogSG93IHRvIGltcGxlbWVudCBpdCBvbiB5b3VyIHNpdGU8d3B0Yj5odHRwOi8vYWJoaW5hdnNpbmdoLmNvbS9ibG9nPHdwdGI%2BQWJoaSYjMDM5O3MgV2VibG9n";</script><ul class="related_post"><li><a href="http://abhinavsingh.com/blog/2010/08/facebook-chat-connect-with-x-facebook-platform-using-jaxl-2-0/" title="Facebook chat connect with X-FACEBOOK-PLATFORM using Jaxl 2.0">Facebook chat connect with X-FACEBOOK-PLATFORM using Jaxl 2.0</a> (115)</li><li><a href="http://abhinavsingh.com/blog/2010/02/writing-your-first-facebook-chat-bot-in-php-using-jaxl-library/" title="Writing your first facebook chat bot in PHP using Jaxl library">Writing your first facebook chat bot in PHP using Jaxl library</a> (58)</li><li><a href="http://abhinavsingh.com/blog/2009/07/facebook-type-image-rotation-and-more-using-php-and-javascript/" title="Facebook type image rotation and more using PHP and Javascript">Facebook type image rotation and more using PHP and Javascript</a> (27)</li><li><a href="http://abhinavsingh.com/blog/2009/01/memcached-and-n-things-you-can-do-with-it/" title="Memcached and &quot;N&quot; things you can do with it &#8211; Part 1">Memcached and &quot;N&quot; things you can do with it &#8211; Part 1</a> (19)</li><li><a href="http://abhinavsingh.com/blog/2008/07/link-to-new-facebook-design-see-it-building-everyday/" title="Link to new facebook design: See it building everyday">Link to new facebook design: See it building everyday</a> (2)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://abhinavsingh.com/blog/2009/05/konami-code-on-facebook-how-to-implement-it-on-your-site/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Getting Google Page Rank using Javascript &#8211; For Adobe AIR Apps</title>
		<link>http://abhinavsingh.com/blog/2009/04/getting-google-page-rank-using-javascript-for-adobe-air-apps/</link>
		<comments>http://abhinavsingh.com/blog/2009/04/getting-google-page-rank-using-javascript-for-adobe-air-apps/#comments</comments>
		<pubDate>Fri, 17 Apr 2009 18:56:52 +0000</pubDate>
		<dc:creator>Abhinav Singh</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Adobe AIR]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Page Rank]]></category>

		<guid isPermaLink="false">http://abhinavsingh.com/blog/?p=352</guid>
		<description><![CDATA[Last week while working on SEO Analyzer v 1.1 desktop application, I faced a challenge of getting google page rank for a particular site using javascript. I am not sure if someone has already done this before, but I thought of sharing this javascript code for all adobe air and web developers out there. googlepagerank.js [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2009%2F04%2Fgetting-google-page-rank-using-javascript-for-adobe-air-apps%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2009%2F04%2Fgetting-google-page-rank-using-javascript-for-adobe-air-apps%2F&amp;source=imoracle&amp;style=normal&amp;service=bit.ly&amp;service_api=R_f027b5a79a20a49b713f16282f1e0857&amp;hashtags=Adobe+AIR,Google,javascript,Page+Rank&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Last week while working on <a target="_blank" href="http://abhinavsingh.com/blog/2009/04/seo-analyzer-version-11-whats-new/">SEO Analyzer v 1.1</a> desktop application, I faced a challenge of getting google page rank for a particular site using javascript. I am not sure if someone has already done this before, but I thought of sharing this javascript code for all adobe air and web developers out there.</p>
<p><strong style="font-size:18px;"><u>googlepagerank.js</u></strong></p>
<pre class="javascript" name="code">
var googlepagerank = {
	hexdec: function(hex_string) {
	    hex_string = (hex_string+'').replace(/[^a-f0-9]/gi, '');
	    return parseInt(hex_string, 16);
	},
	count: function( mixed_var, mode ) {
	    var key, cnt = 0;
	    if( mode == 'COUNT_RECURSIVE' ) mode = 1;
	    if( mode != 1 ) mode = 0;
	    for (key in mixed_var){
	        cnt++;
	        if( mode==1 &#038;&#038; mixed_var[key] &#038;&#038; (mixed_var[key].constructor === Array || mixed_var[key].constructor === Object) ){
	            cnt += count(mixed_var[key], 1);
	        }
	    }
	    return cnt;
	},
	sizeof: function( mixed_var, mode ) {
	    return googlepagerank.count( mixed_var, mode );
	},
	ord: function(string) {
	    return (string+'').charCodeAt(0);
	},
	strlen: function(string) {
	    var str = string+'';
	    var i = 0, chr = '', lgth = 0;
	    var getWholeChar = function (str, i) {
	        var code = str.charCodeAt(i);
	        var next = '', prev = '';
	        if (0xD800 <= code &#038;&#038; code <= 0xDBFF) {
	            if (str.length <= (i+1))  {
	                throw 'High surrogate without following low surrogate';
	            }
	            next = str.charCodeAt(i+1);
	            if (0xDC00 > next || next > 0xDFFF) {
	                throw 'High surrogate without following low surrogate';
	            }
	            return str[i]+str[i+1];
	        } else if (0xDC00 <= code &#038;&#038; code <= 0xDFFF) {
	            if (i === 0) {
	                throw 'Low surrogate without preceding high surrogate';
	            }
	            prev = str.charCodeAt(i-1);
	            if (0xD800 > prev || prev > 0xDBFF) {
	                throw 'Low surrogate without preceding high surrogate';
	            }
	            return false;
	        }
	        return str[i];
	    };
	    for (i=0, lgth=0; i < str.length; i++) {
	        if ((chr = getWholeChar(str, i)) === false) {
	            continue;
	        }
	        lgth++;
	    }
	    return lgth;
	},
	substr: function(f_string,f_start,f_length ) {
			f_string += '';
			if(f_start < 0) {
					f_start += f_string.length;
			}
			if(f_length == undefined) {
					f_length = f_string.length;
			} else if(f_length < 0){
					f_length += f_string.length;
			} else {
					f_length += f_start;
			}
			if(f_length < f_start) {
					f_length = f_start;
			}
			return f_string.substring(f_start, f_length);
	},
	zeroFill: function(a, b){
		z = googlepagerank.hexdec(80000000);
		if (z &#038; a) {
			a = (a >> 1);
			a &#038;= (~ z);
			a |= 0x40000000;
			a = (a >> (b - 1));
		}
		else {
			a = (a >> b);
		}
		return a;
	},
	mix: function(a, b, c){
		a -= b; a -= c; a ^= (this.zeroFill(c, 13));
		b -= c; b -= a; b ^= (a << 8);
		c -= a; c -= b; c ^= (this.zeroFill(b, 13));
		a -= b; a -= c; a ^= (this.zeroFill(c, 12));
		b -= c; b -= a; b ^= (a << 16);
		c -= a; c -= b; c ^= (this.zeroFill(b, 5));
		a -= b; a -= c; a ^= (this.zeroFill(c, 3));
		b -= c; b -= a; b ^= (a << 10);
		c -= a; c -= b; c ^= (this.zeroFill(b, 15));
		return new Array(a, b, c);
	},
	ch: function(url){
		length = googlepagerank.sizeof(url);
		a = 0x9E3779B9;
		b = 0x9E3779B9;
		c = 0xE6359A60;
		k = 0;
		len = length;
		while (len >= 12) {
			a += (url[k + 0] + (url[k + 1] << <img src='http://abhinavsingh.com/blog/wp-includes/images/smilies/icon_cool.gif' alt='8)' class='wp-smiley' /> + (url[k + 2] << 16) + (url[k + 3] << 24));
			b += (url[k + 4] + (url[k + 5] << <img src='http://abhinavsingh.com/blog/wp-includes/images/smilies/icon_cool.gif' alt='8)' class='wp-smiley' /> + (url[k + 6] << 16) + (url[k + 7] << 24));
			c += (url[k + 8] + (url[k + 9] << <img src='http://abhinavsingh.com/blog/wp-includes/images/smilies/icon_cool.gif' alt='8)' class='wp-smiley' /> + (url[k + 10] << 16) + (url[k + 11] << 24));
			m = this.mix(a, b, c);
			a = m[0]; b = m[1]; c = m[2];
			k += 12;
			len -= 12;
		}
		c += length;
		switch (len) {
			case 11: c += (url[k + 10] << 24);
			case 10: c += (url[k + 9] << 16);
			case 9:  c += (url[k + 8] << 8);
			case 8:  b += (url[k + 7] << 24);
			case 7:  b += (url[k + 6] << 16);
			case 6:  b += (url[k + 5] << 8);
			case 5:  b += (url[k + 4]);
			case 4:  a += (url[k + 3] << 24);
			case 3:  a += (url[k + 2] << 16);
			case 2:  a += (url[k + 1] << 8);
			case 1:  a += (url[k + 0]);
		}
		m = this.mix(a, b, c);
		return m[2];
	},
	strord: function(string){
		var result = new Array();
		for (i = 0; i < googlepagerank.strlen(string); i++) {
			result[i] = googlepagerank.ord(string[i]);
		}
		return result;
	},
	gethash: function(url) {
		return this.ch(this.strord("info:" + url));
	},
	getpr: function(baseurl) {
		var query = "";
		query += "http://toolbarqueries.google.com/search";
		query += "?client=navclient-auto";
		query += "&#038;hl=en";
		query += "&#038;ch=6"+googlepagerank.gethash(baseurl);
		query += "&#038;ie=UTF-8";
		query += "&#038;oe=UTF-8";
		query += "&#038;features=Rank";
		query += "&#038;q=info:"+baseurl;

		var req = new XMLHttpRequest();
		req.onreadystatechange = function(){
			if (req.readyState == 4) {
				var str = req.responseText;
				var pagerank = googlepagerank.substr(str, 9, 2);
				alert(pagerank);
			}
		}
		req.open('GET', query, true);
		req.send(null);
	}
}</pre>
<p><strong style="font-size:18px;"><u>How to use script in an adobe air application</u></strong></p>
<pre class="php" name="code"><html>
	<head>

        <script type="text/javascript" src="lib/air/AIRAliases.js"></script>
        <script type="text/javascript" src="lib/air/googlepagerank.js"></script>
		<script type="text/javascript">
			googlepagerank.getpr("http://abhinavsingh.com/blog");
		</script>
	</head>
    <body>

    </body>
</html></pre>
<p><strong style="font-size:18px;"><u>How to use script in an web applications</u></strong><br />
This script cannot be used directly for web applications, mainly because of cross domain XHR limitations. However the script can be modified to use with proxy script provided at <a href="http://developer.yahoo.com/javascript/howto-proxy.html">developer.yahoo.com</a></p>
<p><strong>Please Note:</strong> Getting google page rankings is/might be illegal as per google's policy. If you use this script from webservers, possibilities are google might block your server IP Address. However with adobe air applications (desktop apps), risk is minimized.</p>
<p>Enjoy and Do leave a comment.</p>
<script type="text/javascript">var wordpress_toolbar_urls = ["http:\/\/api.tweetmeme.com\/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2009%2F04%2Fgetting-google-page-rank-using-javascript-for-adobe-air-apps%2F","http:\/\/developer.yahoo.com\/javascript\/howto-proxy.html"];var wordpress_toolbar_url = "http://abhinavsingh.com/blog/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "oinw";var wordpress_toolbar_hash = "aHR0cDovL2FiaGluYXZzaW5naC5jb20vYmxvZy8yMDA5LzA0L2dldHRpbmctZ29vZ2xlLXBhZ2UtcmFuay11c2luZy1qYXZhc2NyaXB0LWZvci1hZG9iZS1haXItYXBwcy88d3B0Yj5HZXR0aW5nIEdvb2dsZSBQYWdlIFJhbmsgdXNpbmcgSmF2YXNjcmlwdCAmIzgyMTE7IEZvciBBZG9iZSBBSVIgQXBwczx3cHRiPmh0dHA6Ly9hYmhpbmF2c2luZ2guY29tL2Jsb2c8d3B0Yj5BYmhpJiMwMzk7cyBXZWJsb2c%3D";</script><ul class="related_post"><li><a href="http://abhinavsingh.com/blog/2009/06/seo-analyzer-v-12-adding-support-for-bing-along-with-google-and-yahoo/" title="SEO Analyzer v 1.2 &#8211; Adding support for Bing along with Google and Yahoo">SEO Analyzer v 1.2 &#8211; Adding support for Bing along with Google and Yahoo</a> (24)</li><li><a href="http://abhinavsingh.com/blog/2009/04/seo-analyzer-version-11-whats-new/" title="SEO Analyzer &#8211; Version 1.1 &#8211; What&#039;s New?">SEO Analyzer &#8211; Version 1.1 &#8211; What&#039;s New?</a> (4)</li><li><a href="http://abhinavsingh.com/blog/2009/04/introducing-seo-analyzer/" title="Introducing SEO Analyzer">Introducing SEO Analyzer</a> (3)</li><li><a href="http://abhinavsingh.com/blog/2008/06/igoogle-portal-implementation-how-to-do-it/" title="iGoogle Portal Implementation: How to do it?">iGoogle Portal Implementation: How to do it?</a> (12)</li><li><a href="http://abhinavsingh.com/blog/2008/05/gmail-type-attachment-how-to-make-one/" title="Gmail Type Attachment &#8211; How to make one?">Gmail Type Attachment &#8211; How to make one?</a> (21)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://abhinavsingh.com/blog/2009/04/getting-google-page-rank-using-javascript-for-adobe-air-apps/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Using Image Maps in Javascript &#8211; A Demo Application</title>
		<link>http://abhinavsingh.com/blog/2009/03/using-image-maps-in-javascript-a-demo-application/</link>
		<comments>http://abhinavsingh.com/blog/2009/03/using-image-maps-in-javascript-a-demo-application/#comments</comments>
		<pubDate>Sun, 22 Mar 2009 19:25:02 +0000</pubDate>
		<dc:creator>Abhinav Singh</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Demo]]></category>
		<category><![CDATA[image map]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://abhinavsingh.com/blog/?p=311</guid>
		<description><![CDATA[Past month I was busy with project back in office, JAXL web chat client and photolog &#8211; a custom made wp-plugin for converting it into a photo blog. As I am close to finish them all, I am back to blogging after more than a month. Here I would like to demonstrate a cool technique [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2009%2F03%2Fusing-image-maps-in-javascript-a-demo-application%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2009%2F03%2Fusing-image-maps-in-javascript-a-demo-application%2F&amp;source=imoracle&amp;style=normal&amp;service=bit.ly&amp;service_api=R_f027b5a79a20a49b713f16282f1e0857&amp;hashtags=Demo,image+map,javascript&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Past month I was busy with <a target="_blank" href="http://in.elections.yahoo.com">project</a> back in office, <a target="_blank" href="http://jaxl.googlegroups.com/web/jaxl-instant-messenger.PNG?gda=C3eGV0wAAADFEG5r_Q2qBojmAJz06pZR52VBSNHpEa7ZITftks4e2NnGpw1kyLV36KvRxqaqXbp4fPh_IXG1gRYJTXFNsae9_Vpvmo5s1aABVJRO3P3wLQ">JAXL web chat client</a> and <a target="_blank" href="http://abhinavsingh.com/photo">photolog</a> &#8211; a custom made wp-plugin for converting it into a photo blog. As I am close to finish them all, I am back to blogging after more than a month.</p>
<p>Here I would like to demonstrate a cool technique which I explored while working for the india elections site. We decided to have a cool india map where we could show data for each state. Though flash is always the best method to go with for such applications (and finally we did it with flash <img src='http://abhinavsingh.com/blog/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> ) I wanted to explore if we can do the same thing efficiently with javascript.</p>
<p>Not being a javascript expert, I first moved to various friends expert in javascript and they told me about image map technique in javascript. I did some research, read various blog posts and finally came up with the application below. (I will be demonstrating the application and challenges you will face while building such application, for basics of image map kindly search for it, you will get many tutorials on web on javascript image maps)</p>
<p><iframe style="float:left;" frameborder="0" width="300px" height="350px" src="http://abhinavsingh.com/webdemos/indiaimagemap/" scrolling="NO"></iframe></p>
<p><strong><u>Challenges I faced:</u></strong><br />
Javascript image map technique utilizes the (x,y) co-ordinates which you provide to javascript. Depending upon the input (x,y) co-ordinates, javascript will build an image map over the image. When I was building this application, the biggest challenge was how to get the pixel by pixel border for each and every state. I don&#8217;t know dreamweaver, photoshop or any other software which can tell me this. Moreover, even if I knew, I was not sure how much effort will it require to note down each and every pixel lying on the state borders. Finally to counter this problem I came up with a javascript, which makes this task 99% easier.</p>
<p><strong><u>Using javascript to detect image borders pixel by pixel:</u></strong><br />
Javascript image map requires pixel to be given in the following format (x1,y1,x2,y2,&#8230;.,xn,yn). So I wrote a javascript which will automatically generate the current pixels of your mouse, in above format as you move it.</p>
<p>Lets try this out. <a target="_blank" href="http://abhinavsingh.com/webdemos/indiaimagemap/edges.html">Click here</a> to open this javascript hack. Click CNTR++ (i.e. zoom into your browser) as many times as you can. You will now have a very enlarged and a bit blurred india map in front of you. But good thing is you can clearly move your mouse over state borders. This javascript gets enabled on your 1st mouse click on the map. So choose a state and click your mouse on its border. Now start moving your mouse on this state&#8217;s border till you come back to the same point, where you started. Click 2nd time on that point to disable this javascript function and WOW! Below you have the border pixel positions in the required format to be used straight with javascript image maps. Copy and paste that to get a final image map like this.</p>
<p>View the final image map file by clicking <a target="_blank" href="http://abhinavsingh.com/webdemos/indiaimagemap/dashboardindiamaparea.xml">here</a>.</p>
<p><strong><u>edges.html</u></strong></p>
<pre name="code" class="php">
<html>
  <head>
    <script language="JavaScript">
      var is_clicked = "no";
      function point_it(event) {
        if(is_clicked == "yes") {
          pos_x = event.offsetX?(event.offsetX):event.pageX-document.getElementById("pointer_div").offsetLeft;
          pos_y = event.offsetY?(event.offsetY):event.pageY-document.getElementById("pointer_div").offsetTop;
          document.getElementById("cross").style.left = (pos_x-1) ;
          document.getElementById("cross").style.top = (pos_y-15) ;
          document.getElementById("cross").style.visibility = "visible" ;
          document.getElementById('xy').innerHTML += pos_x+","+pos_y+",";
        }
      }
      function clicked(event) {
        if(is_clicked == "no")
          is_clicked = "yes";
        else
          is_clicked = "no";
      }
    </script>
  </head>
  <body>
<form name="pointform" method="post">
<div id="pointer_div" onclick="clicked(event)" onmousemove="point_it(event);" style = "background:url('img/dashboard/india.gif') no-repeat scroll 0 0;width:263px;height:301px;">
        <img src="img/dashboard/spacer.gif" id="cross" style="position:relative;visibility:hidden;z-index:2;">
      </div>
<div id="xy" style="font-size:4px;"></div>
</form>

  </body>
</html></pre>
<p>Study the source of the final application by visiting <a target="_blank" href="http://abhinavsingh.com/webdemos/indiaimagemap/">here</a> and use the above javascript to extract edge information of your map file. I know there are some questions unanswered but I will wait for your comments to answer them <img src='http://abhinavsingh.com/blog/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p><strong style="color:red">PS: By demoing my application here, I permit you to use this sample code for any purpose. However I do not permit you to copy paste the indian map images for your personal or professional sites or works.</strong></p>
<div style="clear:both"></div>
<script type="text/javascript">var wordpress_toolbar_urls = ["http:\/\/api.tweetmeme.com\/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2009%2F03%2Fusing-image-maps-in-javascript-a-demo-application%2F","http:\/\/in.elections.yahoo.com","http:\/\/jaxl.googlegroups.com\/web\/jaxl-instant-messenger.PNG?gda=C3eGV0wAAADFEG5r_Q2qBojmAJz06pZR52VBSNHpEa7ZITftks4e2NnGpw1kyLV36KvRxqaqXbp4fPh_IXG1gRYJTXFNsae9_Vpvmo5s1aABVJRO3P3wLQ","http:\/\/abhinavsingh.com\/photo","http:\/\/abhinavsingh.com\/webdemos\/indiaimagemap\/edges.html","http:\/\/abhinavsingh.com\/webdemos\/indiaimagemap\/dashboardindiamaparea.xml","http:\/\/abhinavsingh.com\/webdemos\/indiaimagemap\/"];var wordpress_toolbar_url = "http://abhinavsingh.com/blog/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "oinw";var wordpress_toolbar_hash = "aHR0cDovL2FiaGluYXZzaW5naC5jb20vYmxvZy8yMDA5LzAzL3VzaW5nLWltYWdlLW1hcHMtaW4tamF2YXNjcmlwdC1hLWRlbW8tYXBwbGljYXRpb24vPHdwdGI%2BVXNpbmcgSW1hZ2UgTWFwcyBpbiBKYXZhc2NyaXB0ICYjODIxMTsgQSBEZW1vIEFwcGxpY2F0aW9uPHdwdGI%2BaHR0cDovL2FiaGluYXZzaW5naC5jb20vYmxvZzx3cHRiPkFiaGkmIzAzOTtzIFdlYmxvZw%3D%3D";</script><ul class="related_post"><li><a href="http://abhinavsingh.com/blog/2009/08/introducing-jslider-a-content-slider-plugin-for-jquery/" title="Introducing jSlider: A Content Slider plugin for JQuery">Introducing jSlider: A Content Slider plugin for JQuery</a> (6)</li><li><a href="http://abhinavsingh.com/blog/2009/07/facebook-type-image-rotation-and-more-using-php-and-javascript/" title="Facebook type image rotation and more using PHP and Javascript">Facebook type image rotation and more using PHP and Javascript</a> (27)</li><li><a href="http://abhinavsingh.com/blog/2009/06/seo-analyzer-v-12-adding-support-for-bing-along-with-google-and-yahoo/" title="SEO Analyzer v 1.2 &#8211; Adding support for Bing along with Google and Yahoo">SEO Analyzer v 1.2 &#8211; Adding support for Bing along with Google and Yahoo</a> (24)</li><li><a href="http://abhinavsingh.com/blog/2009/04/seo-analyzer-version-11-whats-new/" title="SEO Analyzer &#8211; Version 1.1 &#8211; What&#039;s New?">SEO Analyzer &#8211; Version 1.1 &#8211; What&#039;s New?</a> (4)</li><li><a href="http://abhinavsingh.com/blog/2009/04/introducing-seo-analyzer/" title="Introducing SEO Analyzer">Introducing SEO Analyzer</a> (3)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://abhinavsingh.com/blog/2009/03/using-image-maps-in-javascript-a-demo-application/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
	</channel>
</rss>

