<?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>Jure Cuhalev &#187; javascript</title>
	<atom:link href="http://www.jurecuhalev.com/blog/category/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jurecuhalev.com/blog</link>
	<description>In pursuit of The Idea</description>
	<lastBuildDate>Sat, 28 Jan 2012 22:22:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="http://superfeedr.com/hubbub"/>		<item>
		<title>Marko Samastur &#8211; Easy deployment of site-extensions with a browser plugin [firefox3 launch party notes]</title>
		<link>http://www.jurecuhalev.com/blog/2008/06/24/marko-samastur-easy-deployment-of-site-extensions-with-a-browser-plugin-firefox3-launch-party-notes/</link>
		<comments>http://www.jurecuhalev.com/blog/2008/06/24/marko-samastur-easy-deployment-of-site-extensions-with-a-browser-plugin-firefox3-launch-party-notes/#comments</comments>
		<pubDate>Tue, 24 Jun 2008 17:06:53 +0000</pubDate>
		<dc:creator>Jure Cuhalev</dc:creator>
				<category><![CDATA[conferences]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[Application programming interface]]></category>
		<category><![CDATA[Cascading Style Sheets]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Document Object Model]]></category>
		<category><![CDATA[FAQs  Help  and Tutorials]]></category>
		<category><![CDATA[Languages]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Style Sheets]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web page]]></category>
		<category><![CDATA[Website]]></category>
		<category><![CDATA[zemanta]]></category>

		<guid isPermaLink="false">http://www.jurecuhalev.com/blog/?p=171</guid>
		<description><![CDATA[


Image by ccmerino via Flickr

Marko Samastur &#8211; Easy deployment of site-extensions with a browser plugin.
Starting with Zemanta presentation, since it&#8217;s relevant for the presentation. Zemanta is a tool for contextual matching for blogging platforms and has to support a wide variety of platforms.
The limitations of XHR was a problem because of limitations of security-model that [...]
Related posts:<ol>
<li><a href='http://www.jurecuhalev.com/blog/2008/06/24/zbigniew-braniecki-the-power-of-communities-firefox3-release-party-notes/' rel='bookmark' title='Zbigniew Braniecki &#8211; the power of communities [firefox3 release party notes]'>Zbigniew Braniecki &#8211; the power of communities [firefox3 release party notes]</a></li>
<li><a href='http://www.jurecuhalev.com/blog/2008/06/24/gorazd-golob-firefox-extensions-and-what-we-have-to-do-with-them-firefox-3-release-party-notes/' rel='bookmark' title='Gorazd Golob &#8211; Firefox extensions and what we have to do with them [firefox 3 release party notes]'>Gorazd Golob &#8211; Firefox extensions and what we have to do with them [firefox 3 release party notes]</a></li>
<li><a href='http://www.jurecuhalev.com/blog/2009/01/07/marko-mrdjenovic-im-posh-are-you/' rel='bookmark' title='Marko Mrdjenovic: I&#8217;m POSH are you?'>Marko Mrdjenovic: I&#8217;m POSH are you?</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><a title="Blog better using Zemanta" href="http://www.flickr.com/photos/79989800@N00/2516113621/" target="_blank"><br />
</a><small><a title="chucks" href="http://www.flickr.com/photos/79989800@N00/2516113621/" target="_blank"></a></small></p>
<div class="zemanta-img" style="margin: 1em; float: right; display: block;"><a href="http://www.flickr.com/photos/11335742@N03/2608025430/"><img style="border: medium none; display: block;" src="http://farm4.static.flickr.com/3122/2608025430_0ef1c8080c_m.jpg" alt="Description unavailable" /></a></p>
<p class="zemanta-img-attribution">Image by <a href="http://www.flickr.com/photos/11335742@N03/2608025430/">ccmerino</a> via Flickr</p>
</div>
<p><a href="http://markos.gaivo.net/">Marko Samastur</a> &#8211; Easy deployment of site-extensions with a browser plugin.</p>
<p>Starting with <a class="zem_slink" title="Zemanta ltd." rel="homepage" href="http://www.zemanta.com">Zemanta</a> presentation, since it&#8217;s relevant for the presentation. Zemanta is a tool for contextual matching for blogging platforms and has to support a wide variety of platforms.</p>
<p>The limitations of <a class="zem_slink" title="XMLHttpRequest" rel="wikipedia" href="http://en.wikipedia.org/wiki/XMLHttpRequest">XHR</a> was a problem because of limitations of security-model that doesn&#8217;t allow cross-domain POST requests. In case of Zemanta, we can use custom-build JavaScript function.</p>
<p><strong>When to use extension?</strong></p>
<p>When web-site as such, doesn&#8217;t provide integration points (e.g., <a class="zem_slink" title="Blogger (service)" rel="homepage" href="http://www.blogger.com/">Blogger.com</a> platform), the other reason is if you want to use functionality that is not available within the normal browser window.</p>
<p>Process</p>
<p>First thing that you need to do, is that you need to find a place for widget. In case of Zemanta, we used right side widget. In this case, we used CSS and made it a bit narrow.</p>
<p><a title="Blog better using Zemanta" href="http://www.flickr.com/photos/79989800@N00/2516113621/" target="_blank"><img src="http://farm3.static.flickr.com/2354/2516113621_7b86f4fc75_m.jpg" border="0" alt="Blog better using Zemanta" /></a><br />
<small><a title="Attribution-NonCommercial-NoDerivs License" href="http://creativecommons.org/licenses/by-nc-nd/2.0/" target="_blank"><img src="http://www.jurecuhalev.com/blog/wp-content/plugins/photo_dropper/images/cc.png" border="0" alt="Creative Commons License" width="16" height="16" align="absmiddle" /></a> <a href="http://www.photodropper.com/photos/" target="_blank">photo</a> credit: <a title="chucks" href="http://www.flickr.com/photos/79989800@N00/2516113621/" target="_blank">chucks</a></small></p>
<p>But wherever you go, CSS selectors that you use, will most probably match styles of the platform. So if you use a widget on different platforms.</p>
<p>You can conquer this within CSS by writing selectors that are more binding than the default way. The one that we did (and is not the best way), we use a platfora of id&#8217;s and classes and then we use these names and classes that get injected into web-page and are more binding than the platform ones. This one works great if you use two files: general one and platform specific one.</p>
<p>Second way is to use nesting and &#8220;id envelops&#8221; &#8211; encapsulation and while it&#8217;s ugly, it&#8217;s the best way:</p>
<p><code>#zem1 #zem2 #zem3 h3 {</code></p>
<p>}</p>
<p>the second thing that you should try to use is microformats. After you put your widget into the page, you usually want that widget to do something, and for that we normally use Javascript.</p>
<p><strong>Javascript problems</strong></p>
<p>The variety of problems is large, but a short selection:</p>
<p><strong>Extending Object and Array</strong> &#8211; it sounds a good idea in a start, but it&#8217;s a major problem down the road. It&#8217;s usually a bad idea that many JavaScript libraries (like JQuery), use Objects as configuration buckets and if you extend it, it means that all objects will have this and bad things will happen.</p>
<p>The second thing is, that if you have a web-site and you want to have it &#8220;extendable&#8221;, it&#8217;s a good idea not to step all over their feet and potential code.</p>
<p><strong>Private name-spaces</strong> &#8211; either through <a class="zem_slink" title="Anonymous function" rel="wikipedia" href="http://en.wikipedia.org/wiki/Anonymous_function">anonymous functions</a> or through object hierarchy. The problem is that sometimes you want to change behaviour of methods that are hidden behind namespaces (e.g., changing how dragging boxes works in 2.3 WordPress).</p>
<p><strong>One thread implication</strong>: what comes later can rely on what came before. It&#8217;s not always true, because JavaScript API&#8217;s like <a class="zem_slink" title="Document Object Model" rel="wikipedia" href="http://en.wikipedia.org/wiki/Document_Object_Model">DOM</a> functions doesn&#8217;t always run in the same thread.</p>
<p>While you can do is to test your JavaScript on slow browser and computers, and on different connections. But this is often not enough, so you should actively protect from this and check to make sure the code and functions are there before you call them.</p>
<p><strong>Useful tools for extension creation</strong></p>
<p>Firefox extension Wizard &#8211; <a href="http://ted.mielczarek.org/code/mozilla/extensionwiz/">http://ted.mielczarek.org/code/mozilla/extensionwiz/</a></p>
<p>FUEL &#8211; <a href="http://developer.mozilla.org/en/docs/FUEL">http://developer.mozilla.org/en/docs/FUEL</a></p>
<p>Besttoolbars &#8211; <a href="http://www.besttoolbars.net/">http://www.besttoolbars.net/</a></p>
<fieldset class="zemanta-related">
<legend>Related articles</legend>
<ul class="zemanta-article-ul">
<li class="zemanta-article-ul-li"><a title="Open in new window" href="http://urbanskudnik.blogspot.com/2008/02/cross-domain-xmlhttprequest.html">Cross-domain XMLHttpRequest</a> [viaÂ Zemanta]</li>
<li class="zemanta-article-ul-li"><a title="Open in new window" href="http://blogs.msdn.com/ie/archive/2008/06/23/securing-cross-site-xmlhttprequest.aspx">Securing Cross Site XMLHttpRequest</a> [viaÂ Zemanta]</li>
<li class="zemanta-article-ul-li"><a title="Open in new window" href="http://www.poynter.org/column.asp?id=31&amp;aid=141476">Zemanta Tools for Bloggers: Two Reviews</a> [viaÂ Zemanta]</li>
</ul>
</fieldset>
<div class="zemanta-pixie" style="margin-top: 10px; height: 15px;"><a class="zemanta-pixie-a" title="Zemified by Zemanta" href="http://reblog.zemanta.com/zemified/a06bf79d-402f-41b5-9015-90859e5eed9e/"><img class="zemanta-pixie-img" style="border: medium none; float: right;" src="http://img.zemanta.com/reblog_c.png?x-id=a06bf79d-402f-41b5-9015-90859e5eed9e" alt="Zemanta Pixie" /></a></div>
<p>Related posts:<ol>
<li><a href='http://www.jurecuhalev.com/blog/2008/06/24/zbigniew-braniecki-the-power-of-communities-firefox3-release-party-notes/' rel='bookmark' title='Zbigniew Braniecki &#8211; the power of communities [firefox3 release party notes]'>Zbigniew Braniecki &#8211; the power of communities [firefox3 release party notes]</a></li>
<li><a href='http://www.jurecuhalev.com/blog/2008/06/24/gorazd-golob-firefox-extensions-and-what-we-have-to-do-with-them-firefox-3-release-party-notes/' rel='bookmark' title='Gorazd Golob &#8211; Firefox extensions and what we have to do with them [firefox 3 release party notes]'>Gorazd Golob &#8211; Firefox extensions and what we have to do with them [firefox 3 release party notes]</a></li>
<li><a href='http://www.jurecuhalev.com/blog/2009/01/07/marko-mrdjenovic-im-posh-are-you/' rel='bookmark' title='Marko Mrdjenovic: I&#8217;m POSH are you?'>Marko Mrdjenovic: I&#8217;m POSH are you?</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.jurecuhalev.com/blog/2008/06/24/marko-samastur-easy-deployment-of-site-extensions-with-a-browser-plugin-firefox3-launch-party-notes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TextMate tip: Making single apostrophes double</title>
		<link>http://www.jurecuhalev.com/blog/2007/11/30/textmate-tip-making-single-apostrophes-double/</link>
		<comments>http://www.jurecuhalev.com/blog/2007/11/30/textmate-tip-making-single-apostrophes-double/#comments</comments>
		<pubDate>Fri, 30 Nov 2007 17:42:24 +0000</pubDate>
		<dc:creator>Jure Cuhalev</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[Planet Kiberpipa]]></category>
		<category><![CDATA[Planet LiveCD]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[apostrophe]]></category>
		<category><![CDATA[bundles]]></category>
		<category><![CDATA[double-apostrophe]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[TextMate]]></category>
		<category><![CDATA[tip]]></category>

		<guid isPermaLink="false">http://www.jurecuhalev.com/blog/2007/11/30/textmate-tip-making-single-apostrophes-double/</guid>
		<description><![CDATA[Coming from Python world where most of text is in double apostrophes like:

"Hello world"

to  JavaScript  where, e.g.  jQuery , expects you to write:

$('#foobar')

with single quotes, it can be quite annoying to always have to type it twice, since for double quotes (&#8220;),  TextMate  it always does it automatically. This feature [...]
Related posts:<ol>
<li><a href='http://www.jurecuhalev.com/blog/2007/10/12/double-bind-for-better-this-experience/' rel='bookmark' title='Double bind() for better `this` experience'>Double bind() for better `this` experience</a></li>
<li><a href='http://www.jurecuhalev.com/blog/2008/05/22/caspar-berry-risk-taking-and-decision-making-professional-poker-player-thinking-digital-session-notes/' rel='bookmark' title='Caspar Berry &#8211;  Risk Taking and Decision Making, Professional Poker player [Thinking digital session notes]'>Caspar Berry &#8211;  Risk Taking and Decision Making, Professional Poker player [Thinking digital session notes]</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><img src="http://upload.wikimedia.org/wikipedia/commons/thumb/1/1c/Quotation_Marks.svg/200px-Quotation_Marks.svg.png" class="zem_image" alt="image" style="margin: 5px; float: right" height="142" width="200" />Coming from Python world where most of text is in double apostrophes like:</p>
<p><code><br />
"Hello world"<br />
</code></p>
<p>to <a href="http://en.wikipedia.org/wiki/JavaScript" title="JavaScript" class="zem_slink"> JavaScript </a> where, e.g. <a href="http://en.wikipedia.org/wiki/JQuery" title="JQuery" class="zem_slink"> jQuery </a>, expects you to write:</p>
<p><code><br />
$('#foobar')<br />
</code></p>
<p>with single quotes, it can be quite annoying to always have to type it twice, since for double quotes (&#8220;), <a href="http://en.wikipedia.org/wiki/TextMate" title="TextMate" class="zem_slink"> TextMate </a> it always does it automatically. This feature is called <a href="http://macromates.com/textmate/manual/working_with_text#auto-paired_characters_quotes_etc">Auto-Paired Characters</a>.</p>
<p>Here is a procedure how to extend your Auto-Paired characters to also include &#8216;, in the default list (or any other character for that matter).</p>
<p>Go to <strong>Bundle Editor</strong>, and locate <strong>Text</strong> bundle (you might have to turn it on using <em>Filter List in bottom left corner). Now locate <strong>Text -&gt; Miscellaneous</strong> with (p) next to it. Inside it you should see a snippet of text that says:</em></p>
<p><code><em><br />
...<br />
smartTypingPairs = (<br />
( '"', '"' ),<br />
( '(', ')' ),<br />
( '{', '}' ),<br />
( '[', ']' ),<br />
( 'â€œ', 'â€' ),<br />
( "', '" ),<br />
);<br />
...<br />
</em></code></p>
<p><em>edit that snippet to look like this:</em></p>
<p><code><br />
...<br />
smartTypingPairs = (<br />
( '"', '"' ),<br />
( '(', ')' ),<br />
( '{', '}' ),<br />
( '[', ']' ),<br />
( 'â€œ', 'â€' ),<br />
( "', '" ),<br />
<strong>		( "'", "'" ),         &lt;--- insert this line<br />
</strong> );<br />
...<br />
</code></p>
<p>And that&#8217;s it! Just restart TextMate  for Bundle to reload and try it out by typing &#8216; and observe its new auto-pairing powers.</p>
<p>Related posts:<ol>
<li><a href='http://www.jurecuhalev.com/blog/2007/10/12/double-bind-for-better-this-experience/' rel='bookmark' title='Double bind() for better `this` experience'>Double bind() for better `this` experience</a></li>
<li><a href='http://www.jurecuhalev.com/blog/2008/05/22/caspar-berry-risk-taking-and-decision-making-professional-poker-player-thinking-digital-session-notes/' rel='bookmark' title='Caspar Berry &#8211;  Risk Taking and Decision Making, Professional Poker player [Thinking digital session notes]'>Caspar Berry &#8211;  Risk Taking and Decision Making, Professional Poker player [Thinking digital session notes]</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.jurecuhalev.com/blog/2007/11/30/textmate-tip-making-single-apostrophes-double/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Double bind() for better `this` experience</title>
		<link>http://www.jurecuhalev.com/blog/2007/10/12/double-bind-for-better-this-experience/</link>
		<comments>http://www.jurecuhalev.com/blog/2007/10/12/double-bind-for-better-this-experience/#comments</comments>
		<pubDate>Fri, 12 Oct 2007 00:46:18 +0000</pubDate>
		<dc:creator>Jure Cuhalev</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[Planet Kiberpipa]]></category>
		<category><![CDATA[Planet LiveCD]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://www.kiberpipa.org/~gandalf/blog/?p=84</guid>
		<description><![CDATA[I am doing some developing with prototype lately and I was having some issues with context of `this` variable. The problem is that javascript is different from python in a way that defines local variable scope of class methods.
So here is short snippet with double bind(this) that allows one to reference class `this`. In essence, [...]
Related posts:<ol>
<li><a href='http://www.jurecuhalev.com/blog/2007/11/30/textmate-tip-making-single-apostrophes-double/' rel='bookmark' title='TextMate tip: Making single apostrophes double'>TextMate tip: Making single apostrophes double</a></li>
<li><a href='http://www.jurecuhalev.com/blog/2006/08/26/msn-live-search-python-api-access/' rel='bookmark' title='MSN Live Search python API access'>MSN Live Search python API access</a></li>
<li><a href='http://www.jurecuhalev.com/blog/2008/03/01/usability-reflections-how-google-failed-to-keep-their-blackberry-experience-simple/' rel='bookmark' title='Usability reflections: How Google failed to keep their BlackBerry experience simple'>Usability reflections: How Google failed to keep their BlackBerry experience simple</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>I am doing some developing with <a href="http://www.prototypejs.org/">prototype</a> lately and I was having some issues with context of `this` variable. The problem is that javascript is different from python in a way that defines local variable scope of class methods.</p>
<p>So here is short snippet with double bind(this) that allows one to reference class `this`. In essence, you just have to make sure that every call is wrapped into bind(this) if you want to be able to access `this` of class instance.</p>
<p><code><br />
// class code goes around and params dict<br />
    new Ajax.Request('json-url',<br />
                    { parameters: params,<br />
                      method: 'post',<br />
                      onSuccess: function(transport) {<br />
                        response = transport.responseText.evalJSON();<br />
                        response.images.map(function(i) {<br />
                          this.local_func(i.image.prop);<br />
                        }.bind(this));<br />
                      }.bind(this)<br />
                      });<br />
</code></p>
<p>Related posts:<ol>
<li><a href='http://www.jurecuhalev.com/blog/2007/11/30/textmate-tip-making-single-apostrophes-double/' rel='bookmark' title='TextMate tip: Making single apostrophes double'>TextMate tip: Making single apostrophes double</a></li>
<li><a href='http://www.jurecuhalev.com/blog/2006/08/26/msn-live-search-python-api-access/' rel='bookmark' title='MSN Live Search python API access'>MSN Live Search python API access</a></li>
<li><a href='http://www.jurecuhalev.com/blog/2008/03/01/usability-reflections-how-google-failed-to-keep-their-blackberry-experience-simple/' rel='bookmark' title='Usability reflections: How Google failed to keep their BlackBerry experience simple'>Usability reflections: How Google failed to keep their BlackBerry experience simple</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.jurecuhalev.com/blog/2007/10/12/double-bind-for-better-this-experience/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Served from: www.jurecuhalev.com @ 2012-02-12 19:32:18 by W3 Total Cache -->
