<?xml version="1.0" encoding="utf-8"?> 
<feed version="0.3" xmlns="http://purl.org/atom/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="zh-tw"> 
<title>網站製作學習誌</title> 
<link rel="alternate" type="text/html" href="http://blog.roodo.com/jaceju/" /> 
<modified>2008-10-08T18:04:56+08:00</modified> 
<tagline>
首頁
讀者留言版
管理介面












_uacct = &quot;UA-450710-1&quot;;
urchinTracker();
</tagline> 
<id>tag:blog.roodo.com,2008://6970</id> 
<generator url="http://blog.yam.com/" version="1.0">Roodo Blog</generator> 
<copyright>Copyright (c) 2005, </copyright> 
 <entry> 
 <title>Bug Tracker 安裝紀錄</title> 
 <link rel="alternate" type="text/html" href="http://blog.roodo.com/jaceju/archives/7231811.html" /> 
 <modified>2008-09-29T13:49:53+08:00</modified> 
 <issued>2008-09-29T13:49:53+08:00</issued> 
 <id>tag:blog.roodo.com,2008://6970.7231811</id> 
 <created>2008-09-23T17:05:44+08:00</created> 
  <author>
 <name></name> 
 <url>http://blog.roodo.com/jaceju/</url> 
 
</author> 
<dc:subject>伺服器安裝與設定</dc:subject> 
<summary type="text/html" mode="escaped">
<![CDATA[
我之前介紹過 Trac 這個軟體的安裝及簡略的使用方式，但是 Trac 是一套基於 Python 開發的軟體缺陷追蹤系統，在安裝上有一定的複雜度。
這次，我推薦大家一套國人自行開發的 Bug Tracker ，它是一套以 PHP 所開發的軟體缺陷追蹤系統，相當適合不想安裝複雜開發環境的 PHP 開發者使用。
這裡有 Neo 寫的簡介：國人自製 Bug Tracker 。 
下載
網址： http://www.twbsd.org/cht/bug_tracker/index.php?page=download.htm
在「按此下載」的連結上點一下，把 BugTracker-2.x.x.tar.gz 存放到網站根目錄就可以了。
安裝
Bug Tracker 號稱安裝非常容易，但其實在 PHP5 的環境上，還是有一些要特別注意的地方。
解開剛剛的 BugTracker-2.x.x.tar.gz ，然後我們會得到一個 bug 目錄；所以到時候我們可以用 http://localhost/bug 的網址來使用這套系統。
假設你的開發環境是 PHP5 ，那麼 short_open_tag 這個選項預設應該是 Off 。而 Bug Tracker 的程式碼大部份都是以 &lt;? 開頭，因此我們需要把 short_open_tag 設為 On 。
不過因為我個人不喜歡去更動系統預設值，所以我改用 .htaccess 來改變 short_open_tag 的設定。請將以下內容存為 .htaccess 後，存在 bug 資料夾下。
php_flag short_open_tag on
接著我們要修改應用程式的設定，請用文字編輯器開始 bug/include/config.php ，找到：
$GLOBALS['BR_dbtype'] = &quot;postgres&quot;;
將它註解掉 (前面加上 //) 。
然後取消以下程式碼開頭的註解：
$GLOBALS['BR_dbtype'] = &quot;mysqlt&quot;;
然後往下看到：
$GLOBALS['BR_dbpwd'] = &quot;&quot;;
在設定值上寫上 MySQL 的 root 密碼，讓程式可以自動建立資料庫。
最後修改應用程式的路徑：
$GLOBALS[&quot;SYS_PROJECT_PATH&quot;] = '/home/synosrc/bug';
將 /home/synosrc/bug 改為你安裝程式的路徑。
現在開啟以下連結，進行安裝動作：
http://localhost/bug/setup/
基本上就是一直按 Next Step 而已，安裝程式會告訴你一切需要的資訊，並自動執行相關的動作。
安裝完後，請記得移除 bug/setup 這個資料夾。
這樣就完成安裝 Bug Tracker 囉~
設定語系
一開始 Bug Tracker 的登入畫面是正體中文：

但用 admin 登入後，我們會發現預設的語系還是英文的：

這時我們可以點選上面的 System (系統設定) 功能，然後選擇 Preference (偏好設定) 項目，將 System Language (系統語言) 改為 Chinese Traditional 即可。
搭配 Subversion 使用
Bug Tracker 目前還沒辦法像 Trac 一樣直接支援 Subversion ，也就是說它目前無法直接讓專案回報與源碼相結合。
這裡我找到一篇反過來讓 TortoiseSVN 配合 Bug Tracker 使用的文章：如何設定 TortoiseSVN 整合 Bug Tracker 系統。
依照文章上的解說，我們可以在 Subversion 的 log 上直接連結到 Bug Tracker 回報的畫面。 
其實 PHP 是可以支援 Subversion 的，但必須配合 php_svn 這個外掛模組。不過 php_svn 還不支援新版的 Subversion ，這是比較可惜的地方。請參考：安裝php_svn.dll 。
結論
其實不論是團隊合作還是個人開發，一套好的追蹤系統都可以協助我們管理好專案的進度；而 Bug Tracker 可以說是慣用中文的 PHP 開發者一個不錯的選擇。
大家有任何使用上的經驗嗎？也歡迎分享喔~
]]>
</summary> 
<content type="text/html" mode="escaped" xml:lang="zh-tw" xml:base="http://blog.roodo.com/jaceju/archives/7231811.html">
<![CDATA[
<p>我之前介紹過 <a href="http://trac.edgewall.org/">Trac</a> 這個軟體的<a href="http://blog.roodo.com/jaceju/archives/2703934.html">安裝</a>及<a href="http://blog.roodo.com/jaceju/archives/2772843.html">簡略的使用方式</a>，但是 Trac 是一套基於 Python 開發的軟體缺陷追蹤系統，在安裝上有一定的複雜度。</p>
<p>這次，我推薦大家一套國人自行開發的 <a href="http://www.twbsd.org/cht/bug_tracker/index.php">Bug Tracker</a> ，它是一套以 PHP 所開發的軟體缺陷追蹤系統，相當適合不想安裝複雜開發環境的 PHP 開發者使用。</p>
<p>這裡有 <a href="http://www.neo.com.tw">Neo</a> 寫的簡介：<a href="http://www.neo.com.tw/archives/000785.html">國人自製 Bug Tracker</a> 。 </p>
<h2>下載</h2>
<p>網址： <a href="http://www.twbsd.org/cht/bug_tracker/index.php?page=download.htm">http://www.twbsd.org/cht/bug_tracker/index.php?page=download.htm</a></p>
<p>在「按此下載」的連結上點一下，把 BugTracker-2.x.x.tar.gz 存放到網站根目錄就可以了。</p>
<h2>安裝</h2>
<p>Bug Tracker 號稱安裝非常容易，但其實在 PHP5 的環境上，還是有一些要特別注意的地方。</p>
<p>解開剛剛的 BugTracker-2.x.x.tar.gz ，然後我們會得到一個 bug 目錄；所以到時候我們可以用 http://localhost/bug 的網址來使用這套系統。</p>
<p>假設你的開發環境是 PHP5 ，那麼 short_open_tag 這個選項預設應該是 Off 。而 Bug Tracker 的程式碼大部份都是以 &lt;? 開頭，因此我們需要把 short_open_tag 設為 On 。</p>
<p>不過因為我個人不喜歡去更動系統預設值，所以我改用 .htaccess 來改變 short_open_tag 的設定。請將以下內容存為 .htaccess 後，存在 bug 資料夾下。</p>
<pre><code>php_flag short_open_tag on</code></pre>
<p>接著我們要修改應用程式的設定，請用文字編輯器開始 bug/include/config.php ，找到：</p>
<pre><code>$GLOBALS['BR_dbtype'] = &quot;postgres&quot;;</code></pre>
<p>將它註解掉 (前面加上 //) 。</p>
<p>然後取消以下程式碼開頭的註解：</p>
<pre><code>$GLOBALS['BR_dbtype'] = &quot;mysqlt&quot;;</code></pre>
<p>然後往下看到：</p>
<pre><code>$GLOBALS['BR_dbpwd'] = &quot;&quot;;</code></pre>
<p>在設定值上寫上 MySQL 的 root 密碼，讓程式可以自動建立資料庫。</p>
<p>最後修改應用程式的路徑：</p>
<pre><code>$GLOBALS[&quot;SYS_PROJECT_PATH&quot;] = '/home/synosrc/bug';</code></pre>
<p>將 /home/synosrc/bug 改為你安裝程式的路徑。</p>
<p>現在開啟以下連結，進行安裝動作：</p>
<p>http://localhost/bug/setup/</p>
<p>基本上就是一直按 Next Step 而已，安裝程式會告訴你一切需要的資訊，並自動執行相關的動作。</p>
<p>安裝完後，請記得移除 bug/setup 這個資料夾。</p>
<p>這樣就完成安裝 Bug Tracker 囉~</p>
<h2>設定語系</h2>
<p>一開始 Bug Tracker 的登入畫面是正體中文：</p>
<p class="image"><img src="http://www.jaceju.net/resources/bugtracker/login.gif" alt="登入畫面" width="619" height="506" /></p>
<p>但用 admin 登入後，我們會發現預設的語系還是英文的：</p>
<p class="image"><img src="http://www.jaceju.net/resources/bugtracker/main.gif" alt="主畫面" width="917" height="522" /></p>
<p>這時我們可以點選上面的 System (系統設定) 功能，然後選擇 Preference (偏好設定) 項目，將 System Language (系統語言) 改為 Chinese Traditional 即可。</p>
<h2>搭配 Subversion 使用</h2>
<p>Bug Tracker 目前還沒辦法像 Trac 一樣直接支援 Subversion ，也就是說它目前無法直接讓專案回報與源碼相結合。</p>
<p>這裡我找到一篇反過來讓 TortoiseSVN 配合 Bug Tracker 使用的文章：<a href="http://blog.miniasp.com/post/2008/09/TortoiseSVN-Integration-with-Bug-Tracking-Systems-Issue-Trackers.aspx">如何設定 TortoiseSVN 整合 Bug Tracker 系統</a>。</p>
<p>依照文章上的解說，我們可以在 Subversion 的 log 上直接連結到 Bug Tracker 回報的畫面。 </p>
<p>其實 PHP 是可以支援 Subversion 的，但必須配合 php_svn 這個外掛模組。不過 php_svn 還不支援新版的 Subversion ，這是比較可惜的地方。請參考：<a href="http://hi.baidu.com/thinkinginlamp/blog/item/5e2a0208383a9cd763d98642.html">安裝php_svn.dll</a> 。</p>
<h2>結論</h2>
<p>其實不論是團隊合作還是個人開發，一套好的追蹤系統都可以協助我們管理好專案的進度；而 Bug Tracker 可以說是慣用中文的 PHP 開發者一個不錯的選擇。</p>
<p>大家有任何使用上的經驗嗎？也歡迎分享喔~</p>

]]>
</content>
</entry> 
 <entry> 
 <title>[jQuery] IE 上的 clone 陷阱</title> 
 <link rel="alternate" type="text/html" href="http://blog.roodo.com/jaceju/archives/7231115.html" /> 
 <modified>2008-10-03T15:03:19+08:00</modified> 
 <issued>2008-10-03T15:03:19+08:00</issued> 
 <id>tag:blog.roodo.com,2008://6970.7231115</id> 
 <created>2008-09-23T14:07:15+08:00</created> 
  <author>
 <name></name> 
 <url>http://blog.roodo.com/jaceju/</url> 
 
</author> 
<dc:subject>JavaScript</dc:subject> 
<summary type="text/html" mode="escaped">
<![CDATA[
前陣子在處理客戶更改版面的需求時，為了偷懶，結果發現了一個 jQuery 在 IE 上 clone 元素的問題。
先簡單說明一下例子：

如上圖所示，我希望在按下「複製」按鈕後，藍色區塊中的 checkbox 被勾選的項目會被複製到紅色區塊中：

這裡我簡單的使用 jQuery 的 clone 方法來完成它，原始程式如下：
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;title&gt;測試&lt;/title&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;jquery/1.2.6.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
$(function () {
    $('#copy').click(function () {
        $('#target').html('').append($('input.test:checked').clone());
    });
});
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;div id=&quot;source&quot; style=&quot;border:1px solid #33F; padding: 20px; width: 200px;&quot;&gt;
&lt;input type=&quot;checkbox&quot; name=&quot;test[]&quot; class=&quot;test&quot; value=&quot;1&quot; /&gt;
&lt;input type=&quot;checkbox&quot; name=&quot;test[]&quot; class=&quot;test&quot; value=&quot;2&quot; /&gt;
&lt;input type=&quot;checkbox&quot; name=&quot;test[]&quot; class=&quot;test&quot; value=&quot;3&quot; /&gt;
&lt;input type=&quot;checkbox&quot; name=&quot;test[]&quot; class=&quot;test&quot; value=&quot;4&quot; /&gt;
&lt;/div&gt;

&lt;br /&gt;

&lt;div id=&quot;target&quot; style=&quot;border:1px solid #F33; padding: 20px; width: 200px;&quot;&gt;
&lt;/div&gt;

&lt;br /&gt;

&lt;input type=&quot;button&quot; value=&quot;複製&quot; id=&quot;copy&quot; /&gt;

&lt;/body&gt;
&lt;/html&gt;
在非 IE 的瀏覽器上， jQuery 的 clone 方法可以正確的把已勾選的 checkbox 的 checked 狀態複製下來，但在 IE 上卻不行，如下圖： 

所以這裡只好針對 IE 再進行一次特別的處理：
$(function () {
    $('#copy').click(function () {
        var $checkedValues = $('input.test:checked').clone();
        if ($.browser.msie) {
            $checkedValues.attr('checked', true);
        }
        $('#target').html('').append($checkedValues);
    });
});
原理很簡單，就是遇到 IE 時，再將複製下來的 checkbox 的 checked 屬性設為 true 即可。
補充：IE6 的逆襲
不過上述程式在 IE6 又會出現問題了，在 IE6 上執行時，會發現 checked 屬性無法正常被設為 true 。
雖然沒有深入去研究，但我猜想是 IE6 在處理 DOM 時的問題，因此我祭出了 setTimeout 大法：
$(function () {
    $('#copy').click(function () {
        var $checkedValues = $('input.test:checked').clone();
        if ($.browser.msie) {
            setTimeout(function () { $checkedValues.attr('checked', true); }, 0);
        }
        $('#target').html('').append($checkedValues);
        
        setTimeout(function () {
            // 其他可能會對處理到 checkbox 的動作
        }, 0);
    });
});
這裡 setTimeout 可以確保程式在 DOM 完全更新後，再執行下一步的動作。 
]]>
</summary> 
<content type="text/html" mode="escaped" xml:lang="zh-tw" xml:base="http://blog.roodo.com/jaceju/archives/7231115.html">
<![CDATA[
<p>前陣子在處理客戶更改版面的需求時，為了偷懶，結果發現了一個 jQuery 在 IE 上 clone 元素的問題。</p>
<p>先簡單說明一下例子：</p>
<p class="image"><img src="http://www.jaceju.net/resources/ie_clone/1.gif" alt="FF未複製前" /></p>
<p>如上圖所示，我希望在按下「複製」按鈕後，藍色區塊中的 checkbox 被勾選的項目會被複製到紅色區塊中：</p>
<p class="image"><img src="http://www.jaceju.net/resources/ie_clone/2.gif" alt="FF複製後" /></p>
<p>這裡我簡單的使用 jQuery 的 clone 方法來完成它，原始程式如下：</p>
<pre><code>&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;title&gt;測試&lt;/title&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;jquery/1.2.6.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
$(function () {
    $('#copy').click(function () {
        <strong>$('#target').html('').append($('input.test:checked').clone());</strong>
    });
});
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;div id=&quot;source&quot; style=&quot;border:1px solid #33F; padding: 20px; width: 200px;&quot;&gt;
&lt;input type=&quot;checkbox&quot; name=&quot;test[]&quot; class=&quot;test&quot; value=&quot;1&quot; /&gt;
&lt;input type=&quot;checkbox&quot; name=&quot;test[]&quot; class=&quot;test&quot; value=&quot;2&quot; /&gt;
&lt;input type=&quot;checkbox&quot; name=&quot;test[]&quot; class=&quot;test&quot; value=&quot;3&quot; /&gt;
&lt;input type=&quot;checkbox&quot; name=&quot;test[]&quot; class=&quot;test&quot; value=&quot;4&quot; /&gt;
&lt;/div&gt;

&lt;br /&gt;

&lt;div id=&quot;target&quot; style=&quot;border:1px solid #F33; padding: 20px; width: 200px;&quot;&gt;
&lt;/div&gt;

&lt;br /&gt;

&lt;input type=&quot;button&quot; value=&quot;複製&quot; id=&quot;copy&quot; /&gt;

&lt;/body&gt;
&lt;/html&gt;</code></pre>
<p>在非 IE 的瀏覽器上， jQuery 的 clone 方法可以正確的把已勾選的 checkbox 的 checked 狀態複製下來，但在 IE 上卻不行，如下圖： </p>
<p class="image"><img src="http://www.jaceju.net/resources/ie_clone/3.gif" alt="IE複製後" /></p>
<p>所以這裡只好針對 IE 再進行一次特別的處理：</p>
<pre><code>$(function () {
    $('#copy').click(function () {
        <strong>var $checkedValues = $('input.test:checked').clone();</strong>
        <strong>if ($.browser.msie) {</strong>
            <strong>$checkedValues.attr('checked', true);</strong>
        <strong>}</strong>
        $('#target').html('').append(<strong>$checkedValues</strong>);
    });
});</code></pre>
<p>原理很簡單，就是遇到 IE 時，再將複製下來的 checkbox 的 checked 屬性設為 true 即可。</p>
<h2>補充：IE6 的逆襲</h2>
<p>不過上述程式在 IE6 又會出現問題了，在 IE6 上執行時，會發現 checked 屬性無法正常被設為 true 。</p>
<p>雖然沒有深入去研究，但我猜想是 IE6 在處理 DOM 時的問題，因此我祭出了 setTimeout 大法：</p>
<pre><code>$(function () {
    $('#copy').click(function () {
        var $checkedValues = $('input.test:checked').clone();
        if ($.browser.msie) {
            <strong>setTimeout(function () {</strong> $checkedValues.attr('checked', true); <strong>}, 0);</strong>
        }
        $('#target').html('').append($checkedValues);
        
        <strong>setTimeout(function () {</strong>
            <strong>// 其他可能會對處理到 checkbox 的動作</strong>
        <strong>}, 0);</strong>
    });
});</code></pre>
<p>這裡 setTimeout 可以確保程式在 DOM 完全更新後，再執行下一步的動作。 </p>

]]>
</content>
</entry> 
 <entry> 
 <title>[Web] 連結分享</title> 
 <link rel="alternate" type="text/html" href="http://blog.roodo.com/jaceju/archives/7209897.html" /> 
 <modified>2008-09-19T22:06:18+08:00</modified> 
 <issued>2008-09-19T22:06:18+08:00</issued> 
 <id>tag:blog.roodo.com,2008://6970.7209897</id> 
 <created>2008-09-19T22:05:49+08:00</created> 
  <author>
 <name></name> 
 <url>http://blog.roodo.com/jaceju/</url> 
 
</author> 
<dc:subject>連結分享</dc:subject> 
<summary type="text/html" mode="escaped">
<![CDATA[
PHP

10 Principles of the PHP Masters 
Simple Easy Parallel Processing in PHP | PHP Everywhere 
Type hints are more useful for scalars than objects 
扩展ArrayObject 
为什么“is_file比file_exists快N倍” 
Creating a PHP5 Framework - Part 1 / Part 2

JavaScript

JavaScript Benchmark Quality 
Javascript的IE和Firefox兼容性汇编 
75 (Really) Useful JavaScript Techniques

jQuery

jQuery and JavaScript Coding: Examples and Best Practices

CSS

CSS Typography: Contrast Techniques, Tutorials and Best Practices 
CSS 三欄排版 
CSS Frameworks

Web Development

Drag and Drop without Drag and Drop 
在不同编码的页面间提交表单 

Database
MySQL

AUTO_INCREMENT and MERGE TABLES 
用mysql触发器自动更新memcache 

Programming

追求神乎其技的程式設計之道(一） 
追求神乎其技的程式設計之道(二） 
追求神乎其技的程式設計之道(三） 
追求神乎其技的程式設計之道(四） 
追求神乎其技的程式設計之道(五） 
追求神乎其技的程式設計之道(六） 

Project

Project release 的 更新/還原 控制 Script

SCM

如何讓 TortoiseSVN 僅匯出新增或修改過的檔案

Service

Learn HTML &amp; CSS at the HTML Playground

]]>
</summary> 
<content type="text/html" mode="escaped" xml:lang="zh-tw" xml:base="http://blog.roodo.com/jaceju/archives/7209897.html">
<![CDATA[
<h2>PHP</h2>
<ul>
<li><a href="http://nettuts.com/articles/10-principles-of-the-php-masters/">10 Principles of the PHP Masters</a> </li>
<li><a href="http://phplens.com/phpeverywhere/?q=node/view/254">Simple Easy Parallel Processing in PHP | PHP Everywhere</a> </li>
<li><a href="http://www.reiersol.com/blog/1_php_in_action/archive/160_type_hints_are_more_useful_for_scalars_than_objects.html">Type hints are more useful for scalars than objects</a> </li>
<li><a href="http://www.tblog.com.cn/archives/679">扩展ArrayObject</a> </li>
<li><a href="http://www.mikespook.com/index.php/archives/181">为什么“is_file比file_exists快N倍”</a> </li>
<li><a href="http://nettuts.com/php/creating-a-php5-framework-part-1/">Creating a PHP5 Framework - Part 1</a> / <a href="http://nettuts.com/php/create-a-php5-framework-part-2/">Part 2</a></li>
</ul>
<h2>JavaScript</h2>
<ul>
<li><a href="http://ejohn.org/blog/javascript-benchmark-quality/">JavaScript Benchmark Quality</a> </li>
<li><a href="http://www.playes.net/Blog/332.asp">Javascript的IE和Firefox兼容性汇编</a> </li>
<li><a href="http://www.smashingmagazine.com/2008/09/11/75-really-useful-javascript-techniques/">75 (Really) Useful JavaScript Techniques</a></li>
</ul>
<h3>jQuery</h3>
<ul>
<li><a href="http://www.smashingmagazine.com/2008/09/16/jquery-examples-and-best-practices/">jQuery and JavaScript Coding: Examples and Best Practices</a></li>
</ul>
<h2>CSS</h2>
<ul>
<li><a href="http://www.noupe.com/css/css-typography-contrast-techniques-tutorials-and-best-practices.html">CSS Typography: Contrast Techniques, Tutorials and Best Practices</a> </li>
<li><a href="http://jax-work-archive.blogspot.com/2008/09/css.html">CSS 三欄排版</a> </li>
<li><a href="http://www.cssnolanche.com.br/css-frameworks/">CSS Frameworks</a></li>
</ul>
<h2>Web Development</h2>
<ul>
<li><a href="http://ernestdelgado.com/articles/ddwdd/">Drag and Drop without Drag and Drop</a> </li>
<li><a href="http://hi.baidu.com/thinkinginlamp/blog/item/e400f819abd9a37cdbb4bd7d.html">在不同编码的页面间提交表单</a> </li>
</ul>
<h2>Database</h2>
<h3>MySQL</h3>
<ul>
<li><a href="http://www.mysqlperformanceblog.com/2008/09/11/auto_increment-and-merge-tables/">AUTO_INCREMENT and MERGE TABLES</a> </li>
<li><a href="http://www.tblog.com.cn/archives/683">用mysql触发器自动更新memcache</a> </li>
</ul>
<h2>Programming</h2>
<ul>
<li><a href="http://blog.vgod.tw/2008/07/05/%E8%BF%BD%E6%B1%82%E7%A5%9E%E4%B9%8E%E5%85%B6%E6%8A%80%E7%9A%84%E7%A8%8B%E5%BC%8F%E8%A8%AD%E8%A8%88%E4%B9%8B%E9%81%93%E4%B8%80%EF%BC%89/">追求神乎其技的程式設計之道(一）</a> </li>
<li><a href="http://blog.vgod.tw/2008/07/07/%E8%BF%BD%E6%B1%82%E7%A5%9E%E4%B9%8E%E5%85%B6%E6%8A%80%E7%9A%84%E7%A8%8B%E5%BC%8F%E8%A8%AD%E8%A8%88%E4%B9%8B%E9%81%93%E4%BA%8C%EF%BC%89/">追求神乎其技的程式設計之道(二）</a> </li>
<li><a href="http://blog.vgod.tw/2008/07/12/%E8%BF%BD%E6%B1%82%E7%A5%9E%E4%B9%8E%E5%85%B6%E6%8A%80%E7%9A%84%E7%A8%8B%E5%BC%8F%E8%A8%AD%E8%A8%88%E4%B9%8B%E9%81%93%E4%B8%89%EF%BC%89/">追求神乎其技的程式設計之道(三）</a> </li>
<li><a href="http://blog.vgod.tw/2008/07/15/%E8%BF%BD%E6%B1%82%E7%A5%9E%E4%B9%8E%E5%85%B6%E6%8A%80%E7%9A%84%E7%A8%8B%E5%BC%8F%E8%A8%AD%E8%A8%88%E4%B9%8B%E9%81%93%E5%9B%9B%EF%BC%89/">追求神乎其技的程式設計之道(四）</a> </li>
<li><a href="http://blog.vgod.tw/2008/07/25/divine-code-5/">追求神乎其技的程式設計之道(五）</a> </li>
<li><a href="http://blog.vgod.tw/2008/08/19/divine-code-6/">追求神乎其技的程式設計之道(六）</a> </li>
</ul>
<h2>Project</h2>
<ul>
<li><a href="http://plog.longwin.com.tw/programming/2008/09/11/project-release-rollback-control-script-2008">Project release 的 更新/還原 控制 Script</a></li>
</ul>
<h2>SCM</h2>
<ul>
<li><a href="http://blog.miniasp.com/post/2008/09/Using-TortoiseSVN-to-Export-Only-Added-Modified-Files.aspx">如何讓 TortoiseSVN 僅匯出新增或修改過的檔案</a></li>
</ul>
<h2>Service</h2>
<ul>
<li><a href="http://www.webmastersbydesign.com/2008/09/03/learn-html-css-at-the-html-playground/">Learn HTML &amp; CSS at the HTML Playground</a></li>
</ul>

]]>
</content>
</entry> 
 <entry> 
 <title>[Web] 連結分享</title> 
 <link rel="alternate" type="text/html" href="http://blog.roodo.com/jaceju/archives/7125781.html" /> 
 <modified>2008-09-06T23:57:32+08:00</modified> 
 <issued>2008-09-06T23:57:32+08:00</issued> 
 <id>tag:blog.roodo.com,2008://6970.7125781</id> 
 <created>2008-09-06T23:56:58+08:00</created> 
  <author>
 <name></name> 
 <url>http://blog.roodo.com/jaceju/</url> 
 
</author> 
<dc:subject>連結分享</dc:subject> 
<summary type="text/html" mode="escaped">
<![CDATA[
PHP

Magic Methods 
PHP 摩斯碼 編碼/解碼 轉換程式 
CRUD with PHP Doctrine 
300+ PHP Presentations Online 
Imagick 

Zend Framework

Join Problems with Zend_Paginator and Zend_Db_Select objects | Let&#39;s explore the web technologies together 
Zend Framework testing: emulating HTTP calls

CSS

9 Top CSS Essential Skills That Every Web designer Should Learn 
Print Watermarks with CSS 
CSS Sprites2 - It&#39;s JavaScript Time 
Urban Grey Side Menu 
Easy Equal Columns with CSS 
Pixel Precision with Diagnostic CSS 
元素层叠级别及z-index剖析 

JavaScript

JavaScript frameworks 
JavaScript Scope 
10款让你震撼的图片展示js代码

jQuery

Trixie Script: jQuery Plugin評分整合 
FancyBox - fancy image zooming tool 
The jQuery emptyonclick Plugin 
Chain.js – Better JavaScript Template Engine (Based on JQuery) 
jQuery datePicker 
jQuery Dropdown Fun 
FancyZoom meet jQuery 

Web Development

Apache的rewrite的重写相关的参数 - PHP安装配置 
PHP SQL Injection 和 XSS 的偵測程式 和 程式撰寫注意事項 - 2008 
跨浏览器使用剪贴板

Browser

[情報] Google Chrome - Google 推出的瀏覽器各項功能一覽
Google 瀏覽器 Chrome for Web deveopler

Project

為什麼老闆不愛我的專案？ 

Software

[軟體] 免費、簡易的 Windows 截圖軟體 - Snapper 

Game

EA免費開放紅色警戒1雙光碟下載，預定RA3還可免費下載RA2

]]>
</summary> 
<content type="text/html" mode="escaped" xml:lang="zh-tw" xml:base="http://blog.roodo.com/jaceju/archives/7125781.html">
<![CDATA[
<h2>PHP</h2>
<ul>
<li><a href="http://blog.dougalmatthews.com/category/php/magic-methods/">Magic Methods</a> </li>
<li><a href="http://plog.longwin.com.tw/programming/2008/08/26/php-morse-encode-decode-convert-2008">PHP 摩斯碼 編碼/解碼 轉換程式</a> </li>
<li><a href="http://www.prodevtips.com/2008/08/24/crud-with-php-doctrine-and-smarty/">CRUD with PHP Doctrine</a> </li>
<li><a href="http://www.webmastersbydesign.com/2008/08/27/300-php-presentations-online/">300+ PHP Presentations Online</a> </li>
<li><a href="http://valokuva.org/">Imagick</a> </li>
</ul>
<h3>Zend Framework</h3>
<ul>
<li><a href="http://www.ajaxray.com/blog/2008/08/24/join-problems-with-zend_paginator-and-zend_db_select-objects/">Join Problems with Zend_Paginator and Zend_Db_Select objects | Let&#39;s explore the web technologies together</a> </li>
<li><a href="http://www.ibuildings.com/blog/archives/1261-Zend-Framework-testing-emulating-HTTP-calls.html">Zend Framework testing: emulating HTTP calls</a></li>
</ul>
<h2>CSS</h2>
<ul>
<li><a href="http://acomment.net/9-top-css-essential-skills-that-every-web-designer-should-learn/299">9 Top CSS Essential Skills That Every Web designer Should Learn</a> </li>
<li><a href="http://www.andypemberton.com/css/print-watermarks-with-css/">Print Watermarks with CSS</a> </li>
<li><a href="http://www.alistapart.com/articles/sprites2">CSS Sprites2 - It&#39;s JavaScript Time</a> </li>
<li><a href="http://www.dynamicdrive.com/style/csslibrary/item/urban_grey_side_menu/">Urban Grey Side Menu</a> </li>
<li><a href="http://www.impressivewebs.com/easy-equal-columns-with-css/">Easy Equal Columns with CSS</a> </li>
<li><a href="http://aloestudios.com/2008/08/pixel-precision-with-diagnostic-css/">Pixel Precision with Diagnostic CSS</a> </li>
<li><a href="http://www.blueidea.com/tech/web/2008/6140.asp">元素层叠级别及z-index剖析</a> </li>
</ul>
<h2>JavaScript</h2>
<ul>
<li><a href="http://hiddenpixels.com/designer-and-developer-resources/javascript-frameworks/">JavaScript frameworks</a> </li>
<li><a href="http://happygiraffe.net/blog/2008/08/27/javascript-scope/">JavaScript Scope</a> </li>
<li><a href="http://www.zcool.com.cn/jscode/javascript/20080325/code_032543362008.html">10款让你震撼的图片展示js代码</a></li>
</ul>
<h3>jQuery</h3>
<ul>
<li><a href="http://blog.darkthread.net/blogs/darkthreadtw/archive/2008/08/26/trixie-script-jquery-plugin-rating.aspx">Trixie Script: jQuery Plugin評分整合</a> </li>
<li><a href="http://fancy.klade.lv/">FancyBox - fancy image zooming tool</a> </li>
<li><a href="http://www.madewithlove.be/blog/the-jquery-emptyonclick-plugin/">The jQuery emptyonclick Plugin</a> </li>
<li><a href="http://javascriptly.com/2008/08/a-better-javascript-template-engine/">Chain.js – Better JavaScript Template Engine (Based on JQuery)</a> </li>
<li><a href="http://www.prodevtips.com/2008/09/02/jquery-datepicker/">jQuery datePicker</a> </li>
<li><a href="http://jgeewax.wordpress.com/2008/09/01/jquery-dropdown-fun/">jQuery Dropdown Fun</a> </li>
<li><a href="http://orderedlist.com/articles/fancyzoom-meet-jquery">FancyZoom meet jQuery</a> </li>
</ul>
<h2>Web Development</h2>
<ul>
<li><a href="http://www.phpv.net/html/1626.html">Apache的rewrite的重写相关的参数 - PHP安装配置</a> </li>
<li><a href="http://plog.longwin.com.tw/programming/2008/08/27/php-sql-injection-xss-security-2008">PHP SQL Injection 和 XSS 的偵測程式 和 程式撰寫注意事項 - 2008</a> </li>
<li><a href="http://realazy.org/blog/2008/09/01/using-clipboard-crossbrowsers/">跨浏览器使用剪贴板</a></li>
</ul>
<h2>Browser</h2>
<ul>
<li><a href="http://nelson.pixnet.net/blog/post/21635044">[情報] Google Chrome - Google 推出的瀏覽器各項功能一覽</a></li>
<li><a href="http://plog.longwin.com.tw/news-google-yahoo/2008/09/03/google-chrome-for-web-developer-2008">Google 瀏覽器 Chrome for Web deveopler</a></li>
</ul>
<h2>Project</h2>
<ul>
<li><a href="http://pesty.yichi.org/blog/2008/08/24/why_boss_doesnt_like_my_project/#more-413">為什麼老闆不愛我的專案？</a> </li>
</ul>
<h2>Software</h2>
<ul>
<li><a href="http://www.goston.net/2008/08/26/1584/">[軟體] 免費、簡易的 Windows 截圖軟體 - Snapper</a> </li>
</ul>
<h2>Game</h2>
<ul>
<li><a href="http://yblog.org/archive/index.php/8967">EA免費開放紅色警戒1雙光碟下載，預定RA3還可免費下載RA2</a></li>
</ul>

]]>
</content>
</entry> 
 <entry> 
 <title>[PHP] 觀念教室 - 取值函式</title> 
 <link rel="alternate" type="text/html" href="http://blog.roodo.com/jaceju/archives/7078107.html" /> 
 <modified>2008-08-31T12:02:12+08:00</modified> 
 <issued>2008-08-31T12:02:12+08:00</issued> 
 <id>tag:blog.roodo.com,2008://6970.7078107</id> 
 <created>2008-08-31T12:01:30+08:00</created> 
  <author>
 <name></name> 
 <url>http://blog.roodo.com/jaceju/</url> 
 
</author> 
<dc:subject> PHP</dc:subject> 
<summary type="text/html" mode="escaped">
<![CDATA[
通常在物件導向的開發過程裡，我們常會將類別的屬性隱藏起來，然後透過設值及取值函式來存取它們，也就是我們常說的 setter/getter 。
例如：
&lt;?php
class SampleClass
{
    private $_attr = 0;

    public function setAttr($value)
    {
        $this-&gt;_attr = (int) $value;
    }
    
    public function getAttr()
    {
        return $this-&gt;_attr;
    }
}
不過設值函式並不是本文的重點，這裡我先略過不談。
從上面的程式碼裡可以看到，取值函式似乎是一段再簡單不過的程式碼，它只是很單純的把物件內部的屬性值回傳而已。
但如果今天我們的屬性值是需要經過計算才能夠回傳的話，怎麼辦呢？我們應該把計算的邏輯寫在取值函式裡嗎？
在討論之前，我們先來假設一個簡單的狀況：
「現在有一個購物車程式，在使用者購買金額未超過 500 元時，我們要在總金額上加上運費 100 元；然而當總金額滿 500 元時，就不需要加入運費了。」
以下就是這個簡化過的購物車程式碼：
&lt;?php
/**
 * 購物車類別
 *
 */
class Cart
{
    /**
     * 購物車項目列表
     *
     * @var array
     */
    private $_itemList = array();

    /**
     * 總金額
     *
     * @var int
     */
    private $_total = 0;

    /**
     * 加入購物車項目
     *
     * @param array $item
     * @return Cart
     */
    public function addItem($item)
    {
        $this-&gt;_itemList[] = $item;
        return $this;
    }

    /**
     * 更新購物車
     *
     * @return Cart
     */
    public function refresh()
    {
        $this-&gt;_total = 0;
        foreach ($this-&gt;_itemList as $item) {
            $this-&gt;_total += $item['subTotal'];
        }
        return $this;
    }

    /**
     * 清空購物車
     *
     * @return void
     */
    public function clearAll()
    {
        $this-&gt;_itemList = array();
        $this-&gt;_total = 0;
    }

    /**
     * 取得總金額
     *
     * @return int
     */
    public function getTotal()
    {
        if ($this-&gt;_total &lt; 500) {
            $this-&gt;_total += 100;
        }
        return $this-&gt;_total;
    }
}
註：我故意省略掉數量、單價等資訊。
在邏輯上，這段程式碼似乎沒有什麼問題，在取得總金額時判斷是否應該加上運費看起來是很合理的。
是嗎？
相信有經驗的朋友，思考一下就能看出這個程式的邏輯錯誤。
看不出來的朋友也沒關係，我簡單寫個測試程式來說明：
&lt;?php

require 'Cart.php';

// 建立購物車物件
$cart = new Cart();

// 顯示總金額 (金額為 520 元，大於 500 元，故不加上運費)
echo $cart
    -&gt;addItem(array('name' =&gt; '商品1', 'subTotal' =&gt; 120))
    -&gt;addItem(array('name' =&gt; '商品2', 'subTotal' =&gt; 100))
    -&gt;addItem(array('name' =&gt; '商品3', 'subTotal' =&gt; 50))
    -&gt;addItem(array('name' =&gt; '商品4', 'subTotal' =&gt; 70))
    -&gt;addItem(array('name' =&gt; '商品5', 'subTotal' =&gt; 80))
    -&gt;refresh()
    -&gt;getTotal(), &quot;\n&quot;;

// 再顯示一次總金額 (正確顯示 520 元)
echo $cart-&gt;getTotal(), &quot;\n&quot;;

// 先清空購物車
$cart-&gt;clearAll();

// 顯示總金額 (金額為 340 元，小於 500 元，故加上 100 元運費)
echo $cart
    -&gt;addItem(array('name' =&gt; '商品1', 'subTotal' =&gt; 120))
    -&gt;addItem(array('name' =&gt; '商品2', 'subTotal' =&gt; 100))
    -&gt;addItem(array('name' =&gt; '商品3', 'subTotal' =&gt; 50))
    -&gt;addItem(array('name' =&gt; '商品4', 'subTotal' =&gt; 70))
    -&gt;refresh()
    -&gt;getTotal(), &quot;\n&quot;;

// 再顯示一次總金額 (錯了！竟然變成 540 元！)
echo $cart-&gt;getTotal(), &quot;\n&quot;;
從上面的程式可以發現，當我們購買金額小於 500 元時， Cart::getTotal 這個取值函式會幫我們自動加上運費。但是我們第二次呼叫 Cart::getTotal 時，程式竟然又幫我們加上了一次運費！
原因我想大家都看出來了，也就是說我們根本不應該在 Cart::getTotal 中加入運費判斷這件事情。這裡正確的做法是應該把運費判斷的條件寫在 Cart::refresh 這個方法裡，而 Cart::getTotal 應該要很單純地只是回傳 $_total 這個屬性值，也就是：
   /**
     * 更新購物車
     *
     * @return Cart
     */
    public function refresh()
    {
        $this-&gt;_total = 0;
        foreach ($this-&gt;_itemList as $item) {
            $this-&gt;_total += $item['subTotal'];
        }

        // 將運費判斷改到這裡
        if ($this-&gt;_total &lt; 500) {
            $this-&gt;_total += 100;
        }
        return $this;
    }
或許有人會問，什麼狀況下你會去呼叫兩次 Cart::getTotal ？其實答案很多，例如有時候在 MVC 模式下，我們常會用 Model 的取值函式來呈現其對應的值，這時我們就可能會多次去呼叫 Cart::getTotal ；也有可能其他團隊成員並不知道 Cart::getTotal 的運作方式，他們一直很快樂地使用著 Cart::getTotal 來取得總金額，直到慘劇的發生...
所以這裡我們暫時得到一個結論：取值函式不應該參與運算邏輯。
是嗎？
其實這樣的結論還是有問題的，接下來我們來看看以下這個計時器類別：
&lt;?php

class Timer
{
    public function getTime()
    {
        return time();
    }
}

$timer = new Timer();

echo $timer-&gt;getTime(), &quot;\n&quot;;
sleep(2);
echo $timer-&gt;getTime(), &quot;\n&quot;;
很明顯的，對計時器這種物件來說，即時性是很重要的，也就是說每一次取得的時間是會變動的。在這裡，取值函式就參與了時間的計算。
因此，我們要修正剛剛的結論，為它加入一個但書：除非有即時性的需求，否則取值函式不應該參與運算邏輯。
有其他想法嗎？歡迎大家一起討論。
]]>
</summary> 
<content type="text/html" mode="escaped" xml:lang="zh-tw" xml:base="http://blog.roodo.com/jaceju/archives/7078107.html">
<![CDATA[
<p>通常在物件導向的開發過程裡，我們常會將類別的屬性隱藏起來，然後透過設值及取值函式來存取它們，也就是我們常說的 setter/getter 。</p>
<p>例如：</p>
<pre><code>&lt;?php
class SampleClass
{
    private $_attr = 0;

    public function setAttr($value)
    {
        $this-&gt;_attr = (int) $value;
    }
    
    public function getAttr()
    {
        return $this-&gt;_attr;
    }
}</code></pre>
<p>不過設值函式並不是本文的重點，這裡我先略過不談。</p>
<p>從上面的程式碼裡可以看到，取值函式似乎是一段再簡單不過的程式碼，它只是很單純的把物件內部的屬性值回傳而已。</p>
<p>但如果今天我們的屬性值是需要經過計算才能夠回傳的話，怎麼辦呢？我們應該把計算的邏輯寫在取值函式裡嗎？</p>
<p>在討論之前，我們先來假設一個簡單的狀況：</p>
<p>「現在有一個購物車程式，在使用者購買金額未超過 500 元時，我們要在總金額上加上運費 100 元；然而當總金額滿 500 元時，就不需要加入運費了。」</p>
<p>以下就是這個簡化過的購物車程式碼：</p>
<pre><code>&lt;?php
/**
 * 購物車類別
 *
 */
class Cart
{
    /**
     * 購物車項目列表
     *
     * @var array
     */
    private $_itemList = array();

    /**
     * 總金額
     *
     * @var int
     */
    private $_total = 0;

    /**
     * 加入購物車項目
     *
     * @param array $item
     * @return Cart
     */
    public function addItem($item)
    {
        $this-&gt;_itemList[] = $item;
        return $this;
    }

    /**
     * 更新購物車
     *
     * @return Cart
     */
    public function refresh()
    {
        $this-&gt;_total = 0;
        foreach ($this-&gt;_itemList as $item) {
            $this-&gt;_total += $item['subTotal'];
        }
        return $this;
    }

    /**
     * 清空購物車
     *
     * @return void
     */
    public function clearAll()
    {
        $this-&gt;_itemList = array();
        $this-&gt;_total = 0;
    }

    /**
     * 取得總金額
     *
     * @return int
     */
    public function getTotal()
    {
        if ($this-&gt;_total &lt; 500) {
            $this-&gt;_total += 100;
        }
        return $this-&gt;_total;
    }
}</code></pre>
<p class="note">註：我故意省略掉數量、單價等資訊。</p>
<p>在邏輯上，這段程式碼似乎沒有什麼問題，在取得總金額時判斷是否應該加上運費看起來是很合理的。</p>
<p><strong>是嗎？</strong></p>
<p>相信有經驗的朋友，思考一下就能看出這個程式的邏輯錯誤。</p>
<p>看不出來的朋友也沒關係，我簡單寫個測試程式來說明：</p>
<pre><code>&lt;?php

require 'Cart.php';

// 建立購物車物件
$cart = new Cart();

// 顯示總金額 (金額為 520 元，大於 500 元，故不加上運費)
echo $cart
    -&gt;addItem(array('name' =&gt; '商品1', 'subTotal' =&gt; 120))
    -&gt;addItem(array('name' =&gt; '商品2', 'subTotal' =&gt; 100))
    -&gt;addItem(array('name' =&gt; '商品3', 'subTotal' =&gt; 50))
    -&gt;addItem(array('name' =&gt; '商品4', 'subTotal' =&gt; 70))
    -&gt;addItem(array('name' =&gt; '商品5', 'subTotal' =&gt; 80))
    -&gt;refresh()
    -&gt;getTotal(), &quot;\n&quot;;

// 再顯示一次總金額 (正確顯示 520 元)
echo $cart-&gt;getTotal(), &quot;\n&quot;;

// 先清空購物車
$cart-&gt;clearAll();

// 顯示總金額 (金額為 340 元，小於 500 元，故加上 100 元運費)
echo $cart
    -&gt;addItem(array('name' =&gt; '商品1', 'subTotal' =&gt; 120))
    -&gt;addItem(array('name' =&gt; '商品2', 'subTotal' =&gt; 100))
    -&gt;addItem(array('name' =&gt; '商品3', 'subTotal' =&gt; 50))
    -&gt;addItem(array('name' =&gt; '商品4', 'subTotal' =&gt; 70))
    -&gt;refresh()
    -&gt;getTotal(), &quot;\n&quot;;

// 再顯示一次總金額 (錯了！竟然變成 540 元！)
echo $cart-&gt;getTotal(), &quot;\n&quot;;</code></pre>
<p>從上面的程式可以發現，當我們購買金額小於 500 元時， Cart::getTotal 這個取值函式會幫我們自動加上運費。但是我們第二次呼叫 Cart::getTotal 時，程式竟然又幫我們加上了一次運費！</p>
<p>原因我想大家都看出來了，也就是說我們根本不應該在 Cart::getTotal 中加入運費判斷這件事情。這裡正確的做法是應該把運費判斷的條件寫在 Cart::refresh 這個方法裡，而 Cart::getTotal 應該要很單純地只是回傳 $_total 這個屬性值，也就是：</p>
<pre><code>   /**
     * 更新購物車
     *
     * @return Cart
     */
    public function refresh()
    {
        $this-&gt;_total = 0;
        foreach ($this-&gt;_itemList as $item) {
            $this-&gt;_total += $item['subTotal'];
        }

        <strong>// 將運費判斷改到這裡</strong>
        if ($this-&gt;_total &lt; 500) {
            $this-&gt;_total += 100;
        }
        return $this;
    }</code></pre>
<p>或許有人會問，什麼狀況下你會去呼叫兩次 Cart::getTotal ？其實答案很多，例如有時候在 MVC 模式下，我們常會用 Model 的取值函式來呈現其對應的值，這時我們就可能會多次去呼叫 Cart::getTotal ；也有可能其他團隊成員並不知道 Cart::getTotal 的運作方式，他們一直很快樂地使用著 Cart::getTotal 來取得總金額，直到慘劇的發生...</p>
<p>所以這裡我們暫時得到一個結論：<strong>取值函式不應該參與運算邏輯。</strong></p>
<p><strong>是嗎？</strong></p>
<p>其實這樣的結論還是有問題的，接下來我們來看看以下這個計時器類別：</p>
<pre><code>&lt;?php

class Timer
{
    public function getTime()
    {
        return time();
    }
}

$timer = new Timer();

echo $timer-&gt;getTime(), &quot;\n&quot;;
sleep(2);
echo $timer-&gt;getTime(), &quot;\n&quot;;</code></pre>
<p>很明顯的，對計時器這種物件來說，即時性是很重要的，也就是說每一次取得的時間是會變動的。在這裡，取值函式就參與了時間的計算。</p>
<p>因此，我們要修正剛剛的結論，為它加入一個但書：<strong>除非有即時性的需求，否則取值函式不應該參與運算邏輯。</strong></p>
<p>有其他想法嗎？歡迎大家一起討論。</p>

]]>
</content>
</entry> 
 <entry> 
 <title>[Web] 連結分享</title> 
 <link rel="alternate" type="text/html" href="http://blog.roodo.com/jaceju/archives/6954675.html" /> 
 <modified>2008-08-26T17:09:23+08:00</modified> 
 <issued>2008-08-26T17:09:23+08:00</issued> 
 <id>tag:blog.roodo.com,2008://6970.6954675</id> 
 <created>2008-08-24T03:47:42+08:00</created> 
  <author>
 <name></name> 
 <url>http://blog.roodo.com/jaceju/</url> 
 
</author> 
<dc:subject>連結分享</dc:subject> 
<summary type="text/html" mode="escaped">
<![CDATA[
PHP

嘗試行為驅動開發 
Stupid PHP Tricks: Illegal Variable Names

Zend Framework

Loading models within modules in the Zend Framework 

JavaScript

A Javascript stacktrace in any browser 
Object.getPrototypeOf 
JavaScript Arguments 
20 frische AJAX- und Javascripts

jQuery

Create A Tabbed Interface Using jQuery 
The Complete Guide for You to Become an Almighty jQuery Developer 
Generating Automatic Website Footnotes with jQuery 
timeago: a jQuery plugin 
65 Excellent jQuery Resources (tutorials,cheat sheets,ebooks,demos,plugins…) 
Tracking Clicks with jQuery and Google Analytics 
5 jQuery Questions...and Answers 
jQuery Tabbed Navigation 
Animation Jump - quick tip 

CSS

Form Elements: 40+ CSS/JS Styling and Functionality Techniques 
10 Invaluable CSS Resources 
CSS 3 Rounded Corners 
5 Steps for the Perfect Tabbed Navigation Menu 
20 Popular CSS Online Tools and Generators

Web Development

Dynamically Resizing Text with CSS and Javascript 
SQL Injection attacks in the wild - why they&#39;re working and what to do

Browser

該你上場了！Mozilla號召使用者勾勒夢幻瀏覽器 
幫Firefox檢查書籤是否還連得上（Bookmarks Link Checker Minus） 

Design

Using Light, Color and Contrast Effectively in UI Design 

Service

FaceYourManga.com 

System

整合 Subversion、Apache 與 Active Directory
Apache 整合微軟 Active Directory 做身份認證

]]>
</summary> 
<content type="text/html" mode="escaped" xml:lang="zh-tw" xml:base="http://blog.roodo.com/jaceju/archives/6954675.html">
<![CDATA[
<h2>PHP</h2>
<ul>
<li><a href="http://www.dualface.com/blog/?p=552">嘗試行為驅動開發</a> </li>
<li><a href="http://www.otton.org/2008/08/21/stupid-php-tricks-illegal-variable-names/">Stupid PHP Tricks: Illegal Variable Names</a></li>
</ul>
<h3>Zend Framework</h3>
<ul>
<li><a href="http://phpimpact.wordpress.com/2008/08/12/loading-models-within-modules-in-the-zend-framework/">Loading models within modules in the Zend Framework</a> </li>
</ul>
<h2>JavaScript</h2>
<ul>
<li><a href="http://eriwen.com/javascript/js-stack-trace/">A Javascript stacktrace in any browser</a> </li>
<li><a href="http://ejohn.org/blog/objectgetprototypeof/">Object.getPrototypeOf</a> </li>
<li><a href="http://www.seifi.org/javascript/javascript-arguments.html">JavaScript Arguments</a> </li>
<li><a href="http://www.drweb.de/weblog/weblog/?p=1345">20 frische AJAX- und Javascripts</a></li>
</ul>
<h3>jQuery</h3>
<ul>
<li><a href="http://nettuts.com/javascript-ajax/create-a-tabbed-interface-using-jquery/">Create A Tabbed Interface Using jQuery</a> </li>
<li><a href="http://effectize.com/jquery-developer-guide">The Complete Guide for You to Become an Almighty jQuery Developer</a> </li>
<li><a href="http://www.cssnewbie.com/generating-automatic-website-footnotes-with-jquery/">Generating Automatic Website Footnotes with jQuery</a> </li>
<li><a href="http://timeago.yarp.com/">timeago: a jQuery plugin</a> </li>
<li><a href="http://speckyboy.com/2008/04/02/65-excellent-jquery-resources-tutorialscheat-sheetsebooksdemosplugins/">65 Excellent jQuery Resources (tutorials,cheat sheets,ebooks,demos,plugins…)</a> </li>
<li><a href="http://www.prodevtips.com/2008/08/19/tracking-clicks-with-jquery-and-google-analytics/">Tracking Clicks with jQuery and Google Analytics</a> </li>
<li><a href="http://www.detacheddesigns.com/blog/blogSpecific.aspx?BlogId=74">5 jQuery Questions...and Answers</a> </li>
<li><a href="http://trevordavis.net/blog/tutorial/jquery-tabbed-navigation/">jQuery Tabbed Navigation</a> </li>
<li><a href="http://jqueryfordesigners.com/animation-jump-quick-tip/">Animation Jump - quick tip</a> </li>
</ul>
<h2>CSS</h2>
<ul>
<li><a href="http://www.noupe.com/css/form-elements-40-cssjs-styling-and-functionality-techniques.html">Form Elements: 40+ CSS/JS Styling and Functionality Techniques</a> </li>
<li><a href="http://crazeegeekchick.com/blog/10-invaluable-css-resources/">10 Invaluable CSS Resources</a> </li>
<li><a href="http://stylizedweb.com/2008/08/19/css3-rounded-corners/">CSS 3 Rounded Corners</a> </li>
<li><a href="http://www.usabilitypost.com/post/6-5-steps-for-the-perfect-tabbed-navigation-menu">5 Steps for the Perfect Tabbed Navigation Menu</a> </li>
<li><a href="http://www.cssjuice.com/20-popular-css-online-tools/">20 Popular CSS Online Tools and Generators</a></li>
</ul>
<h2>Web Development</h2>
<ul>
<li><a href="http://mirificampress.com/permalink/daynamically_resizing_text_with_css_and_javascript">Dynamically Resizing Text with CSS and Javascript</a> </li>
<li><a href="http://www.greghughes.net/rant/SQLInjectionAttacksInTheWildWhyTheyreWorkingAndWhatToDo.aspx">SQL Injection attacks in the wild - why they&#39;re working and what to do</a></li>
</ul>
<h2>Browser</h2>
<ul>
<li><a href="http://mozlinks-zh.blogspot.com/2008/08/mozilla.html">該你上場了！Mozilla號召使用者勾勒夢幻瀏覽器</a> </li>
<li><a href="http://briian.com/?p=5685">幫Firefox檢查書籤是否還連得上（Bookmarks Link Checker Minus）</a> </li>
</ul>
<h2>Design</h2>
<ul>
<li><a href="http://www.usabilitypost.com/post/5-using-light-color-and-contrast-effectively-in-ui-design">Using Light, Color and Contrast Effectively in UI Design</a> </li>
</ul>
<h2>Service</h2>
<ul>
<li><a href="http://www.faceyourmanga.com/faceyourmanga.php?lang=eng">FaceYourManga.com</a> </li>
</ul>
<h2>System</h2>
<ul>
<li><a href="http://blog.adahsu.net/ada/space/start/2008-08-19/1#??_Subversion?Apache_?_Active_Directory_">整合 Subversion、Apache 與 Active Directory</a></li>
<li><a href="http://blog.adahsu.net/ada/space/start/2008-08-15/1">Apache 整合微軟 Active Directory 做身份認證</a></li>
</ul>

]]>
</content>
</entry> 
 <entry> 
 <title>[Web] 連結分享</title> 
 <link rel="alternate" type="text/html" href="http://blog.roodo.com/jaceju/archives/6794485.html" /> 
 <modified>2008-08-14T10:33:48+08:00</modified> 
 <issued>2008-08-14T10:33:48+08:00</issued> 
 <id>tag:blog.roodo.com,2008://6970.6794485</id> 
 <created>2008-08-14T10:33:03+08:00</created> 
  <author>
 <name></name> 
 <url>http://blog.roodo.com/jaceju/</url> 
 
</author> 
<dc:subject>連結分享</dc:subject> 
<summary type="text/html" mode="escaped">
<![CDATA[
PHP

    Debugging PHP with Firebug and FirePHP 
    Using Annotations in PHP 
    PHP: todo:php53 
    innerHTML in php-dom 
    12 PHP optimization tips 
    PHP5的 SPL 
    PHP: Using PHP from the command line 
    Write Your Own Virtual Host Control Panel - Part 1 
    Accessing Incoming PUT Data from PHP 
    Parallel web scraping in PHP: cURL multi functions 
    PHP5 Autoloading on Steroids 
    Create custom backups from your website using cURL 
    Strand sort presented in PHP 
    Geolocate your visitors with PHP (part 2) 
    Upcoming features in PHP 5.3 
    Where is the include coming from? 
    Testing php5.3.0 alpha1 
    PHP5.3 新特性之&quot;命名空间&quot;介绍 
    mysqlnd成为php 5.3中的默认mysql驱动 
    PHP面试题汇总 
    微軟推出官方版的 Microsoft SQL Server 2005 Driver for PHP 

Zend Framework

    Zend Framework 1.6 Release Candidate 1 available 
    Zend_File_Transfer examples or using validators to increase security 
    Zend Framework Architecture 
    Adobe to contribute AMF support to Zend Framework 
    Zend_View_smarty 
    Zend Framework 1.6.0 Preview, or, PHP 4 is Dead 
    Implementing Zend Layout and Smarty using Zend Framework MVC 

JavaScript

    Non-blocking JavaScript Downloads 
    用JS实现一个页面两份样式表 
    Preventing XSS in Javascript strings 
    Unit PNG Fix 

jQuery

    Five jQuery plugins that are a joy to use 
    jQuery ColorPicker with Easy Customization 
    Extendable Flash Banner with jQuery Flash 
    6 More jQuery Tips: Text Searching, Page Load Time and Others 
    Image Fade Revisited 
    Bind a Hot Key Combination with jQuery Hotkeys 
    Simple Static Tooltip Widget using jQuery.UI 

CSS

    CSS Layouts: 40+ Tutorials, Tips, Demos and Best Practices 
    Removing The Dotted Outline 
    CSS Frameworks 
    Solving 5 Common CSS Headaches 
    Specifics on CSS Specificity 
    Top 10 CSS Table Designs 
    border-image in Firefox 
    &lt;SELECT&gt;-Free Layer 

Web Development

    網頁重覆送出問題，IE的專利? 
    Button Width in IE 
    Internet Explorer Submit Button Horizontal Padding 
    SQL Injection Cheat Sheet 
    A brand new PNG fix for IE6 
    URL Rewriting for Beginners 
    How to Backup a Web Server 

Database

    How Are Dates Stored In SQL Server? 

MySQL

    MySQL Memcache_engine的安裝與使用 
    MySQL拆表 
    Quick tip: how to convert tables to InnoDB 
    檢查 mysql sql 效能使用 MySQL Slow Queries

Browser

    The Best Firefox Developer Extensions Around 
    [教學] 兩個小技巧讓 ScrapBook 更好用 
    CSS3 support in Firefox 3.1 
    [分享] Pencil - 讓你用 Firefox 來畫圖 
    用Firefox就可以下載YouTube影片、Flash遊戲！（Video DownloadHelper擴充套件） 

Programming

    十個軟體設計師應該有的觀念 
    5 rules of variable naming. 
    天兵學弟 

SCM

    Subversion pre-commit hook 

Service

    MSN Minimise Me - MSN官方推出的大頭貼製作工具！ 
    Fontifier - Your own handwriting on your computer! 
    台灣工研院研發「中文文字轉語音合成系統」，好玩！ 

Software

    介紹好用工具：Streams 讓你瞭解神秘的 NTFS 檔案系統 
    AVIcodec v1.2 build 113 - 檢測影片編碼 
    Process Monitor基本操作教學 
    URL2JPEG v1.1 - 擷取網頁圖片 

System

    【茶包射手專欄】Windows桌面開太多東西就&quot;怪怪的&quot; 
    修復因安裝不友好的deb導致包管理系統癱瘓的思路 

]]>
</summary> 
<content type="text/html" mode="escaped" xml:lang="zh-tw" xml:base="http://blog.roodo.com/jaceju/archives/6794485.html">
<![CDATA[
<h2 >PHP</h2>
<ul>
    <li><a href="http://www.developertutorials.com/blog/php/debugging-php-with-firebug-and-firephp-365/" >Debugging PHP with Firebug and FirePHP</a> </li>
    <li><a href="http://phpimpact.wordpress.com/2008/07/19/using-annotations-in-php/" >Using Annotations in PHP</a> </li>
    <li><a href="http://wiki.php.net/todo/php53" >PHP: todo:php53</a> </li>
    <li><a href="http://verens.com/archives/2008/07/28/innerhtml-in-php-dom/" >innerHTML in php-dom</a> </li>
    <li><a href="http://www.moskalyuk.com/blog/php-optimization-tips/1272" >12 PHP optimization tips</a> </li>
    <li><a href="http://www.phpobject.net/blog/read.php?140" >PHP5的 SPL</a> </li>
    <li><a href="http://tw.php.net/features.commandline" >PHP: Using PHP from the command line</a> </li>
    <li><a href="http://cognifty.com/main.content/write_your_own_virtual_host_control_panel_part_1.html" >Write Your Own Virtual Host Control Panel - Part 1</a> </li>
    <li><a href="http://www.lornajane.net/posts/2008/Accessing-Incoming-PUT-Data-from-PHP" >Accessing Incoming PUT Data from PHP</a> </li>
    <li><a href="http://www.developertutorials.com/blog/php/parallel-web-scraping-in-php-curl-multi-functions-375/" >Parallel web scraping in PHP: cURL multi functions</a> </li>
    <li><a href="http://codefeast.com/?p=11" >PHP5 Autoloading on Steroids</a> </li>
    <li><a href="http://www.web-development-blog.com/archives/create-custom-backups-from-your-website-using-curl/#more-145" >Create custom backups from your website using cURL</a> </li>
    <li><a href="http://threebyte.eu/2008/07/30/strand-sort-presented-in-php/" >Strand sort presented in PHP</a> </li>
    <li><a href="http://htmlblog.net/geolocate-your-visitors-with-php-part-2/" >Geolocate your visitors with PHP (part 2)</a> </li>
    <li><a href="http://www.rooftopsolutions.nl/article/199" >Upcoming features in PHP 5.3</a> </li>
    <li><a href="http://phpimpact.wordpress.com/2008/08/04/php-applications-where-is-the-include-coming-from/" >Where is the include coming from?</a> </li>
    <li><a href="http://www.phpfreaks.com/blog/testing-php530" >Testing php5.3.0 alpha1</a> </li>
    <li><a href="http://www.phpv.net/html/PHP_namespace.html" >PHP5.3 新特性之&quot;命名空间&quot;介绍</a> </li>
    <li><a href="http://www.ooso.net/index.php/archives/464" >mysqlnd成为php 5.3中的默认mysql驱动</a> </li>
    <li><a href="http://www.phpv.net/html/1622.html" >PHP面试题汇总</a> </li>
    <li><a href="http://blog.miniasp.com/post/2008/08/Microsoft-SQL-Server-2005-Driver-for-PHP-Released.aspx" >微軟推出官方版的 Microsoft SQL Server 2005 Driver for PHP</a> </li>
</ul>
<h3 >Zend Framework</h3>
<ul>
    <li><a href="http://www.zendframeworkinaction.com/2008/07/22/zend-framework-16-release-candidate-1-available/" >Zend Framework 1.6 Release Candidate 1 available</a> </li>
    <li><a href="http://www.thomasweidner.com/flatpress/2008/07/20/zend_file_transfer-examples-or-using-validators-to-increase-security" >Zend_File_Transfer examples or using validators to increase security</a> </li>
    <li><a href="http://phpimpact.wordpress.com/2008/07/28/zend-framework-architecture/" >Zend Framework Architecture</a> </li>
    <li><a href="http://andigutmans.blogspot.com/2008/07/adobe-to-contribute-amf-support-to-zend.html" >Adobe to contribute AMF support to Zend Framework</a> </li>
    <li><a href="http://propaganda.io/tutorials/" >Zend_View_smarty</a> </li>
    <li><a href="http://weierophinney.net/matthew/archives/183-Zend-Framework-1.6.0-Preview,-or,-PHP-4-is-Dead.html" >Zend Framework 1.6.0 Preview, or, PHP 4 is Dead</a> </li>
    <li><a href="http://anders.tyckr.com/2008/03/12/" >Implementing Zend Layout and Smarty using Zend Framework MVC</a> </li>
</ul>
<h2 >JavaScript</h2>
<ul>
    <li><a href="http://yuiblog.com/blog/2008/07/22/non-blocking-scripts/" >Non-blocking JavaScript Downloads</a> </li>
    <li><a href="http://www.blueidea.com/tech/web/2008/5980.asp" >用JS实现一个页面两份样式表</a> </li>
    <li><a href="http://www.rooftopsolutions.nl/article/197" >Preventing XSS in Javascript strings</a> </li>
    <li><a href="http://labs.unitinteractive.com/unitpngfix.php" >Unit PNG Fix</a> </li>
</ul>
<h3 >jQuery</h3>
<ul>
    <li><a href="http://www.pathf.com/blogs/2008/07/five-jquery-plugins-that-are-a-joy-to-use/" >Five jQuery plugins that are a joy to use</a> </li>
    <li><a href="http://www.webappers.com/2008/07/23/jquery-colorpicker-with-easy-customization/" >jQuery ColorPicker with Easy Customization</a> </li>
    <li><a href="http://www.prodevtips.com/2008/07/26/extendable-flash-banner-with-jquery-flash/" >Extendable Flash Banner with jQuery Flash</a> </li>
    <li><a href="http://johannburkard.de/blog/programming/javascript/6-more-jquery-tips-text-searching-page-load-time-and-others.html" >6 More jQuery Tips: Text Searching, Page Load Time and Others</a> </li>
    <li><a href="http://jqueryfordesigners.com/image-fade-revisited/" >Image Fade Revisited</a> </li>
    <li><a href="http://www.webappers.com/2008/07/31/bind-a-hot-key-combination-with-jquery-hotkeys/" >Bind a Hot Key Combination with jQuery Hotkeys</a> </li>
    <li><a href="http://mosesofegypt.net/post/2008/08/02/Simple-Static-Tooltip-Widget-using-jQueryUI.aspx" >Simple Static Tooltip Widget using jQuery.UI</a> </li>
</ul>
<h2 >CSS</h2>
<ul>
    <li><a href="http://www.noupe.com/css/css-layouts-40-tutorials-tips-demos-and-best-practices.html" >CSS Layouts: 40+ Tutorials, Tips, Demos and Best Practices</a> </li>
    <li><a href="http://css-tricks.com/removing-the-dotted-outline/" >Removing The Dotted Outline</a> </li>
    <li><a href="http://hiddenpixels.com/css-stuffs/css-frameworks/" >CSS Frameworks</a> </li>
    <li><a href="http://nettuts.com/html-css-techniques/solving-5-common-css-headaches/" >Solving 5 Common CSS Headaches</a> </li>
    <li><a href="http://css-tricks.com/specifics-on-css-specificity/" >Specifics on CSS Specificity</a> </li>
    <li><a href="http://www.smashingmagazine.com/2008/08/13/top-10-css-table-designs/" >Top 10 CSS Table Designs</a> </li>
    <li><a href="http://ejohn.org/blog/border-image-in-firefox/" >border-image in Firefox</a> </li>
    <li><a href="http://www.hedgerwow.com/360/bugs/css-select-free.html" >&lt;SELECT&gt;-Free Layer</a> </li>
</ul>
<h2 >Web Development</h2>
<ul>
    <li><a href="http://blog.darkthread.net/blogs/darkthreadtw/archive/2008/07/23/3356.aspx" >網頁重覆送出問題，IE的專利?</a> </li>
    <li><a href="http://jehiah.cz/archive/button-width-in-ie" >Button Width in IE</a> </li>
    <li><a href="http://www.mrkirkland.com/internet-explorer-submit-button-horizontal-padding/" >Internet Explorer Submit Button Horizontal Padding</a> </li>
    <li><a href="http://ferruh.mavituna.com/sql-injection-cheatsheet-oku/" >SQL Injection Cheat Sheet</a> </li>
    <li><a href="http://stylizedweb.com/2008/07/27/a-brand-new-png-fix-for-ie6/" >A brand new PNG fix for IE6</a> </li>
    <li><a href="http://www.addedbytes.com/apache/url-rewriting-for-beginners/" >URL Rewriting for Beginners</a> </li>
    <li><a href="http://www.webappers.com/2008/08/05/how-to-backup-a-web-server/" >How to Backup a Web Server</a> </li>
</ul>
<h2 >Database</h2>
<ul>
    <li><a href="http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/how-are-dates-stored-in-sql-server" >How Are Dates Stored In SQL Server?</a> </li>
</ul>
<h3 >MySQL</h3>
<ul>
    <li><a href="http://www.phpv.net/html/1617.html" >MySQL Memcache_engine的安裝與使用</a> </li>
    <li><a href="http://www.rollenc.com/id/419" >MySQL拆表</a> </li>
    <li><a href="http://www.mysqlperformanceblog.com/2008/07/30/quick-tip-how-to-convert-tables-to-innodb/" >Quick tip: how to convert tables to InnoDB</a> </li>
    <li><a href="http://gglog.net/blog/index.php?op=ViewArticle&amp;articleId=82&amp;blogId=1" >檢查 mysql sql 效能使用 MySQL Slow Queries</a></li>
</ul>
<h2 >Browser</h2>
<ul>
    <li><a href="http://www.webmastersbydesign.com/2008/07/23/the-best-firefox-developers-extensions-around/" >The Best Firefox Developer Extensions Around</a> </li>
    <li><a href="http://blog.pixnet.net/Nelson/post/20371072" >[教學] 兩個小技巧讓 ScrapBook 更好用</a> </li>
    <li><a href="http://www.css3.info/css3-support-in-firefox-31/" >CSS3 support in Firefox 3.1</a> </li>
    <li><a href="http://blog.pixnet.net/Nelson/post/20592714" >[分享] Pencil - 讓你用 Firefox 來畫圖</a> </li>
    <li><a href="http://briian.com/?p=5663" >用Firefox就可以下載YouTube影片、Flash遊戲！（Video DownloadHelper擴充套件）</a> </li>
</ul>
<h2 >Programming</h2>
<ul>
    <li><a href="http://tangblack.blogspot.com/2008/07/blog-post_25.html" >十個軟體設計師應該有的觀念</a> </li>
    <li><a href="http://ianhickman.blogspot.com/2008/07/5-rules-of-variable-naming.html" >5 rules of variable naming.</a> </li>
    <li><a href="http://chenpc.csie.net/?p=289" >天兵學弟</a> </li>
</ul>
<h2 >SCM</h2>
<ul>
    <li><a href="http://blog.urdada.net/2008/07/30/88/" >Subversion pre-commit hook</a> </li>
</ul>
<h2 >Service</h2>
<ul>
    <li><a href="http://www.freegroup.org/msn-minimise-me" >MSN Minimise Me - MSN官方推出的大頭貼製作工具！</a> </li>
    <li><a href="http://www.fontifier.com/" >Fontifier - Your own handwriting on your computer!</a> </li>
    <li><a href="http://briian.com/?p=5665" >台灣工研院研發「中文文字轉語音合成系統」，好玩！</a> </li>
</ul>
<h2 >Software</h2>
<ul>
    <li><a href="http://blog.miniasp.com/post/2008/07/Useful-tools-Streams-let-you-know-the-uncovered-secret-in-NTFS.aspx" >介紹好用工具：Streams 讓你瞭解神秘的 NTFS 檔案系統</a> </li>
    <li><a href="http://portable.easylife.idv.tw/376" >AVIcodec v1.2 build 113 - 檢測影片編碼</a> </li>
    <li><a href="http://blog.darkthread.net/blogs/darkthreadtw/archive/2007/08/18/977.aspx" >Process Monitor基本操作教學</a> </li>
    <li><a href="http://portable.easylife.idv.tw/1413" >URL2JPEG v1.1 - 擷取網頁圖片</a> </li>
</ul>
<h2 >System</h2>
<ul>
    <li><a href="http://blog.darkthread.net/blogs/darkthreadtw/archive/2008/07/31/desktop-heap-issue.aspx" >【茶包射手專欄】Windows桌面開太多東西就&quot;怪怪的&quot;</a> </li>
    <li><a href="http://www.smallway.idv.tw/f2blog/index.php?load=read&amp;id=9" >修復因安裝不友好的deb導致包管理系統癱瘓的思路</a> </li>
</ul>

]]>
</content>
</entry> 
 <entry> 
 <title>[JavaScript] 五分鐘小教室 - 不重複送出 Ajax Request</title> 
 <link rel="alternate" type="text/html" href="http://blog.roodo.com/jaceju/archives/6643083.html" /> 
 <modified>2008-08-02T17:35:04+08:00</modified> 
 <issued>2008-08-02T17:35:04+08:00</issued> 
 <id>tag:blog.roodo.com,2008://6970.6643083</id> 
 <created>2008-08-02T17:32:50+08:00</created> 
  <author>
 <name></name> 
 <url>http://blog.roodo.com/jaceju/</url> 
 
</author> 
<dc:subject>JavaScript</dc:subject> 
<summary type="text/html" mode="escaped">
<![CDATA[
這次在設計購物車時，遇到了以下的介面：

客戶的需求是在按下「 + 」 或「 - 」時，要以 Ajax 發送更新的數量到後端系統去驗算；每按一次「 + 」 或「 - 」，就要送出一次 Ajax Request。
可是這時候問題就來啦，如果數量要 10 個的話就要連續按 10 次「 + 」，也會連續發送 10 次的 Ajax Request ；這樣不但會浪費珍貴的網路頻寬，更不用說會造成後端系統的負擔。 
怎麼解決呢？其實方法很多，而這裡我採用最簡單的 setTimeout 和 clearTimeout 。程式如下：
var sending = null;

var _formSubmit = function () {
    alert('Form submited!');
};

var _doAjaxPost = function () {
    if (sending !== null) {
        clearTimeout(sending);
        sending = null;
    }
    sending = setTimeout(_formSubmit, 1000);
};

var plusQuantity = function () {
    // ... 執行增加數量的動作 ...
    _doAjaxPost();
    return false;
};

var minusQuantity = function () {
    // ... 執行減少數量的動作 ...
    _doAjaxPost();
    return false;
};

$(function () {
    // 增加數量
    $('a.plus').click(plusQuantity);

    // 減少數量
    $('a.minus').click(minusQuantity);
});
註：這裡我大量使用了 jQuery 的功能。 
想法很簡單，就是當我們按下「 + 」 或「 - 」時，要隔一秒才會送出 Ajax Request ；而在這一秒內如果再次按下「 + 」 或「 - 」，那麼就重新計時。 
因此程式的主要重點在 _doAjaxPost 這個函式以及全域變數： sending ；當第一次呼叫 _doAjaxPost 時 sending 還是 null ，這時我們利用 setTimeout 開始計時，並將計時器指定給 sending 這個變數。而當第二次呼叫時， sending 變數已經不為空值，因此我們再利用 clearTimeout 將它清除，並重設為 null 以達到重新計時的目的。
是不是很簡單呢？
如果各位有更好的作法，也歡迎分享~ 
]]>
</summary> 
<content type="text/html" mode="escaped" xml:lang="zh-tw" xml:base="http://blog.roodo.com/jaceju/archives/6643083.html">
<![CDATA[
<p>這次在設計購物車時，遇到了以下的介面：</p>
<p class="image"><img src="http://www.jaceju.net/resources/norepeat_ajax/ajax_interface.gif" alt="" width="64" height="50" /></p>
<p>客戶的需求是在按下「 + 」 或「 - 」時，要以 Ajax 發送更新的數量到後端系統去驗算；每按一次「 + 」 或「 - 」，就要送出一次 Ajax Request。</p>
<p>可是這時候問題就來啦，如果數量要 10 個的話就要連續按 10 次「 + 」，也會連續發送 10 次的 Ajax Request ；這樣不但會浪費珍貴的網路頻寬，更不用說會造成後端系統的負擔。 </p>
<p>怎麼解決呢？其實方法很多，而這裡我採用最簡單的 setTimeout 和 clearTimeout 。程式如下：</p>
<pre><code><strong>var sending = null;</strong>

var _formSubmit = function () {
    alert('Form submited!');
};

<strong>var _doAjaxPost = function () {</strong>
    <strong>if (sending !== null) {</strong>
        <strong>clearTimeout(sending);</strong>
        <strong>sending = null;</strong>
    <strong>}</strong>
    <strong>sending = setTimeout(_formSubmit, 1000);</strong>
<strong>};</strong>

var plusQuantity = function () {
    // ... 執行增加數量的動作 ...
    _doAjaxPost();
    return false;
};

var minusQuantity = function () {
    // ... 執行減少數量的動作 ...
    _doAjaxPost();
    return false;
};

$(function () {
    // 增加數量
    $('a.plus').click(plusQuantity);

    // 減少數量
    $('a.minus').click(minusQuantity);
});</code></pre>
<p class="note">註：這裡我大量使用了 <a href="http://jquery.com/">jQuery</a> 的功能。 </p>
<p>想法很簡單，就是當我們按下「 + 」 或「 - 」時，要隔一秒才會送出 Ajax Request ；而在這一秒內如果再次按下「 + 」 或「 - 」，那麼就重新計時。 </p>
<p>因此程式的主要重點在 _doAjaxPost 這個函式以及全域變數： sending ；當第一次呼叫 _doAjaxPost 時 sending 還是 null ，這時我們利用 setTimeout 開始計時，並將計時器指定給 sending 這個變數。而當第二次呼叫時， sending 變數已經不為空值，因此我們再利用 clearTimeout 將它清除，並重設為 null 以達到重新計時的目的。</p>
<p>是不是很簡單呢？</p>
<p>如果各位有更好的作法，也歡迎分享~ </p>

]]>
</content>
</entry> 
</feed>