<?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/tag/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>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>Config LinkedIN Javascript API for multiple environments (OTAP)</title>
		<link>http://www.ladysign-apps.com/blog/code/api/config-linkedin-javascript-api-for-multiple-environments-otap/</link>
		<comments>http://www.ladysign-apps.com/blog/code/api/config-linkedin-javascript-api-for-multiple-environments-otap/#comments</comments>
		<pubDate>Tue, 01 Feb 2011 10:26:28 +0000</pubDate>
		<dc:creator>Lee</dc:creator>
				<category><![CDATA[api]]></category>
		<category><![CDATA[environments]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[linkedin]]></category>
		<category><![CDATA[otap]]></category>

		<guid isPermaLink="false">http://www.ladysign-apps.com/blog/?p=1001</guid>
		<description><![CDATA[<p><strong>Difficulty:</strong> 2 out of 5 stars</p>
<p>This is a solution how you can configure the LinkedIN Javascript API for multiple environments. For example OTAP.</p>
<p>First r[......]</p><p class='read-more'><a href='http://www.ladysign-apps.com/blog/code/api/config-linkedin-javascript-api-for-multiple-environments-otap/'>继续阅读</a></p>]]></description>
			<content:encoded><![CDATA[<p><strong>Difficulty:</strong> 2 out of 5 stars</p>
<p>This is a solution how you can configure the LinkedIN Javascript API for multiple environments. For example OTAP.</p>
<p>First register all environment API keys @ Linkedin:<br />
<a href="https://www.linkedin.com/secure/developer">https://www.linkedin.com/secure/developer</a><br />
If you have a Local, Test and Live environment, you should add 3 new applications to LinkedIn, containing the path to the environment.</p>
<p>Now let Javascript, detect the environment, and set you API_KEY.<br />
(change the keys in the code)</p>
<pre class="brush: plain; title: ;">
Properties = {
	init: function(){
		var url = window.location.href;
		if(url.indexOf(&quot;test&quot;) != -1){
			this.testEnv();
		} else if(url.indexOf(&quot;localhost&quot;) != -1) {
			this.localEnv();
		} else {
			this.liveEnv();
		}

	},
	liveEnv: function(){
		console.log(&quot;--LIVE--&quot;);
		Properties. API_KEY = &quot;LIVE-KEY-HERE&quot;;
		this.setScriptTag();
	},
	testEnv: function(){
		console.log(&quot;--TEST--&quot;);
		Properties.API_KEY = &quot;TEST-KEY-HERE&quot;;
		this.setScriptTag();
	},
	localEnv: function(){
		console.log(&quot;--LOCAL--&quot;);
		Properties.API_KEY = &quot;LOCAL_KEY_HERE&quot;;
		this.setScriptTag();
	},
	setScriptTag: function(){
		var script = document.createElement(&quot;script&quot;);
		script.setAttribute(&quot;type&quot;,&quot;text/javascript&quot;);
		script.setAttribute(&quot;src&quot;,&quot;http://platform.linkedin.com/in.js&quot;);
		script.setAttribute(&quot;id&quot;,&quot;linkedinScript&quot;);
		script.innerHTML = &quot;api_key:&quot; + Properties.API_KEY + &quot;\n authorize: true&quot;;
		document.getElementsByTagName('head')[0].appendChild(script);
	}
}
Properties.init();
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.ladysign-apps.com/blog/code/api/config-linkedin-javascript-api-for-multiple-environments-otap/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mash-ups with YQL</title>
		<link>http://www.ladysign-apps.com/blog/code/javascript/mash-ups-with-yql/</link>
		<comments>http://www.ladysign-apps.com/blog/code/javascript/mash-ups-with-yql/#comments</comments>
		<pubDate>Sat, 07 Nov 2009 11:00:32 +0000</pubDate>
		<dc:creator>Lee</dc:creator>
				<category><![CDATA[YUI Library]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[opensource]]></category>
		<category><![CDATA[corizon]]></category>
		<category><![CDATA[mash-ups]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[yql]]></category>

		<guid isPermaLink="false">http://www.ladysign-apps.com/blog/?p=923</guid>
		<description><![CDATA[<h5>&#8230;and why Corizon mashups suck.</h5>
<p><strong>Difficulty:</strong> 2 out of 5 stars<br />
It was because of working with Corizon that I became more interested in creating Mas[......]</p><p class='read-more'><a href='http://www.ladysign-apps.com/blog/code/javascript/mash-ups-with-yql/'>继续阅读</a></p>]]></description>
			<content:encoded><![CDATA[<h5>&#8230;and why Corizon mashups suck.</h5>
<p><strong>Difficulty:</strong> 2 out of 5 stars<br />
It was because of working with Corizon that I became more interested in creating Mash-ups*.<br />
During the last 2 years, I&#8217;ve seen a lot of mash-up tools, From the easy (&#8221;Lego-like&#8221;) Popfly from Microsoft which is recently discontinued, to large handy API&#8217;s or serverside Java frameworks; such as the nice but heavy <a title="SiteMesh" href="http://www.opensymphony.com/sitemesh/" id="i2v4">SiteMesh</a> framework.<br />
But it was the <a href="http://www.corizon.com/">Corizon mash-up</a> toolkit that I started to realize, coding mash-ups can have it&#8217;s ups and downs.</p>
<p>In my opinion creating a mash-up should be easy &amp; fast. Not buggy and heavy (running 2 or 3 Tomcat servers in the background *kuch*). Also it&#8217;s an unwritten rule that for a mash-up you should not first destroy and rebuild it&#8217;s components before you gonna mix them up. This means you can only mash-up content what&#8217;s in your maintenance and when one of your components changes, your mash-up is broken.<br />
It&#8217;s not a wonder that I became extremely positive about YQL, when I first saw this working.<br />
And now, after <a href="http://www.fronteers.nl">Fronteers 2009</a>, where I had a presentation and talk with <a href="http://icant.co.uk">Chris Heilmann</a> from Yahoo.</p>
<p>With YQL (Yahoo Query Language), you can make the same mash-ups, client or serverside and you don&#8217;t need thousands lines of code.<br />
<b>Why you should use YQL for a mash-up?</b></p>
<ul>
<li>You won’t use your own bandwidth, but the bandwidth from Yahoo.</li>
<li>It’s easy, just the basic SQL knowledge is required.</li>
<li>It’s lightweight.</li>
<li>It’s fast.</li>
</ul>
<p>But like every Mashup tool, there are also downside&#8217;s. So it&#8217;s good to consider:</p>
<p><b>Why you shouldn&#8217;t use YQL for a mash-up?</b></p>
<ul>
<li>When one of the including components is slow or has timeouts, you result object will be <strong>null</strong>.</li>
</ul>
<h5>Mash-ups with YQL</h5>
<p>Ok enough with the theory. Let&#8217;s practice with a simple YQL mash-up. As you might know, I like videogames. So I want to have a website with the release dates of games on my website, which I can watch on YouTube. Fokzine Games (<a href="http://games.fok.nl/overzicht.php?action=release">http://games.fok.nl/overzicht.php?action=release</a>) has a nice game release list.</p>
<ul>
<li>For using this tutorial, you will need a Yahoo Developer Account, which you can create for free. </li>
<li>Unless you like to write full XPath lines without any help,<br />
you’ll also need <a title="Mozilla Firefox" href="http://www.mozilla-europe.org/nl/firefox/" id="me3x">Mozilla Firefox</a> browser with the <a title="Firebug" href="https://addons.mozilla.org/en-US/firefox/addon/1843" id="f_1b">Firebug</a> plugin installed.</li>
</ul>
<ol>
<li><b>Register your Yahoo Dev account.</b><br />
Go to the below URL, register your Yahoo account and login<br />
to the YQL console:&nbsp;<a href="http://developer.yahoo.com/yql/console/" target="_blank">http://developer.yahoo.com/yql</a>
</li>
<li><b>Query the content.</b><br />
YQL is quite similar to SQL. To query content (the videogame<br />
release list) from an external website, I will select all the HTML nodes from an URL. With Xpath I can point to the part of the website I will need. (Now you’ll need Firebug, inspect the website, till you’ll reach the table tag of the release list. – In top of your Firebug screen, you will see the full Xpath line.<br />
– Just right click, and “Copy Xpath”. This will be your YQL query for selecting the table tag on Fok.nl Game Release Page:</p>
<pre class="brush: sql; title: ;">
select * from html where url ='http://games.fok.nl/overzicht.php?action=release' and xpath ='//*[@id=&quot;itemtext&quot;]'
//or select the tr tag on Fok.nl Game Release page
//(note that I removed “tbody” from the xpath line to make it work)
select * from html where url ='http://games.fok.nl/overzicht.php?action=release' and xpath ='/html/body/div[4]/table/tr/td[2]/div[2]/div/table/tr'
</pre>
<p>Hit enter (or press “Test”) and you can switch between formatted view or tree view to see the result. Result can be in XML of JSON.<br />
Also note that you can copy the REST URL Query, from the console:<br />
<strong><br />
http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20html%20where%20url%20%3D%20&#8242;http%3A%2F%2Fgames.fok.nl%2Foverzicht.php%3Faction%3Drelease&#8217;%20and%20xpath%20%3D%20&#8242;%2Fhtml%2Fbody%2Fdiv%5B4%5D%2Ftable%2Ftr%2Ftd%5B2%5D%2Fdiv%5B2%5D%2Fdiv%2Ftable%2Ftr&#8217;&amp;format=xml<br />
</strong><br />
<img src="yql.jpg" alt="YQL Console" />
</li>
<li>
<b>How the retrieved XML looks like:</b></p>
<pre class="brush: xml; title: ;">&lt;query xmlns:yahoo=&quot;http://www.yahooapis.com/v1/base.rng&quot;yahoo:count=&quot;50&quot; yahoo:created=&quot;2009-09-25T12:14:12Z&quot;yahoo:lang=&quot;en-US&quot; yahoo:updated=&quot;2009-09-25T12:14:12Z&quot;
yahoo:uri=&quot;http://query.yahooapis.com/v1/yql?q=select+*+from+html+where+url+%3D+%27http%3A%2F%2Fgames.fok.nl%2Foverzicht.php%3Faction%3Drelease%27+and+xpath+%3D+%27%2Fhtml%2Fbody%2Fdiv%5B4%5D%2Ftable%2Ftr%2Ftd%5B2%5D%2Fdiv%5B2%5D%2Fdiv%2Ftable%2Ftr%27&quot;&gt;
&lt;diagnostics&gt;
&lt;publiclyCallable&gt;true&lt;/publiclyCallable&gt;
&lt;url execution-time=&quot;263&quot; proxy=&quot;DEFAULT&quot;&gt;&lt;![CDATA[http://games.fok.nl/overzicht.php?action=release]]&gt;&lt;/url&gt;
&lt;user-time&gt;272&lt;/user-time&gt;
&lt;service-time&gt;263&lt;/service-time&gt;
&lt;build-version&gt;3130&lt;/build-version&gt;
&lt;/diagnostics&gt;
&lt;results&gt;
 &lt;tr bgcolor=&quot;#E0E0E0&quot;&gt;
  &lt;td&gt;
   &lt;img alt=&quot;PC&quot; src=&quot;http://images.fok.nl/ads/games/IB_PC.png&quot;/&gt;
  &lt;/td&gt;
  &lt;td&gt;
   &lt;p&gt;29-09-2009&lt;/p&gt;
  &lt;/td&gt;
  &lt;td&gt;
   &lt;a class=&quot;invisiblelink&quot; href=&quot;gameinfo.php?gameid=9985&quot;&gt;Tales of Monkey Island episode 3&lt;/a&gt;
  &lt;/td&gt;
 &lt;/tr&gt;
  ..
&lt;/results&gt;
&lt;/query&gt;</pre>
<p><b>How your JSON (Javascript object looks like:</b></p>
<pre class="brush: jscript; title: ;">releaseList({
 &quot;query&quot;:{
 &quot;count&quot;:&quot;50&quot;,
 &quot;created&quot;:&quot;2009-09-25T12:10:17Z&quot;,
 &quot;lang&quot;:&quot;en-US&quot;,
 &quot;updated&quot;:&quot;2009-09-25T12:10:17Z&quot;,
 &quot;uri&quot;:&quot;http://query.yahooapis.com/v1/yql?q=select+*+from+html+where+url+%3D+%27http%3A%2F%2Fgames.fok.nl%2Foverzicht.php%3Faction%3Drelease%27+and+xpath+%3D+%27%2Fhtml%2Fbody%2Fdiv%5B4%5D%2Ftable%2Ftr%2Ftd%5B2%5D%2Fdiv%5B2%5D%2Fdiv%2Ftable%2Ftr%27&quot;,
 &quot;diagnostics&quot;:{
  &quot;publiclyCallable&quot;:&quot;true&quot;,
  &quot;url&quot;:{
   &quot;execution-time&quot;:&quot;28&quot;,
   &quot;proxy&quot;:&quot;DEFAULT&quot;,
   &quot;content&quot;:&quot;http://games.fok.nl/overzicht.php?action=release&quot;
  },
 &quot;user-time&quot;:&quot;36&quot;,
 &quot;service-time&quot;:&quot;28&quot;,
 &quot;build-version&quot;:&quot;3130&quot;
 },
&quot;results&quot;:{
 &quot;tr&quot;:[{
 &quot;bgcolor&quot;:&quot;#E0E0E0&quot;,
 &quot;td&quot;:[.. ]
 }
..
 ]
}}});</pre>
</li>
<li><b>Use the YQL widget.</b><br />
Create a new HTML page. In this page, you&#8217;ll include the YQL JS Widget:<br />
<a href="http://github.com/sh1mmer/dotnet-yql-tutorial/blob/master/yql_js_widget.js" target="_blank">http://github.com/sh1mmer/dotnet-yql-tutorial/blob/master/yql_js_widget.js</a><br />
This is a pre-made Javascript widget. If you check out the links on the end of this article, you can check out other implementations as well. (Such as Dojo-YQL or JQuery YQL).<br />
For this article, we will use vanilla Javascript.</li>
<li><b>Create the Mash-up.</b><br />
The only think what you&#8217;ll need now is the logic to implement the previous made YQL query, to have the YQL results in your Document Object Model (DOM).<br />
With the Firebug plug-in, you can check the &#8220;Net&#8221; tab, to see if the correct object is retrieved. You can walk through the results, and implement it in your Javascript to do fancy things with it.</li>
<pre class="brush: xml; title: ;">
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;YQL - Game Release&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;yql-js-widget.js&quot; &gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
var config = {};
var format = '&lt;li class=&quot;{td[0].img.alt}&quot;&gt;{td[1].p} - &lt;a href=&quot;http://games.fok.nl/{td[2].a.href}&quot; target=&quot;_blank&quot;&gt;{td[2].a.content}&lt;/a&gt; - &lt;a href=&quot;http://www.youtube.com/results?search_query={td[2].a.content}&quot; target=&quot;_blank&quot;&gt;Watch on YouTube&lt;/a&gt;&lt;/li&gt;';
var gameQuery = &quot;select * from html where url = 'http://games.fok.nl/overzicht.php?action=release' and xpath = '/html/body/div[4]/table/tr/td[2]/div[2]/div/table/tr'&quot;;
yqlWidget.push(gameQuery, config, format, &quot;widgetContainer&quot;);
yqlWidget.render();
&lt;/script&gt;&lt;ul id=&quot;widgetContainer&quot;&gt;&lt;/ul&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>Well that&#8217;s it. See how easy it is to create a nice Mash-up? As long as you can reach the DOM, you can mash-up everything. Below my article, I&#8217;ve written some nice links. If you liked my article or you would like to discuss with me about YQL or Mash-up technologies; feel free to add me on <a title="LinkedIn" href="http://www.linkedin.com/in/leeboonstra" id="a93_">LinkedIn</a> or <a title="Twitter" href="http://twitter.com/ladysign" id="e:f5">Twitter</a>.</p>
<ul>
<li>YQL Community:<a href="http://github.com/yql/" target="_blank"> http://github.com/yql/</a></li>
<li>YQL video by Jonathan LeBlanc: <a href="http://developer.yahoo.com/yui/theater/video.php?v=leblanc-yql" target="_blank">http://developer.yahoo.com/yui/theater/video.php?v=leblanc-yql</a></li>
</ul>
<h6>* In webdevelopment, a mashup is a web page or application that combines<br />
data or functionality from two or more external sources to create a new<br />
service. An example of a Mash-up is a Google Map combined with Wikipedia<br />
town information and a (accuweather.com) Weather indicator.</h6>
</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.ladysign-apps.com/blog/code/javascript/mash-ups-with-yql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Invoke a Java Servlet with Javascript</title>
		<link>http://www.ladysign-apps.com/blog/code/javascript/invoke-a-java-servlet-with-javascript/</link>
		<comments>http://www.ladysign-apps.com/blog/code/javascript/invoke-a-java-servlet-with-javascript/#comments</comments>
		<pubDate>Thu, 20 Aug 2009 15:05:31 +0000</pubDate>
		<dc:creator>Lee</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[request]]></category>
		<category><![CDATA[servlet]]></category>

		<guid isPermaLink="false">http://ladysign-apps.com/blog/?p=830</guid>
		<description><![CDATA[<p><strong>Difficulty:</strong> 3 out of 5 stars<br />
It is possible to invoke a Java Servlet from your Javascript.<br />
Just implement this code. Please see the comments in the fu[......]</p><p class='read-more'><a href='http://www.ladysign-apps.com/blog/code/javascript/invoke-a-java-servlet-with-javascript/'>继续阅读</a></p>]]></description>
			<content:encoded><![CDATA[<p><strong>Difficulty:</strong> 3 out of 5 stars<br />
It is possible to invoke a Java Servlet from your Javascript.<br />
Just implement this code. Please see the comments in the function.</p>
<pre class="brush: jscript; title: ;">var request;
/*
 * doRequest
 * param servletName - Javascript String, Servlet name (as implemented in your config)
 * param servletArguments - Javascript String, any parameters
 */
function doSomeRequest(servletName, servletArguments){
    var servlet = servletName;
    var arg = servletArguments;
    var req = servlet + &quot;?&quot; + arg;

    addRequest(req);
    request.onreadystatechange = function(){
        //do something with the response
    }
}

function addRequest(req) {
    try {   //create a request for netscape, mozilla, opera, etc.
        request = new XMLHttpRequest();
    }catch (e) {

        try {    //create a request for internet explorer
            request = new ActiveXObject(&quot;Microsoft.XMLHTTP&quot;);
        }catch (e) {   //do some error-handling
            alert(&quot;XMLHttpRequest error: &quot; + e);
        }
    }

    request.open(&quot;GET&quot;, req, true);   //prepare the request
    request.send(null);   //send it
    return request;   //return the request
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.ladysign-apps.com/blog/code/javascript/invoke-a-java-servlet-with-javascript/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Cookies in Javascript</title>
		<link>http://www.ladysign-apps.com/blog/code/javascript/cookies-in-javascript/</link>
		<comments>http://www.ladysign-apps.com/blog/code/javascript/cookies-in-javascript/#comments</comments>
		<pubDate>Wed, 08 Jul 2009 15:10:00 +0000</pubDate>
		<dc:creator>Lee</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[cookies]]></category>

		<guid isPermaLink="false">http://ladysign-apps.com/blog/?p=791</guid>
		<description><![CDATA[<p><strong>Difficulty:</strong> 2 out of 5 stars<br />
A cookie (also tracking cookie, browser cookie, and HTTP cookie) is a small string of text stored on a user&#8217;s compu[......]</p><p class='read-more'><a href='http://www.ladysign-apps.com/blog/code/javascript/cookies-in-javascript/'>继续阅读</a></p>]]></description>
			<content:encoded><![CDATA[<p><strong>Difficulty:</strong> 2 out of 5 stars<br />
A cookie (also tracking cookie, browser cookie, and HTTP cookie) is a small string of text stored on a user&#8217;s computer by a web browser. A cookie consists of one or more name-value pairs containing bits of information.<br />
Beside the name/value pair, a cookie may also contain an expiration date, a path, a domain name, and whether the cookie is intended only for encrypted connections. These pieces of data follow the name=newvalue pair and are separated by semicolons. For example, a cookie can be created by the server by sending a line </p>
<pre class="brush: jscript; title: ;">Set-Cookie: name=newvalue; expires=date; path=/; domain=.example.org.</pre>
<p>With Javascript you can also set cookies. It&#8217;s not hard at all. I think it&#8217;s useful for folding/unfolding or hiding/displaying CSS content. This part of Javascript I wrote for setting, getting and deleting a cookie:</p>
<pre class="brush: jscript; title: ;">/*
* Set the cookie
* @param name - the name of the cookie variable
* @param value - the value of the variable which will be saved in the cookie.
* @expires - the
*/
function setCookie(name, value, expires) {
	var today = new Date();  //set new date object
	var defaultDays = 30;
	today.setTime(today.getTime());
	if (expires) {
		expires = expires * 1000 * 60 * 60 * 24;
	}else{
		expires = defaultDays * 1000 * 60 * 60 * 24;
	}

	document.cookie = name + &quot;=&quot; + escape(value) +
        &quot;; path=/&quot; + ((expires == null) ? &quot;&quot; : &quot;; expires=&quot; +
        expires.toGMTString());
}

/*
 * Get Cookie
 * @param: name of the cookie variable you would like to retrieve
 */
function getCookie(name) {
	var cookieValue = null;
	var startPos = document.cookie.indexOf(name+&quot;=&quot;);
	var lengthVal = startPos + name.length + 1;

	if((startPos)&amp;&amp;(startPos&gt;0)&amp;&amp;
        (name == document.cookie.substring(0, name.length))){
		var endPos = document.cookie.indexOf( &quot;;&quot;, lengthVal);

		if (endPos == -1){
			endPos = document.cookie.length;
		}
		cookieValue = unescape(
                   document.cookie.substring(lengthVal, endPos)
                );
	}

	return cookieValue;
}

/*
 * Delete Cookie
 * @param delete the cookie variable by passing the name
 */
function delCookie(name) {
    document.cookie = name +
    &quot;=; expires=Thu, 01-Jan-70 00:00:01 GMT&quot; + &quot;; path=/&quot;;
} </pre>
]]></content:encoded>
			<wfw:commentRss>http://www.ladysign-apps.com/blog/code/javascript/cookies-in-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

