<?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>Position Absolute, resources for the web developer &#187; Small Projects &amp; plugins</title>
	<atom:link href="http://www.position-absolute.com/category/our-projects/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.position-absolute.com</link>
	<description>Get your web worker news fix</description>
	<lastBuildDate>Mon, 06 Feb 2012 15:17:55 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Creating a CSS3D hovering state with fallback for older browsers</title>
		<link>http://www.position-absolute.com/articles/creating-a-css3d-hovering-state-with-fallback-for-older-browsers/</link>
		<comments>http://www.position-absolute.com/articles/creating-a-css3d-hovering-state-with-fallback-for-older-browsers/#comments</comments>
		<pubDate>Thu, 14 Jul 2011 01:42:49 +0000</pubDate>
		<dc:creator>Cedric Dugas</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[CSS / HTML]]></category>
		<category><![CDATA[Small Projects & plugins]]></category>

		<guid isPermaLink="false">http://www.position-absolute.com/?p=3673</guid>
		<description><![CDATA[<p>HTML5 &#038; CSS3 are a big sugar rush in the front-end community currently, you can see those nice CSS3 buttons popping everywhere around the web. For one project I am working on I  wanted to use a nice 3d flip&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>HTML5 &#038; CSS3 are a big sugar rush in the front-end community currently, you can see those nice CSS3 buttons popping everywhere around the web. For one project I am working on I  wanted to use a nice 3d flip effect like <a href="http://desandro.github.com/3dtransforms/examples/card-01.html">this one</a>. </p>
<p>Unfortunately that kind of effect is currently only achievable with Safari and Chrome, so to make this thing work I needed a normal hover behavior for other browsers, and that is what I wanted to show you how to do here.</p>
<style>
.containerCard {
	height:194px;
	position:relative;
	background:#fff;
	width:144px;
}
	.containerCard .element{
		height:194px;
		position:absolute;
		top:0; left:0;
		background:#fff;
		width:144px;
	} .containerCard .elementB{
		display:none;
	} .containerCard:hover .elementA {
			display:none;
		} .containerCard:hover .elementB{
			display:block;
		} @media screen and (-webkit-min-device-pixel-ratio:0) {
.containerCard .elementB{
				-webkit-transform: rotateY(-180deg);
				-webkit-transform-style: preserve-3d;
				-webkit-backface-visibility: hidden;</p>
<p>				/* -- transition is the magic sauce for animation -- */
				transition: all .4s ease-in-out;
				-moz-transition: all .4s ease-in-out;
				-webkit-transition: all .4s ease-in-out;
			}	
.containerCard .elementA{
				-webkit-transform: rotateY(0deg);
				-webkit-transform-style: preserve-3d;
				-webkit-backface-visibility: hidden;
				/* -- transition is the magic sauce for animation -- */
				transition: all .4s ease-in-out;
				-moz-transition: all .4s ease-in-out;
				-webkit-transition: all .4s ease-in-out;
			}
.containerCard:hover .elementA{
					-webkit-transform: rotateY(180deg);
				}
.containerCard:hover .elementB{
					-webkit-transform: rotateY(0deg);
				}
.containerCard{
					-webkit-perspective: 600;
				}
.containerCard:hover .elementA{
					display:block;
				}
.containerCard .elementB{display:block;}		
		}		
</style>
<div class="containerCard">
<div class="elementA element"><img src="/back.jpg" width="144" height="194" alt="Back"></div>
<div class="elementB element"><img src="/king.jpg" width="144" height="194" alt="Back"></div>
</div>
<h2>Setup</h2>
<p>I&#8217;m not going to be talking about how to do the flip effect, there is already <a href="http://desandro.github.com/3dtransforms/">several</a> <a href="http://24ways.org/2010/intro-to-css-3d-transforms">posts</a> about <a href="http://css3wizardry.com/2010/07/13/css3-page-flips/">that</a>. What I will show you is how to use it intelligently and make it fallback. </p>
<p>So, why this effect is not working on Firefox you might ask? Firefox had css3d since version 3.5 after all, well webkit implemented a new property, *currently a w3c draft* called <a href="http://www.w3.org/TR/css3-3d-transforms/">backface-visibility</a>. This nifty property allow you to hide the back face of an element. I guess you can imagine and this can come handy in a flip effect. This is something that IE9 and Firefox does not currently support.</p>
<h2>Creating a version compatible with other browsers</h2>
<p>For achieving this, we will need to use 2 absolute positioned elements, and show and hide them with display:none on the hover state, pretty easy in fact. The tricky part is that we also need to override this behavior on webkit based browsers(and maybe other browsers one day). For this, we will need to use a nice css feature called media queries.</p>
<h2>Media queries </h2>
<p>Yup, you can do conditionals statement in CSS. This is really handy if you want to implement edgy stuff on browser that supports it, and still give a nice level of support for older browsers (it&#8217;s, of course, useful for <a href="http://www.w3.org/TR/css3-mediaqueries/">other very important things</a>). For our little project we will use this media query.</p>
<div class="geshi no html">
<ol>
<li class="li1">
<div class="de1">@media screen and (-webkit-min-device-pixel-ratio:0) { }</div>
</li>
</ol>
</div>
<p>So why use <em>-webkit-min-device-pixel-ratio</em>? Well because this property has been added at the same time that backface-visibility. So yes, this is a <strong>hack</strong>! But it works, I would like to have something cleaner but this will do for now, we will also need use something similar when firefox will implement backface-visibility.</p>
<p>So what our CSS code looks like?</p>
<div class="geshi no html">
<ol>
<li class="li1">
<div class="de1">.containerCard {
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;height:194px;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;position:relative;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;background:#fff;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;width:144px;
</div>
</li>
<li class="li1">
<div class="de1">}
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;.containerCard .element{
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; height:194px;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; position:absolute;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; top:0; left:0;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; background:#fff;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; width:144px;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;}
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;.containerCard .elementB{
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; display:none;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;}
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; .containerCard:hover .elementA {
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;display:none;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; }
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; .containerCard:hover .elementB{
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;display:block;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; }
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; @media screen and (-webkit-min-device-pixel-ratio:0) {
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;.containerCard .elementB{
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; -webkit-transform: rotateY(-180deg);
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; -webkit-transform-style: preserve-3d;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; -webkit-backface-visibility: hidden;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; /* &#8212; transition is the magic sauce for animation &#8212; */
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; transition: all .4s ease-in-out;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; -moz-transition: all .4s ease-in-out;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; -webkit-transition: all .4s ease-in-out;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;}
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;.containerCard .elementA{
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; -webkit-transform: rotateY(0deg);
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; -webkit-transform-style: preserve-3d;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; -webkit-backface-visibility: hidden;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; /* &#8212; transition is the magic sauce for animation &#8212; */
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; transition: all .4s ease-in-out;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; -moz-transition: all .4s ease-in-out;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; -webkit-transition: all .4s ease-in-out;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;}
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; .containerCard:hover .elementA{
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp;-webkit-transform: rotateY(180deg);
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; }
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; .containerCard:hover .elementB{
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp;-webkit-transform: rotateY(0deg);
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; }
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; .containerCard{
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp;-webkit-perspective: 600;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; }
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; .containerCard:hover .elementA{
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp;display:block;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; }
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; .containerCard .elementB{display:block;} &nbsp;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; }</div>
</li>
</ol>
</div>
<h2>Download</h2>
<p>There we have it! As usual the code can be found on github.</p>
<p class="clearfix"><a class="download" href="https://github.com/posabsolute/css3d-hover-effect-with-fallback">Download the source code</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.position-absolute.com/articles/creating-a-css3d-hovering-state-with-fallback-for-older-browsers/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Handling javascript errors on production websites</title>
		<link>http://www.position-absolute.com/articles/handling-javascript-errors-on-production-websites/</link>
		<comments>http://www.position-absolute.com/articles/handling-javascript-errors-on-production-websites/#comments</comments>
		<pubDate>Wed, 30 Mar 2011 21:41:51 +0000</pubDate>
		<dc:creator>Cedric Dugas</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Javascript / jQuery]]></category>
		<category><![CDATA[Small Projects & plugins]]></category>

		<guid isPermaLink="false">http://www.position-absolute.com/?p=3636</guid>
		<description><![CDATA[<p>Handling javascript errors as always been sort of a problem for me. Testing every combination possible in a big application is hard, and there is always a chance you will miss something.</p>
<p>Of course, we should always strive to make an&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>Handling javascript errors as always been sort of a problem for me. Testing every combination possible in a big application is hard, and there is always a chance you will miss something.</p>
<p>Of course, we should always strive to make an application as bug free as possible, but users seems to always find a way to break it. You can always expect them to do something you never have think of, and this is one of the reason I created this plugin.</p>
<p>When a javascript error is detected, this plugin will do an ajax request to your server and then sends an email, of course you could also log it in a database. It&#8217;s certainly not a revolutionary idea, but still, I was finding the idea cool enough to add it to my list of online plugin.</p>
<p>It&#8217;s also very useful for debugging big live applications that you have not written. In which case you want to know if some users hit javascript errors already.</p>
<p class="clearfix"><a class="download" href="https://github.com/posabsolute/jQuery-Error-Handler-Plugin">Download the source code</a></p>
<h2>Integration</h2>
<p>Load the plugin just after the jQuery library</p>
<div class="geshi no html">
<ol>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; $(document).jsErrorHandler();</div>
</li>
</ol>
</div>
<p>Your done.</p>
<h2>Options</h2>
<p>By default the plugin automatically fetch the domain and add it to the email subject, but you can overwrite it.<br />
You can also define a from attribute, I would highly recommend that you change the from setting in the plugin file (jquery.onerror.js)  if your going to use this plugin on multiple websites.</p>
<div class="geshi no html">
<ol>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp;$(document).jsErrorHandler({
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; from: &quot;support@youremail.com&quot;,
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; website: document.domain
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp;});</div>
</li>
</ol>
</div>
<h2>The Email</h2>
<p>The email received will look like this:</p>
<p>A javascript error has been detected on www.position-absolute.com</p>
<p>Error: variable is not defined<br />
Url: http://www.position-absolute.com/creation/onerror/<br />
Line: 21<br />
UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.0) Gecko/20100101 Firefox/4.0</p>
<h2>Limitation</h2>
<p>The plugin works on:<br />
Firefox 3.6+<br />
Chrome Latest<br />
IE 7+</p>
<p>It does not work on Safari (but it will not break your application)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.position-absolute.com/articles/handling-javascript-errors-on-production-websites/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Form validation engine 2.0 is live</title>
		<link>http://www.position-absolute.com/news/form-validation-engine-2-0-is-live/</link>
		<comments>http://www.position-absolute.com/news/form-validation-engine-2-0-is-live/#comments</comments>
		<pubDate>Mon, 17 Jan 2011 18:12:53 +0000</pubDate>
		<dc:creator>Cedric Dugas</dc:creator>
				<category><![CDATA[Javascript / jQuery]]></category>
		<category><![CDATA[Random news]]></category>
		<category><![CDATA[Small Projects & plugins]]></category>

		<guid isPermaLink="false">http://www.position-absolute.com/?p=3539</guid>
		<description><![CDATA[<p>As said previously a rewrite of the validation engine has been in the work for sometimes and  today it is finally live, the API changed a lot, might be a good idea to have a look at the new documentation&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>As said previously a rewrite of the validation engine has been in the work for sometimes and  today it is finally live, the API changed a lot, might be a good idea to have a look at the new documentation if you are upgrading.</p>
<p>I will be updating the documentation today, but the most up to date doc will always be the readme on github. The legacy 1.7 documentation and download can be found under package when you hit download on github</p>
<p>Time to stop squeezing ketchup (inside joke) and hail to the <a href="https://github.com/posabsolute/jQuery-Validation-Engine">beast</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.position-absolute.com/news/form-validation-engine-2-0-is-live/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
		<item>
		<title>stackJS, a javascript module loader and dependencies handler</title>
		<link>http://www.position-absolute.com/articles/stackjs-a-javascript-module-loader-and-dependencies-handler/</link>
		<comments>http://www.position-absolute.com/articles/stackjs-a-javascript-module-loader-and-dependencies-handler/#comments</comments>
		<pubDate>Fri, 03 Dec 2010 22:12:53 +0000</pubDate>
		<dc:creator>Cedric Dugas</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Javascript / jQuery]]></category>
		<category><![CDATA[Small Projects & plugins]]></category>

		<guid isPermaLink="false">http://www.position-absolute.com/?p=3418</guid>
		<description><![CDATA[<p>Writing good and maintainable javascript is hard, especially when your first javascript framework was jQuery. Couples of years ago, you could be ok using document.ready for implementing your minimal features. Now not so much, web application use more and more&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>Writing good and maintainable javascript is hard, especially when your first javascript framework was jQuery. Couples of years ago, you could be ok using document.ready for implementing your minimal features. Now not so much, web application use more and more javascript, and there comes a time where using anonymous functions with a ton of  events is just not enough.  jQuery is pretty good at handling everything cross-browser, but is does nothing to help you implement a clean architecture and rectifying that is the basic idea behind stackJS.</p>
<p>Most of you guys are probably aware that some frameworks have popped up to fill this blank, like the excellent <a href="http://javascriptmvc.com/">javascriptMVC</a> (a jQuery MVC framework), another good example would be backbone.js. I really like what javascriptMVC has to offer, it&#8217;s really a professional offering with all the bells and whistles. But It is actually kind of too much for me. There is <strong>a lot</strong> of features in jMVC and on a daily basis I really don&#8217;t need them all. jMVC is pretty big and understanding all the underlying mechanics would also be a bit too long for me.</p>
<h2>Introducing stackJS, or how to take your code one step further</h2>
<p>Generally your back-end framework control the javascript and css files loading. With stackJS,  all dependencies are  controlled by javascript configurations files, both globally and per modules. In your HTML file you only include the stackJS file and you define by parameters which module you want to load. I am also working at a version that use sammy.js as a router for loading modules.</p>
<p>stackJS is loosely based on <a href="http://msdn.microsoft.com/en-ca/scriptjunkie/gg314983.aspx">Nicholas Zakas proposed architecture</a>. Here the features stackJS attempt to fill :</p>
<ul class="">
<li>Javascript module loader &#038; dependencies</li>
<li>Move DOM focused code to functionality focused code</li>
<li>Better Code organization</li>
<li>Handles plugin dependencies globally and per module separately</li>
<li>Stop module accessing other modules (loose couple them (pub/sub yay!))</li>
<li>Library agnostic</li>
</ul>
<p>&nbsp;</g></p>
<h2>What it look like on paper</h2>
<p><img src="http://www.position-relative.net/pres/images/system.jpg" /></p>
<h2>requireJS</h2>
<p>The dependencies are handled by requireJS in stackJS, this make for a nice opportunity. With the framework is bundled the optimization tool of requireJS. Which make it pretty easy to optimize all your js files in a production folder and only change  a variable in stackJS configuration to access the optimized version on your live server.</p>
<h2>Beta&#8230;</h2>
<p>This is still in beta, but I am currently integrating it in a production project and hope to release a 1.0 version in 1 month or 2.</p>
<p>You can see an example below, I also linked a download link, it include the full documentation in the readme.md. Obviously choosing between a solution like JavascriptMVC and stackJS is a no brainer (take jMVC), but if your looking to evolve the way you do jQuery a bit, I suggest you take a peak at stackJS, it&#8217;s only about 300 lines of code and if your looking to build a framework yourself, that could be a good starting point, or at least inspire you a bit.</p>
<p class="clearfix"><a class="download" href="https://github.com/posabsolute/stackjs">Download the source code</a> <a class="demo" href="http://www.position-relative.net/creation/stackjs/app.htm" target="_blank">View demo</a></p>
<h2>Symfony plugin</h2>
<p>I am currently for working on a symfony helper for loading modules, I will bundle it with the project once it&#8217;s finished.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.position-absolute.com/articles/stackjs-a-javascript-module-loader-and-dependencies-handler/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Managing string localization in javascript files</title>
		<link>http://www.position-absolute.com/articles/managing-string-localization-in-javascript-files/</link>
		<comments>http://www.position-absolute.com/articles/managing-string-localization-in-javascript-files/#comments</comments>
		<pubDate>Fri, 12 Nov 2010 02:14:56 +0000</pubDate>
		<dc:creator>Cedric Dugas</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Javascript / jQuery]]></category>
		<category><![CDATA[Small Projects & plugins]]></category>

		<guid isPermaLink="false">http://www.position-absolute.com/?p=3369</guid>
		<description><![CDATA[<p>One thing that is really frustrating to deal with is localization. There is nothing funny about localizing text from your application. But this is a necessary step when you want to go for very a broad market in multiple languages.&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>One thing that is really frustrating to deal with is localization. There is nothing funny about localizing text from your application. But this is a necessary step when you want to go for very a broad market in multiple languages. So while your there, why not having a localization infrastructure in all your front-end. </p>
<p>Most PHP frameworks and JS widget libraries can now be easily customized as far as localization is concerned. However your bound to have some string messages in your javascript modules. Not thinking about the localization of these little pesky messages leads to painful hours of looking through every files to find some strings that have not been localized.</p>
<h2>Consolidating your localization architecture</h2>
<p>Okay your widget has 2 or 3 files, each for one language, that&#8217;s a start, but why not centralized all that on the front-end? The idea here is to create one one or multiple objects, that will handle all the localization for your application.</p>
<p>Meaning that in your javascript application code, instead of actually writing down the localization, you will be doing a look up using a function to a single object that will be containing every language localization for this string. That also means that you need to set a variable with the current language your app is in.</p>
<h2>Let&#8217;s try to be a little bit clearer</h2>
<p>Here is what we are going to do.</p>
<p><strong>1. First we need a way of knowing your current language state. It could be a javascript variable outputted form your framework or an attribute on your body tag, that you will store in js, for exmaple: </strong></p>
<div class="geshi no html">
<ol>
<li class="li1">
<div class="de1">&lt;body lang=&quot;fr&quot;&gt;</div>
</li>
</ol>
</div>
<p>of simply</p>
<div class="geshi no html">
<ol>
<li class="li1">
<div class="de1">&lt;script&gt;
</div>
</li>
<li class="li1">
<div class="de1">currentLanguage =&quot;fr&quot;;
</div>
</li>
<li class="li1">
<div class="de1">&lt;/script&gt;</div>
</li>
</ol>
</div>
<p><strong>2. Create a JSON object (or multiple) with all your languages translations</strong></p>
<div class="geshi no html">
<ol>
<li class="li1">
<div class="de1">var globalTranslations = {
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;&quot;en&quot;:{
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &quot;myquote&quot;: &quot;English quote&quot;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;}
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;&quot;fr&quot;:{
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &quot;myquote&quot;: &quot;Quote en francais&quot;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;}
</div>
</li>
<li class="li1">
<div class="de1">}</div>
</li>
</ol>
</div>
<p>The idea here is to use the current language and fallback to english if some strings are missing. So a good idea could be to separate the object in separate files per language and only load the english localization and the _insert current language_.</p>
<p><strong><br />
3. A central function that will route all messages to the current language state. </strong></p>
<p>This part is little bit more complicated but, the idea is that when you need a string, your going to call the function like this :  <strong>tools.getLocalisation(globalTraductions[currentLanguage], ['validation', 'required'])</strong></p>
<p>For example, this would look in your object for globalTraductions.en.validation.required node. The way getLocalisation is written, if the string is not found, it&#8217;s going to default to the &#8220;default language&#8221; (currently English), and if this is still undefined, it&#8217;s going to actually output the object lookup (in this case: validation required)</p>
<p class="clearfix"><a class="download" href="https://github.com/posabsolute/Javascript-localization-manager">Download the source code</a> <a class="demo" href="http://www.position-relative.net/creation/localization/" target="_blank">View demo</a></p>
<h2>That&#8217;s it</h2>
<p>Following this pattern  you never create javascript error with undefined properties, and  it can also default to English or to a, somewhat, understandable state. Hope it can help you guys get your localizations going! </p>
]]></content:encoded>
			<wfw:commentRss>http://www.position-absolute.com/articles/managing-string-localization-in-javascript-files/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>A javascript module framework starter</title>
		<link>http://www.position-absolute.com/articles/a-javascript-module-starter/</link>
		<comments>http://www.position-absolute.com/articles/a-javascript-module-starter/#comments</comments>
		<pubDate>Fri, 21 May 2010 01:20:24 +0000</pubDate>
		<dc:creator>Cedric Dugas</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Javascript / jQuery]]></category>
		<category><![CDATA[Small Projects & plugins]]></category>

		<guid isPermaLink="false">http://www.position-absolute.com/?p=2466</guid>
		<description><![CDATA[<p><em>This is the following article to <a href="http://www.position-absolute.com/articles/javascript-patterns-headache-the-path-to-modular-applications-part-1/">part 1 on javascript patterns</a>.</em></p>
<h2>A namespace to rule them all</h2>
<p>This is a small javascript framework that I use for starting my javascript/jQuery project. I think it could be most beneficial for those coming from&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p><em>This is the following article to <a href="http://www.position-absolute.com/articles/javascript-patterns-headache-the-path-to-modular-applications-part-1/">part 1 on javascript patterns</a>.</em></p>
<h2>A namespace to rule them all</h2>
<p>This is a small javascript framework that I use for starting my javascript/jQuery project. I think it could be most beneficial for those coming from libraries like jQuery. Dojo being quite expressive on how to work with it, and Mootools and Prototype being a bit more structured.</p>
<p><em>A small note, I used jQuery in the framework because of the AOP plugin (and because I mainly work with jQuery), you can erase any jQuery reference easily in less than 30 seconds .</em></p>
<p><strong>What this framework aims to do:</strong></p>
<ul>
<li>Easy to understand</li>
<li>Modular</li>
<li>Each module will heritage a set of tools and each module can be instantiate</li>
<li>One namespace</li>
<li>Can apply tests or unit test out side of the application itself.</li>
<li>Use the jQuery aop plugin (aspect oriented programming) to add logs to internal functions</li>
</ul>
<p class="clearfix"><a class="download" href="http://www.position-relative.net/creation/frameworkJS/frameworkJS.zip">Download the source code</a></p>
<p><strong>** I am not an expert in javascript design patterns, but that is what I have come to in light of my experience, I will certainly take constructive comments, and if you like it, please use and modify it as you want.</strong></p>
<h2>Schema</h2>
<p><img border="0" src="/wp-content/themes/default/images/PSIMG/uml.jpg"><br />
<a target="_blank" href="/wp-content/themes/default/images/PSIMG/DIAGRAM-Architecture-JS-v0.1.pdf">Download the full version in pdf</a></p>
<h2>How it works</h2>
<p><strong>LABjs to load all your scripts</strong><br />
First thing first, in app.html you will see that JS files are loaded asynchronously from the bottom body tag with <a href="http://labjs.com/">LABjs</a>. This tools will make you js files load faster and your script will no longer block page resources download (images, etc). You can use .wait() to define load order if necessary. Have a look at the <a href="http://labjs.com/documentation.php">documentation</a>. The major drawback from loading asynchronously is that you might have a situation where someone clicked on a button and the script associate with it might not be loaded.</p>
<div class="geshi no html">
<ol>
<li class="li1">
<div class="de1">&lt;script&gt;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;$LAB
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;.script(&quot;framework.js&quot;).wait()
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;.script(&quot;plugin.framework.js&quot;)
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;.script(&quot;myplugin.framework.js&quot;).wait()
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;.script(&quot;init.js&quot;);
</div>
</li>
<li class="li1">
<div class="de1">&lt;/script&gt;</div>
</li>
</ol>
</div>
<p><strong>Namespace</strong><br />
I try to use only one or 2 namespaces for all my applications or even websites. This is why in objectUtils.construct.js you will see that the global namespace is define by this line:</p>
<div class="geshi no html">
<ol>
<li class="li1">
<div class="de1">/* Global App Namespace */
</div>
</li>
<li class="li1">
<div class="de1">var ApplicationNamespace = {}</div>
</li>
</ol>
</div>
<p>Each module will be declared using this object. So for example, a lightbox class would be declared this way :  ApplicationNamespace.lightboxClass = function(){}</p>
<h2>Modules</h2>
<p>A typical module in your app should look likes this:</p>
<div class="geshi no html">
<ol>
<li class="li1">
<div class="de1">ApplicationNamespace.Classname = function() {
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; // constructor &nbsp; &nbsp;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; function privateFunctionInit() {
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; // private
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; }
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; this.privilegedFunction = function() {
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; // privileged
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; privateFunction();
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; };
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;privateFunctionInit()
</div>
</li>
<li class="li1">
<div class="de1">};
</div>
</li>
<li class="li1">
<div class="de1">ApplicationNamespace.Classname.prototype = {
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; utils: object.create(namespace.moduleUtils),
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; Method: function(){}
</div>
</li>
<li class="li1">
<div class="de1">}
</div>
</li>
<li class="li1">
<div class="de1">var class = new ApplicationNamespace.Classname();</div>
</li>
</ol>
</div>
<p>We have a pretty cool module here. Let&#8217;s get a bit into details here.</p>
<p>This is a private function that will not be available in the global scope. These method cannot also be tested externally, unless doing a small trick that I will talk later on.</p>
<div class="geshi no html">
<ol>
<li class="li1">
<div class="de1">function privateFunctionInit() {
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; // private
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; }</div>
</li>
</ol>
</div>
<p>This is our privileged function that can access private functions and can be accessed outside after we instantiate it by using, in this case :   class.privilegedFunction</p>
<div class="geshi no html">
<ol>
<li class="li1">
<div class="de1">&nbsp;this.privilegedFunction = function() {
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; // privileged
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; privateFunction();
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; };</div>
</li>
</ol>
</div>
<p>This will be called after we instanciate (var class = new namespace.Classname()) and automatically launch this init function. You should also note that this might happen before the DOM is ready, if you use jQuery you need the DOM ready wrapper here.</p>
<div class="geshi no html">
<ol>
<li class="li1">
<div class="de1">privateFunctionInit()</div>
</li>
</ol>
</div>
<p>This is where we declare the prototype associate at our module and method shared by every instance of the module.You can have more informations on prototype in my other article.</p>
<div class="geshi no html">
<ol>
<li class="li1">
<div class="de1">ApplicationNamespace.Classname.prototype = {</div>
</li>
</ol>
</div>
<p>This is where we get or create the utility module shared by every modules.</p>
<div class="geshi no html">
<ol>
<li class="li1">
<div class="de1">&nbsp; &nbsp; utils: object.create(namespace.moduleUtils),</div>
</li>
</ol>
</div>
<p>And finally we instantiate the module. There is probably a lot of modules that you might have to instantiate only one time. </p>
<div class="geshi no html">
<ol>
<li class="li1">
<div class="de1">&nbsp; &nbsp; var class = new ApplicationNamespace.Classname();</div>
</li>
</ol>
</div>
<h2>Modules utilities object</h2>
<p>The utility object is shared across every modules. the definition is done in objectUtils.construct.js.</p>
<p>This is notably important if you want to run some unit test or run some debug from outside your modules. One thing I really like to do,is using the jQuery AOP (Aspect oriented) plugin. This will allow you to bind debug methods to any functions in any modules, it also give you the DOM caller if it exist and it&#8217;s context. Here is an example:</p>
<div class="geshi no html">
<ol>
<li class="li1">
<div class="de1">// WRITE TEST METHODS
</div>
</li>
<li class="li1">
<div class="de1">moduleUtils.debug = {
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;live : true,
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;loadModal : function(){
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; jQuery.aop.before( {target: appModal, method: &#39;load&#39;}, function(object) {
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; console.log(&#39;Modal opened&#39;);
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; console.log(object);
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; console.log(this);
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; console.log(&#39;&#8212;&#8212;&#8212;-&#39;);
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; }
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; );
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;},
</div>
</li>
<li class="li1">
<div class="de1">}
</div>
</li>
<li class="li1">
<div class="de1">$(document).ready(function(){
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;// USE TEST METHODS
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;if(moduleUtils.debug.live == true){
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; appModal.utils.debug.loadModal();
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;}
</div>
</li>
<li class="li1">
<div class="de1">});</div>
</li>
</ol>
</div>
<p>As you can see the object is created even if live is false (in production you might want to enable and disable it often), normally this file should not be loaded when the project goes live.</p>
<h2>Unit Tests</h2>
<p>I really wanted to include QUnit as a part of my work flow, unfortunately, you can&#8217;t load QUnit dynamically for now. I really want my unit tests to be in a small lightbox and decide to load it in my app from a small variable state. I will probably create a really small unit test plugin in the near future, I think this is really important to test regressions.  </p>
<h2> That&#8217;s it, here it is</h2>
<p>I am certainly not going to say this is a perfect solution, but that&#8217;s what I use for now, it will certainly evolve with time.</p>
<p class="clearfix"><a class="download" href="http://www.position-relative.net/creation/frameworkJS/frameworkJS.zip">Download the source code</a> <a class="demo" href="http://www.position-relative.net/creation/frameworkJS/app.htm" target="_blank">View demo</a></p>
<p><strong>Version 0.5 Online</strong></p>
<p><br clear="all" /><br />
If you like and use this script, please consider buying me a beer, it&#8217;s cheap and a simple way to give back!</p>
<form style="text-align:left;" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input name="cmd" type="hidden" value="_s-xclick" />
<input name="encrypted" type="hidden" value="-----BEGIN PKCS7-----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-----END PKCS7-----" />
<input style="align:left" alt="PayPal - The safer, easier way to pay online!" name="submit" src="http://www.position-absolute.com/wp-content/themes/default/images/bg_buy.jpg" type="image" />
<img src="https://www.paypal.com/en_US/i/scr/pixel.gif" border="0" alt="" width="1" height="1" /><br />
</form>
]]></content:encoded>
			<wfw:commentRss>http://www.position-absolute.com/articles/a-javascript-module-starter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQTouch HTML5 database api extension</title>
		<link>http://www.position-absolute.com/articles/jqtouch-html5-database-api-extension/</link>
		<comments>http://www.position-absolute.com/articles/jqtouch-html5-database-api-extension/#comments</comments>
		<pubDate>Wed, 23 Dec 2009 02:22:27 +0000</pubDate>
		<dc:creator>Cedric Dugas</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Javascript / jQuery]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Small Projects & plugins]]></category>
		<category><![CDATA[featured]]></category>

		<guid isPermaLink="false">http://www.position-absolute.com/?p=2154</guid>
		<description><![CDATA[<p>If you want to dive in mobile website and you are a good jQuery developer, you will love <a href="http://www.jqtouch.com">jQTouch</a>. It&#8217;s one of the best mobile web framework out there. </p>
<p>However, one thing I found it was missing, was some database&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>If you want to dive in mobile website and you are a good jQuery developer, you will love <a href="http://www.jqtouch.com">jQTouch</a>. It&#8217;s one of the best mobile web framework out there. </p>
<p>However, one thing I found it was missing, was some database api. In webkit you now have access to one database per website address. Think of it as a better cookie. You could for example easily create a To do list with this feature.</p>
<h3>Webkit is touchy about its database</h3>
<p>You don&#8217;t mess with the webkit database, if you do, there is a good chance it will crash. Building this script, I never saw so much crash in Safari! so be careful using it. This script creates an abstraction of the webkit database api, it will enable you to write faster and less bloated code. It makes it really easy to play with the database, look at the demo, the HTML5 database section is all loaded from the webkit database.</p>
<p class="clearfix"><a class="demo" href="http://www.position-relative.net/mobile/demos/main/index.html#home" target="_blank">View demo</a><br clear="all">(The Demo works only on Safari and webkit devices)</p>
<p>It can really be beneficial performance wise to use the database as a cache, this loads a lot faster than ajax web page, but you need to be careful on how much information you load from it. The iPhone is not a power house, you will need to find a balance. Also, used with the offline mode, you can really create powerful app that can be used offline.</p>
<p><strong>Update:</strong> Apple is also doing database cache with the iPhone web user guide, interestingly enough they cache 1.4mb, the entire guide in the database in one shot. I personally did not see great performance when adding thousands of rows in the database, I am currently looking at how the pastry kit deal with the database executions. A good solution would be to create the database on the web application loading screen(when the application is added at the home screen).</p>
<h2>How to use it</h2>
<p>In fact what you see in the demo runs with basically 7 lines of code. Here a typical use of the extension:</p>
<div class="geshi no html">
<ol>
<li class="li1">
<div class="de1">&nbsp; jQT.dbSelectAll(&quot;favoriteThing&quot;,function(result){
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; for (var i = 0; i &lt; result.rows.length; ++i) {
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var row = result.rows.item(i);
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $(&quot;#database ul&quot;).append(&#39;&lt;li class=&quot;arrow&quot;&gt;&lt;a href=&quot;#&#39;+row[&#39;link&#39;]+&#39;&quot;&gt;&#39;+row[&#39;name&#39;]+&#39;&lt;/a&gt;&lt;/li&gt;&#39;)
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp;$(&quot;body&quot;).append(&#39;&lt;div id=&quot;&#39;+row[&#39;link&#39;]+&#39;&quot;&gt;&lt;div class=&quot;toolbar&quot;&gt;&lt;h1&gt;Database&lt;/h1&gt;&lt;a class=&quot;back&quot; href=&quot;#database&quot;&gt;Home&lt;/a&gt;&lt;/div&gt;&#39;+row[&#39;content&#39;]+&#39;&lt;/div&gt;&#39;)
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;})</div>
</li>
</ol>
</div>
<h2>The API</h2>
<h3>Open database</h3>
<p><strong>jQT.dbOpen(&#8220;name&#8221;, &#8220;version&#8221;,&#8221;descriptione&#8221;, size);	</strong><br />
This function is needed on every page where you use the webkit database, be careful with version and size. Set a bigger size that you think you need, trying to add space later could prompt users permission. Example:<br />
jQT.dbOpen(&#8220;databaseTest&#8221;, &#8220;1.0&#8243;,&#8221;jqTouch web application database&#8221;, 200000);	</p>
<h4>Create Tables</h4>
<p><strong>jQT.dbCreateTables(json)</strong><br />
You would use this typically to create the basic structure of your database, I would store it in another file called dbstructure.js, or something like this, a quick reference to go to when you need to change something in the structure. It can also be used to simply add a table at a selected time.<br />
An example of the json structure to follow:</p>
<div class="geshi no html">
<ol>
<li class="li1">
<div class="de1">jsonTb= { &quot;createTables&quot; :
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp;[
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; {&quot;table&quot;: &quot;favoriteThing&quot;, &nbsp;&quot;property&quot;: [
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&quot;name&quot;: &quot;id&quot;, &quot;type&quot;: &quot;INTEGER PRIMARY KEY AUTOINCREMENT&quot; },
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&quot;name&quot;: &quot;name&quot;, &quot;type&quot;: &quot;TEXT&quot; },
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&quot;name&quot;: &quot;link&quot;, &quot;type&quot;: &quot;TEXT&quot; },
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&quot;name&quot;: &quot;content&quot;, &quot;type&quot;: &quot;TEXT&quot; }
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ]
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; },
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; {&quot;table&quot;: &quot;listRecipe&quot;, &nbsp; &quot;property&quot;: [
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&quot;name&quot;: &quot;id&quot;, &quot;type&quot;: &quot;INTEGER PRIMARY KEY AUTOINCREMENT&quot; },
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&quot;name&quot;: &quot;etat&quot;, &quot;type&quot;: &quot;REAL&quot; },
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&quot;name&quot;: &quot;name&quot;, &quot;type&quot;: &quot;TEXT&quot; }
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ]
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; },
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp;]
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; }</div>
</li>
</ol>
</div>
<h3>Create Rows</h3>
<p><strong>jQT.dbInsertRows(json)</strong><br />
You would use this typically to add rows in your table.<br />
An example of the json structure to follow:</p>
<div class="geshi no html">
<ol>
<li class="li1">
<div class="de1">jsonAddRow1 = { &quot;addRow&quot; :
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp;[
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; {&quot;table&quot;: &quot;favoriteThing&quot;, &nbsp;&quot;property&quot;: [
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&quot;name&quot;: &quot;name&quot;, &quot;value&quot;: &quot;Field from database 1&quot; },
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&quot;name&quot;: &quot;link&quot;, &quot;value&quot;: &quot;database1&quot; },
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&quot;name&quot;: &quot;content&quot;, &quot;value&quot;: &quot;This text is coming from the database 1&quot; }
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ]
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; },
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; {&quot;table&quot;: &quot;favoriteThing&quot;, &nbsp;&quot;property&quot;: [
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&quot;name&quot;: &quot;name&quot;, &quot;value&quot;: &quot;Field from database 2&quot; },
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&quot;name&quot;: &quot;link&quot;, &quot;value&quot;: &quot;database2&quot; },
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&quot;name&quot;: &quot;content&quot;, &quot;value&quot;: &quot;This text is coming from the database2&quot; }
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ]
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; },
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp;]
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; }</div>
</li>
</ol>
</div>
<h3>Delete table</h3>
<p><strong>jQT.dbDropTable(&#8220;table&#8221;)</strong><br />
Delete a table with all its information</p>
<h3>Basic Delete Row</h3>
<p><strong>jQT.dbDeleteRow(&#8220;table&#8221;,&#8221;key&#8221;,&#8221;value&#8221;)</strong><br />
Delete a row following the statement WHERE KEY = VALUE. An example : jQT.dbDeleteRow(&#8220;listRecipe&#8221;,&#8221;id&#8221;,&#8221;&#8216;5&#8242;&#8221;)</p>
<h3>Get all the content from a table</h3>
<p><strong>jQT.dbSelectAll(&#8220;table&#8221;, callback(result))</strong><br />
Get all the information from a specific table. An Example:</p>
<div class="geshi no html">
<ol>
<li class="li1">
<div class="de1">jQT.dbSelectAll(&quot;favoriteThing&quot;,function(result){
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;// Handle Result
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;for (var i = 0; i &lt; result.rows.length; ++i) {
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; var row = result.rows.item(i);
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; row[&#39;column&#39;]
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;}
</div>
</li>
<li class="li1">
<div class="de1">})</div>
</li>
</ol>
</div>
<h3>Custom query</h3>
<p><strong>jQT.dbExecuteQuery(&#8220;Query&#8221;,&#8221;Debug text&#8221;, callback(result))</strong><br />
You can create your custom query and get  a callback with the result. you will probably not need the debug text. Example:</p>
<div class="geshi no html">
<ol>
<li class="li1">
<div class="de1">&nbsp;jQT.dbExecuteQuery(&quot;SELECT * FROM favoriteThing&quot;,&quot;&quot;,function(result){
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; console.log(result.rows)
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;})</div>
</li>
</ol>
</div>
<h4>Debug mode</h4>
<p>I added a debug mode that you can enable in the extension, change the variable debugging to true. It will add an overlay and tell you about every query executed in the script.</p>
<h3>Still in a early stage</h3>
<p>I consider this release as beta v0.1. It works pretty well for what it does, but it&#8217;s not optimized and it&#8217;s not thoroughly tested, so be careful and have fun. </p>
<p class="clearfix"><a class="download" target="_blank" href="http://www.position-relative.net/mobile/extensions/jqt.database.js">Download the source code</a> <a class="demo" href="http://www.position-relative.net/mobile/demos/main/index.html#home" target="_blank">View demo</a></p>
<p><strong>Tested on:</strong><br />
Safari 4<br />
Iphone webkit</p>
<p><strong>Version 0.1 Online</strong><br />
December 22, Initial release</p>
]]></content:encoded>
			<wfw:commentRss>http://www.position-absolute.com/articles/jqtouch-html5-database-api-extension/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>Best front-end workflow within a production team</title>
		<link>http://www.position-absolute.com/articles/best-front-end-work-flow/</link>
		<comments>http://www.position-absolute.com/articles/best-front-end-work-flow/#comments</comments>
		<pubDate>Fri, 18 Sep 2009 17:10:30 +0000</pubDate>
		<dc:creator>Cedric Dugas</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[CSS / HTML]]></category>
		<category><![CDATA[Opinions]]></category>
		<category><![CDATA[Small Projects & plugins]]></category>
		<category><![CDATA[featured]]></category>

		<guid isPermaLink="false">http://www.position-absolute.com/?p=1625</guid>
		<description><![CDATA[<p>Optimizing front-end teams&#8217; workflow is hard, there is always something that comes in the way, but it is important to at least try to optimize the front-end work. It could save your team considerable time over a project. Front-enders could&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>Optimizing front-end teams&#8217; workflow is hard, there is always something that comes in the way, but it is important to at least try to optimize the front-end work. It could save your team considerable time over a project. Front-enders could work more efficiently together and within the production team.<br />
<strong></p>
<p>Let&#8217;s take a look at front-enders&#8217; typical relationship within a production team: (take it lightly)</strong></p>
<p>First, you got designers that, generally, do not really like front-end developers because they do not render exactly there  graphic design, and you got front-enders that &#8220;hate&#8221; designers because they are doing complicated design, costing too much money and time to render to HTML. </p>
<p>Back-end developers also have a general tendency to be a bit careless with HTML, which, not visible at first sight, can cause trouble on older browsers and pass without no one seeing it on live versions. Improving this type of team relationships should be a priority.</p>
<p>Now that you have taken these relationships within your team in consideration, you have to know that every front-ender has a way of doing CSS a bit differently. Many ways of doing the same thing can be good in CSS. But somewhere in the middle, a team needs interoperability, everyone needs to be comfortable with the CSS and Javascript of the others. This is one of the main reason I launched my own &#8220;<a href="http://www.position-absolute.com/articles/posabsolute-css-framework-website-starter-kit/">CSS Framework</a>&#8220;.</p>
<h3>My workflow</h3>
<p><img src="/wp-content/themes/default/images/PSIMG/workflow.gif"></p>
<p>Assigning a lead front-end developer by project was a tough choice, but was inevitable. You need someone to refer to with a strong knowledge of the project and who can fix things easily. As he makes the main template, most of the CSS is based on his style of coding and he is clearly the man for the job if something turns bad. He is lead on the project but not necessary the lead front-end of the team.</p>
<p>Another nice thing here, there is actually someone in charge! You know how it goes in a project. Front-enders come and go, but even if one lead is not really doing any work on the project, he needs to take a look time-to-time to be sure the front-end code quality is matching his expectation.</p>
<p>Having the designer look at the first templates will also save you 90% of the problems a designer can cause looking at a final product. This can be disastrous if no validation is done before transforming the HTML template to the CMS.</strong>.</p>
<p>Don&#8217;t be afraid to add your touch and present this to your boss. You will probably save time, and your boss&#8217; money, and a boss really likes to save money.</p>
<h3>What about you?</h3>
<p>You&#8217;re doing this work yourself? Want to share your way? Send me your work flow with some explications and I will put it on this page, editorial [at] position-absolute.com.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.position-absolute.com/articles/best-front-end-work-flow/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>posAbsolute CSS Framework, website starter kit</title>
		<link>http://www.position-absolute.com/articles/posabsolute-css-framework-website-starter-kit/</link>
		<comments>http://www.position-absolute.com/articles/posabsolute-css-framework-website-starter-kit/#comments</comments>
		<pubDate>Wed, 09 Sep 2009 00:24:01 +0000</pubDate>
		<dc:creator>Cedric Dugas</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[CSS / HTML]]></category>
		<category><![CDATA[Small Projects & plugins]]></category>
		<category><![CDATA[featured]]></category>

		<guid isPermaLink="false">http://www.position-absolute.com/?p=1556</guid>
		<description><![CDATA[<p>Web development companies have a bad habit of doing inconsistent websites depending on which developer coded the website. It is one of the reason we have so much back-end framework. However front-end teams are a bit more in the dark.&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>Web development companies have a bad habit of doing inconsistent websites depending on which developer coded the website. It is one of the reason we have so much back-end framework. However front-end teams are a bit more in the dark. While there is basic guidelines for CSS and JS, there is generally less management by team leaders. It becomes a big gray zone where inconsistencies often become the norm. This is what this framework aims for, empowering your front-end developers with a tool to make their JS and CSS code more coherent.</p>
<h3>Why use a CSS framework</h3>
<p>Better quality and coherence coding inside a front-end team<br />
Preset CSS classes, know where your going with highly reusable classes<br />
A collection of some of the best jquery scripts<br />
A solid cross browser compatible stylesheet</p>
<p>A new project means getting JS plug-ins together, clean a CSS and restart. This framework is intended to be your project starter, and in most case, you can jump in the project right away with a solid css foundation. This is not really a CSS &#8220;framework&#8221; but more a website starter kit.</p>
<p>The framework is based on a 960px grid, but is very easy to manipulate to get the grid you want. It is however not intended to be used as a liquid grid.</p>
<p class="clearfix"><a class="download" href="http://www.position-relative.net/creation/posAbsolute_CSS_Framework/posAbsolute_CSS_Framework.zip">Download the source code</a> <a class="demo" href="http://www.position-relative.net/creation/posAbsolute_CSS_Framework/" target="_blank">View demo</a></p>
<p><img src="/wp-content/themes/default/images/PSIMG/arboCSS.jpg" alt="" /></p>
<h3>It includes:</h3>
<p>A basic tree folder, with good practice implemented<br />
A valid XHTML template with basic website foundation and a small demo of every plug-ins implemented.<br />
A Basic CSS style, using a reset style, and a import for elements like form design.</p>
<p><strong>It also includes jQuery with most frequently used plug-ins </strong><br />
jquey.cookie.js  // Cookie simplified<br />
jquey.easing.js  // Make your animations more pro, without the high KB cost of jquery UI<br />
jquery.validationEngine.js // Beautiful form validation<br />
jquery.linkFader.js  // Make your CSS sprite fade, implemented on the Nav framework<br />
jquery.tooltip.js  // Nice elastic tooltip<br />
jquery.colorbox.js // A nice lightbox.</p>
<h3>Why jQuery and those plug-ins?</h3>
<p>jQuery is probably the most common JS library right now, it is easy to use, easy to understand and can help you save a lot of <strong>time</strong>. The plug-in core implemented are mature (which means they have been implemented in a lot of website easily) and have a high level of re-usability, that said you can add or delete the ones you don&#8217;t want. Remember that while all these plug-ins are there, there is absolutely no obligation to link them in your web site, you can just let them sit there until you need them. </p>
<p>One problem with JS plug-ins is the bad repartition of images and CSS involved with them. In this framework, every images and CSS stay in there plug-in folder, and every plug-ins you will add needs to follow this rule! It gives you a less bloated CSS and images folder, which will hold only website items.</p>
<h3>CSS practices</h3>
<p>The framework heavily promotes indentation, remember that C in CSS means cascading. It also promotes the use of CSS sprite in general and especially for your navigation, if you look at the implemented template, the navigation use CSS sprite with the linkfader script, which gives it a nice hovering fade animation (add the class linkFader to your link and your done)! </p>
<p>The framework use the CSS functionality @import to link other stylesheet inside global.css. This gives you a great way to link to different style sheets for special purposes. Currently, it imports a reset, external links and basic form style sheets. I do not recommend importing to much style sheets, keep it simple.</p>
<p>The print CSS is basic, it deletes everything but the #contentSection, and add the print logo. In a general way, printing the entire website looks bad, printing the text content makes it nicer to read.</p>
<h4>Hey! font-size are not in em!</h4>
<p>While em give a great power over the way font-size are displayed on a website, it has some downsides. First, it is harder to manipulate, em is unfortunately not relative to the body, but to it&#8217;s parent. You basically need a reference to know which size to apply when relative em&#8217;s collide. It makes it harder to maintain, you could change a parent font-size without knowing that a children on another page will be affected.</p>
<p>All modern browser can resize px font-size, only IE6 can&#8217;t and I would argue that only a small fraction of it&#8217;s user base know and use this tool</p>
<p>I know that em is a good practice. I certainly don&#8217;t want to start a crusade against it, but I just find it unpractical, especially when working with a team, 1 pixel difference for a title can make a designer scream. So if I can avoid it, I will.</p>
<h3>HTML practices</h3>
<p>While this template validates strict Doctype, you are welcome to move back to transitional doctype any time you want. You can&#8217;t control user input content, and this will probably make your template invalid. Keep it clean and indented, the use of HTML comments is not recommended as there is sometimes quirks with IE6 (It sometimes add spaces, which is pretty bad).</p>
<h3>Javascript practices</h3>
<p>Please put all your javascript code, related to a specific website, in common.js. The framework has some light examples in the demo page, also there is some basic jQuery events in common.js, to make it easier to remember the syntax. </p>
<p class="clearfix"><a class="download" href="http://www.position-relative.net/creation/posAbsolute_CSS_Framework/posAbsolute_CSS_Framework.zip">Download the source code</a> <a class="demo" href="http://www.position-relative.net/creation/posAbsolute_CSS_Framework/" target="_blank">View demo</a></p>
<p><strong>Tested on:</strong><br />
Internet Exploder 6 &#038; 7<br />
Firefox 3+<br />
Safari 4</p>
<p><strong>Version 1.0.1 online</strong><br />
1.0.1: Small fixes, removes JS includes, added new clearfix method</p>
<p><br clear="all" /><br />
If you like and use this script, please consider buying me a beer, it&#8217;s cheap and a simple way to give back!</p>
<form style="text-align:left;" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input name="cmd" type="hidden" value="_s-xclick" />
<input name="encrypted" type="hidden" value="-----BEGIN PKCS7-----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-----END PKCS7-----" />
<input style="align:left" alt="PayPal - The safer, easier way to pay online!" name="submit" src="http://www.position-absolute.com/wp-content/themes/default/images/bg_buy.jpg" type="image" />
<img src="https://www.paypal.com/en_US/i/scr/pixel.gif" border="0" alt="" width="1" height="1" /><br />
</form>
<div class="ads">
<strong>Ads</strong>
<p>Become expert developer with <a href="http://www.test-king.com/exams/646-046.htm">testking 646-046</a> web development course.  learn about all latest trends and updates in web development using <a href="http://www.test-king.com/exams/642-533.htm">testking 642-533</a> video tutorials and expert <a href="http://www.test-king.com/exams/70-536.htm">testking 70-536</a> study guide.</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.position-absolute.com/articles/posabsolute-css-framework-website-starter-kit/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Display your tweets in real time, a basic twitter API use.</title>
		<link>http://www.position-absolute.com/articles/display-your-tweet-in-real-time-a-basic-twitter-api-use/</link>
		<comments>http://www.position-absolute.com/articles/display-your-tweet-in-real-time-a-basic-twitter-api-use/#comments</comments>
		<pubDate>Mon, 03 Aug 2009 00:55:36 +0000</pubDate>
		<dc:creator>Cedric Dugas</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Javascript / jQuery]]></category>
		<category><![CDATA[Small Projects & plugins]]></category>
		<category><![CDATA[featured]]></category>

		<guid isPermaLink="false">http://www.position-absolute.com/?p=1271</guid>
		<description><![CDATA[<p>Recently I began optimizing social networking on Position Absolute, which lead me to the Twitter API. I wanted to display tweets in the top corner of the site. However I did not want to display my last tweet, but display&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>Recently I began optimizing social networking on Position Absolute, which lead me to the Twitter API. I wanted to display tweets in the top corner of the site. However I did not want to display my last tweet, but display my tweeting in real time.</p>
<h3>Real time ?</h3>
<p>This way I do not alienate frequent users with tweets pop-up. When you click on the appearing tweet box, it redirects you to my Twitter account.This is only a small JavaScript plug-in, so it unfortunately resorts to intervals, after 10 seconds it does an API call, after it happens every 30 seconds. By this time if I tweet something, it will appear to everyone on the site.</p>
<p>This may not seem much, but over time I think it may pay off.</p>
<p>One thing you must remember is that you can only call a maximum of 150 times per hour per person (a twitter limitation). For this reason, and for convenience, an interval of 30 seconds is necessary, more than that was a tad aggressive and this way you will never go over the limit. Also the demo is not linked to any Twitter account and faking the actual result.The downloadable version, however, is the same version used on this site.</p>
<p class="clearfix"><a class="demo" href="http://www.position-relative.net/creation/twitter/" target="_blank">View demo</a></p>
<h3>Now how it works</h3>
<p>Receiving your last tweet is really quite simple you call a JavaScript from Twitter like this:</p>
<div class="geshi no html">
<ol>
<li class="li1">
<div class="de1">&lt;script type=&quot;text/javascript&quot; src=&quot;http://twitter.com/statuses/user_timeline/PosAbsolute.json?callback=twitterCallback2&amp;count=1&quot;&gt;&lt;/script&gt;</div>
</li>
</ol>
</div>
<p>Hop, you got a callback, which is in fact a JavaScript function with a JSON of your last tweet as parameter. Of course you only receive one tweet because of the &#038;count=1. Now you want to call the Twitter API at a frequent interval, the response will automatically call the function twitterCallback2() each time:</p>
<div class="geshi no html">
<ol>
<li class="li1">
<div class="de1">setInterval(&quot;createJSONtweet(&#39;fdsfsd&#39;)&quot;,15000)
</div>
</li>
<li class="li1">
<div class="de1">function createJSONtweet(){ &nbsp; &nbsp;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;var getTweet = document.createElement(&quot;script&quot;);
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;getTweet.src=&quot;http://twitter.com/statuses/user_timeline/PosAbsolute.json?callback=twitterCallback2&amp; count=1&quot;;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;document.getElementById(&#39;twitter_script&#39;).appendChild(getTweet)
</div>
</li>
<li class="li1">
<div class="de1">}</div>
</li>
</ol>
</div>
<div class="geshi no html">
<ol>
<li class="li1">
<div class="de1">// You get this JSON from calling Twitter
</div>
</li>
<li class="li1">
<div class="de1">twitterCallback2([
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;{&quot;text&quot;:&quot;Just testing my new script that will show in real time my tweet on Pa, article to comes!&quot;,
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;&quot;in_reply_to_user_id&quot;:null,
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;&quot;user&quot;:
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; {&quot;description&quot;:&quot;A front-end developer in the javascript heaven and the IE6 hell.&quot;,
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &quot;utc_offset&quot;:-18000,
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &quot;profile_text_color&quot;:&quot;000000&quot;,
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &quot;screen_name&quot;:&quot;PosAbsolute&quot;,
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &quot;profile_background_image_url&quot;:&quot;http://s3.amazonaws.com/twitter_production/profile_background_images/7614536/bg_site.jpg&quot;,
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &quot;favourites_count&quot;:0,
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &quot;profile_link_color&quot;:&quot;4d5aff&quot;,
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &quot;profile_background_tile&quot;:false,
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &quot;followers_count&quot;:58,
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &quot;url&quot;:&quot;http://www.position-absolute.com&quot;,
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &quot;name&quot;:&quot;Cedric Dugas&quot;,
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &quot;statuses_count&quot;:71,
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &quot;created_at&quot;:&quot;Mon Apr 06 00:40:12 +0000 2009&quot;,
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &quot;profile_background_color&quot;:&quot;313131&quot;,
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &quot;protected&quot;:false,
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &quot;friends_count&quot;:17,
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &quot;verified&quot;:false,
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &quot;profile_sidebar_fill_color&quot;:&quot;dbdbdb&quot;,
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &quot;time_zone&quot;:&quot;Quito&quot;,
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &quot;following&quot;:null,
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &quot;profile_sidebar_border_color&quot;:&quot;ffffff&quot;,
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &quot;location&quot;:&quot;Montreal, Canada&quot;},
</div>
</li>
<li class="li1">
<div class="de1">&quot;favorited&quot;:false}]);
</div>
</li>
<li class="li1">
<div class="de1">&#8230;</div>
</li>
</ol>
</div>
<p>Getting your tweet from JSON is quite simple, tweet[0].text. As you can see, you can also get all sorts of cool informations.</p>
<p>The rest is a bit of jQuery and some CSS ( CSS included in js for convenience). </p>
<p>Add the last <a href="http://www.jquery.com">jQuery</a> version and jquery.tweetInterval.js to your website, change the Twitter account, tweetInterval(&#8220;twitterName&#8221;), and you got your tweets pop-up working automatically on your website.</p>
<p class="clearfix"><a class="download" href="http://www.position-relative.net/creation/twitter/jquery.tweetInterval.js">Download the source code</a> <a class="demo" href="http://www.position-relative.net/creation/twitter/" target="_blank">View demo</a></p>
<p><strong>Tested on:</strong><br />
Firefox 3+<br />
Internet Exploder 7<br />
Safari 4<br />
<strong>Limited support on IE6</strong> (You will need to do some CSS tweak)</p>
<p><br clear="all" /><br />
If you like and use this script, please consider buying me a beer, it&#8217;s cheap and a simple way to give back!</p>
<form style="text-align:left;" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input name="cmd" type="hidden" value="_s-xclick" />
<input name="encrypted" type="hidden" value="-----BEGIN PKCS7-----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-----END PKCS7-----" />
<input style="align:left" alt="PayPal - The safer, easier way to pay online!" name="submit" src="http://www.position-absolute.com/wp-content/themes/default/images/bg_buy.jpg" type="image" />
<img src="https://www.paypal.com/en_US/i/scr/pixel.gif" border="0" alt="" width="1" height="1" /><br />
</form>
<div class='ads' style="">
<strong>Ads</strong></p>
<p>
Get professional <a href="http://www.test-king.com/exams/70-236.htm">testking 70-236</a> training to become expert in web development. Using <a href="http://www.test-king.com/exams/70-663.htm">testking 70-663</a> study guides and <a href="http://www.test-king.com/exams/NS0-153.htm">testking NS0-153</a> web tutorials learn about all the basics of web development.</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.position-absolute.com/articles/display-your-tweet-in-real-time-a-basic-twitter-api-use/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
	</channel>
</rss>

