<?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>Tech Mug &#187; jQuery</title>
	<atom:link href="http://www.techmug.com/tech/tutorials/jquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.techmug.com</link>
	<description></description>
	<lastBuildDate>Tue, 31 Jan 2012 12:15:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Simple jQuery Slideshow with Controls</title>
		<link>http://www.techmug.com/simple-jquery-slideshow-with-controls/</link>
		<comments>http://www.techmug.com/simple-jquery-slideshow-with-controls/#comments</comments>
		<pubDate>Tue, 28 Jun 2011 13:18:21 +0000</pubDate>
		<dc:creator>Fraz Ahmed</dc:creator>
				<category><![CDATA[Freebies]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[jQuery Cycle plugin]]></category>
		<category><![CDATA[Simple jQuery Slideshow]]></category>
		<category><![CDATA[Slideshow]]></category>

		<guid isPermaLink="false">http://www.techmug.com/?p=630</guid>
		<description><![CDATA[I was looking for a simple Slideshow to add in one of my projects. But after searching on the internet I was not able to find my desired slideshow component then I decided to create my own. I created this nice and simple slideshow using jQuery and jQuery Cycle plugin. It has Numbers control with [...]]]></description>
			<content:encoded><![CDATA[<p>I was looking for a simple Slideshow to add in one of my projects. But after searching on the internet I was not able to find my desired slideshow component then I decided to create my own.</p>
<p>I created this nice and simple <strong>slideshow using jQuery</strong> and <strong>jQuery Cycle plugin</strong>. It has Numbers control with Next and Previous control. This is not only image based slideshow but you may also put some content in each slide too.</p>
<p>I&#8217;m releasing this component for free. You may download and may use it in your own projects.</p>
<p><span id="more-630"></span></p>
<p style="text-align: center;"><script type="text/javascript"><!--
google_ad_client = "pub-7217075623453662";
google_ad_slot = "2820701010";
google_ad_width = 336;
google_ad_height = 280;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<center><font-size="9px">Advertisement</font></center></p>
<p style="text-align: center;"><a href="http://www.techmug.com/demo/simple-slideshow/" target="_blank"><img class="alignnone size-full wp-image-336" title="See Demo" src="http://www.techmug.com/wp-content/uploads/2010/10/btn-see-demo.jpg" alt="See Demo" width="140" height="90" /></a> <a href="http://www.techmug.com/demo/simple-slideshow/simple-slideshow.zip"><img class="alignnone size-full wp-image-337" title="Download Source Code" src="http://www.techmug.com/wp-content/uploads/2010/10/btn-source-code.jpg" alt="Download Source Code" width="140" height="90" /></a></p>
<p></p>
<p>Your comments and suggestions are always welcome. Please spread the word and share this component on your favorite website.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.techmug.com/simple-jquery-slideshow-with-controls/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AJAX Currency Converter with Google API</title>
		<link>http://www.techmug.com/ajax-currency-converter-with-google-api/</link>
		<comments>http://www.techmug.com/ajax-currency-converter-with-google-api/#comments</comments>
		<pubDate>Fri, 27 Aug 2010 15:42:03 +0000</pubDate>
		<dc:creator>Fraz Ahmed</dc:creator>
				<category><![CDATA[API]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[Converter]]></category>
		<category><![CDATA[Currency]]></category>
		<category><![CDATA[development]]></category>

		<guid isPermaLink="false">http://www.techmug.com/?p=211</guid>
		<description><![CDATA[No doubt, Google is a magical search engine. Google also provides many APIs to be incorporated in your application. Today, we will use Google&#8217;s hidden currency conversion API. Why hidden? Because there is no official documentation for it. We will build a currency converter from scratch, it pulls data from Google and display the results [...]]]></description>
			<content:encoded><![CDATA[<p>No doubt, Google is a magical search engine. Google also provides many APIs to be incorporated in your application. Today, we will use Google&#8217;s hidden currency conversion API. Why hidden? Because there is no official documentation for it.</p>
<p><span id="more-211"></span></p>
<p>We will build a currency converter from scratch, it pulls data from Google and display the results using jQuery AJAX function. For you better understanding, you may visit demo or download source code below:</p>
<p style="text-align: center;"><strong><a href="/demo/currency-converter/techmug-currency-converter.zip"><img class="alignnone size-full wp-image-337" title="Download Source Code" src="http://www.techmug.com/wp-content/uploads/2010/10/btn-source-code.jpg" alt="Download Source Code" width="140" height="90" /></a><a href="/demo/currency-converter/" target="_blank"><img class="alignnone size-full wp-image-336" title="See Demo" src="http://www.techmug.com/wp-content/uploads/2010/10/btn-see-demo.jpg" alt="See Demo" width="140" height="90" /></a></strong></p>
<p>Basically our whole code consist of three components &#8211; HTML for displaying interface, Javascript for AJAX functionality and PHP for fetching and manipulating conversion results from Google.</p>
<p style="text-align: center;"><script type="text/javascript"><!--
google_ad_client = "pub-7217075623453662";
google_ad_slot = "2820701010";
google_ad_width = 336;
google_ad_height = 280;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<center><font-size="9px">Advertisement</font></center></p>
<h1>HTML Structure</h1>
<p>HTML structure for this application is simple enough. There are two drop downs, one input field, one button and a div for displaying results. Drop downs are used for selecting From Currency and To Currency while input field is used for entering the desired amount to be converted in your selected currency. Conversion result displays in results div once you click on convert button. When you click on the button, it fires a Javascript function which is described below.</p>
<h1>Javascript</h1>
<p>Following is the code for our AJAX enabled javascript. Below code is executed upon clicking on convert button.</p>
<pre class="brush: jscript; title: ; notranslate">

$(document).ready(function() {

 $('#convert').click(function(){

 //Get all the values
 var amount = $('#amount').val();
 var from = $('#fromCurrency').val();
 var to = $('#toCurrency').val();

 //Make data string
 var dataString = &quot;amount=&quot; + amount + &quot;&amp;from=&quot; + from + &quot;&amp;to=&quot; + to;

 $.ajax({
 type: &quot;POST&quot;,
 url: &quot;ajax_converter.php&quot;,
 data: dataString,

 success: function(data){
 //Show results div
 $('#results').show();

 //Put received response into result div
 $('#results').html(data);
 }

 });
 });
});
</pre>
<p>Above code is very simple and should be self explanatory, if you are familiar with jQuery AJAX function. For those who does not know, what&#8217;s going on here I tr to explain them.</p>
<p><em>$(&#8216;#convert&#8217;).click(function&#8230;</em> this is the starting point of our code, it means that execute the underneath code of this function when an element with id of  &#8216;convert&#8217; is clicked. In our case this id is used for &#8216;convert&#8217; button.</p>
<p>After that we grab values from our HTML elements by using <em>.val()</em> function of jQuery and assign these values into Javascript variables. These variables are then used in dataString variable.</p>
<p>In our AJAX function we are using POST method and in &#8216;url&#8217;, we provide the url of our PHP file which will provide conversion results back to this AJAX function. We are sending &#8216;dataString&#8217; as data to our PHP script.</p>
<p>After successful iterating to our PHP script, this AJAX function first shows our results div and out the received data into our results div as HTML.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-7217075623453662";
google_ad_slot = "4831550702";
google_ad_width = 300;
google_ad_height = 250;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<center><font-size="9px">Advertisement</font></center></p>
<h1>PHP Code</h1>
<p>The brain of our application is below PHP code.</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
//Get Posted data
$amount = $_POST['amount'];
$from = $_POST['from'];
$to = $_POST['to'];

//make string to be put in API
$string = &quot;1&quot;.$from.&quot;=?&quot;.$to;

//Call Google API
$google_url = &quot;http://www.google.com/ig/calculator?hl=en&amp;q=&quot;.$string;

//Get and Store API results into a variable
$result = file_get_contents($google_url);

//Explode result to convert into an array
$result = explode('&quot;', $result);

################################
# Right Hand Side
################################
$converted_amount = explode(' ', $result[3]);
$conversion = $converted_amount[0];
$conversion = preg_replace('/[\x00-\x08\x0B-\x1F]/', '', $conversion);
$conversion = $conversion * $amount;
$conversion = round($conversion, 2);

//Get text for converted currency
$rhs_text = ucwords(str_replace($converted_amount[0],&quot;&quot;,$result[3]));

//Make right hand side string
$rhs = $conversion.$rhs_text;

################################
# Left Hand Side
################################
$google_lhs = explode(' ', $result[1]);
$from_amount = $google_lhs[0];

//Get text for converted from currency
$from_text = ucwords(str_replace($from_amount,&quot;&quot;,$result[1]));

//Make left hand side string
$lhs = $amount.&quot; &quot;.$from_text;

################################
# Make the result
################################

echo $lhs.&quot; = &quot;.$rhs;
?&gt;
</pre>
<p>Above code is well commented to make you understand better. In this code we are using some built-in PHP functions &#8211; <a href="http://php.net/manual/en/function.file-get-contents.php" target="_blank">file_get_contents</a>, <a href="http://php.net/manual/en/function.explode.php" target="_blank">explode</a>, <a href="http://php.net/manual/en/function.round.php" target="_blank">round</a> and <a href="http://php.net/manual/en/function.ucwords.php">ucwords</a>.</p>
<ul>
<li>In start we grab the values posted to this script by our AJAX function. We store these values into variables.</li>
<li>We make a string variable using above explained variables.</li>
<li>We concatenate this string variable to Google Currency Calculator API url and store the url in a new variable named $google_url.</li>
<li>We fetch the data of $google_url to $result variable using PHP&#8217;s <a href="http://php.net/manual/en/function.file-get-contents.php" target="_blank">file_get_contents</a> function.</li>
<li>We receive data from Google something similar to<br />
<em><strong>{lhs: &#8220;1 Euro&#8221;,rhs: &#8220;1.2692 U.S. dollars&#8221;,error: &#8220;&#8221;,icc: true}</strong></em></li>
<li>Using PHP&#8217;s <a href="http://php.net/manual/en/function.explode.php" target="_blank">explode</a> function, we separate <strong>lhs</strong> and <strong>rhs</strong> from the received response.</li>
<li>From <strong>rhs</strong> we get the converted value and multiply it by our dsired amount to get total conversion.</li>
<li>Using PHP&#8217;s <a href="http://php.net/manual/en/function.round.php" target="_blank">round</a> function, converted amount is round off to two digits.</li>
<li>After this we use PHP&#8217;s <a href="http://php.net/manual/en/function.ucwords.php">ucwords</a> function to Capitalize our text&#8217;s first letter.</li>
<li>We almost do the same for lhs.</li>
<li>At last we make results by joining lhs and rhs and echo it to give the results back to our AJAX function.</li>
</ul>
<h1>Last words</h1>
<p>In the source code I have applied some CSS to make the user interface better. So don&#8217;t be puzzled with the code in source file.</p>
<p>Finally, you have a working Live Currency Converter. You may use this script in your website to attract more visitors. Just play around the code and let me know if you can enhance it further. Please feel free to ask, your comments are always welcome.</p>
<p>If you like this article, please share it on your favorite website. It may help someone somewhere!</p>
<div id="_mcePaste" class="mcePaste" style="position: absolute; left: -10000px; top: 570px; width: 1px; height: 1px; overflow: hidden;">&lt;script type=&#8221;text/javascript&#8221;&gt;&lt;!&#8211;<br />
google_ad_client = &#8220;ca-pub-7217075623453662&#8243;;<br />
/* Tm &#8211; 336 x 280 */<br />
google_ad_slot = &#8220;2820701010&#8243;;<br />
google_ad_width = 336;<br />
google_ad_height = 280;<br />
//&#8211;&gt;<br />
&lt;/script&gt;<br />
&lt;script type=&#8221;text/javascript&#8221;<br />
src=&#8221;http://pagead2.googlesyndication.com/pagead/show_ads.js&#8221;&gt;<br />
&lt;/script&gt;</div>
]]></content:encoded>
			<wfw:commentRss>http://www.techmug.com/ajax-currency-converter-with-google-api/feed/</wfw:commentRss>
		<slash:comments>40</slash:comments>
		</item>
		<item>
		<title>jMouse Follower</title>
		<link>http://www.techmug.com/jmouse-follower/</link>
		<comments>http://www.techmug.com/jmouse-follower/#comments</comments>
		<pubDate>Wed, 29 Jul 2009 19:33:14 +0000</pubDate>
		<dc:creator>Fraz Ahmed</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[cursor]]></category>
		<category><![CDATA[div]]></category>
		<category><![CDATA[follow]]></category>
		<category><![CDATA[mouse]]></category>
		<category><![CDATA[object]]></category>
		<category><![CDATA[swf]]></category>
		<category><![CDATA[trail]]></category>

		<guid isPermaLink="false">http://www.techmug.com/?p=28</guid>
		<description><![CDATA[What is Mouse Follower?

Mouse Follower or Cursor Trail is typically an image or set of images which follows the cursor in your browser screen.]]></description>
			<content:encoded><![CDATA[<h2>What is Mouse Follower?</h2>
<p>Mouse Follower or Cursor Trail is typically an image or set of images which follows the cursor in your browser screen.</p>
<h2><strong>Demo and Download</strong></h2>
<p>To understand more clearly visit <a title="jMouse Follower Demo" href="http://www.techmug.com/demo/mouse-follower/" target="_blank">demo</a>. Alternatively you may also download the files from <a title="Download jMouse Follower" href="http://www.techmug.com/demo/mouse-follower/mouse-follower.zip" target="_blank">here</a>.</p>
<h2><strong>Problem</strong></h2>
<p>Today I was asked to enhance the existing mouse trail feature of a website. They were using 3 or 4 PNG images to make the mouse trail. But the problem was that images were inline. While our client wanted some more advanced animation with mouse trail/follower. And that animation was not possible without using flash animation in it.</p>
<p>From the above its clear that we were need to have a DIV in the script where all of the Flash embedded code may be inserted. I searched for many scripts but the problem was that they were doing well with IE but for Firefox answer was NO.</p>
<p><span id="more-28"></span></p>
<h2><strong>Things to do</strong></h2>
<p>Eventually I had to play with code. And surely my first choice for Javascript is always jQuery. Basically the concept was so simple, to achieve Mouse Follower effect we need to do following:</p>
<ol>
<li>Create a DIV for Flash Object (You may also use image in this DIV).</li>
<li>Find X and Y co-ordinates of cursor&#8217;s current position.</li>
<li>Change DIV position according to X and Y position of Cursor.</li>
</ol>
<p style="text-align: center;"><script type="text/javascript"><!--
google_ad_client = "pub-7217075623453662";
google_ad_slot = "2820701010";
google_ad_width = 336;
google_ad_height = 280;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<center><font-size="9px">Advertisement</font></center></p>
<h2><strong>How it works?</strong></h2>
<pre class="brush: jscript; title: ; notranslate">
&lt;script type=&quot;text/javascript&quot;&gt;// &lt;![CDATA[
$(document).ready(function(){
   $(&quot;*&quot;).mousemove(function(e){
	  $(&quot;#follower&quot;).css({'position' : 'absolute', 'margin-left' : e.pageX+10, 'margin-top' : e.pageY+10, 'display' : 'block', 'z-index' : '999'});
   });
})
// ]]&gt;&lt;/script&gt;
</pre>
<p><strong>Explanation</strong></p>
<ol>
<li>In the above code first we define use <em>document.ready()</em> it simply call the underneath function on the load of page.</li>
<li><em>$(&#8220;*&#8221;).mousemove(function(e){</em>&#8230; &#8211; this line reads that call the function whenever mouse move on any element of the page. <em>mousemove</em> is a jQuey event. Click <a title="jQuery Events" href="http://docs.jquery.com/Events" target="_blank">here</a> to learn more jQuery events.</li>
<li><em>$(&#8220;#follower&#8221;).css({</em>&#8230; &#8211; this line looks for an element which ID is &#8220;follower&#8221;. This is our Flash Object DIV. In this line we change the CSS style of our DIV. jQuery has made it much easy for us to change the CSS style of any element on the move.</li>
<li>We get X and Y co-ordinates by calling <em>page.X</em> and <em>page.Y</em> builtin functions of jQuery.</li>
<li>We used <em>margin-left</em> and <em>margin-top</em> to style our DIV. Values of both margins are set equivalent of <em>page.X</em> and <em>page.Y</em></li>
<li>So, every time when mouse moves on the page<em>, </em>our DIV changes its position itself. And this all is happening because we have defined the <em>position</em> of our DIV to <em>absolute. </em>So, DIV is free to move anywhere on the page.</li>
<li>We used <em>+10</em> with <em>page.X</em> and <em>page.Y</em> its just because we wanted to move our object a little far from the cursor.</li>
<li>Our DIV has a Flash Object. And we have made this flash animation a transparent one. So, it will not hide any element on the page. Code for our DIV is below:</li>
</ol>
<pre class="brush: php; title: ; notranslate">
&lt;div id=&quot;follower&quot;&gt;
 &lt;object id=&quot;followers&quot; classid=&quot;clsid:d27cdb6e-ae6d-11cf-96b8-444553540000&quot; width=&quot;250&quot; height=&quot;150&quot; codebase=&quot;http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0&quot;&gt;
 &lt;param name=&quot;name&quot; value=&quot;follower&quot; /&gt;
 &lt;param name=&quot;align&quot; value=&quot;middle&quot; /&gt;
 &lt;param name=&quot;allowScriptAccess&quot; value=&quot;sameDomain&quot; /&gt;
 &lt;param name=&quot;allowFullScreen&quot; value=&quot;false&quot; /&gt;
 &lt;param name=&quot;quality&quot; value=&quot;high&quot; /&gt;
 &lt;param name=&quot;bgcolor&quot; value=&quot;#ffffff&quot; /&gt;
 &lt;param name=&quot;wmode&quot; value=&quot;transparent&quot; /&gt;
 &lt;param name=&quot;allowScale&quot; value=&quot;false&quot; /&gt;
 &lt;param name=&quot;src&quot; value=&quot;mouse.swf&quot; /&gt;
 &lt;param name=&quot;allowfullscreen&quot; value=&quot;false&quot; /&gt;
 &lt;embed id=&quot;followers&quot; type=&quot;application/x-shockwave-flash&quot; width=&quot;250&quot; height=&quot;150&quot; src=&quot;mouse.swf&quot; allowscale=&quot;false&quot; wmode=&quot;transparent&quot; bgcolor=&quot;#ffffff&quot; quality=&quot;high&quot; allowfullscreen=&quot;false&quot; allowscriptaccess=&quot;sameDomain&quot; align=&quot;middle&quot; name=&quot;follower&quot;&gt;&lt;/embed&gt;
 &lt;/object&gt;
&lt;/div&gt;
</pre>
<p><script type="text/javascript"><!--
google_ad_client = "pub-7217075623453662";
google_ad_slot = "4831550702";
google_ad_width = 300;
google_ad_height = 250;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<center><font-size="9px">Advertisement</font></center></p>
<p>Don’t forget to share the post on your favorite website. It may also help someone somewhere.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.techmug.com/jmouse-follower/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

