<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>prototype channel</title>
    <link>http://tobyho.com/tag/prototype</link>
    <description>prototype channel</description>
    <language>en-us</language>
    <item>
      <title>Making justtodolist work for chrome and safari</title>
      <description>Since &lt;a href="/Google_Chrome"&gt;Chrome &lt;/a&gt;is so great, I wanted to use it for all my browser needs. But the apps I've been working on myself have not been targeted for WebKit - the rendering engine used by chrome, and also used my Safari. This is mostly due to laziness on my part - having to handle two browsers at a time is chaos enough. But Safari compatibility is on my todo list for more than one of my projects, and chrome is a good push for this cause. And so I went in today and made &lt;a href="http://justtodolist.appspot.com"&gt;&lt;i&gt;just todo list. &lt;/i&gt;&lt;/a&gt;compatible with Chrome and Safari. The differences I encountered were:&lt;br&gt;&lt;ol&gt;&lt;li&gt;This is really prototype specific - prototype adds an empty underscore parameter for all Ajax request for WebKit browsers. Because apparently, Safari errors out when you try to post with an empty body on XHR calls. And, who knows, this might already be fixed in WebKit. I happened to have code that was not handling this fact on the server side. This was no biggy.&lt;/li&gt;&lt;li&gt;This is an error on my part really, but I had a form with a text input inside. But also registered for the key events on the text input so that when enter is pressed I called form.submit(). The key event code is really unnecessary because an enter on the text input triggers the form submit on both FF and IE. So, although on the other 2 browsers this was no problem, in WebKit this triggers 2 posts. So... just DON'T do this.&lt;br&gt;&lt;/li&gt;&lt;/ol&gt;&lt;br&gt;</description>
      <pubDate>Tue, 02 Sep 2008 23:01:32 -0400</pubDate>
      <guid>http://tobyho.com/Making_justtodolist_work_for_chrome_and_safari</guid>
      <author>toby ho</author>
      <link>http://tobyho.com/Making_justtodolist_work_for_chrome_and_safari</link>
    </item>
    <item>
      <title>Play Date with jQuery</title>
      <description>I had a new toy project and started out with my trusty sidekick: prototype.js but a bit of the way in i decide to try my hand at jQuery instead, since I've already read a lot about jQuery and really like the &lt;a href="http://osteele.com/archives/2008/02/inlined-frommaybe" mce_href="http://osteele.com/archives/2008/02/inlined-frommaybe"&gt;monad-like paradigm&lt;/a&gt; which allows you to write elegant "flow" code without having to worry about null values anywhere in the chain.&lt;br&gt;&lt;br&gt;It was quite easy translating my existing prototype.js code to jQuery(probably just around 30 lines). &lt;br&gt;&lt;ul&gt;&lt;li&gt;The end result was probably 20% more succient.&lt;/li&gt;&lt;li&gt;I love the css 3 capable selectors, it's very refreshing to be able to use attribute and partial string match selectors which normally you don't get to use for your work.&amp;nbsp;&lt;/li&gt;&lt;li&gt;I also like the way attributes are set as chained methods(again, in the monad flavor), you do something like &lt;font face="courier new,courier"&gt;$('#myid').attr('value')&lt;/font&gt; to get the value and &lt;font face="courier new,courier"&gt;$('#myid').attr('value', 1)&lt;/font&gt; to set the value to 1. This again, allows you to chain stuff together. What's the point of this? ...I guess I just like the monad thing.&lt;/li&gt;&lt;li&gt;I think the jQuery syntax for behavioral javascript is prettier than prototype.js + lowpro.js&lt;br&gt;&lt;/li&gt;&lt;/ul&gt;I really have nothing bad to say about jQuery. Even the UI components seem pretty on par with prototype.js, there's jqueryui, from which I used the autocomplete plugin. It's a little bit unfortunate that I had already invested about 1800 lines of javascript code on writing javascript components based on prototype.js and scriptaculous at work, otherwise had I started over I would very probably use jQuery. I will definitely go jQuery for my other projects.&lt;br&gt;&lt;br&gt;Are there anything from prototype.js that I miss? Well, yes, I miss the array extensions from prototype, which lets you use ruby/smalltalk/lisp-like internal iterator style list operations. jQuery has a $.each, but it's not quite as pretty... but it gets the job done. And I haven't looked, but I am not sure there's an equivalent to prototype's Event.KEY_RETURN, Event.KEY_BACKSPACE and such in jQuery. Also, I had gotten comfortable to the OO model from prototype, and doing without it will be different, but then again I am adaptable. Plus, there's nothing at all stopping you from using jQuery and prototype.js together.&lt;br&gt;</description>
      <pubDate>Sun, 31 Aug 2008 23:47:39 -0400</pubDate>
      <guid>http://tobyho.com/Play_Date_with_jQuery</guid>
      <author>toby ho</author>
      <link>http://tobyho.com/Play_Date_with_jQuery</link>
    </item>
    <item>
      <title>FF3 vs FF2 setting of position and width</title>
      <description>Wow, FF3 broke my app!&lt;br&gt;&lt;br&gt;I had a line like this(sorry this code uses prototype.js, but it's not specific to it):&lt;br&gt;&lt;font face="courier new,courier"&gt;myDiv.setStyle({&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; position: 'absolute',&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; top: elmPos.top + elm.offsetHeight,&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; left: elmPos.left,&lt;br&gt;
&amp;nbsp; &amp;nbsp; width: elm.offsetWidth - 5});&lt;/font&gt;&lt;br&gt;&lt;br&gt;This won't work anymore because starting FF3, you can't set the attributes: top, left, width, height to numeric values anymore, they have to labeled with a unit, like so:&lt;br&gt;&lt;font face="courier new,courier"&gt;myDiv.setStyle({&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; position: 'absolute',&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; top: asPx(elmPos.top + elm.offsetHeight),&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; left: asPx(elmPos.left),&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; width: asPx(elm.offsetWidth - 5)});&lt;/font&gt;&lt;br&gt;&lt;br&gt;Where asPx is:&lt;br&gt;&lt;font face="courier new,courier"&gt;function asPx(n){&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return n + 'px';&lt;br&gt;}&lt;/font&gt;&lt;br&gt;</description>
      <pubDate>Mon, 23 Jun 2008 21:45:42 -0400</pubDate>
      <guid>http://tobyho.com/FF3_vs_FF2_setting_of_position_and_width</guid>
      <author>toby ho</author>
      <link>http://tobyho.com/FF3_vs_FF2_setting_of_position_and_width</link>
    </item>
    <item>
      <title>Use up() instead of parentNode</title>
      <description>With prototype.js, you should use element.up() instead of element.parentNode. This is again because of &lt;a href="/FF%27s_built_in_Element_class"&gt;this browser difference&lt;/a&gt;.&lt;br&gt;</description>
      <pubDate>Wed, 04 Jun 2008 16:12:08 -0400</pubDate>
      <guid>http://tobyho.com/Use_up%28%29_instead_of_parentNode</guid>
      <author>toby ho</author>
      <link>http://tobyho.com/Use_up%28%29_instead_of_parentNode</link>
    </item>
    <item>
      <title>Prototype's Element dot extend</title>
      <description>Element.extend is an important method is the prototype framework. It adds all the helper/mixin methods to a dom element, like this:&lt;br&gt;Element.extend(myElem);&lt;br&gt;If for some reason you have to do this manually(probably in IE), this is what you need.&lt;br&gt;</description>
      <pubDate>Wed, 04 Jun 2008 12:26:37 -0400</pubDate>
      <guid>http://tobyho.com/Prototype%27s_Element_dot_extend</guid>
      <author>toby ho</author>
      <link>http://tobyho.com/Prototype%27s_Element_dot_extend</link>
    </item>
    <item>
      <title>Constructor Chaining in Prototype</title>
      <description>Ever wonder how to do constructor chaining in prototype.js?&lt;br&gt;Here's how:&lt;br&gt;&lt;br&gt;var Person = Class.create({&lt;br&gt;&amp;nbsp; initialize: function(){&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; console.log('hello world!');&lt;br&gt;&amp;nbsp; }&lt;br&gt;});&lt;br&gt;var Pirate = Class.create(Person,{&lt;br&gt;&amp;nbsp; initialize: function($super){&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; console.log('before super');&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $super();&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; console.log('after super');&lt;br&gt;&amp;nbsp; }&lt;br&gt;});&lt;br&gt;new Person();&lt;br&gt;new Pirate();&lt;br&gt;&lt;br&gt;The $super parameter is "special", and is detected by the library. It gives you a reference to the method of the same name defined in the super class(Ruby style, basically). Notice that unlike Java, you can do stuff before super's constructor is called. For more, see &lt;a href="http://www.prototypejs.org/learn/class-inheritance" mce_href="http://www.prototypejs.org/learn/class-inheritance"&gt;here&lt;/a&gt;.&lt;br&gt;</description>
      <pubDate>Tue, 20 May 2008 21:32:26 -0400</pubDate>
      <guid>http://tobyho.com/Constructor_Chaining_in_Prototype</guid>
      <author>toby ho</author>
      <link>http://tobyho.com/Constructor_Chaining_in_Prototype</link>
    </item>
  </channel>
</rss>
