<?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>Blog: timdream</title>
	<atom:link href="http://blog.timc.idv.tw/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.timc.idv.tw</link>
	<description>網路、Mozilla、天文、物理、科學、科幻、社會 …… 自由</description>
	<lastBuildDate>Wed, 28 Jul 2010 03:44:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Responsive Web Design</title>
		<link>http://blog.timc.idv.tw/posts/responsive-web-design/</link>
		<comments>http://blog.timc.idv.tw/posts/responsive-web-design/#comments</comments>
		<pubDate>Wed, 28 Jul 2010 03:44:59 +0000</pubDate>
		<dc:creator>timdream</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[MozTW]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Usability]]></category>

		<guid isPermaLink="false">http://blog.timc.idv.tw/?p=963</guid>
		<description><![CDATA[Ethan Marcotte 的《Responsive Web Design》，布丁爸爸說這是 2010 上半年最重要的文章之一。 內文主要是在闡述一個重要的 Idea：「Responsive Web Design」。隨著 Web 從 PC 螢幕移動到各式各樣的裝置，為每個裝置設計不同的網站版本（iPad 版、iPhone 版、手機版）是個 viable 但是不 scalable 的解決方法。作者認為，網站開發時如同「Responsive Architecture」的概念一樣，讓環境去適應使用者的存在 －－ 像是自動調節室內溫度、將窗戶霧化以保護隱私等。網站設計不應該是平面出版的電子化，存在於固定的版面、文字大小、圖文配置；設計應該要自然的適應不同的裝置，自動調整版面的 flow，甚至是互動 UI 的大小等等。 實作的細節，作者花了後半的篇幅在介紹 CSS media query。Media Query 是以前 CSS 2 的 media type 延伸，不同的是它不只是一組預先設定好的媒體（螢幕、紙本、點字、語音&#8230;），它可以讓開發者自行設定 CSS 規則適用的裝置類型、寬度等等。文章內提供了具體的範例，展示了使用 Media Query，作者可以指定當裝置的螢幕寬度小於多少、或是介於多少時，網頁可以隨之切換欄數、圖片寬度、圖文配置等等。 我自己把文章印了出來（地球對不起 &#62; &#60;），認真讀了一遍，滿有收穫的。雖然 CSS media query 是早就知道的東西，但是不了解前面的設計哲學與意義就不會有動機去玩它（現在就超有動機的哈）。作者的文筆讓人耳目一新，闡述概念的方式相當的生動，可以拿來練英文（真的）。 有個研伸的問題，作者也有簡略提到。CSS media query 解決了排版適應裝置畫面的問題，但如果開發者希望在不同裝置呈現不同的內容，甚至不同的互動時，多版本網站還是解法。如果只是幾行字，或許可以用 display 屬性開關切換掉，但總不會 [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.alistapart.com/authors/m/emarcotte">Ethan Marcotte</a> 的<strong>《<a href="http://www.alistapart.com/articles/responsive-web-design/">Responsive Web Design</a>》</strong>，<a href="http://iamhlb.com/">布丁爸爸</a><a href="http://twitter.com/bobchao/status/19557422609">說這是 2010 上半年最重要的文章之一</a>。</p>
<p>內文主要是在闡述一個重要的 Idea：「Responsive Web Design」。隨著 Web 從 PC 螢幕移動到各式各樣的裝置，為每個裝置設計不同的網站版本（iPad 版、iPhone 版、手機版）是個 viable 但是不 scalable 的解決方法。作者認為，網站開發時如同「Responsive Architecture」的概念一樣，<strong>讓環境去適應使用者的存在</strong> －－ 像是自動調節室內溫度、將窗戶霧化以保護隱私等。網站設計不應該是平面出版的電子化，存在於固定的版面、文字大小、圖文配置；<strong>設計應該要自然的適應不同的裝置，自動調整版面的 flow，甚至是互動 UI 的大小等等</strong>。</p>
<p>實作的細節，作者花了後半的篇幅在介紹 <strong>CSS media query</strong>。Media Query 是以前 <a href="http://www.w3.org/TR/CSS2/media.html">CSS 2 的 media type</a> 延伸，不同的是它不只是一組預先設定好的媒體（螢幕、紙本、點字、語音&#8230;），它可以讓開發者自行設定 CSS 規則適用的裝置類型、寬度等等。文章內提供了具體的範例，展示了使用 Media Query，作者可以指定當裝置的螢幕寬度小於多少、或是介於多少時，網頁可以隨之切換欄數、圖片寬度、圖文配置等等。</p>
<p>我自己把文章印了出來（地球對不起 &gt; &lt;），認真讀了一遍，滿有收穫的。雖然 CSS media query 是早就知道的東西，但是不了解前面的設計哲學與意義就不會有動機去玩它（現在就超有動機的哈）。作者的文筆讓人耳目一新，闡述概念的方式相當的生動，可以拿來練英文（真的）。</p>
<p>有個研伸的問題，作者也有簡略提到。CSS media query 解決了排版適應裝置畫面的問題，但如果開發者希望在不同裝置呈現不同的內容，甚至不同的互動時，多版本網站還是解法。如果只是幾行字，或許可以用 display 屬性開關切換掉，但總不會 <a href="http://www.facebook.com/">Facebook</a> 套了另一份 CSS 就變成 <a href="http://touch.facebook.com/">Facebook for touch devices</a> 吧 <img src='http://blog.timc.idv.tw/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> 。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.timc.idv.tw/posts/responsive-web-design/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>知識信用與 HTML5</title>
		<link>http://blog.timc.idv.tw/posts/intellectual-honesty-and-html5/</link>
		<comments>http://blog.timc.idv.tw/posts/intellectual-honesty-and-html5/#comments</comments>
		<pubDate>Sat, 05 Jun 2010 15:36:50 +0000</pubDate>
		<dc:creator>timdream</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[MozTW]]></category>

		<guid isPermaLink="false">http://blog.timc.idv.tw/?p=959</guid>
		<description><![CDATA[Chris Blizzard 的文章 intellectual honesty and html5，正中我上篇文章講的 Apple 如何假裝開放實際上還是在做 vendor locked-in 的陰謀(陽謀?)。只是這次做的太明顯然後就翻船了。 Blizzard 主要的論點是 Apple 竟然大聲說他們喜歡創新的網路，那出來的產品跟作法就要言行一致 －－ 尤其是 HTML5 這一系列的創新本身的目標之一就是互通性 －－ 不能到處廣告說 Safari 支援 HTML5 然後故意把其他也支援的瀏覽器從示範網頁排除掉；這種顯然是沒有信用、不誠懇的傳遞知識的做為。 Mozilla 的 Sayre 做了一個很酸的 HTML5 demo，哈哈哈 (當然不代表 Mozilla 的立場)。]]></description>
			<content:encoded><![CDATA[<p>Chris Blizzard 的文章 <a href="http://www.0xdeadbeef.com/weblog/2010/06/intellectual-honesty-and-html5/">intellectual honesty and html5</a>，正中我<a href="http://blog.timc.idv.tw/posts/ipad-ready-ipad-only/">上篇文章</a>講的 Apple 如何假裝開放實際上還是在做 vendor locked-in 的陰謀(陽謀?)。只是這次做的太明顯然後就翻船了。</p>
<p>Blizzard 主要的論點是 Apple 竟然大聲說他們喜歡創新的網路，那出來的產品跟作法就要言行一致 －－ 尤其是 HTML5 這一系列的創新本身的目標之一就是互通性 －－ 不能到處廣告說 Safari 支援 HTML5 然後故意把其他也支援的瀏覽器從示範網頁排除掉；這種顯然是沒有信用、不誠懇的傳遞知識的做為。</p>
<p>Mozilla 的 Sayre 做了<a href="http://blog.mozilla.com/rob-sayre/2010/06/04/check-out-these-html5-demos/">一個很酸的 HTML5 demo</a>，哈哈哈 (當然不代表 Mozilla 的立場)。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.timc.idv.tw/posts/intellectual-honesty-and-html5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iPad Ready? iPad Only?</title>
		<link>http://blog.timc.idv.tw/posts/ipad-ready-ipad-only/</link>
		<comments>http://blog.timc.idv.tw/posts/ipad-ready-ipad-only/#comments</comments>
		<pubDate>Sun, 04 Apr 2010 17:08:30 +0000</pubDate>
		<dc:creator>timdream</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.timc.idv.tw/?p=924</guid>
		<description><![CDATA[My fellow Web Developers, I know it&#8217;s exciting to work with new devices and experimenting with new interactions, like multi-touch. I also acknowledge that sometimes it&#8217;s best to have a special look-and-feel that fit the device. But this time Apple is deliberately hurting the open web. Yes, you must have heard the phrase &#8220;iPhone is [...]]]></description>
			<content:encoded><![CDATA[<p>My fellow Web Developers, I know it&#8217;s exciting to work with new devices and experimenting with new interactions, like multi-touch. I also acknowledge that <em>sometimes</em> it&#8217;s best to have a special look-and-feel that fit the device. But this time <strong>Apple is deliberately hurting the open web</strong>.</p>
<p>Yes, you must have heard the phrase &#8220;iPhone is the new IE6&#8243;; back then I think Apple was doing a great job bringing the web as-we-know-it (kind of) to the mobile, and the cost to develop a separate iPhone website is justify because <em>it&#8217;s mobile &#8211; a distinct device.</em> Yet, for iPad it&#8217;s a completely different story:</p>
<ul>
<li>No matter how Apple marketed it, the device is an 1024&#215;768 <strong>tablet</strong>, with enough screen size to fit regular web.</li>
<li>Even if I want to build a specific website for iPhone/iPad, <del datetime="2010-04-05T11:05:46+00:00">their devices doesn&#8217;t use open standard like CSS @media-query to identify themselves</del> <ins>their device does do that, but not yet adopt by most developers</ins>. In fact, the way noteworthy companies doing the identification (e.g. Google&#8217;s GMail) is <strong>by detecting UA string</strong>. I couldn&#8217;t stop imaging the string <code>iPhone</code> or <code>iPad</code> would one day present in every mobile browser, just like the string <code>Mozilla</code> did. The <code>&lt;meta viewpoint&gt;</code> spec was also poorly designed &#8211; Apple should be more careful if they intend to establish a new de-facto standard.</li>
<li>For all the things above, I could just make excuses for them, like I did with iPhone Safari: it&#8217;s one of it&#8217;s kind, and Apple is focusing on delivering the best user experience they could give (like we all do) &#8211; but not for this: the flashy shrine of <a href="http://www.apple.com/ipad/ready-for-ipad/">iPad-ready websites</a>. <strong>Apple is purposely asking web content providers to build websites for it&#8217;s garden &#8211; and guess what, the garden is <em>walled</em> due to constraint above.</strong></li>
</ul>
<p><strong>Web is the first platform without a vendor.</strong> Nobody want to market a term they cannot trademark; every vendor of the market-leading browsers &#8211; from NCSA Mosaic, Microsoft Internet Explorer, to Apple iPad/iPhone Safari now, want to make World Wide Web their own from simply replace the terminology*, break the content standard, to moving open content to their closed garden.</p>
<p>Let&#8217;s defend that, first by giving your iPhone/iPad ready website an independent universal-accessible address, then demand browser vendors provide feasible standard to address their device capacities. No more UA string hacking please.</p>
<p><small>* Little-known early history of WWW; Back then, NCSA promotes their Mosaic browser without even mentioning the term &#8220;WWW&#8221;. This gesture prompted Sir Tim Berners-Lee to fund <a href="http://www.w3.org/">W3C</a> to ensure the openness of the Web. More stories can be found on his book &#8220;Weaving the Web.&#8221;</small></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.timc.idv.tw/posts/ipad-ready-ipad-only/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>CNNIC certificate criss: what you should do</title>
		<link>http://blog.timc.idv.tw/posts/cnnic-certificate-criss-what-you-should-do/</link>
		<comments>http://blog.timc.idv.tw/posts/cnnic-certificate-criss-what-you-should-do/#comments</comments>
		<pubDate>Mon, 22 Feb 2010 05:42:00 +0000</pubDate>
		<dc:creator>timdream</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[My Scripts]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.timc.idv.tw/?p=909</guid>
		<description><![CDATA[Disclaimer: I am a Mozilla Taiwan Community contributor, however the followings are my own point of view; not the view of entire community. 中文版貼在 Mozilla Links。 So, now we got bug 476766 calling Mozilla to remove CNNIC CA certs from it&#8217;s codebase, and people posted over on how to remove it manually. Personally I agreed [...]]]></description>
			<content:encoded><![CDATA[<blockquote>
<p><strong>Disclaimer</strong>: I am a <a href="http://moztw.org/">Mozilla Taiwan Community</a> contributor, however the followings are my own point of view; not the view of entire community.</p>
<p><strong>中文版</strong><a href="http://mozlinks-zh.blogspot.com/2010/02/cnnic.html">貼在 Mozilla Links</a>。</p>
</blockquote>
<p>So, now we got <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=476766#c33">bug 476766</a> calling Mozilla to remove CNNIC CA certs from it&#8217;s codebase, and people posted over on how to <a href="http://autoproxy.org/zh-CN/node/66">remove it manually</a>. Personally I agreed with the objective argument in the bug, that <em>officially</em> CNNIC is considered innocent until proven guilty. To make my point, here is a <del>PhotoShop</del> MS Paint mock up for you. <strong>Please stop the nonsense in bug 476766 unless you see this</strong>:</p>
<p><img src="http://blog.timc.idv.tw/wp-content/uploads/mock-up-cnnic-fake-ssl.png" alt="" title="mock-up-cnnic-fake-ssl" width="378" height="214" class="aligncenter size-full wp-image-911" /></p>
<p>But if you do, please <strong>immediately click [Detail...] and export the fake SSL cert</strong>. Every responsible browser vendor, include Mozilla, will remove the CNNIC Root upon this goes public, and the fake certificate would be the biggest scandal of the year to China, on the Internet.</p>
<h3>What you should do before that</h3>
<p>If you feel unsafe on the standard practice of browser vendors, you could disable the CA certs in your computer. Mozilla is correct on not-removing the CA certs, <strong>but for user who want to remove them themselves, I don&#8217;t think Mozilla has provided an easy tool for that. Clicking Tools &#8211; Options &#8211; Advanced &#8211; Security &#8211; Certificate Manager is just too painful.</strong> So here is an add-on I wrote which does that for you: <a href="https://addons.mozilla.org/en-US/firefox/addon/83152">CA Untrustworthy</a>. Do remember that removing CNNIC CA certs will break legit CNNIC-signed websites.</p>
<p>For the less paranoid, Rex provided us an add-on &#8220;<a href="http://github.com/chihchun/certalert/downloads">Cert Alert</a>&#8221; that alerts user whenever they encountered an CNNIC-signed website. Install it, after that, when you see the alert, you could use your judgment to consider the trustworthiness of the website &#8211; you might actually find the fake SSL cert that way.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.timc.idv.tw/posts/cnnic-certificate-criss-what-you-should-do/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Animation Smoothness</title>
		<link>http://blog.timc.idv.tw/posts/animation-smoothness/</link>
		<comments>http://blog.timc.idv.tw/posts/animation-smoothness/#comments</comments>
		<pubDate>Fri, 05 Feb 2010 03:41:23 +0000</pubDate>
		<dc:creator>timdream</dc:creator>
				<category><![CDATA[My Scripts]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.timc.idv.tw/?p=905</guid>
		<description><![CDATA[中文： 寫了一個測試動畫順暢度的網頁，用了三種不同的處理方法：一種讓 JavaScript 去改 CSS 的 top 和 left、另一種是改 background-position、最後就是用 HTML 5 的 &#60;canvas&#62; 來繪圖。結論是 background-position 最順，另外 Webkit 感覺比 Gecko 厲害一點。 I wrote a little test to find out which way of doing animation is the most smooth one. The three animation being tested are: Changing CSS top and left property. Chainging CSS background-position property. [...]]]></description>
			<content:encoded><![CDATA[<blockquote>
<p><strong>中文：</strong> 寫了一個<a href="http://timc.idv.tw/anismooth/">測試動畫順暢度</a>的網頁，用了三種不同的處理方法：一種讓 JavaScript 去改 CSS 的 top 和 left、另一種是改 background-position、最後就是用 HTML 5 的 &lt;canvas&gt; 來繪圖。結論是 background-position 最順，另外 Webkit 感覺比 Gecko 厲害一點。</p>
</blockquote>
<p>I wrote <a href="http://timc.idv.tw/anismooth/">a little test</a> to find out which way of doing animation is the most smooth one. The three animation being tested are:</p>
<ol>
<li>Changing CSS top and left property.</li>
<li>Chainging CSS background-position property.</li>
<li>Copy the image into a &lt;canvas&gt;</li>
</ol>
<p><strong>background-position</strong> seems to be wining on both Webkit and Gecko; Gecko preformed poorly on top/left property changing when full page zoom is in effect. Also Webkit preforms better than Gecko in all three animations.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.timc.idv.tw/posts/animation-smoothness/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>HTML5 File API + XmlHttpRequest = SWFUpload, now what?</title>
		<link>http://blog.timc.idv.tw/posts/html5-file-api-xmlhttprequest-swfupload-now-what/</link>
		<comments>http://blog.timc.idv.tw/posts/html5-file-api-xmlhttprequest-swfupload-now-what/#comments</comments>
		<pubDate>Mon, 25 Jan 2010 16:10:01 +0000</pubDate>
		<dc:creator>timdream</dc:creator>
				<category><![CDATA[MozTW]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.timc.idv.tw/?p=879</guid>
		<description><![CDATA[So what should you do if you decided to ditch SWFUpload and embrace HTML5 solution for ajax file upload? In honor of the releases of Firefox 3.6 (with File API), I decided to just that in the GFX Firefox promotion site. (sounds perfectly reasonable to use Fx-only technology on such site, right?) Firefox now gives [...]]]></description>
			<content:encoded><![CDATA[<p>So what should you do if you decided to ditch <a href="http://swfupload.org/">SWFUpload</a> and embrace HTML5 solution for ajax file upload? In honor of the releases of <a href="http://www.mozilla.com/">Firefox 3.6</a> (with File API), I decided to just that in the <a href="http://gfx.tw/">GFX Firefox promotion site</a>. <small>(sounds perfectly reasonable to use Fx-only technology on such site, right?)</small> Firefox now gives us the bricks (File API, binary XHR, and File drag-drop), but to build a house it still takes some work. <a href="http://demos.hacks.mozilla.org/openweb/uploadingFiles/">The Mozilla Hacks demo</a> works great but to work with the existing site I need:</p>
<ol>
<li>To create a SWFUpload-like button that opens file selection dialog instead of HTML form file input.</li>
<li>To send the file as a ordinary file upload form &#8211; no need to change php backend to handle raw post</li>
<li>Send the file by jQuery.ajax, firing global callbacks</li>
</ol>
<p>I came up with these methods to solve them:</p>
<p><span id="more-879"></span></p>
<h3>SWFUpload-like button</h3>
<div style="margin: 1em auto">
<input type="file" />
</div>
<p>From the JavaScript almighty <a href="http://www.quirksmode.org/">ppk</a> we know that <a href="http://www.quirksmode.org/dom/inputfile.html">file input from control is almost impossible to style</a>. The solution outlined on that page only tell us how to replace the control with images using <code>opacity: 0</code> trick. In order to fit the clickable area into my 65&#215;65-px button, I have to enlarge the control and confine it into a &lt;div&gt; with <code>overflow: hidden</code>. </p>
<div style="overflow: hidden; height: 65px; width: 65px; background: #ffcccc; margin: 1em auto">
<input type="file" style="opacity: 0.5" />
</div>
<p>The actual hard part is how to enlarge the control. It turns out in Firefox <strong>it ignores CSS specified height and width</strong>; the only thing left for you to set is <code>font-size</code> propriety. </p>
<div style="overflow: hidden; height: 65px; width: 65px; background: #ffcccc; margin: 1em auto">
<input type="file" style="font-size: 65px; opacity: 0.5" />
</div>
<p>Another CSS properity it ignores is the cursor. Firefox puts the &#8220;browse&#8221; button at the very right, so you might what to make sure the arrow cursor, instead of text-input cursor, shows.</p>
<div style="overflow: hidden; height: 65px; width: 65px; background: #ffcccc; margin: 1em auto; position: relative">
<input type="file" style="font-size: 65px; opacity: 0.5; position: absolute; right: 0" />
</div>
<h3>Simulate form upload</h3>
<p>On Mozilla Hacks demo, the file is sent as raw HTTP POST/PUT data. To process such input, one must craft the server-side script all over, without any upload-handling library that I&#8217;ve known of. So we go back to client-side solution: the question now effectively becomes <strong>how to implement <a href="http://www.ietf.org/rfc/rfc1867.txt">RFC 1867</a> format to your (raw) post data</strong>. I&#8217;ll simply post my code snippet below &#8211; turn out to be quite self-explanatory. <sup><a href="#note-rfc-1522">*</a></sup></p>
<pre>
var bd = 'gfx-xhrupload-'
	+ parseInt(Math.random()*(2 &lt;&lt; 16));
var data = '--' + bd + '\n'
	+ 'content-disposition: form-data; name="Filedata";'
	+ ' filename="' + files[0].name + '"\n'
	+ 'Content-Type: ' + files[0].type + '\n\n'
	+ ev.target.result + '\n\n'
	+ '--' + bd + '--';
</pre>
<p>Where <code>ev.target.result</code> is the binary string represent the file, access using FileReader object, and <code>files</code> is the FileList object.</p>
<h3>Send the file via jQuery.ajax</h3>
<blockquote>
<p><strong>Update:</strong> Just found an easy way to do this right instead below: overwrite <code>xhr.send</code> with <code>xhr.sendAsBinary</code> since it&#8217;s seems all right to send text data in binary mode.<a href="#xhr-prototype"><sup>*</sup></a></p>
<pre>
if (window.XMLHttpRequest &#038;&#038; XMLHttpRequest.prototype.sendAsBinary) {
	XMLHttpRequest.prototype.send = function (data) {
		return this.sendAsBinary(data);
	};
}
</pre>
</blockquote>
<p>You might think this is the easiest part, but in reality the normal <code>$.ajax</code> won&#8217;t work even if you set the correct Content-Type, which, according to RFC 1867, is <code>'multipart/form-data, boundary=' + bd</code>.</p>
<p>What went wrong? The problem is jQuery hard-coded <code>xhr.send(data)</code> in it&#8217;s function, and it does not send binary data. I resolved the problem by <strong>actually copying jQuery code, &#8220;patch&#8221; it, and overwrite the original $.ajax function.</strong> I added a &#8220;binary&#8221; option for the purpose; the function would switch to <code>xhr.sendAsBinary(data)</code> if the option is set to true.</p>
<h3>Bonus: File drag and drop</h3>
<p>What SWFUpload doesn&#8217;t do is to make the control accepts files by droping them on it. With Firefox 3.6 you could to that, but you cannot hook the drop event on the &lt;input&gt; itself. Frankly speaking, the button would be to small to aim, so for the sake of better UX, a larger overlay, like the one in Mozilla Hacks demo, should be made. Do remember that hiding the overlay as soon as dragleave fires will stop drop event from firing though &#8211; took me a day to figure that out.</p>
<p>Also, keep in mind your transparent button will accept file dropping if the user had installed <a href="https://addons.mozilla.org/firefox/addon/2190">dragdropupload</a> add-on.</p>
<h3>Conclusion</h3>
<p>With all these research, looks like it&#8217;s actually possible to write <strong>a SWFUpload.js without Flash</strong>. The library would support anything SWFUpload does, except cursor choices on the button. For my project, I didn&#8217;t craft a new <code>XHRUpload()</code> object to replace <code>SWFUpload()</code> because I don&#8217;t need that much of functionality, yet it&#8217;s something can be done.</p>
<p><a href="http://twitter.com/timdream/status/8017601285">It struck me</a> that HTML 5 is practically involves around what Google want to do things w/o Flash. StreetView? We got WebGL. GMail attach. upload? Got File API.</p>
<p>HTML 5. Exciting new world.</p>
<p><small>For complete code on the implementation, stay tuned and check code <a href="http://gfx.tw/js/page.editor.js">here</a> once it went live. For the site, we have not deliver English version yet, but feel free to play around with buttons and symbols &#8211; you should be able to understand it without reading any Chinese.</small></p>
<p><small><strong><a id="note-rfc-1522">Note: </a></strong>According to the MIME spec, the filename should be encoded according to RFC 1522 (&#8220;quoted-printable&#8221;) if it contains characters other than US-ASCII. Personally I replace these characters with underlines instead &#8211; <code>name = name.replace(/[^\x20-\x7E]/g, '_');</code>.</p>
<p><small><strong><a id="xhr-prototype">More update: </a></strong><code>XMLHttpRequest.prototype.sendAsBinary</code> instead of <code>(new XMLHttpRequest()).sendAsBinary<code></small></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.timc.idv.tw/posts/html5-file-api-xmlhttprequest-swfupload-now-what/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>A simple interaction design model</title>
		<link>http://blog.timc.idv.tw/posts/a-simple-interaction-design-model/</link>
		<comments>http://blog.timc.idv.tw/posts/a-simple-interaction-design-model/#comments</comments>
		<pubDate>Tue, 08 Dec 2009 08:49:01 +0000</pubDate>
		<dc:creator>timdream</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Usability]]></category>

		<guid isPermaLink="false">http://blog.timc.idv.tw/?p=871</guid>
		<description><![CDATA[From “Interaction Design: beyond human-computer interaction” by Preece, Rogers, and Sharp. 2002.]]></description>
			<content:encoded><![CDATA[<p>From “<a href="http://as.wiley.com/WileyCDA/WileyTitle/productCd-0471492787.html">Interaction Design: beyond human-computer interaction</a>” by Preece, Rogers, and Sharp. 2002.</p>
<p><a href="http://blog.timc.idv.tw/wp-content/uploads/a-simple-interaction-design-model.svg"><img src="http://blog.timc.idv.tw/wp-content/uploads/a-simple-interaction-design-model.png" alt="A Simple Interaction Design Model" title="A Simple Interaction Design Model" width="500" height="300" class="aligncenter size-full wp-image-874" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.timc.idv.tw/posts/a-simple-interaction-design-model/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>慶祝與紀念</title>
		<link>http://blog.timc.idv.tw/posts/cerebration-and-remembrance/</link>
		<comments>http://blog.timc.idv.tw/posts/cerebration-and-remembrance/#comments</comments>
		<pubDate>Fri, 27 Nov 2009 16:06:26 +0000</pubDate>
		<dc:creator>timdream</dc:creator>
				<category><![CDATA[Journal]]></category>

		<guid isPermaLink="false">http://blog.timc.idv.tw/?p=865</guid>
		<description><![CDATA[寫篇文章慶祝與紀念這個星期的風風雨雨。 慶祝在遇到如此複雜度的事情的關頭上，能夠找到夠多的朋友與家人的溫暖與陪伴，以及擁有足夠的成熟與 capacity 。 紀念逝去的天真，還有那個大家都可以好好相處永遠當好朋友的美好想像。 There are life challenges ahead. I won&#8217;t back down.]]></description>
			<content:encoded><![CDATA[<p>寫篇文章慶祝與紀念這個星期的風風雨雨。</p>
<p>慶祝在遇到如此複雜度的事情的關頭上，能夠找到夠多的朋友與家人的溫暖與陪伴，以及擁有足夠的成熟與 capacity 。</p>
<p>紀念逝去的天真，還有那個大家都可以好好相處永遠當好朋友的美好想像。</p>
<p><object width="560" height="340"><param name="movie" value="http://www.youtube-nocookie.com/v/cCf2T2-6Ixg&#038;hl=zh_TW&#038;fs=1&#038;color1=0x3a3a3a&#038;color2=0x999999"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube-nocookie.com/v/cCf2T2-6Ixg&#038;hl=zh_TW&#038;fs=1&#038;color1=0x3a3a3a&#038;color2=0x999999" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="340"></embed></object></p>
<p>There are life challenges ahead. I won&#8217;t back down.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.timc.idv.tw/posts/cerebration-and-remembrance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
