<?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>El Blog del Antonio &#187; Javascript</title>
	<atom:link href="http://www.ramirezcobos.com/tag/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ramirezcobos.com</link>
	<description>Programming Web with PHP, CSS, Javascript and ∞</description>
	<lastBuildDate>Wed, 14 Jul 2010 14:03:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Torrenova Rentacar</title>
		<link>http://www.ramirezcobos.com/2010/03/31/torrenova-rentacar/</link>
		<comments>http://www.ramirezcobos.com/2010/03/31/torrenova-rentacar/#comments</comments>
		<pubDate>Wed, 31 Mar 2010 09:32:14 +0000</pubDate>
		<dc:creator>Antonio Ramirez</dc:creator>
				<category><![CDATA[Portfolio]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Jobs]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.ramirezcobos.com/?p=408</guid>
		<description><![CDATA[I would like to show you one of the reasons of why I have been so busy lately: torrenovarentacar.com. One of the most complete sites in terms of rentacar systems. Fully synchronized with one of the most used rent a car management programs in Spain, CarPlus (www.cargestion.es) and with a highly powerful control panel where]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.ramirezcobos.com/wp-content/uploads/2010/02/Imagen-5.png"></a><a href="http://www.ramirezcobos.com/wp-content/uploads/2010/03/Imagen-5-300x274.png"></a><a href="http://www.ramirezcobos.com/wp-content/uploads/2010/02/Imagen-5-300x274.png"></a><strong><span style="font-weight: normal;"> </span></strong></p>
<div id="attachment_410" class="wp-caption alignright" style="width: 310px"><a rel="attachment wp-att-410" href="http://www.ramirezcobos.com/2010/03/31/torrenova-rentacar/picture-1-5/"><img class="size-medium wp-image-410" title="Torrenova Rentacar" src="http://www.ramirezcobos.com/wp-content/uploads/2010/03/Picture-11-300x165.png" alt="Torrenova Rentacar" width="300" height="165" /></a><p class="wp-caption-text">Torrenova Rentacar</p></div>
<p><em>I would like to show you one of the reasons of why I have been so busy lately: <a href="http://www.torrenovarentacar.com" target="_blank">torrenovarentacar.com</a>. </em></p>
<p>One of the most complete sites in terms of rentacar systems. Fully synchronized with one of the most used rent a car management programs in Spain, CarPlus (www.cargestion.es) and with a highly powerful control panel where the rent a car owner controls absolutely everything. Its web panel features:</p>
<ul>
<li>Company details</li>
<li>Contacts</li>
<li>Offices and their Google locations</li>
<li>CarPlus Settings and Sync</li>
<li>Users</li>
<li>Extras</li>
<li>Cars</li>
<li>Car Groups</li>
<li>Car Models</li>
<li>Translations (It can set new languages at will)</li>
</ul>
<p>If you have time, please check it out as I would love to get some feedback about it.<br />
Thanks!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ramirezcobos.com/2010/03/31/torrenova-rentacar/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Visual Lightbox</title>
		<link>http://www.ramirezcobos.com/2010/02/08/visual-lightbox/</link>
		<comments>http://www.ramirezcobos.com/2010/02/08/visual-lightbox/#comments</comments>
		<pubDate>Mon, 08 Feb 2010 15:38:19 +0000</pubDate>
		<dc:creator>Antonio Ramirez</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[On The Web]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://www.ramirezcobos.com/?p=273</guid>
		<description><![CDATA[This post is for those who wish to implement a beautiful Lightbox plugin on their site or blog and, unfortunately, do not have a clue about Javascript and/or jQuery and/or Html. VisualLightBox is a free application that helps you easily generate online photo albums, lightbox gallery with a nice Lightbox-style overlay effect, in a few]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.ramirezcobos.com/wp-content/uploads/2010/02/lightboxXL-thumb.jpg"><a href="http://www.ramirezcobos.com/wp-content/uploads/2010/02/add-images-to-gallery.jpg"><img class="alignright size-medium wp-image-385" title="add-images-to-gallery" src="http://www.ramirezcobos.com/wp-content/uploads/2010/02/add-images-to-gallery-300x210.jpg" alt="" width="300" height="210" /></a></a>This post is for those who wish to implement a beautiful Lightbox plugin on their site or blog and, unfortunately, do not have a clue about Javascript and/or jQuery and/or Html.</p>
<p>VisualLightBox is a free application that helps you easily generate online photo albums, lightbox gallery with a nice Lightbox-style overlay effect, in a few clicks without writing a single line of code.</p>
<p>Just drag&amp;drop your photos to VisualLightBox wizard window, press &#8220;Publish&#8221; and your own css web site album with beautiful LightBox effects will open in the browser instantly!<br />
No css, image editing, javascript, html coding, just a click to get your cool web page album ready.</p>
<p>It takes less than a minute to have your own image gallery.</p>
<p>For full documentation please go to http://lightbox2.com/</p>
<p>Newbies, now there is no excuse to have your featured lightbox on your site!<br />
<script type="text/javascript"><!--
google_ad_client = "pub-7060132287364604";
/* 468x60, creado 16/03/10 */
google_ad_slot = "9029910384";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ramirezcobos.com/2010/02/08/visual-lightbox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get Latitude and Longitude with Google Maps V3</title>
		<link>http://www.ramirezcobos.com/2010/01/22/get-latitude-and-longitude-with-google-maps-v3/</link>
		<comments>http://www.ramirezcobos.com/2010/01/22/get-latitude-and-longitude-with-google-maps-v3/#comments</comments>
		<pubDate>Fri, 22 Jan 2010 14:56:24 +0000</pubDate>
		<dc:creator>Antonio Ramirez</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Google Maps]]></category>

		<guid isPermaLink="false">http://www.ramirezcobos.com/?p=251</guid>
		<description><![CDATA[I would like to share with you a little piece of code that I find quite useful in my applications. I do create lots of guides that require a small utility to find out the latitude and longitude of a business location from a control panel in order to display the maps appropiately on the]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.ramirezcobos.com/wp-content/uploads/2010/01/Picture-22.png"><a href="http://www.ramirezcobos.com/wp-content/uploads/2010/03/Picture-22-300x198.png"><img class="alignright size-full wp-image-320" title="Picture-22-300x198" src="http://www.ramirezcobos.com/wp-content/uploads/2010/03/Picture-22-300x198.png" alt="" width="300" height="198" /></a></a>I would like to share with you a little piece of code that I find quite useful in my applications. I do create lots of guides that require a small utility to find out the latitude and longitude of a business location from a control panel in order to display the maps appropiately on the Web. Here I will do my best to explain a step procedure on how to do that -once you know the procedure, it is easy to create plugins or whatever you wish to do.</p>
<h3>Step 1</h3>
<p>First of all, lets make a reference to the new version of Google Maps. Check that we have to specify a parameter sensor=false. To find out more about this parameter please follow this <a href="http://code.google.com/intl/en-EN/apis/maps/documentation/#SpecifyingSensor">link</a>.</p>
<pre class="brush: xml;">
&lt;script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"&gt;&lt;/script&gt;
</pre>
<h3>Step 2</h3>
<p>Now we are going to write the HTML tags on the BODY of our document that will hold the map and the controls that will hold latitude, longitude and zoom level references. Also, see the CSS that control the size of the map holder.</p>
<pre class="brush: xml;">
&lt;style&gt;
div#gmap {
width: 100%;
height: 300px;
}
&lt;/style&gt;
&lt;body&gt;
&lt;center&gt;
&lt;!-- MAP HOLDER --&gt;
&lt;div id="gmap"&gt;&lt;/div&gt;
&lt;!-- REFERENCES --&gt;
lat:&lt;span id="lat"&gt;&lt;/span&gt; lon:&lt;span id="lon"&gt;&lt;/span&gt;&lt;br/&gt;
zoom level: &lt;span id="zoom_level"&gt;&lt;/span&gt;
&lt;/center&gt;
&lt;/body&gt;
</pre>
<h3>Step 3</h3>
<p>Now, we are going to write the function that will display the map when the document loads. The function, that we will call &#8216;initialize&#8217; has different parts that we will describe now:</p>
<h4>Part 1</h4>
<p>Setting the map zoom level and its position in the world:</p>
<pre class="brush: jscript;">
var myLatlng = new google.maps.LatLng(38.971154274048345,1.415863037109375); // IBIZA <img src='http://www.ramirezcobos.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />
var myOptions = {
zoom: 16,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
map = new google.maps.Map(document.getElementById("gmap"), myOptions);
</pre>
<h4>Part 2</h4>
<p>Placing a marker on the map specifying its center position (please refer to above code for LatLon location).</p>
<pre class="brush: jscript;">
// marker refers to a global variable
marker = new google.maps.Marker({
position: myLatlng,
map: map
});
</pre>
<h4>Part 3</h4>
<p>Now, the events that will take control of the marker center re-positioning and placing the information on the correspondent document objects (lat, lon, and zoom level).</p>
<pre class="brush: jscript;">
// if center changed then update lat and lon document objects
google.maps.event.addListener(map, 'center_changed', function() {
var location = map.getCenter();
document.getElementById("lat").innerHTML = location.lat();
document.getElementById("lon").innerHTML = location.lng();
// call function to reposition marker location
placeMarker(location);
});
// if zoom changed, then update document object with new info
google.maps.event.addListener(map, 'zoom_changed', function() {
zoomLevel = map.getZoom();
document.getElementById("zoom_level").innerHTML = zoomLevel;
});
// double click on the marker changes zoom level
google.maps.event.addListener(marker, 'dblclick', function() {
zoomLevel = map.getZoom()+1;
if (zoomLevel == 20) {
zoomLevel = 10;
}
document.getElementById("zoom_level").innerHTML = zoomLevel;
map.setZoom(zoomLevel);
});
</pre>
<h4>Part 4</h4>
<p>Initialize the document objects with default information</p>
<pre class="brush: jscript;">
document.getElementById("zoom_level").innerHTML = 16;
document.getElementById("lat").innerHTML = 38.971154274048345;
document.getElementById("lon").innerHTML = 1.415863037109375;
</pre>
<h4>Step 4</h4>
<p>Finally, we have to write the function that will reposition the marker on &#8216;zoom_changed&#8217; map event and call the &#8216;initialize&#8217; function on window load event.</p>
<pre class="brush: jscript;">
function placeMarker(location) {
var clickedLocation = new google.maps.LatLng(location);
marker.setPosition(location);
}
window.onload = function(){initialize()};
</pre>
<p>And that&#8217;s it, we have a great utility to plug onto our projects in order to find out the latitude and longitude of an address.</p>
<h3>DOWNLOAD</h3>
<p>I have included the working version of this tutorial for you to download. If you make any changes on the code in order to improve/add more functionality to it (that is easy fellows), please share it here with us.</p>
<div style="padding: 10px; text-align: center; background-color: #ffffff; border: 3px solid #dddddd;"><table style="border: 1px solid #CCC;" cellpadding="3" width="100%">
  <tr>
    <td width="35">
      <img src="http://www.ramirezcobos.com/wp-content/plugins/downloads-manager/img/icons/default.gif" alt="http://www.ramirezcobos.com/wp-content/plugins/downloads-manager/img/icons/default.gif">
    </td>
    <td>
      <b>download:</b> <a href="http://www.ramirezcobos.com/?file_id=9">Get Lat Lon Finder</a> <small>(1.41KB)</small><br />
      <b>added:</b> 22/01/2010 <br />
      <b>clicks:</b> 375 <br />
      <b>description:</b>  <br />
    </td>
  </tr>
</table></div>
<script type="text/javascript"><!--
google_ad_client = "pub-7060132287364604";
/* 468x60, creado 16/03/10 */
google_ad_slot = "9029910384";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
]]></content:encoded>
			<wfw:commentRss>http://www.ramirezcobos.com/2010/01/22/get-latitude-and-longitude-with-google-maps-v3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery 1.4 -Are you ready?</title>
		<link>http://www.ramirezcobos.com/2010/01/14/jquery-1-4-are-you-ready/</link>
		<comments>http://www.ramirezcobos.com/2010/01/14/jquery-1-4-are-you-ready/#comments</comments>
		<pubDate>Thu, 14 Jan 2010 15:17:48 +0000</pubDate>
		<dc:creator>Antonio Ramirez</dc:creator>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[On The Web]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://www.ramirezcobos.com/?p=241</guid>
		<description><![CDATA[jQuery lovers, today, 14th of January, the programmers of jQuery celebrate its anniversary releasing a new version of this wonderful library. Better iFrame support, great new shorthands, I don&#8217;t know what to say fellows but I am eager to find out what its new features are capable of. The jQuery programmers not happy with a]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.ramirezcobos.com/wp-content/uploads/2009/12/Picture-121.png"><a href="http://www.ramirezcobos.com/wp-content/uploads/2010/03/Picture-121-300x157.png"><img class="alignright size-full wp-image-372" title="Picture-121-300x157" src="http://www.ramirezcobos.com/wp-content/uploads/2010/03/Picture-121-300x157.png" alt="" width="300" height="157" /></a></a>jQuery lovers, today, 14th of January, the programmers of jQuery celebrate its anniversary releasing a new version of this wonderful library. Better iFrame support, great new shorthands, I don&#8217;t know what to say fellows but I am eager to find out what its new features are capable of.</p>
<p>The jQuery programmers not happy with a new release has also created a new  <a href="http://api.jquery.com/" target="_blank">jQuery API site</a>. Check what they have done on their API site <a href="http://jquery14.com/pre-release-1/new-jquery-api-site" target="_blank">here</a>.</p>
<p>John Resig will announce 1.4 release details tomorrow but meanwhile, you can download it and see for yourself.</p>
<ul>
<li><a rel="nofollow" href="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.js">Download jQuery 1.4 from Google CDN</a></li>
<li><a rel="nofollow" href="http://code.jquery.com/jquery-1.4.js">Download jQuery 1.4 from Official jQuery website</a></li>
</ul>
<p>Also, if you want to learn more about what is new in jQuery 1.4 then you might find the following resources useful:</p>
<ol>
<li><a rel="nofollow" href="http://jquery14.com/">14 Days of jQuery</a></li>
<li><a rel="nofollow" href="http://blog.jquery.com/">Official jQuery Blog</a></li>
<li><a rel="nofollow" href="http://futurecolors.ru/jquery/">jQuery 1.4 Cheatsheet</a></li>
<li><a rel="nofollow" href="http://twitter.com/jquery">jQuery on Tweeter</a></li>
</ol>
<p>Check what is new or changed on this new release <a href="http://api.jquery.com/category/version/1.4/" target="_blank">here</a>.</p>
<p>Happy birthday jQuery! Thanks for the good work!<br />
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ramirezcobos.com/2010/01/14/jquery-1-4-are-you-ready/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Build iPhone Web Apps with iWebKit</title>
		<link>http://www.ramirezcobos.com/2010/01/05/build-iphone-web-apps-with-iwebkit/</link>
		<comments>http://www.ramirezcobos.com/2010/01/05/build-iphone-web-apps-with-iwebkit/#comments</comments>
		<pubDate>Wed, 06 Jan 2010 00:15:55 +0000</pubDate>
		<dc:creator>Antonio Ramirez</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[On The Web]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.ramirezcobos.com/?p=173</guid>
		<description><![CDATA[Iwebkit is the revolutionnairy open source development kit used to create high quality iPhone and iPod touch websites in a few minutes. In the first 4 months of it’s existance the pack has greatly evolved from a basic idea to a project that has reached worldwide fame! This Open Source Free Development Kit is accessible to]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><a href="http://www.ramirezcobos.com/wp-content/uploads/2010/01/Picture-8.png"><a href="http://www.ramirezcobos.com/wp-content/uploads/2010/03/open-source-iphone-ipod-touch-development-kit-iwebkit-300x104.jpg"><img class="alignright size-full wp-image-296" title="open-source-iphone-ipod-touch-development-kit-iwebkit-300x104" src="http://www.ramirezcobos.com/wp-content/uploads/2010/03/open-source-iphone-ipod-touch-development-kit-iwebkit-300x104.jpg" alt="" width="300" height="104" /></a></a>Iwebkit is the revolutionnairy <strong>open source development kit</strong> used to create high quality <strong>iPhone and iPod touch websites</strong> in a few minutes. In the first 4 months of it’s existance the pack has greatly evolved from a basic idea to a project that has reached worldwide fame!</p>
<p style="text-align: justify;">This Open Source Free Development Kit is accessible to anyone even people without any html knowledge and is simple to understand. In a couple of minutes you will have created a full and profesional looking website.</p>
<p style="text-align: justify;">Awesome new and advanced features offered by no pack in the world like a custom popup and iphone-style form elements.</p>
<p style="text-align: justify;">Check out their website:<a href="http://iwebkit.net/"> http://iwebkit.net/</a></p>
<p style="text-align: justify;">And their demo: <a href="http://demo.iwebkit.net/">http://demo.iwebkit.net/</a></p>
<p style="text-align: center;"></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ramirezcobos.com/2010/01/05/build-iphone-web-apps-with-iwebkit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SWFUpload_0_0. Error HTTP Status: 403 Solved</title>
		<link>http://www.ramirezcobos.com/2010/01/05/swfupload_0_0-error-http-status-403-solved/</link>
		<comments>http://www.ramirezcobos.com/2010/01/05/swfupload_0_0-error-http-status-403-solved/#comments</comments>
		<pubDate>Tue, 05 Jan 2010 11:21:18 +0000</pubDate>
		<dc:creator>Antonio Ramirez</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[On The Web]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.ramirezcobos.com/?p=161</guid>
		<description><![CDATA[SWFUpload is a client-side file upload tool originally developed by Vinterwebb.se. It uses a combination of Flash and JavaScript to provide file upload functionality beyond what the basic browser provides with the &#60;input type=&#8221;file&#8221; /&#62; tag. The main features that SWFUpload provides are: The ability to select multiple files in the file browser dialog. AJAX-style]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.ramirezcobos.com/wp-content/uploads/2010/01/Picture-6.png"><a href="http://www.ramirezcobos.com/wp-content/uploads/2010/03/Picture-6.png"><img class="alignright size-medium wp-image-312" title="Picture-6" src="http://www.ramirezcobos.com/wp-content/uploads/2010/03/Picture-6-300x143.png" alt="" width="300" height="143" /></a></a><br />
<a href="http://www.swfupload.org/">SWFUpload</a> is a client-side file upload tool originally developed by <a href="http://www.vinterwebb.se/">Vinterwebb.se</a>. It uses a combination of Flash and JavaScript to 	provide file upload functionality beyond what the basic browser provides with the &lt;input type=&#8221;file&#8221; /&gt; tag.</p>
<p>The main features that SWFUpload provides are:</p>
<ul>
<li>The ability to select multiple files in the file browser dialog.</li>
<li>AJAX-style uploading without a page refresh.</li>
<li>Upload progress events.</li>
<li>Namespaced classes compatible with other JavaScript libraries (i.e., jQuery, Prototype, etc.).</li>
<li>Flash 9 and Flash 10 support. (Flash 8 support dropped in version 2.2.0)</li>
</ul>
<p>SWFUpload is different from other Flash based upload tools because of the philosophy 		behind its design.  SWFUpload gives developers control by leaving the UI in the browser (as much as possible). 		Developers can use XHTML, CSS, and JavaScript to tailor the upload UI to the needs and 		style of their site.  Upload status updates are made through a set of simple JavaScript events. 		The developer uses these events to update the webpage as the file upload progresses.</p>
<h3>How to use it</h3>
<p>I am not going to explain how to use it, if any of you are interested on it, SWFUpload guys have developed a very <a href="http://demo.swfupload.org/Documentation/" target="_blank">good site explaining its full functionality</a>.</p>
<h3>The problem</h3>
<p>After successfully installing the component on one of my projects and working amazingly good on the local computer, when I uploaded the project to the server where I contracted the hosting, suddenly I had an error: SWFUpload_0_0. Error HTTP Status: 403.</p>
<p>I google to find a solution to my problem and found tons of people having the same issue and the answers where always the same. For example:</p>
<p><strong><span style="color: #000000;"><em>&#8220;You are getting a 403.  Which means &#8220;forbidden&#8221;.  This is something on the web server that you&#8217;ll have to figure out.SWFUpload doesn&#8217;t save the file. It just uploads it to your upload_url (upload.php). You need to add PHP code that saves the file. In PHP the uploaded file is found in $_FILE["Filedata"] by default.&#8221;</em></span></strong></p>
<p>Say what? I looked at my server&#8217;s configuration, checked folder permissions, reviewed my JS and PHP code&#8230; <strong>NOTHING</strong>. Then I thought it was something wrong with server POST Payload checks. Normally,<a href="http://www.modsecurity.org/documentation/modsecurity-apache/1.9.3/html-multipage/03-configuration.html" target="_blank"> this security configuration is disabled by default on Apache Servers</a> but my provider &#8216;could&#8217; possibly had this security check on. I had to try and&#8230;</p>
<h3>Solution</h3>
<p>I solved the issue by creating an .htaccess file and writing the following in it:</p>
<p><strong><em>SetEnvIfNoCase Content-Type &#8220;^multipart/form-data;&#8221; &#8220;MODSEC_NOPOSTBUFFERING=Do not buffer file uploads&#8221;</em></strong></p>
<p>Hope this also works for those having the same issue.</p>
<p><em>Happy New Year BTW!</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ramirezcobos.com/2010/01/05/swfupload_0_0-error-http-status-403-solved/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cookie jQuery Plugin</title>
		<link>http://www.ramirezcobos.com/2010/01/02/cookie-jquery-plugin/</link>
		<comments>http://www.ramirezcobos.com/2010/01/02/cookie-jquery-plugin/#comments</comments>
		<pubDate>Sat, 02 Jan 2010 12:18:29 +0000</pubDate>
		<dc:creator>Antonio Ramirez</dc:creator>
				<category><![CDATA[JQuery]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Plugin]]></category>

		<guid isPermaLink="false">http://www.ramirezcobos.com/?p=148</guid>
		<description><![CDATA[As published on my last post, JSON gives us the great possibility to save objects on Cookies. I have already created a JSON Plugin for jQuery, then, why not create one Cookie Plugin that, in conjunction with the JSON plugin, allows us to save objects on cookies? Well, the challenge was simple and I decided]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.ramirezcobos.com/wp-content/uploads/2009/12/Picture-121.png"><a href="http://www.ramirezcobos.com/wp-content/uploads/2010/03/Picture-121-300x157.png"><img class="alignright size-full wp-image-372" title="Picture-121-300x157" src="http://www.ramirezcobos.com/wp-content/uploads/2010/03/Picture-121-300x157.png" alt="" width="300" height="157" /></a></a>As published <a href="http://www.ramirezcobos.com/2010/01/01/cookies-on-roids/">on my last post</a>, JSON gives us the great possibility to save objects on Cookies. I have already created a JSON Plugin for jQuery, then, why not create one Cookie Plugin that, in conjunction with the JSON plugin, allows us to save objects on cookies? Well, the challenge was simple and I decided to do it for those using jQuery.</p>
<h3>The code</h3>
<p>Remember than this plugin works in conjunction with my <a href="http://www.ramirezcobos.com/2009/12/30/json-jquery-plugin/">JSON jQuery Plugin</a>, also on this blog.</p>
<pre class="brush: jscript;">
jQuery.cookie = {

set : function(name,value,options){

options = $.extend({}, options);

if (value === null) {
value = '';
options.expires = -1;
}
var expires = '';
if (options.expires &amp;&amp; (typeof options.expires == 'number' || options.expires.toUTCString)) {
var date;
if (typeof options.expires == 'number') {
date = new Date();
date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
} else {
date = options.expires;
}
expires = '; expires=' + date.toUTCString();
}

value = options.json ? encodeURIComponent($.JSON.encode(value)):encodeURIComponent(value);

var path = options.path ? '; path=' + (options.path) : '';
var domain = options.domain ? '; domain=' + (options.domain) : '';
var secure = options.secure ? '; secure' : '';

document.cookie = [name, '=', value, expires, path, domain, secure].join('');
},
get : function(name,json){

var cookieValue = null;

if (document.cookie &amp;&amp; document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i &lt; cookies.length; i++) {
var cookie = $.trim(cookies[i]);
if (cookie.substring(0, name.length + 1) == (name + '=')) {
cookieValue = json ? $.JSON.decode(decodeURIComponent(cookie.substring(name.length + 1))):decodeURIComponent(cookie.substring(name.length + 1));
break;
}
}
}

return cookieValue;

},
unset: function(name){
this.set(name,'',-1);
}
};
</pre>
<h3>How to use</h3>
<p>Note that you have to insert the jquery library on your head section and also the <a href="../2009/12/30/json-jquery-plugin/">JSON jQuery Plugin</a> -they are all included into the zip file below. Please, also refer to <a href="http://www.ramirezcobos.com/2010/01/01/cookies-on-roids/">the example provided on my last article &#8216;cookies on roids&#8217; </a>to view more cookie options.</p>
<pre class="brush: jscript;">
var obj = {json:'this is a test json property',xml:'this is a test xml property'};
var arr = ['A','B of 2 index array','C','D'];
var str = 'This is a string test';
var num = 123;

$.cookie.set('testobject',obj,{json:true});
$.cookie.set('testarray',arr,{json:true});
$.cookie.set('teststring',str);
$.cookie.set('testnumber',num);

var a = $.cookie.get('testobject',true);
var b = $.cookie.get('testarray',true);
var c = $.cookie.get('teststring');
var d = $.cookie.get('testnumber');

$.cookie.unset('testobject');
$.cookie.unset('testarray');
$.cookie.unset('teststring');
$.cookie.unset('testnumber');

alert('object:'+a.xml);
alert('array:'+b[1]);
alert('string:'+c);
alert('number:'+d);
</pre>
<p><strong>DOWNLOAD</strong><br />
The zip file includes the JSON jQuery Plugin and Cookie jQuery Plugin together with an example page on how to use them.</p>
<div style="padding: 10px; text-align: center; background-color: #ffffff; border: 3px solid #dddddd;"><table style="border: 1px solid #CCC;" cellpadding="3" width="100%">
  <tr>
    <td width="35">
      <img src="http://www.ramirezcobos.com/wp-content/plugins/downloads-manager/img/icons/default.gif" alt="http://www.ramirezcobos.com/wp-content/plugins/downloads-manager/img/icons/default.gif">
    </td>
    <td>
      <b>download:</b> <a href="http://www.ramirezcobos.com/?file_id=6">jQuery Cookie Plugin</a> <small>(23.84KB)</small><br />
      <b>added:</b> 02/01/2010 <br />
      <b>clicks:</b> 426 <br />
      <b>description:</b>  <br />
    </td>
  </tr>
</table></div>
<script type="text/javascript"><!--
google_ad_client = "pub-7060132287364604";
/* 468x60, creado 16/03/10 */
google_ad_slot = "9029910384";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
]]></content:encoded>
			<wfw:commentRss>http://www.ramirezcobos.com/2010/01/02/cookie-jquery-plugin/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Cookies on Roids -JSON Based</title>
		<link>http://www.ramirezcobos.com/2010/01/01/cookies-on-roids/</link>
		<comments>http://www.ramirezcobos.com/2010/01/01/cookies-on-roids/#comments</comments>
		<pubDate>Fri, 01 Jan 2010 21:13:25 +0000</pubDate>
		<dc:creator>Antonio Ramirez</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Cookies]]></category>

		<guid isPermaLink="false">http://www.ramirezcobos.com/?p=142</guid>
		<description><![CDATA[Every Web programmer, one day or another, works with cookies. Some of us prefer to use server side cookies, others client cookies, and also both, client and server cookies. On my older blogspot blog, one that I even really care to update everyday as I do with this one, I post one class to work]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.ramirezcobos.com/wp-content/uploads/2010/01/cookies.jpg"><img class="alignright size-medium wp-image-144" style="border: 3px solid #ddd; margin: 5px;" title="cookies" src="http://www.ramirezcobos.com/wp-content/uploads/2010/01/cookies-300x168.jpg" alt="" width="300" height="168" /></a>Every Web programmer, one day or another, works with cookies. Some of us prefer to use server side cookies, others client cookies, and also both, client and server cookies. On my older blogspot blog, one that I even really care to update everyday as I do with this one, I post one class to work with cookies on the client side and one fellow programmer told me about <a href="http://www.lalit.org/lab/jsoncookies">json cookies</a>. I thought it was a great script and that was because by using JSON (thanks David Crockford again!) encoding we could save objects and arrays of information into our good friends &#8216;cookies&#8217;.</p>
<p>Well, on my last post, I have included a JSON Plugin script to use with JQuery. By making a couple of modifications I have created a Cookie and JSON javascript objects to provide you with the possibility to save objects and arrays on cookies. Both of the objects do not require any other dependency library&#8230;</p>
<p><strong>Here is the script:</strong></p>
<p>
<pre class="brush: jscript;">&lt;br /&gt;
var JSON = {&lt;br /&gt;
    useHasOwn : ({}.hasOwnProperty ? true : false),&lt;br /&gt;
  	pad : function(n) {&lt;br /&gt;
        return n &amp;lt; 10 ? &amp;quot;0&amp;quot; + n : n;&lt;br /&gt;
    },&lt;br /&gt;
    m : {&lt;br /&gt;
        &amp;quot;\b&amp;quot;: '\\b',&lt;br /&gt;
        &amp;quot;\t&amp;quot;: '\\t',&lt;br /&gt;
        &amp;quot;\n&amp;quot;: '\\n',&lt;br /&gt;
        &amp;quot;\f&amp;quot;: '\\f',&lt;br /&gt;
        &amp;quot;\r&amp;quot;: '\\r',&lt;br /&gt;
        '&amp;quot;' : '\\&amp;quot;',&lt;br /&gt;
        &amp;quot;\\&amp;quot;: '\\\\'&lt;br /&gt;
    },&lt;br /&gt;
    encodeString : function(s){&lt;br /&gt;
        if (/[&amp;quot;\\\x00-\x1f]/.test(s)) {&lt;br /&gt;
            return '&amp;quot;' + s.replace(/([\x00-\x1f\\&amp;quot;])/g, function(a, b) {&lt;br /&gt;
                var c = m[b];&lt;br /&gt;
                if(c){&lt;br /&gt;
                    return c;&lt;br /&gt;
                }&lt;br /&gt;
                c = b.charCodeAt();&lt;br /&gt;
                return &amp;quot;\\u00&amp;quot; +&lt;br /&gt;
                    Math.floor(c / 16).toString(16) +&lt;br /&gt;
                    (c % 16).toString(16);&lt;br /&gt;
            }) + '&amp;quot;';&lt;br /&gt;
        }&lt;br /&gt;
        return '&amp;quot;' + s + '&amp;quot;';&lt;br /&gt;
    },&lt;br /&gt;
    encodeArray : function(o){&lt;br /&gt;
        var a = [&amp;quot;[&amp;quot;], b, i, l = o.length, v;&lt;br /&gt;
            for (i = 0; i &amp;lt; l; i += 1) {&lt;br /&gt;
                v = o[i];&lt;br /&gt;
                switch (typeof v) {&lt;br /&gt;
                    case &amp;quot;undefined&amp;quot;:&lt;br /&gt;
                    case &amp;quot;function&amp;quot;:&lt;br /&gt;
                    case &amp;quot;unknown&amp;quot;:&lt;br /&gt;
                        break;&lt;br /&gt;
                    default:&lt;br /&gt;
                        if (b) {&lt;br /&gt;
                            a.push(',');&lt;br /&gt;
                        }&lt;br /&gt;
                        a.push(v === null ? &amp;quot;null&amp;quot; : JSON.encode(v));&lt;br /&gt;
                        b = true;&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
            a.push(&amp;quot;]&amp;quot;);&lt;br /&gt;
            return a.join(&amp;quot;&amp;quot;);&lt;br /&gt;
    },&lt;br /&gt;
    encodeDate : function(o){&lt;br /&gt;
        return '&amp;quot;' + o.getFullYear() + &amp;quot;-&amp;quot; +&lt;br /&gt;
                pad(o.getMonth() + 1) + &amp;quot;-&amp;quot; +&lt;br /&gt;
                pad(o.getDate()) + &amp;quot;T&amp;quot; +&lt;br /&gt;
                pad(o.getHours()) + &amp;quot;:&amp;quot; +&lt;br /&gt;
                pad(o.getMinutes()) + &amp;quot;:&amp;quot; +&lt;br /&gt;
                pad(o.getSeconds()) + '&amp;quot;';&lt;br /&gt;
    },&lt;br /&gt;
    encode : function(o){&lt;br /&gt;
        if(typeof o == &amp;quot;undefined&amp;quot; || o === null){&lt;br /&gt;
            return &amp;quot;null&amp;quot;;&lt;br /&gt;
        }else if(o instanceof Array){&lt;br /&gt;
            return JSON.encodeArray(o);&lt;br /&gt;
        }else if(o instanceof Date){&lt;br /&gt;
            return JSON.encodeDate(o);&lt;br /&gt;
        }else if(typeof o == &amp;quot;string&amp;quot;){&lt;br /&gt;
            return JSON.encodeString(o);&lt;br /&gt;
        }else if(typeof o == &amp;quot;number&amp;quot;){&lt;br /&gt;
            return isFinite(o) ? String(o) : &amp;quot;null&amp;quot;;&lt;br /&gt;
        }else if(typeof o == &amp;quot;boolean&amp;quot;){&lt;br /&gt;
            return String(o);&lt;br /&gt;
        }else {&lt;br /&gt;
            var a = [&amp;quot;{&amp;quot;], b, i, v;&lt;br /&gt;
            for (i in o) {&lt;br /&gt;
                if(!JSON.useHasOwn || o.hasOwnProperty(i)) {&lt;br /&gt;
                    v = o[i];&lt;br /&gt;
                    switch (typeof v) {&lt;br /&gt;
                    case &amp;quot;undefined&amp;quot;:&lt;br /&gt;
                    case &amp;quot;function&amp;quot;:&lt;br /&gt;
                    case &amp;quot;unknown&amp;quot;:&lt;br /&gt;
                        break;&lt;br /&gt;
                    default:&lt;br /&gt;
                        if(b){&lt;br /&gt;
                            a.push(',');&lt;br /&gt;
                        }&lt;br /&gt;
                        a.push(JSON.encode(i), &amp;quot;:&amp;quot;,&lt;br /&gt;
                                v === null ? &amp;quot;null&amp;quot; : JSON.encode(v));&lt;br /&gt;
                        b = true;&lt;br /&gt;
                    }&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
            a.push(&amp;quot;}&amp;quot;);&lt;br /&gt;
            return a.join(&amp;quot;&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    },&lt;br /&gt;
    decode : function(json){&lt;br /&gt;
        return eval(&amp;quot;(&amp;quot; + json + ')');&lt;br /&gt;
    }&lt;br /&gt;
};&lt;/p&gt;
&lt;p&gt;var Cookie = {&lt;br /&gt;
	jsonencode : JSON.encode,&lt;br /&gt;
	jsondecode : JSON.decode,&lt;/p&gt;
&lt;p&gt;   	set : function(name,value,options){&lt;/p&gt;
&lt;p&gt;   		options = this.extend({}, options);&lt;/p&gt;
&lt;p&gt;        if (value === null) {&lt;br /&gt;
            value = '';&lt;br /&gt;
            options.expires = -1;&lt;br /&gt;
        }&lt;br /&gt;
        var expires = '';&lt;br /&gt;
        if (options.expires &amp;amp;&amp;amp; (typeof options.expires == 'number' || options.expires.toUTCString)) {&lt;br /&gt;
            var date;&lt;br /&gt;
            if (typeof options.expires == 'number') {&lt;br /&gt;
                date = new Date();&lt;br /&gt;
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));&lt;br /&gt;
            } else {&lt;br /&gt;
                date = options.expires;&lt;br /&gt;
            }&lt;br /&gt;
            expires = '; expires=' + date.toUTCString();&lt;br /&gt;
        }&lt;/p&gt;
&lt;p&gt;        var self = this;&lt;/p&gt;
&lt;p&gt;  		value = options.json ? encodeURIComponent(Cookie.jsonencode(value)):encodeURIComponent(value);&lt;/p&gt;
&lt;p&gt;        var path = options.path ? '; path=' + (options.path) : '';&lt;br /&gt;
        var domain = options.domain ? '; domain=' + (options.domain) : '';&lt;br /&gt;
        var secure = options.secure ? '; secure' : '';&lt;/p&gt;
&lt;p&gt;        document.cookie = [name, '=', value, expires, path, domain, secure].join('');&lt;br /&gt;
	},&lt;br /&gt;
	get : function(name,json){&lt;/p&gt;
&lt;p&gt;		var cookieValue = null;&lt;/p&gt;
&lt;p&gt;        if (document.cookie &amp;amp;&amp;amp; document.cookie != '') {&lt;br /&gt;
            var cookies = document.cookie.split(';');&lt;br /&gt;
            for (var i = 0; i &amp;lt; cookies.length; i++) {&lt;br /&gt;
                var cookie = this.trim(cookies[i]);&lt;br /&gt;
                // Does this cookie string begin with the name we want?&lt;br /&gt;
                if (cookie.substring(0, name.length + 1) == (name + '=')) {&lt;br /&gt;
                    cookieValue = json ? this.jsondecode(decodeURIComponent(cookie.substring(name.length + 1))):decodeURIComponent(cookie.substring(name.length + 1));&lt;br /&gt;
                    break;&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;/p&gt;
&lt;p&gt;        return cookieValue;&lt;/p&gt;
&lt;p&gt;	},&lt;br /&gt;
	unset: function(name){&lt;br /&gt;
		Cookie.set(name,'',-1);&lt;br /&gt;
	},&lt;br /&gt;
	trim: function( val ) {&lt;br /&gt;
		return (val || &amp;quot;&amp;quot;).replace( /^\s+|\s+$/g, &amp;quot;&amp;quot; );&lt;br /&gt;
	},&lt;br /&gt;
	extend: function()&lt;br /&gt;
	{&lt;br /&gt;
		var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options;&lt;br /&gt;
		if ( typeof target === &amp;quot;boolean&amp;quot; ) {&lt;br /&gt;
			deep = target;&lt;br /&gt;
			target = arguments[1] || {};&lt;br /&gt;
			i = 2;&lt;br /&gt;
		}&lt;br /&gt;
		if ( typeof target !== &amp;quot;object&amp;quot; &amp;amp;&amp;amp; !isFunction(target) )&lt;br /&gt;
			target = {};&lt;br /&gt;
		if ( length == i ) {&lt;br /&gt;
			target = this;&lt;br /&gt;
			--i;&lt;br /&gt;
		}&lt;br /&gt;
		for ( ; i &amp;lt; length; i++ )&lt;br /&gt;
			if ( (options = arguments[ i ]) != null )&lt;br /&gt;
				for ( var name in options ) {&lt;br /&gt;
					var src = target[ name ], copy = options[ name ];&lt;/p&gt;
&lt;p&gt;					if ( target === copy )&lt;br /&gt;
						continue;&lt;/p&gt;
&lt;p&gt;					if ( deep &amp;amp;&amp;amp; copy &amp;amp;&amp;amp; typeof copy === &amp;quot;object&amp;quot; &amp;amp;&amp;amp; !copy.nodeType )&lt;br /&gt;
						target[ name ] = this.extend( deep,&lt;br /&gt;
							src || ( copy.length != null ? [ ] : { } )&lt;br /&gt;
						, copy );&lt;/p&gt;
&lt;p&gt;					else if ( copy !== undefined )&lt;br /&gt;
						target[ name ] = copy;&lt;/p&gt;
&lt;p&gt;				}&lt;br /&gt;
		return target;&lt;br /&gt;
	},&lt;br /&gt;
	isFunction: function(obj){&lt;br /&gt;
		return toString.call(obj) === &amp;quot;[object Function]&amp;quot;;&lt;br /&gt;
	}&lt;br /&gt;
};&lt;br /&gt;
</pre>
</p>
<p>As you can see above, I have included a couple of methods that allow me to extend the options of the object at will (thanks jQuery). I believe that you will find it quite useful to extend its functionality. Any ideas will be highly appreciated.</p>
<p><strong>How to use it</strong></p>
<p>
<pre class="brush: jscript;">&lt;/p&gt;
&lt;p&gt;// Create a cookie with the given name and value and other optional parameters.&lt;br /&gt;
//&lt;br /&gt;
// session cookie -no json&lt;br /&gt;
Cookie.set('the_cookie_name', 'the_value');&lt;/p&gt;
&lt;p&gt;// get cookie (no json):&lt;br /&gt;
var cv = Cookie.get('the_cookie_name');&lt;/p&gt;
&lt;p&gt;// session cookie -json, the value can be an object or an array too&lt;br /&gt;
Cookie.set('the_cookie_name', 'the_value', {json:true});&lt;/p&gt;
&lt;p&gt;// get the cookie (json)&lt;br /&gt;
var cv = Cookie.get('the_cookie_name',true);&lt;/p&gt;
&lt;p&gt;// Secured cookie, expiring in 14 days&lt;br /&gt;
Cookie.set('the_cookie_name', 'the_value', { expires: 14, path: '/', domain: 'yourdomain.com', secure: true });&lt;/p&gt;
&lt;p&gt;// Deleting a cookie&lt;br /&gt;
Cookie.unset('the_cookie_name', null);&lt;/p&gt;
&lt;p&gt;</pre>
</p>
<p><strong>DOWNLOAD</strong></p>
<div style="padding: 10px; text-align: center; background-color: #ffffff; border: 3px solid #dddddd;"><table style="border: 1px solid #CCC;" cellpadding="3" width="100%">
  <tr>
    <td width="35">
      <img src="http://www.ramirezcobos.com/wp-content/plugins/downloads-manager/img/icons/default.gif" alt="http://www.ramirezcobos.com/wp-content/plugins/downloads-manager/img/icons/default.gif">
    </td>
    <td>
      <b>download:</b> <a href="http://www.ramirezcobos.com/?file_id=5">Cookies on Roids</a> <small>(2.18KB)</small><br />
      <b>added:</b> 01/01/2010 <br />
      <b>clicks:</b> 233 <br />
      <b>description:</b>  <br />
    </td>
  </tr>
</table></div>
<p><center><br />
<script type="text/javascript"><!--
google_ad_client = "pub-7060132287364604";
/* 468x60, creado 16/03/10 */
google_ad_slot = "9029910384";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
</center></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ramirezcobos.com/2010/01/01/cookies-on-roids/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>JSON jQuery Plugin</title>
		<link>http://www.ramirezcobos.com/2009/12/30/json-jquery-plugin/</link>
		<comments>http://www.ramirezcobos.com/2009/12/30/json-jquery-plugin/#comments</comments>
		<pubDate>Wed, 30 Dec 2009 10:53:42 +0000</pubDate>
		<dc:creator>Antonio Ramirez</dc:creator>
				<category><![CDATA[JQuery]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://www.ramirezcobos.com/?p=139</guid>
		<description><![CDATA[I finally got a bit of time and I started playing around with the creation of jQuery plugins and did created a couple of them that I believe all of you will find useful, one of them is a JSON plugin. As you all know jQuery do not have a JSON encode function. I truly]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.ramirezcobos.com/wp-content/uploads/2009/12/Picture-121.png"><a href="http://www.ramirezcobos.com/wp-content/uploads/2010/03/Picture-121-300x157.png"><img class="alignright size-full wp-image-372" title="Picture-121-300x157" src="http://www.ramirezcobos.com/wp-content/uploads/2010/03/Picture-121-300x157.png" alt="" width="300" height="157" /></a></a>I finally got a bit of time and I started playing around with the creation of jQuery plugins and did created a couple of them that I believe all of you will find useful, one of them is a JSON plugin.</p>
<p>As you all know jQuery do not have a JSON encode function. I truly do not know the reason why but to implement it was quite easy -maybe the guys from jQuery thought that it wasn&#8217;t really necessary and I agree with them. Most of us use JSON on the server side through PHP or whatever the server tech we use but sometimes, and I repeat, sometimes, we require to develop client applications that by using JSON (thanks David Crockford) we can reduce our server resources and the amount of data transmitted between client and server. But this is a subject that I will treat in the next posts.</p>
<p>Here is the plugin code:</p>
<pre class="brush: jscript;">
jQuery.JSON = {
useHasOwn : ({}.hasOwnProperty ? true : false),
pad : function(n) {
return n &lt; 10 ? "0" + n : n;
},
m : {
"\b": '\\b',
"\t": '\\t',
"\n": '\\n',
"\f": '\\f',
"\r": '\\r',
'"' : '\\"',
"\\": '\\\\'
},
encodeString : function(s){
if (/["\\\x00-\x1f]/.test(s)) {
return '"' + s.replace(/([\x00-\x1f\\"])/g, function(a, b) {
var c = m[b];
if(c){
return c;
}
c = b.charCodeAt();
return "\\u00" +
Math.floor(c / 16).toString(16) +
(c % 16).toString(16);
}) + '"';
}
return '"' + s + '"';
},
encodeArray : function(o){
var a = ["["], b, i, l = o.length, v;
for (i = 0; i &lt; l; i += 1) {
v = o[i];
switch (typeof v) {
case "undefined":
case "function":
case "unknown":
break;
default:
if (b) {
a.push(',');
}
a.push(v === null ? "null" : this.encode(v));
b = true;
}
}
a.push("]");
return a.join("");
},
encodeDate : function(o){
return '"' + o.getFullYear() + "-" +
pad(o.getMonth() + 1) + "-" +
pad(o.getDate()) + "T" +
pad(o.getHours()) + ":" +
pad(o.getMinutes()) + ":" +
pad(o.getSeconds()) + '"';
},
encode : function(o){
if(typeof o == "undefined" || o === null){
return "null";
}else if(o instanceof Array){
return this.encodeArray(o);
}else if(o instanceof Date){
return this.encodeDate(o);
}else if(typeof o == "string"){
return this.encodeString(o);
}else if(typeof o == "number"){
return isFinite(o) ? String(o) : "null";
}else if(typeof o == "boolean"){
return String(o);
}else {
var self = this;

var a = ["{"], b, i, v;
for (i in o) {
if(!this.useHasOwn || o.hasOwnProperty(i)) {
v = o[i];
switch (typeof v) {
case "undefined":
case "function":
case "unknown":
break;
default:
if(b){
a.push(',');
}
a.push(self.encode(i), ":",
v === null ? "null" : self.encode(v));
b = true;
}
}
}
a.push("}");
return a.join("");
}
},
decode : function(json){
return eval("(" + json + ')');
}
};
</pre>
<p>How to use</p>
<p>Copy and paste the above code onto a file and name it whatever you like, for the sake of the example we will call it<strong> jquery.json.js</strong>. And then configure your head section like this:</p>
<pre class="brush: xml;">
&lt;!-- jquery library (if you dont have it, then download it <img src='http://www.ramirezcobos.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  --&gt;
&lt;script language="javascript" src="jquery.1.3.2.js" &gt;&lt;/script&gt;
&lt;!-- our plugin file --&gt;
&lt;script language="javascript" src="jquery.json.js"&gt;&lt;/script&gt;
</pre>
<p>That&#8217;s it, now we can call our plugin like this:</p>
<pre class="brush: jscript;">
// test variables
var obj = {json:'this is a test json property',xml:'this is a test xml property'};
var arr = ['A','B of 2 index array','C','D'];

// encoding an object
var a = $.JSON.encode(obj);
alert('json encoded object:'+a);

// decoding an object
var b = $.JSON.decode(a);
alert('json decoded object property:'+b.json);

// encoding an array
a = $.JSON.encode(arr);
alert('json encoded array:'+a);

// decoding the array
b = $.JSON.decode(a);
alert('json decoded array:'+b[1]);
</pre>
<p>On future posts we will make use of this plugin to show what we can do with it.<br />
<script type="text/javascript"><!--
google_ad_client = "pub-7060132287364604";
/* 468x60, creado 16/03/10 */
google_ad_slot = "9029910384";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ramirezcobos.com/2009/12/30/json-jquery-plugin/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Javascript Online Compression Tools</title>
		<link>http://www.ramirezcobos.com/2009/12/21/javascript-online-compression-tools/</link>
		<comments>http://www.ramirezcobos.com/2009/12/21/javascript-online-compression-tools/#comments</comments>
		<pubDate>Mon, 21 Dec 2009 11:03:28 +0000</pubDate>
		<dc:creator>Antonio Ramirez</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[On The Web]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.ramirezcobos.com/?p=118</guid>
		<description><![CDATA[When a Web project is finished, it is time to think how to make it better, faster&#8230; how to improve user&#8217;s experience. One of the most important things is javascript code compression in order to speed up page downloads and there are a couple of tools around that allows us to do it. I just]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.ramirezcobos.com/wp-content/uploads/2009/12/Picture-9-300x218.png" alt="Picture 9" title="Picture 9" width="300" height="218" class="alignright size-medium wp-image-119" style="border:3px solid #ddd;margin:5px" />When a Web project is finished, it is time to think how to make it better, faster&#8230; how to improve user&#8217;s experience. One of the most important things is javascript code compression in order to speed up page downloads and there are a couple of tools around that allows us to do it.</p>
<p>I just include three references:</p>
<ul>
<li><a title="Online YUI Compressor" href="http://refresh-sf.com/yui/" target="_blank">The Online YUI Compressor</a> &#8211; by Mike</li>
<li><a title="Online YUI Compressor" href="http://yui.2clics.net/" target="_blank">The Online YUI Compressor</a> &#8211; by Rodolphe Stoclin</li>
<li><a title="JSCompress" href="http://jscompress.com/" target="_blank">The Online Javascript Minifier </a>- by Vance Lucas</li>
</ul>
<h3>The Online YUI Compressors</h3>
<p>These tools allows us to make use of the famous Yahoo Javascript Compression algorithm. Both of the above references does the same results, there is only a major difference between both: whilst the one created by Mike allows you to paste your script or upload a file to compress, the one created by Rodolphe Stoclin only allows us to upload the file to compress.</p>
<h3>The Online Javascript Minifier</h3>
<p>This tool can reduce our code by using two different algorithms: the <a title="David Crockford" href="http://www.crockford.com/javascript/jsmin.html" target="_blank">JSMin by David Crockford</a> and the <a href="http://dean.edwards.name/packer/">Packer</a> method by Dean Edwards.</p>
<h3>Which One to Use?</h3>
<p>I personally like those algorithms that do not make any use of the <strong>eval</strong> function and doesn&#8217;t change much the code I program, test, and implement. I think that will only depend of the developer choice.</p>
<p>There is an online tool that help us compare the algorithms. If that helps you to decide which one to use: <a title="Javascript Compressor Rater" href="http://compressorrater.thruhere.net/" target="_blank">http://compressorrater.thruhere.net/</a></p>
<p><center><br />
<br />
</center></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ramirezcobos.com/2009/12/21/javascript-online-compression-tools/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
