<?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>Ladysign Dev Blog &#187; javascript</title>
	<atom:link href="http://www.ladysign-apps.com/blog/category/code/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ladysign-apps.com/blog</link>
	<description>Girls can code.</description>
	<lastBuildDate>Mon, 12 Dec 2011 16:58:15 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Semicolons after javascript statements</title>
		<link>http://www.ladysign-apps.com/blog/code/javascript/semicolons-after-javascript-statements/</link>
		<comments>http://www.ladysign-apps.com/blog/code/javascript/semicolons-after-javascript-statements/#comments</comments>
		<pubDate>Mon, 12 Dec 2011 14:16:06 +0000</pubDate>
		<dc:creator>Lee</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://www.ladysign-apps.com/blog/?p=1030</guid>
		<description><![CDATA[<p>According to Javascript; the semicolon after a statement (for example a function), is optional.<br />
However, it&#8217;s much better to end your line with [......]</p><p class='read-more'><a href='http://www.ladysign-apps.com/blog/code/javascript/semicolons-after-javascript-statements/'>继续阅读</a></p>]]></description>
			<content:encoded><![CDATA[<p>According to Javascript; the semicolon after a statement (for example a function), is optional.<br />
However, it&#8217;s much better to end your line with a semicolon. A validator like JSLint for example, will throw a warning, even though<br />
the browser won&#8217;t, and accepts it.</p>
<p>See below, which strange things can happen when you won&#8217;t end your line with a semicolon.<br />
Javascript errors because of the order of javascript functions mixed with jQuery plugins&#8230;<br />
<a href="http://jsfiddle.net/bpsuW/11/">http://jsfiddle.net/bpsuW/11/</a></p>
<p>foo is a simple javascript function.<br />
Baz is a simple self running jQuery plugin. (because of the parentheses surrounding it).</p>
<p><code>foo = function(){<br />
    alert("function 1");<br />
}</p>
<p>(function(){<br />
    $.fn.Baz = function(opt){<br />
        alert("function 2");<br />
    }<br />
 })(jQuery)<br />
</code></p>
<p>See below the script, without strange javascript errors.<br />
<a href="http://jsfiddle.net/bpsuW/10/">http://jsfiddle.net/bpsuW/10/</a></p>
<p>The answer is really logical.<br />
Because there is no semicolon, the jQuery plugin (Baz) will directly execute, because of the parentheses.<br />
Like it&#8217;s a parameter of the javascript function you wrote before. (foo), and then throws errors.<br />
So:</p>
<p><code>foo(Baz)</code></p>
<p>When you mix your jQuery plugins with native javascript classes and functions in different orders; these kind of errors can happen.<br />
This scenario above shows you why you should <strong>always</strong> end your statements with a semicolon.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ladysign-apps.com/blog/code/javascript/semicolons-after-javascript-statements/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>jQuery does not load 3G iphone safari</title>
		<link>http://www.ladysign-apps.com/blog/code/javascript/jquery-does-not-load-3g-iphone-safari/</link>
		<comments>http://www.ladysign-apps.com/blog/code/javascript/jquery-does-not-load-3g-iphone-safari/#comments</comments>
		<pubDate>Wed, 17 Aug 2011 09:25:39 +0000</pubDate>
		<dc:creator>Lee</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[3G]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[jquery mobile]]></category>
		<category><![CDATA[O2]]></category>
		<category><![CDATA[parse errors]]></category>
		<category><![CDATA[safari]]></category>
		<category><![CDATA[t-mobile]]></category>

		<guid isPermaLink="false">http://www.ladysign-apps.com/blog/?p=1017</guid>
		<description><![CDATA[<p><strong>Difficulty:</strong> 3 out of 5 stars</p>
<p>Today I found out a very strange thing&#8230; My jQuery Mobile website doesn&#8217;t work on iPhone Safari in 3G mode. In[......]</p><p class='read-more'><a href='http://www.ladysign-apps.com/blog/code/javascript/jquery-does-not-load-3g-iphone-safari/'>继续阅读</a></p>]]></description>
			<content:encoded><![CDATA[<p><strong>Difficulty:</strong> 3 out of 5 stars</p>
<p>Today I found out a very strange thing&#8230; My jQuery Mobile website doesn&#8217;t work on iPhone Safari in 3G mode. In WIFI mode my page is fully loaded, and jQuery Mobile works fine.<br />
I enabled debug messages on my iPhone. And then I found out that jquery.min.js gives me parse errors.</p>
<p><strong>Parse errors jQuery.min.js</strong><br />
From jQuery 1.5 and higher..  You&#8217;ll receive parse errors in jQuery and therefore also jQuery Mobile can not be loaded. &#8211; And probably also not the other scripts that use jQuery.</p>
<pre class="brush: jscript; title: ;">
javascript parse error line 3.
Can't find variable jQuery.
</pre>
<p>The problem seems to be with the mobile carrier&#8217;s transparent proxy. In this case T-Mobile / O2.<br />
I tethered my phone so that I could browse on 3G and the file downloaded is completely different from that downloaded through my wired connection. Also, the downloaded files MD5 sums didn&#8217;t match!</p>
<p>Check this:<br />
3G:</p>
<pre class="brush: jscript; title: ;">
H TTP/1.1 200 OK
C ontent-Encoding: gzip
S erver: Apache/2.2.9 (Unix) PHP/5.2.6
E tag: &quot;360ce-164ce-4a4b742e336c0&quot;
A ccept-Ranges: bytes
C ontent-Type: application/javascript
A ge: 1317
D ate: Thu, 16 Jun 2011 14:56:25 GMT
L ast-Modified: Thu, 02 Jun 2011 09:28:35 GMT
E xpires: Fri, 17 Jun 2011 14:56:25 GMT
T ransfer-Encoding: chunked
</pre>
<p>Wired:</p>
<pre class="brush: jscript; title: ;">
H TTP/1.1 200 OK
D ate: Thu, 16 Jun 2011 15:29:06 GMT
S erver: Apache/2.2.9 (Unix) PHP/5.2.6
L ast-Modified: Thu, 02 Jun 2011 09:28:35 GMT
E tag: &quot;360ce-164ce-4a4b742e336c0&quot;
A ccept-Ranges: bytes
C ontent-Length: 91342
K eep-Alive: timeout=5, max=100
C onnection: Keep-Alive
C ontent-Type: application/javascript
</pre>
<p><strong>How to solve?</strong><br />
Don&#8217;t serve your jQuery file yourself but use a CDN like google:<br />
<strong>http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js</strong></p>
<p>This did the trick!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ladysign-apps.com/blog/code/javascript/jquery-does-not-load-3g-iphone-safari/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Google Visualization API with Typo3 &amp; FF3.6</title>
		<link>http://www.ladysign-apps.com/blog/code/javascript/google-visualization-api-with-typo3-ff3-6/</link>
		<comments>http://www.ladysign-apps.com/blog/code/javascript/google-visualization-api-with-typo3-ff3-6/#comments</comments>
		<pubDate>Wed, 08 Jun 2011 12:22:03 +0000</pubDate>
		<dc:creator>Lee</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[base href]]></category>
		<category><![CDATA[google chart]]></category>
		<category><![CDATA[google visualization]]></category>
		<category><![CDATA[Mootools]]></category>
		<category><![CDATA[typo3]]></category>

		<guid isPermaLink="false">http://www.ladysign-apps.com/blog/?p=1011</guid>
		<description><![CDATA[<p><strong>Difficulty:</strong> 4 out of 5 stars</p>
<p>I noticed this bug: my Google Visualization Charts were not working in FF3.6<br />
Strange enough it did work in all of the oth[......]</p><p class='read-more'><a href='http://www.ladysign-apps.com/blog/code/javascript/google-visualization-api-with-typo3-ff3-6/'>继续阅读</a></p>]]></description>
			<content:encoded><![CDATA[<p><strong>Difficulty:</strong> 4 out of 5 stars</p>
<p>I noticed this bug: my Google Visualization Charts were not working in FF3.6<br />
Strange enough it did work in all of the other browsers I tested (Chrome, FF4, IE7, IE8); deeping this problem down, I found out that Google Visualization Charts do work in FF3.6, but not when loaded from Typo3 CMS.<br />
Then I noticed that this bitch made the bug:</p>
<p><base href="path"> &#8211; Typo3 is setting a base path. The reason why Google Visualization API is buggy, is because they use relative paths.</p>
<p>Here&#8217;s the fix for Mootools:</p>
<pre class="brush: jscript; title: ;">
      google.setOnLoadCallback(drawChart);

		/**
		 * Google Visualization API crashes because of base href tag in TYPO3
		 * Quickfix
		 */
		function fixGoogleCharts(){
			var arrIframe = $(document.body).getElements('iframe[id*=Drawing_Frame_]');
		    arrIframe.each(function(el){
				var content = $(el).contentWindow.document.body;
				var arrG = ($(content).getElementsByTagName('g'));

				for(var i = 0; i&lt;arrG.length; i++){
					if(arrG[i].getAttribute('clip-path')) {
						arrG[i].setAttribute('clip-path', 'url(' + document.location + arrG[i].getAttribute('clip-path').substring(4))
					}
				}

		    });
		}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.ladysign-apps.com/blog/code/javascript/google-visualization-api-with-typo3-ff3-6/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Nice search field</title>
		<link>http://www.ladysign-apps.com/blog/code/css/nice-search-field/</link>
		<comments>http://www.ladysign-apps.com/blog/code/css/nice-search-field/#comments</comments>
		<pubDate>Wed, 02 Feb 2011 10:21:46 +0000</pubDate>
		<dc:creator>Lee</dc:creator>
				<category><![CDATA[css]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[search]]></category>
		<category><![CDATA[searchinput]]></category>

		<guid isPermaLink="false">http://www.ladysign-apps.com/blog/?p=1003</guid>
		<description><![CDATA[<p><strong>Difficulty:</strong> 3 out of 5 stars</p>
<p>Advanced HTML5 search field with placeholder and fallback for the other browsers.<br />
Styling with gradient + radius + image [......]</p><p class='read-more'><a href='http://www.ladysign-apps.com/blog/code/css/nice-search-field/'>继续阅读</a></p>]]></description>
			<content:encoded><![CDATA[<p><strong>Difficulty:</strong> 3 out of 5 stars</p>
<p>Advanced HTML5 search field with placeholder and fallback for the other browsers.<br />
Styling with gradient + radius + image in field.<br />
With JS logics: Search on input string and search on enter.</p>
<p>HTML:</p>
<pre class="brush: xml; title: ;">
&lt;fieldset class=&quot;search&quot;&gt;&lt;div class=&quot;inputsearchgroup&quot;&gt;
&lt;span class=&quot;search_icon&quot;&gt;&lt;/span&gt;
&lt;input type=&quot;hidden&quot; name=&quot;url&quot; value=&quot;search.php&quot;&gt;
&lt;input class=&quot;search&quot; type=&quot;search&quot; placeholder=&quot;Search...&quot; name=&quot;search&quot;&gt;&lt;/div&gt;
&lt;button class=&quot;smallradius submit&quot;&gt;Search&lt;/button&gt;
&lt;/fieldset&gt;
</pre>
<p>CSS:</p>
<pre class="brush: css; title: ;">
fieldset.search {
	border: none;
	padding: 0;
	position: relative;
}

fieldset.search input {
    -webkit-appearance: none;
    -webkit-box-sizing: content-box;
    background: none;
    background: -webkit-gradient(linear, left top, left bottom, from(rgba(250, 250, 250, 1)), to(rgba(250, 250, 250, 0)), color-stop(.3,rgba(250, 250, 250, 0))););
    background-image: -moz-linear-gradient(rgba(250, 250, 250, 1) 0%, rgba(255, 255, 255, 0) 30%);
    border: 1px solid #f2f2f3;
    float: left;
    margin-right: 5px;
    padding: 10px 0 10px 44px;
    background-color: #fff;
}

fieldset.search div.inputsearchgroup {
	position: relative;
	float: left;
}

fieldset.search div.inputsearchgroup span.search_icon {
	background: url(icon_search_glass.png) no-repeat 10px 7px;
	display: inline-block;
	position: absolute;
	top: 0;
	left: 0;
	width: 37px;
	height: 33px;
}

/*
 * CSS3
 */
.smallradius {
	-moz-border-radius: 3px;
	-webkit-border-radius: 3px;
	border-radius: 3px;
}
</pre>
<p>JS:</p>
<pre class="brush: jscript; title: ;">
(function(){
	/*
	 * jQuery PlaceHolder + Search Submit
	 * it submits the search query on enter button and on search button.
	 * place holder functionality for browsers which don't support placeholder
	 * @author Lee Boonstra
	 * @since 21 jan 2011
	 * @version 1.0
	 *
	 * @uses jQuery 1.2.6, &lt;http://www.jquery.com&gt; or higher
	 */
	$.fn.SearchInput = function(){
		var strSavedString = &quot;&quot;;

		/*
		 * Does the browser support placeholder attribute?
		 * @return boolean
		 */
		function isBrowserSupport(){
			var i = document.createElement(&quot;input&quot;);
			return &quot;placeholder&quot; in i;
		}
		return this.each(function(){
			var button = $(this).parent().parent().find('.submit');
			var url = $(this).parent().find('input[name|=url]').val();
			var e = $(this);

			var strPlaceHolderText = e.attr(&quot;placeholder&quot;);

			if(e.val().length == 0){
				e.val(strPlaceHolderText);
			}

			/*
			 * On field focus remove placeholder if there is no written text in it.
			 * @return void
			 */
			e.focus(function(){
				strSavedString = e.val();
				if (strSavedString === strPlaceHolderText) {
					e.val(&quot;&quot;);
				}
			});

			/*
			 * Save the written text in a variable
			 * @return void
			 */
			e.change(function(){
				strSavedString = e.val();
			});

			/*
			 * While leaving the focus of the field, put the placeholder back
			 * or the written text.
			 * @return void
			 */
			e.blur(function(){
				if(isBrowserSupport()===false){
					if(strSavedString !== strPlaceHolderText &amp;&amp; strSavedString !== &quot;&quot;){
						e.val(strSavedString);
					} else {
						e.val(strPlaceHolderText);
					}
				}
			});

			/*
			 * Search if the key is enter or button has been clicked,
			 * if there's a input hidden url and the input is not empty and does not contain the    placeholder
			 */
			function search(ev){
				if (ev.keyCode === 13 &amp;&amp; strSavedString !== strPlaceHolderText &amp;&amp; strSavedString !== &quot;&quot; &amp;&amp; url !== null) {
					window.location.href = url + &quot;?q=&quot; + strSavedString;
				}
				if(ev===&quot;click&quot; &amp;&amp; strSavedString !== strPlaceHolderText &amp;&amp; strSavedString !== &quot;&quot; &amp;&amp; url !== null){
					window.location.href = url + &quot;?q=&quot; + strSavedString;
				}
			}

			/*
			 * Submit the query
			 */
			e.keyup(function(ev){
				search(ev);
			})
			button.click(function(){
				search(&quot;click&quot;);
			});

		});

	};
})(jQuery);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.ladysign-apps.com/blog/code/css/nice-search-field/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sencha Touch app offline</title>
		<link>http://www.ladysign-apps.com/blog/code/javascript/sencha-touch-app-offline/</link>
		<comments>http://www.ladysign-apps.com/blog/code/javascript/sencha-touch-app-offline/#comments</comments>
		<pubDate>Wed, 29 Sep 2010 08:01:47 +0000</pubDate>
		<dc:creator>Lee</dc:creator>
				<category><![CDATA[ExtJs]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Ext Js]]></category>
		<category><![CDATA[ipad]]></category>
		<category><![CDATA[offline]]></category>
		<category><![CDATA[sencha touch]]></category>

		<guid isPermaLink="false">http://www.ladysign-apps.com/blog/?p=983</guid>
		<description><![CDATA[<p><strong>Difficulty:</strong> 3 out of 5 stars</p>
<p>This tutorial will help you to put your Sencha Touch ipad app offline.</p>
<p><strong>1. create your cache manifest file</strong><br />
create a file y[......]</p><p class='read-more'><a href='http://www.ladysign-apps.com/blog/code/javascript/sencha-touch-app-offline/'>继续阅读</a></p>]]></description>
			<content:encoded><![CDATA[<p><strong>Difficulty:</strong> 3 out of 5 stars</p>
<p>This tutorial will help you to put your Sencha Touch ipad app offline.</p>
<p><strong>1. create your cache manifest file</strong><br />
create a file yourappname.manifest in your application root.<br />
In the file enter all files you have to cache to make your app working offline.</p>
<p>for example the app.manifest file looks like this:</p>
<pre class="brush: jscript; title: ;">
CACHE MANIFEST
#rev2

# Explicitly cached entries
CACHE:
index.html

img/icon.png
img/phone_startup.png
img/tablet_startup.png
img/main-image.png

css/ext-touch.css
css/default.css

js/ext-touch-debug.js
js/ext-touch.js
js/index.js

# Resources that require the user to be online.
NETWORK:
js/twitter.js

#If source in inaccessible serve other file. for example: /index.php /index.html
FALLBACK:
</pre>
<p><strong>2. Add your manifest to your application .html file header</strong><br />
In your html file:</p>
<pre class="brush: xml; title: ;">
&lt;!doctype html&gt;
&lt;html manifest=&quot;yourappname.manifest&quot;&gt;
</pre>
<p><strong>3. Create a .htaccess file and add expire configuration for your *.manifest file to your app root.</strong></p>
<pre class="brush: jscript; title: ;">
&lt;Files yourappname.manifest&gt;
    ExpiresActive On
    ExpiresDefault &quot;access&quot;
&lt;/Files&gt;
</pre>
<p><strong>4. Add type manifest to your apache config (apache.conf / vhost.conf or .htaccess file)</strong></p>
<pre class="brush: jscript; title: ;">
AddType text/cache-manifest .manifest
</pre>
<p>That&#8217;s it, now your app should work offline.</p>
<p>You should know that, as soon as the manifest file fails with caching the files. It stops.<br />
That means that the files will not be updated.</p>
<p>Use this code to check/swap cache via code:</p>
<pre class="brush: jscript; title: ;">
var i = -1;

// Convenience array of status values
var cacheStatusValues = [];
 cacheStatusValues[0] = 'uncached';
 cacheStatusValues[1] = 'idle';
 cacheStatusValues[2] = 'checking';
 cacheStatusValues[3] = 'downloading';
 cacheStatusValues[4] = 'updateready';
 cacheStatusValues[5] = 'obsolete';

 // Listeners for all possible events
 var cache = window.applicationCache;
 cache.addEventListener('cached', logEvent, false);
 cache.addEventListener('checking', logEvent, false);
 cache.addEventListener('downloading', logEvent, false);
 cache.addEventListener('error', logEvent, false);
 cache.addEventListener('noupdate', logEvent, false);
 cache.addEventListener('obsolete', logEvent, false);
 cache.addEventListener('progress', logEvent, false);
 cache.addEventListener('updateready', logEvent, false);

 // Log every event to the console
 function logEvent(e) {
 	 i=i+1;
     var online, status, type, message;
     online = (isOnline()) ? 'yes' : 'no';
     status = cacheStatusValues[cache.status];
     type = e.type;
     message = 'online: ' + online;
     message+= ', event: ' + type;
     message+= ', status: ' + status;
     if (type == 'error' &amp;&amp; navigator.onLine) {
         message+= ' There was an unknown error, check your Cache Manifest.';
     }
     log(i + ' ' + message);
 }

 function log(s) {
    //alert(s);
	console.log(s);
 }

 function isOnline() {
     return navigator.onLine;
 }

 if (!$('html').attr('manifest')) {
    log('No Cache Manifest listed on the tag.')
 }

 // Swap in newly download files when update is ready
 cache.addEventListener('updateready', function(e){
         // Don't perform &quot;swap&quot; if this is the first cache
         if (cacheStatusValues[cache.status] != 'idle') {
             cache.swapCache();
             log('Swapped/updated the Cache Manifest.');
         }
     }
 , false);

 // These two functions check for updates to the manifest file
 function checkForUpdates(){
     cache.update();
 }
 function autoCheckForUpdates(){
     setInterval(function(){cache.update()}, 10000);
 }
</pre>
<p>More info&#8217;s, can be found here:<br />
<a href="http://developer.apple.com/library/safari/#documentation/iPhone/Conceptual/SafariJSDatabaseGuide/OfflineApplicationCache/OfflineApplicationCache.html">http://developer.apple.com/library/safari/#documentation/iPhone/Conceptual/SafariJSDatabaseGuide/OfflineApplicationCache/OfflineApplicationCache.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ladysign-apps.com/blog/code/javascript/sencha-touch-app-offline/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

