<?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>哇寶部落格 &#187; jQuery</title>
	<atom:link href="http://blog.wabow.com/archives/category/it/jquery/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.wabow.com</link>
	<description>Wabow Information Inc. Blog</description>
	<lastBuildDate>Fri, 21 May 2010 15:11:05 +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>[jQuery Plugin]抓取YouTube影片的截圖 jYouTube</title>
		<link>http://blog.wabow.com/archives/1985</link>
		<comments>http://blog.wabow.com/archives/1985#comments</comments>
		<pubDate>Thu, 20 Aug 2009 07:38:13 +0000</pubDate>
		<dc:creator>andrew</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[技術分享]]></category>

		<guid isPermaLink="false">http://blog.wabow.com/?p=1985</guid>
		<description><![CDATA[官方網站 http://jquery-howto.blogspot.com/2009/05/jyoutube-jquery-youtube-thumbnail.html js下載點 http://plugins.jquery.com/files/jyuotube.zip 介紹 YouTube(http://www.youtube.com/)是一個非常知名的影像網站，影片瀏覽起來速度還蠻快的，也因此很多網站在想要顯示影片時，都會連到這個網站。作法上有很多種，假使我們今天希望在自己的網站放置某個YouTube影片的截圖，然後點截圖才連到YouTube網站去瀏覽影片，這個截圖的動作有沒有比較簡單的做法呢?jQuery的Plugin--jYouTube提供了很簡單就可以達到目的的方法，讓我們來看看要怎麼處理吧! 程式碼 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 small : use video URL&#60;br /&#62; &#60;img src='' id='img1'&#62;&#60;br /&#62; big : use video ID &#60;br /&#62; &#60;img src='' id='img2'&#62; &#160; &#60;script type=&#34;text/javascript&#34; src=&#34;jquery-1.2.6.min.js&#34;&#62;&#60;/script&#62; &#60;script type=&#34;text/javascript&#34; src=&#34;jyuotube.js&#34;&#62;&#60;/script&#62; &#60;script [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://blog.wabow.com/wp-content/uploads/2009/08/sample.JPG" alt="sample" width="331" height="379" class="aligncenter size-full wp-image-2025" /><br />
官方網站  <a href="http://jquery-howto.blogspot.com/2009/05/jyoutube-jquery-youtube-thumbnail.html">http://jquery-howto.blogspot.com/2009/05/jyoutube-jquery-youtube-thumbnail.html</a><br />
js下載點  <a href="http://plugins.jquery.com/files/jyuotube.zip">http://plugins.jquery.com/files/jyuotube.zip</a><br />
<span id="more-1985"></span></p>
<h3>介紹</h3>
<p>YouTube(<a href="http://www.youtube.com/">http://www.youtube.com/</a>)是一個非常知名的影像網站，影片瀏覽起來速度還蠻快的，也因此很多網站在想要顯示影片時，都會連到這個網站。作法上有很多種，假使我們今天希望在自己的網站放置某個YouTube影片的截圖，然後點截圖才連到YouTube網站去瀏覽影片，這個截圖的動作有沒有比較簡單的做法呢?jQuery的Plugin--jYouTube提供了很簡單就可以達到目的的方法，讓我們來看看要怎麼處理吧!</p>
<h3>程式碼</h3>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;">small : use video URL<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">img</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">''</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">'img1'</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;</span>
big   : use video ID <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">img</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">''</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">'img2'</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;jquery-1.2.6.min.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;jyuotube.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;</span>
&nbsp;
$(function(){
&nbsp;
    var imgSrc = $.jYoutube('http://www.youtube.com/watch?v=hPzNl6NKAG0', 'small');
    var imgSrc2 = $.jYoutube('hPzNl6NKAG0');
&nbsp;
	$('#img1').attr('src',imgSrc);
	$('#img2').attr('src',imgSrc2);
&nbsp;
})
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span></pre></td></tr></table></div>

<h3>解說</h3>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;jquery-1.2.6.min.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;jyuotube.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span></pre></td></tr></table></div>

<p>這兩行是載入必要的js。</p>
<p>jYouTube的寫法很簡單，如下：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$.<span style="color: #660066;">jYoutube</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'hPzNl6NKAG0'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//指定YouTube的影片ID後回傳一個大的截圖網址</span>
$.<span style="color: #660066;">jYoutube</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'http://www.youtube.com/watch?v=hPzNl6NKAG0'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'small'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//指定YouTube的影片網址後回傳一個小的截圖網址</span></pre></td></tr></table></div>

<p>也就說，jYoutube會使用到兩個參數，第一個參數你可以設定為YouTube的影片ID(如:hPzNl6NKAG0)或是YouTube的影片網址(如:http://www.youtube.com/watch?v=hPzNl6NKAG0)；第二個參數則是希望顯示的截圖大小，如果保留空白則顯示較大的截圖，相對的如果輸入small則顯示小的截圖。實際顯示的效果可參照本文開頭的範例圖。</p>
<h3>總結</h3>
<p>jYouTube提供了很簡單就能取得YouTube影片的截圖，在需要大量引用時比用printscreen來的快速，提供給大家做個參考。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.wabow.com/archives/1985/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Float Messenger 的應用 與 當 jQuery 遇上 Big5</title>
		<link>http://blog.wabow.com/archives/1614</link>
		<comments>http://blog.wabow.com/archives/1614#comments</comments>
		<pubDate>Thu, 25 Jun 2009 06:00:24 +0000</pubDate>
		<dc:creator>suzy</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[技術分享]]></category>
		<category><![CDATA[big5]]></category>
		<category><![CDATA[keycode]]></category>

		<guid isPermaLink="false">http://blog.wabow.com/?p=1614</guid>
		<description><![CDATA[大家好, 我又來了, 在這麼短時間又要發一篇blog, 實在不像我ㄚ XD.... 今天要講的是如何套用 Jace 所寫的 jQuery Plugin Float Messenger.js. 然後再延伸 鍵盤控制的新功能, 讓 Enter, Esc 還有 Ctrl + O 或 Shift + O 都可以聽你的話. 這是 FloatMessenger 原來的模樣: 首先我做了一個新框框, 把它 css 化, 只要掌握到下面的巢狀結構, 就可以輕易的替她換新衣服... 1 2 3 4 5 6 &#60;div id=&#34;messenger&#34;&#62; &#60;div class=&#34;wrapper&#34;&#62; &#60;blockquote&#62;&#60;span&#62;MESSAGE&#60;/span&#62;&#60;/blockquote&#62; &#60;form method=&#34;post&#34; action=&#34;&#34;&#62;....&#60;/form&#62; &#60;/div&#62; &#60;/div&#62; 原本的 css 位置擺放也都已經寫好了, 稍加修改即可: [...]]]></description>
			<content:encoded><![CDATA[<p>大家好, 我又來了, 在這麼短時間又要發一篇blog, 實在不像我ㄚ XD....</p>
<p>今天要講的是如何套用 Jace 所寫的 jQuery Plugin <strong>Float Messenger.js</strong>. 然後再延伸 <strong>鍵盤控制的新功能</strong>, 讓 Enter, Esc 還有 Ctrl + O 或 Shift + O 都可以聽你的話.<br />
<span id="more-1614"></span><br />
這是 FloatMessenger 原來的模樣:<br />
<a href="http://blog.wabow.com/wp-content/uploads/2009/06/fm.jpg"><img src="http://blog.wabow.com/wp-content/uploads/2009/06/fm.jpg" alt="fm" width="470" height="311" class="alignnone size-full wp-image-1618" /></a></p>
<p>首先我做了一個新框框, 把它 css 化, 只要掌握到下面的巢狀結構, 就可以輕易的替她換新衣服...</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;messenger&quot;</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;wrapper&quot;</span>&gt;</span>
        <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">blockquote</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">span</span>&gt;</span>MESSAGE<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">span</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">blockquote</span>&gt;</span>
        <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">form</span> <span style="color: #000066;">method</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;post&quot;</span> <span style="color: #000066;">action</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span>&gt;</span>....<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">form</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></pre></td></tr></table></div>

<p>原本的 css 位置擺放也都已經寫好了, 稍加修改即可:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
</pre></td><td class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#messenger</span> <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">463px</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">margin-bottom</span><span style="color: #00AA00;">:</span> <span style="color: #933;">20px</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">bg-poll-header.gif</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">no-repeat</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">12px</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">line-height</span><span style="color: #00AA00;">:</span><span style="color: #933;">20px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#messenger</span> h2 <span style="color: #00AA00;">&#123;</span>
    <span style="color: #808080; font-style: italic;">/*text-indent: -100000px;*/</span>
    <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#ca0000</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">16px</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">10px</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#messenger</span> <span style="color: #6666ff;">.closeMessenger</span> <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">right</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">2px</span> <span style="color: #933;">6px</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span> <span style="color: #933;">8px</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">11px</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#000</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#messenger</span> <span style="color: #6666ff;">.closeMessenger</span><span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#ccc</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#messenger</span> <span style="color: #6666ff;">.wrapper</span> <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">463px</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">padding-bottom</span><span style="color: #00AA00;">:</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">bg-poll-footer.gif</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">no-repeat</span> <span style="color: #cc66cc;">0</span> <span style="color: #000000; font-weight: bold;">bottom</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#messenger</span> p <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #933;">27px</span> <span style="color: #933;">10px</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">28px</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">12px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#messenger</span> form <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">458px</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">8px</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">bg-poll-content.gif</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">repeat-y</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#messenger</span> form label <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">margin-right</span><span style="color: #00AA00;">:</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#messenger</span> form <span style="color: #6666ff;">.btnGroup</span> <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #933;">10px</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>變成紅白風啦啦啦啦啦 Wohoo~~<br />
<a href="http://blog.wabow.com/wp-content/uploads/2009/06/fm2.jpg"><img src="http://blog.wabow.com/wp-content/uploads/2009/06/fm2.jpg" alt="fm2" width="476" height="170" class="alignnone size-full wp-image-1619" /></a></p>
<p>OK...一切都很順利, 不過在幾乎要完成的時候遇到了一個問題, 就是 Enter 無法使用, 這對慣用 Enter 的使用者可能會造成不便!?.. 困難點是 Float Messenger 裡面的 form submit 時, 我沒辦法讓 submit這個動作 (or Enter) 跟 '確定'按鈕同步去做同一件事, 尤其當有很多 Float Messenger 在交替使用的時候, 也沒辦法在一開始就寫死, 因為是同一個 form 的 submit() 阿....... 這個問題一度卡了我有點久, 不過昨天靈光一閃, 才發現原來其實可以很簡單.. <img src='http://blog.wabow.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><strong>DEMO</strong> 有 Enter 煩惱的 FloatMessenger: <a href="http://www.dodoke.com/testground/messenger/problem.php">點我點我</a></p>
<p>我在 FloatMessenger 多加了一個 setting.. <strong>onSubmit: function() {} </strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">    $.<span style="color: #660066;">floatMessenger</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
        title<span style="color: #339933;">:</span> <span style="color: #3366CC;">'請輸入密碼'</span><span style="color: #339933;">,</span>
        message<span style="color: #339933;">:</span> <span style="color: #3366CC;">'您輸入的 E-mail 已註冊，請輸入密碼 &quot;111&quot; 。'</span><span style="color: #339933;">,</span>
        form<span style="color: #339933;">:</span> <span style="color: #3366CC;">'....略'</span><span style="color: #339933;">,</span>
        buttons<span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #3366CC;">'確定'</span><span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> memberLoginHandler<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
        onSubmit<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> memberLoginHandler<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>然後在 FloatMessenger.js 裡加入:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">    <span style="color: #006600; font-style: italic;">// 送出控制</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>_settings.<span style="color: #660066;">onSubmit</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'form'</span><span style="color: #339933;">,</span> $html<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">submit</span><span style="color: #009900;">&#40;</span>_settings.<span style="color: #660066;">onSubmit</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
       <span style="color: #006600; font-style: italic;">// 這是預設, 加這行是為了防止按 enter 會直接 submit 的情形, 我不希望這樣</span>
    	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'form'</span><span style="color: #339933;">,</span> $html<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">submit</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
    <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>這樣就可以解決 Enter 的問題了, 也可以跟我想要的按鈕同步^o^... 然後既然都已經 Enter 了, 那就再來點別的吧!<br />
我想讓 Esc 也有功能, 按了之後會 unblock! 所以我在 FloatMessenger.js 加了這個:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">keypress</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> key <span style="color: #339933;">=</span> e.<span style="color: #660066;">charCode</span> <span style="color: #339933;">||</span> e.<span style="color: #660066;">keyCode</span> <span style="color: #339933;">||</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>key <span style="color: #339933;">==</span> <span style="color: #CC0000;">27</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #006600; font-style: italic;">// ESC</span>
        $.<span style="color: #660066;">unblockUI</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span></pre></td></tr></table></div>

<p>我想讓 Ctrl + 某鍵 跟 Shift + 某鍵 會有功能. 在設定檔改就可以了.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$.<span style="color: #660066;">floatMessenger</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
    title<span style="color: #339933;">:</span> <span style="color: #3366CC;">'忘記密碼'</span><span style="color: #339933;">,</span>
    message<span style="color: #339933;">:</span> <span style="color: #3366CC;">'我們將密碼以電子郵件方式送給您。)'</span><span style="color: #339933;">,</span>
    form<span style="color: #339933;">:</span> <span style="color: #3366CC;">''</span><span style="color: #339933;">,</span>
    buttons<span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #3366CC;">'請寄送密碼給我 (Shift + P)'</span><span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> getPasswordBlock<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
        <span style="color: #3366CC;">'忘了這件事 (Shift + F)'</span><span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> $.<span style="color: #660066;">unblockUI</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
        <span style="color: #3366CC;">'回哇寶首頁 (Shift + H)'</span><span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> location.<span style="color: #660066;">href</span><span style="color: #339933;">=</span><span style="color: #3366CC;">'http://www.wabow.com'</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
    ctrlKeys<span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
    shiftKeys<span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #3366CC;">'p'</span><span style="color: #339933;">:</span><span style="color: #CC0000;">80</span><span style="color: #339933;">,</span>
        <span style="color: #3366CC;">'f'</span><span style="color: #339933;">:</span><span style="color: #CC0000;">70</span><span style="color: #339933;">,</span>
        <span style="color: #3366CC;">'h'</span><span style="color: #339933;">:</span><span style="color: #CC0000;">72</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>'p' 是 key<br />
80 是 keycode<br />
每一個鍵都有固定的 keycode, 網路上可以查得到所有的 keycode..<br />
這3 個 shiftKeys 其實是按照 buttons 的順序去排的, 按了之後會跟 button 有同樣的功能.</p>
<p><a href="http://blog.wabow.com/wp-content/uploads/2009/06/fm3.jpg"><img src="http://blog.wabow.com/wp-content/uploads/2009/06/fm3.jpg" alt="fm3" width="478" height="139" class="alignnone size-full wp-image-1621" /></a></p>
<p><strong>DEMO</strong> 沒有 Enter 煩惱的 FLoatMessenger: <a href="http://www.dodoke.com/testground/messenger/index.php">點我點我</a></p>
<p>好, 按鍵問題終於解決了, 順便跟大家分享 jQuery 遇上 big5 中文的問題.....<br />
我在跑 ajax 的時候, 我要 用 form POST 中文字, 然後再丟到資料庫去查詢, 可是資料庫一直查不到資料...<br />
echo 出來的值也是對的阿, 氣死我啦, 後來才發現, 很見鬼的, Big5 的字 丟到 jQuery 它會丟出 UTF8 給你.............................</p>
<p>所以我們要加上 iconv 轉碼的動作:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// 解決 jQuery 使用 UTF-8 送出資料的問題</span>
<span style="color: #000088;">$big5Name</span> <span style="color: #339933;">=</span> <span style="color: #990000;">iconv</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'utf-8'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'big5'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$name</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #666666; font-style: italic;">// 這樣才能在資料庫找得到</span>
<span style="color: #000088;">$sql</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT * FROM table WHERE vipName = '<span style="color: #006699; font-weight: bold;">$big5Name</span>'&quot;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>以為這樣就沒問題了, 上線後的第三天, 許先生抗議了...<br />
許功蓋啦 &gt;"&lt;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// 解決許功蓋的問題</span>
<span style="color: #000088;">$big5Name</span> <span style="color: #339933;">=</span> <span style="color: #990000;">addslashes</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$big5Name</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>然後存進 SESSION 時, 記得要加 stripslashes:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// 如果不 stripslashes 會顯示 許\先生</span>
<span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'VIP_NAME'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">stripslashes</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$big5Name</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<h2>心得</h2>
<p>以為半天就可以解決的事, 結果有這麼多意想不到的問題發生.... 一度很想偷懶跳過這些工, 但是幸好有堅持下去才能解決...解決後發現其實也不難嘛 ( ￣ c￣)y▂ξ (囂張貌)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.wabow.com/archives/1614/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>jQuery FCKEditor + HTML Purifier</title>
		<link>http://blog.wabow.com/archives/1502</link>
		<comments>http://blog.wabow.com/archives/1502#comments</comments>
		<pubDate>Tue, 23 Jun 2009 10:47:49 +0000</pubDate>
		<dc:creator>suzy</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[技術分享]]></category>
		<category><![CDATA[HTML Filtering]]></category>
		<category><![CDATA[standards compliant]]></category>
		<category><![CDATA[xss]]></category>

		<guid isPermaLink="false">http://blog.wabow.com/?p=1502</guid>
		<description><![CDATA[今天要介紹的是 wysiwyg + filter = wysiwyfter(?) 得知客戶需要一套 輕量型的 所見即所得(wysiwyg)編輯器. 要求是可以快速地載入編輯器, 進行 HTML 編輯, 但也需要嚴格防止駭客輸入不當的程式碼. 因此我們挑選了 jQuery FCKEditor (註1) 以及 HTML Purifier. HTML Purifier 是用來濾掉可疑的 XSS 程式碼, 且內容仍符合 W3C 的標準 (Standards Compliant). 註1: 曾試著裝 jWYSIWYG, 但發現許多小問題, 所以還是用回 FCKEditor 安裝與設定 1. 下載 jQuery FCKEditor 以及 HTML Purifier 2. 安裝 jQuery FCKEditor 1 2 3 &#60;!-- head --&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>今天要介紹的是 wysiwyg + filter = wysiwyfter(?)</p>
<p>得知客戶需要一套 輕量型的 所見即所得(wysiwyg)編輯器. 要求是可以快速地載入編輯器, 進行 HTML 編輯, 但也需要嚴格防止駭客輸入不當的程式碼.</p>
<p>因此我們挑選了 <a href="http://www.fyneworks.com/jquery/FCKEditor/">jQuery FCKEditor</a> (註1) 以及 <a href="http://htmlpurifier.org/">HTML Purifier</a>. </p>
<p>HTML Purifier 是用來濾掉可疑的 XSS 程式碼, 且內容仍符合 W3C 的標準 (Standards Compliant). </p>
<p><span id="more-1502"></span><br />
註1: 曾試著裝 jWYSIWYG, 但發現許多小問題, 所以還是用回 FCKEditor</p>
<h2>安裝與設定</h2>
<p>1. 下載 jQuery FCKEditor 以及 HTML Purifier<br />
2. 安裝 jQuery FCKEditor</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">&lt;!-- head --&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;jquery.js&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;fck.js&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span></pre></td></tr></table></div>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">&lt;!-- body --&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">form</span> <span style="color: #000066;">method</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;post&quot;</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">textarea</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;myEditor&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;content&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">textarea</span>&gt;</span>  
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;submit&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;送出&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">form</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
$(function () {
    $('#myEditor').fck({
        path: 'http://localhost/test/fckeditor/', // fckeditor 資料夾的位置
        config: {
            ToolbarSet: 'MyToolbarSet', // 在 fckconfig.js 中自定 ToolbarSet
            EditorAreaCSS: 'layout.css' // css 設定檔
        },
        width:  650,
        height: 200
    });
});
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span></pre></td></tr></table></div>

<p>3. 將下列設定<strong>新增</strong>在 /fckeditor/fckconfig.js 最下方(編輯器會顯示:粗體, 斜體, 底線, 連結, 及 文字大小)</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;">FCKConfig.ToolbarSets[&quot;MyToolbarSet&quot;] = [
	['Bold','Italic','Underline','Link','Unlink','FontSize']
] ;</pre></td></tr></table></div>

<p>4. 其他 fckconfig.js 的設定</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;">FCKConfig.DefaultFontSizeLabel = '小' ;
FCKConfig.DefaultLinkTarget = '_blank' ;
&nbsp;
FCKConfig.FontSizes		= '12/小;15/中;18/大' ;
&nbsp;
FCKConfig.LinkDlgHideTarget		= true ;
FCKConfig.LinkDlgHideAdvanced	= true ;
&nbsp;
FCKConfig.LinkBrowser		= false ;
FCKConfig.LinkUpload		= false ;</pre></td></tr></table></div>

<p>樣式如圖:<br />
<a href="http://blog.wabow.com/wp-content/uploads/2009/06/fck1.jpg"><img src="http://blog.wabow.com/wp-content/uploads/2009/06/fck1.jpg" alt="fck1" class="alignnone size-full wp-image-1580" /></a></p>
<p>5. 在連結的區域, 我們也不需要多餘的 "超連結類型" 跟 "通訊協定". </p>
<p><a href="http://blog.wabow.com/wp-content/uploads/2009/06/fck2.jpg"><img src="http://blog.wabow.com/wp-content/uploads/2009/06/fck2.jpg" alt="fck2" class="alignnone size-full wp-image-1582" /></a></p>
<p>修改檔案: /fckeditor/editor/dialog/fck_link.html</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;">@ Line 37-40
<span style="color: #808080; font-style: italic;">&lt;!-- 註解掉</span>
<span style="color: #808080; font-style: italic;">&lt;option value=&quot;anchor&quot; fckLang=&quot;DlgLnkTypeAnchor&quot;&gt;Anchor in this page&lt;/option&gt;</span>
<span style="color: #808080; font-style: italic;">&lt;option value=&quot;email&quot; fckLang=&quot;DlgLnkTypeEMail&quot;&gt;E-Mail&lt;/option&gt;</span>
<span style="color: #808080; font-style: italic;">--&gt;</span>
&nbsp;
@ Line 51-56
<span style="color: #808080; font-style: italic;">&lt;!-- 註解掉</span>
<span style="color: #808080; font-style: italic;">&lt;option value=&quot;https://&quot;&gt;https://&lt;/option&gt;</span>
<span style="color: #808080; font-style: italic;">&lt;option value=&quot;ftp://&quot;&gt;ftp://&lt;/option&gt;</span>
<span style="color: #808080; font-style: italic;">&lt;option value=&quot;news://&quot;&gt;news://&lt;/option&gt;</span>
<span style="color: #808080; font-style: italic;">&lt;option value=&quot;&quot; fckLang=&quot;DlgLnkProtoOther&quot;&gt;&lt;other&gt;&lt;/option&gt;</span>
<span style="color: #808080; font-style: italic;">--&gt;</span></pre></td></tr></table></div>

<p>到這裡 FCKEditor 的部份就算完成了. <img src='http://blog.wabow.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>如果有需要更動到文字敘述可以修改語言檔: /fckeditor/editor/lang/zh.js</p>
<p>6. 再來就是安裝 HTML Purifier. 解壓縮後找到一個叫 library 的資料夾, 把它 copy 出來, 我將它重新命名為 HTMLPurifier</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #b1b100;">require</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'HTMLPurifier/HTMLPurifier.auto.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// 最快的安裝方式:</span>
<span style="color: #000088;">$purifier</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HTMLPurifier<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$cleanContent</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$purifier</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">purify</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'content'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// -------------------------------------------------------------</span>
<span style="color: #666666; font-style: italic;">// 如果要更改預設值, 可以照以下步驟設定:</span>
<span style="color: #000088;">$config</span> <span style="color: #339933;">=</span> HTMLPurifier_Config<span style="color: #339933;">::</span><span style="color: #004000;">createDefault</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// 設定編碼, 預設是 UTF-8</span>
<span style="color: #000088;">$config</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Core'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Encoding'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'ISO-8859-1'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// 設定 Doctype, 預設是 XHTML Transitional</span>
<span style="color: #000088;">$config</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'HTML'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Doctype'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'HTML 4.01 Transitional'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">&lt;!--</span>
    <span style="color: #339933;">*</span> HTML <span style="color:#800080;">4.01</span> Strict
    <span style="color: #339933;">*</span> HTML <span style="color:#800080;">4.01</span> Transitional
    <span style="color: #339933;">*</span> XHTML <span style="color:#800080;">1.0</span> Strict
    <span style="color: #339933;">*</span> XHTML <span style="color:#800080;">1.0</span> Transitional
    <span style="color: #339933;">*</span> XHTML <span style="color:#800080;">1.1</span>
<span style="color: #339933;">--&gt;</span>
<span style="color: #666666; font-style: italic;">// 選擇允許的 HTML Tags, 除了 以下的 Tags[Attributes], 其他的一律都會被過濾掉</span>
<span style="color: #000088;">$config</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'HTML'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Allowed'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'p,br,strong,em,u,span[style],a[href|target]'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$config</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Attr'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'AllowedFrameTargets'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'_blank, _self'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// 將 $config 帶入 object </span>
<span style="color: #000088;">$purifier</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HTMLPurifier<span style="color: #009900;">&#40;</span><span style="color: #000088;">$config</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$cleanContent</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$purifier</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">purify</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'content'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>到這裡就大功告成啦 <img src='http://blog.wabow.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<h2>使用報告</h2>
<p>這裡有 <a href="http://htmlpurifier.org/live/smoketests/xssAttacks.php">HTMLPurifier 的 xssAttack List</a>, 代表它已通過這些xss測試.</p>
<p>HTML Purifier 還有以下功能: </p>
<ul>
<li>缺 closing tag 會補</li>
<li>輸入 &lt;img src=""&gt; 會變成 &lt;img src="" alt="" /&gt;</li>
<li>form, input, script 自動消失 (除非設定 allow)</li>
<li>&lt;p onclick="alert();"&gt;x&lt;/p&gt; 會過濾成 &lt;p&gt;x&lt;/p&gt;</li>
</ul>
<p>其他的大家可以來 <a href="http://www.dodoke.com/testground/wysiwyfter/purifier.php">這裡</a> 跟 <a href="http://www.dodoke.com/testground/wysiwyfter/fckpurifier.php">這裡</a> 試玩..</p>
<p>HTML Purifier 滿強大的, 應該可以再多加運用 <img src='http://blog.wabow.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.wabow.com/archives/1502/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[jQuery Plugin] jBind</title>
		<link>http://blog.wabow.com/archives/1537</link>
		<comments>http://blog.wabow.com/archives/1537#comments</comments>
		<pubDate>Thu, 18 Jun 2009 03:41:41 +0000</pubDate>
		<dc:creator>abu</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[技術分享]]></category>

		<guid isPermaLink="false">http://blog.wabow.com/?p=1537</guid>
		<description><![CDATA[官網：HERE 展示：HERE 自從用了Smarty之後，讓我完全無法脫離那種 --&#62; 輕易控制樣板上的資料呈現方式。 偶然看到原來javascript也有樣板系統，既然有類似的樣板概念，就來試用看看吧。 javascript樣板有很多款，這次選定的是一款jQuery Plugin → 『jBind』。 使用方式： 載入 jQuery 及 jBind &#38;lt;script src=&#34;js/jquery.js&#34; type=&#34;text/javascript&#34;&#38;gt;&#38;lt;/script&#38;gt; &#160; &#38;lt;script src=&#34;js/jquery.jbind.js&#34; type=&#34;text/javascript&#34;&#38;gt;&#38;lt;/script&#38;gt; html部份 &#60;div style=&#34;display:none;&#34;&#62; &#60;div class=&#34;content&#34;&#62; &#60;!--data--&#62; &#60;div class=&#34;viewBlock&#34;&#62; #{id} &#160; &#60;strong&#62;{name} {family}&#60;/strong&#62;, &#160; &#60;em&#62;{education}&#60;/em&#62;, &#160; {history} &#60;!--birthdate--&#62; &#60;div class=&#34;age&#34;&#62; {month} {date} {year}&#60;/div&#62; &#60;!--birthdate--&#62; &#60;!--Publications--&#62; &#60;div class=&#34;role&#34;&#62; {book} ({year})&#60;/div&#62; &#60;!--Publications--&#62;&#60;/div&#62; &#60;!--data--&#62;&#60;/div&#62; &#60;/div&#62; 最外層第一個div(id=template)，是我們設定的樣板樣式，最外層第二個div(id=show)，是用來輸出結果。 javascript部份 [...]]]></description>
			<content:encoded><![CDATA[<ul>
<li>官網：<a href="http://www.arashkarimzadeh.com/index.php/jquery/11-jbind-jquery-bind-template.html">HERE</a></li>
<li>展示：<a href="http://www.arashkarimzadeh.com/index.php/jquery/11-jbind-jquery-bind-template.html">HERE</a></li>
</ul>
<p>自從用了Smarty之後，讓我完全無法脫離那種 --&gt; 輕易控制樣板上的資料呈現方式。</p>
<p><span id="more-1537"></span>偶然看到原來javascript也有樣板系統，既然有類似的樣板概念，就來試用看看吧。</p>
<p>javascript樣板有很多款，這次選定的是一款jQuery Plugin → 『jBind』。</p>
<p>使用方式：</p>
<p>載入 jQuery 及 jBind</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>script src<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;js/jquery.js&quot;</span> type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;&amp;</span>lt<span style="color: #339933;">;/</span>script<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>script src<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;js/jquery.jbind.js&quot;</span> type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;&amp;</span>lt<span style="color: #339933;">;/</span>script<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span></pre></div></div>

<p>html部份</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;display:none;&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;content&quot;</span>&gt;</span>
<span style="color: #808080; font-style: italic;">&lt;!--data--&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;viewBlock&quot;</span>&gt;</span>
#{id}
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">strong</span>&gt;</span>{name} {family}<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">strong</span>&gt;</span>,
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">em</span>&gt;</span>{education}<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">em</span>&gt;</span>,
&nbsp;
{history}
<span style="color: #808080; font-style: italic;">&lt;!--birthdate--&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;age&quot;</span>&gt;</span>
{month} {date} {year}<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #808080; font-style: italic;">&lt;!--birthdate--&gt;</span>
<span style="color: #808080; font-style: italic;">&lt;!--Publications--&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;role&quot;</span>&gt;</span>
{book} ({year})<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #808080; font-style: italic;">&lt;!--Publications--&gt;</span><span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #808080; font-style: italic;">&lt;!--data--&gt;</span><span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></pre></div></div>

<p>最外層第一個div(id=template)，是我們設定的樣板樣式，最外層第二個div(id=show)，是用來輸出結果。</p>
<p>javascript部份</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> template <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#template'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> data <span style="color: #339933;">=</span> 	<span style="color: #009900;">&#91;</span>
<span style="color: #009900;">&#123;</span>
id<span style="color: #339933;">:</span><span style="color: #CC0000;">41</span><span style="color: #339933;">,</span>
<span style="color: #000066;">name</span><span style="color: #339933;">:</span><span style="color: #3366CC;">'Scott'</span><span style="color: #339933;">,</span>
family<span style="color: #339933;">:</span><span style="color: #3366CC;">'Adams'</span><span style="color: #339933;">,</span>
education<span style="color: #339933;">:</span><span style="color: #3366CC;">'Economics'</span><span style="color: #339933;">,</span>
history<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;Scott Adams was born in Windham, New York in 1957 and received his Bachelor's degree in Economics from Hartwick College in 1979. He also studied economics and management for his 1986 MBA from the Haas School of Business at the University of California, Berkeley.&quot;</span><span style="color: #339933;">,</span>
birthdate<span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>month<span style="color: #339933;">:</span><span style="color: #3366CC;">'June'</span><span style="color: #339933;">,</span>date<span style="color: #339933;">:</span><span style="color: #CC0000;">8</span><span style="color: #339933;">,</span>year<span style="color: #339933;">:</span><span style="color: #CC0000;">1957</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
Publications<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#123;</span>book<span style="color: #339933;">:</span><span style="color: #3366CC;">'The Dilbert Future'</span><span style="color: #339933;">,</span>year<span style="color: #339933;">:</span><span style="color: #CC0000;">1997</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><span style="color: #009900;">&#123;</span>book<span style="color: #339933;">:</span><span style="color: #3366CC;">'The Dilbert Principle'</span><span style="color: #339933;">,</span>year<span style="color: #339933;">:</span><span style="color: #CC0000;">1996</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#93;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
<span style="color: #009900;">&#123;</span>
id<span style="color: #339933;">:</span><span style="color: #CC0000;">59</span><span style="color: #339933;">,</span>
<span style="color: #000066;">name</span><span style="color: #339933;">:</span><span style="color: #3366CC;">'Jack'</span><span style="color: #339933;">,</span>
family<span style="color: #339933;">:</span><span style="color: #3366CC;">'Welch'</span><span style="color: #339933;">,</span>
education<span style="color: #339933;">:</span><span style="color: #3366CC;">'Chemical Engineering'</span><span style="color: #339933;">,</span>
history<span style="color: #339933;">:</span><span style="color: #3366CC;">'Jack Welch was born in Peabody, Massachusetts to John, a Boston &amp;amp; Maine Railroad conductor, and Grace, a housewife. Welch attended Salem High School and later the University of Massachusetts Amherst, graduating in 1957 with a Bachelor of Science degree in chemical engineering. While at UMass he was a member of the Alpha chapter of the Phi Sigma Kappa fraternity.'</span><span style="color: #339933;">,</span>
birthdate<span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>month<span style="color: #339933;">:</span><span style="color: #3366CC;">'November'</span><span style="color: #339933;">,</span>date<span style="color: #339933;">:</span><span style="color: #CC0000;">19</span><span style="color: #339933;">,</span>year<span style="color: #339933;">:</span><span style="color: #CC0000;">1935</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
Publications<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#123;</span>book<span style="color: #339933;">:</span><span style="color: #3366CC;">'Winning'</span><span style="color: #339933;">,</span>year<span style="color: #339933;">:</span><span style="color: #CC0000;">2005</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#93;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> node <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span>template<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">bindTo</span><span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
$<span style="color: #009900;">&#40;</span>node<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">appendTo</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#show'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>樣板對應javascript資料的方式，有比較簡單的兩個大原則<br />
1.資料根區塊，需用<!--data-->註解符號包起來。<br />
2.資料內，若是陣列型態，需使用該陣列變數名稱作為註解符號，將資料包起來，例如birthdate為一陣列，則在希望加上birthdate內容的部份，頭尾補上<!--birthdate-->，在<!--birthdate-->區塊內，左右大括號{}內直接填birthdate的變數key值即可顯示資料。</p>
<p>另外還有一些比較高級的應用方式，可直接參考官網，有很詳細的sample，或是<a href="http://www.arashkarimzadeh.com/downloads.html?func=startdown&amp;id=35">打包回家</a>慢慢研究。</p>
<p>因為之前沒用過javascript的樣板系統，覺得蠻新鮮的，目前沒有專案使用這樣的方式，未來若有機會再來嘗試看看。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.wabow.com/archives/1537/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[jQuery Plugin] jquery.history AJAX 無法回到上一頁的解決方案</title>
		<link>http://blog.wabow.com/archives/1527</link>
		<comments>http://blog.wabow.com/archives/1527#comments</comments>
		<pubDate>Thu, 18 Jun 2009 03:33:01 +0000</pubDate>
		<dc:creator>daniel</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[AJAX]]></category>

		<guid isPermaLink="false">http://blog.wabow.com/?p=1527</guid>
		<description><![CDATA[原始網站：history plugin AJAX 技術的廣泛運用，對網際網路的發展帶來重大變革；透過更新部分頁面即可維護資料，更有效率的反應使用者動作，避免在網路上發送沒有改變的資訊所帶來的頻寬的浪費。但是這樣部分更新的做法，同時也伴隨著缺點，其中受到最多批評的就是瀏覽器後退按鈕的失效；因為 AJAX 並不會更新整個頁面，自然也就無法在瀏覽器中的歷史紀錄留下資訊。 不過這個問題，早在 google 廣泛利用 AJAX 技術的初期，就已經被他們解決囉！雖然必須針對各種瀏覽器做各自不同的處理，但是現在 jQuery 已有網海中的前輩推出簡單使用的 Plugin囉：history plugin，官網本身也是展示網頁；下面稍微介紹一下使用以及運作的流程： 首先建立簡單的 AJAX 超連結： Ajax load&#60;br /&#62; &#60;a href="#1" rel="history"&#62;load 1&#60;/a&#62;&#60;br /&#62; &#60;a href="#2" rel="history"&#62;load 2&#60;/a&#62;&#60;br /&#62; &#60;a href="#3" rel="history"&#62;load 3&#60;/a&#62;&#60;br /&#62; &#60;hr /&#62; Loaded html:&#60;br /&#62; &#60;div id="load"&#62;&#60;/div&#62; &#60;hr /&#62; 接下來載入 jQuery 以及 jquery.history： &#60;script type="text/javascript" src="jquery-1.3.2.min.js"&#62;&#60;/script&#62; &#60;script type="text/javascript" src="jquery.history.js"&#62;&#60;/script&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>原始網站：<a href="http://www.mikage.to/jquery/jquery_history.html" target="_blank">history plugin</a></p>
<p>AJAX 技術的廣泛運用，對網際網路的發展帶來重大變革；透過更新部分頁面即可維護資料，更有效率的反應使用者動作，避免在網路上發送沒有改變的資訊所帶來的頻寬的浪費。但是這樣部分更新的做法，同時也伴隨著<a href="http://zh.wikipedia.org/w/index.php?title=AJAX&amp;variant=zh-tw#.E4.BC.98.E7.82.B9.E5.92.8C.E6.89.B9.E8.AF.84" target="_blank">缺點</a>，其中受到最多批評的就是瀏覽器後退按鈕的失效；因為 AJAX 並不會更新整個頁面，自然也就無法在瀏覽器中的歷史紀錄留下資訊。</p>
<p>不過這個問題，早在 google 廣泛利用 AJAX 技術的初期，就已經被他們解決囉！雖然必須針對各種瀏覽器做各自不同的處理，但是現在 jQuery 已有網海中的前輩推出簡單使用的 Plugin囉：<a href="http://www.mikage.to/jquery/jquery_history.html" target="_blank">history plugin</a>，官網本身也是展示網頁；下面稍微介紹一下使用以及運作的流程：</p>
<p><span id="more-1527"></span>首先建立簡單的 AJAX 超連結：</p>
<pre style="color:#d1d1d1;background:#000000;">Ajax load<span style="color:#ff8906; ">&lt;</span><span style="color:#e66170; font-weight:bold; ">br</span> <span style="color:#ff8906; ">/&gt;</span>
<span style="color:#ff8906; ">&lt;</span><span style="color:#e66170; font-weight:bold; ">a</span> href<span style="color:#d2cd86; ">=</span><span style="color:#00c4c4; ">"#1"</span> rel<span style="color:#d2cd86; ">=</span><span style="color:#00c4c4; ">"history"</span><span style="color:#ff8906; ">&gt;</span>load <span style="color:#00a800; ">1</span><span style="color:#ff8906; ">&lt;/</span><span style="color:#e66170; font-weight:bold; ">a</span><span style="color:#ff8906; ">&gt;</span><span style="color:#ff8906; ">&lt;</span><span style="color:#e66170; font-weight:bold; ">br</span> <span style="color:#ff8906; ">/&gt;</span>
<span style="color:#ff8906; ">&lt;</span><span style="color:#e66170; font-weight:bold; ">a</span> href<span style="color:#d2cd86; ">=</span><span style="color:#00c4c4; ">"#2"</span> rel<span style="color:#d2cd86; ">=</span><span style="color:#00c4c4; ">"history"</span><span style="color:#ff8906; ">&gt;</span>load <span style="color:#00a800; ">2</span><span style="color:#ff8906; ">&lt;/</span><span style="color:#e66170; font-weight:bold; ">a</span><span style="color:#ff8906; ">&gt;</span><span style="color:#ff8906; ">&lt;</span><span style="color:#e66170; font-weight:bold; ">br</span> <span style="color:#ff8906; ">/&gt;</span>
<span style="color:#ff8906; ">&lt;</span><span style="color:#e66170; font-weight:bold; ">a</span> href<span style="color:#d2cd86; ">=</span><span style="color:#00c4c4; ">"#3"</span> rel<span style="color:#d2cd86; ">=</span><span style="color:#00c4c4; ">"history"</span><span style="color:#ff8906; ">&gt;</span>load <span style="color:#00a800; ">3</span><span style="color:#ff8906; ">&lt;/</span><span style="color:#e66170; font-weight:bold; ">a</span><span style="color:#ff8906; ">&gt;</span><span style="color:#ff8906; ">&lt;</span><span style="color:#e66170; font-weight:bold; ">br</span> <span style="color:#ff8906; ">/&gt;</span>

<span style="color:#ff8906; ">&lt;</span><span style="color:#e66170; font-weight:bold; ">hr</span> <span style="color:#ff8906; ">/&gt;</span>
Loaded html:<span style="color:#ff8906; ">&lt;</span><span style="color:#e66170; font-weight:bold; ">br</span> <span style="color:#ff8906; ">/&gt;</span>
<span style="color:#ff8906; ">&lt;</span><span style="color:#e66170; font-weight:bold; ">div</span> id<span style="color:#d2cd86; ">=</span><span style="color:#00c4c4; ">"load"</span><span style="color:#ff8906; ">&gt;</span><span style="color:#ff8906; ">&lt;/</span><span style="color:#e66170; font-weight:bold; ">div</span><span style="color:#ff8906; ">&gt;</span>
<span style="color:#ff8906; ">&lt;</span><span style="color:#e66170; font-weight:bold; ">hr</span> <span style="color:#ff8906; ">/&gt;</span></pre>
<p>接下來載入 jQuery 以及 jquery.history：</p>
<pre style="color:#d1d1d1;background:#000000;"><span style="color:#ff8906; ">&lt;</span><span style="color:#e66170; font-weight:bold; ">script type="text/javascript" src="jquery-1.3.2.min.js"</span><span style="color:#ff8906; ">&gt;</span><span style="color:#ff8906; ">&lt;/</span><span style="color:#e66170; font-weight:bold; ">script</span><span style="color:#ff8906; ">&gt;</span>
<span style="color:#ff8906; ">&lt;</span><span style="color:#e66170; font-weight:bold; ">script type="text/javascript" src="jquery.history.js"</span><span style="color:#ff8906; ">&gt;</span><span style="color:#ff8906; ">&lt;/</span><span style="color:#e66170; font-weight:bold; ">script</span><span style="color:#ff8906; ">&gt;</span></pre>
<p>然後插入 JavaScript：</p>
<pre style="color:#d1d1d1;background:#000000;"><span style="color:#d2cd86; ">&lt;</span>script type<span style="color:#d2cd86; ">=</span><span style="color:#00c4c4; ">"text/javascript"</span><span style="color:#d2cd86; ">&gt;</span>

<span style="color:#9999a9; ">// 「上一頁」觸發後執行的函數</span>
<span style="color:#e66170; font-weight:bold; ">function</span> pageload<span style="color:#d2cd86; ">(</span>hash<span style="color:#d2cd86; ">)</span> <span style="color:#b060b0; ">{</span>
    <span style="color:#9999a9; ">// 根據傳回的 hash（錨點），AJAX 置換顯示的內容</span>
    <span style="color:#e66170; font-weight:bold; ">if</span><span style="color:#d2cd86; ">(</span>hash<span style="color:#d2cd86; ">)</span> <span style="color:#b060b0; ">{</span>
        <span style="color:#9999a9; ">// 重新讀取指定頁面</span>
        $<span style="color:#d2cd86; ">(</span><span style="color:#00c4c4; ">"#load"</span><span style="color:#d2cd86; ">)</span><span style="color:#d2cd86; ">.</span>load<span style="color:#d2cd86; ">(</span>hash <span style="color:#d2cd86; ">+</span> <span style="color:#00c4c4; ">".html"</span><span style="color:#d2cd86; ">)</span><span style="color:#b060b0; ">;</span>
    <span style="color:#b060b0; ">}</span> <span style="color:#e66170; font-weight:bold; ">else</span> <span style="color:#b060b0; ">{</span>
        <span style="color:#9999a9; ">// 如果沒有回傳值，代表已經回到 AJAX 的初始狀態頁，清空顯示的內容</span>
        $<span style="color:#d2cd86; ">(</span><span style="color:#00c4c4; ">"#load"</span><span style="color:#d2cd86; ">)</span><span style="color:#d2cd86; ">.</span>empty<span style="color:#d2cd86; ">(</span><span style="color:#d2cd86; ">)</span><span style="color:#b060b0; ">;</span>
    <span style="color:#b060b0; ">}</span>
<span style="color:#b060b0; ">}</span>

$<span style="color:#d2cd86; ">(</span><span style="color:#e66170; font-weight:bold; ">function</span> <span style="color:#d2cd86; ">(</span><span style="color:#d2cd86; ">)</span> <span style="color:#b060b0; ">{</span>
    <span style="color:#9999a9; ">// 初始化 history plugin，並設定回傳使用的函數</span>
    $<span style="color:#d2cd86; ">.</span>historyInit<span style="color:#d2cd86; ">(</span>pageload<span style="color:#d2cd86; ">)</span><span style="color:#b060b0; ">;</span>

    <span style="color:#9999a9; ">// 設定觸發寫入歷史紀錄條件的按鈕事件</span>
    $<span style="color:#d2cd86; ">(</span><span style="color:#00c4c4; ">"a[rel='history']"</span><span style="color:#d2cd86; ">)</span><span style="color:#d2cd86; ">.</span>click<span style="color:#d2cd86; ">(</span><span style="color:#e66170; font-weight:bold; ">function</span><span style="color:#d2cd86; ">(</span><span style="color:#d2cd86; ">)</span><span style="color:#b060b0; ">{</span>
            <span style="color:#9999a9; ">// 取得超連結的錨點</span>
        <span style="color:#e66170; font-weight:bold; ">var</span> hash <span style="color:#d2cd86; ">=</span> <span style="color:#e66170; font-weight:bold; ">this</span><span style="color:#d2cd86; ">.</span>href<span style="color:#b060b0; ">;</span>
        hash <span style="color:#d2cd86; ">=</span> hash<span style="color:#d2cd86; ">.</span><span style="color:#e66170; font-weight:bold; ">replace</span><span style="color:#d2cd86; ">(</span><span style="color:#02d045; ">/</span><span style="color:#d2cd86; ">^</span><span style="color:#d2cd86; ">.</span><span style="color:#d2cd86; ">*</span><span style="color:#00c4c4; ">#</span><span style="color:#02d045; ">/</span><span style="color:#d2cd86; ">,</span> <span style="color:#00c4c4; ">''</span><span style="color:#d2cd86; ">)</span><span style="color:#b060b0; ">;</span>
        <span style="color:#9999a9; ">// 點選 AJAX 頁面時，紀錄位置於瀏覽器的歷史紀錄中</span>
        $<span style="color:#d2cd86; ">.</span>historyLoad<span style="color:#d2cd86; ">(</span>hash<span style="color:#d2cd86; ">)</span><span style="color:#b060b0; ">;</span>
        <span style="color:#e66170; font-weight:bold; ">return</span> <span style="color:#0f4d75; ">false</span><span style="color:#b060b0; ">;</span>
    <span style="color:#b060b0; ">}</span><span style="color:#d2cd86; ">)</span><span style="color:#b060b0; ">;</span>
<span style="color:#b060b0; ">}</span><span style="color:#d2cd86; ">)</span><span style="color:#b060b0; ">;</span>
<span style="color:#d2cd86; ">&lt;</span><span style="color:#d2cd86; ">/</span>script<span style="color:#d2cd86; ">&gt;</span></pre>
<p>大致上的流程為：</p>
<blockquote><p>1. <strong>historyInit()</strong> 初始化 history plugin，設定回傳使用的函數；根據使用的函數載入歷史頁面。對 IE 及 safari 採取不同的處理方式，並設定每隔 0.1 秒觸發 historyCheck() 函數。<br />
2. <strong>historyCheck()</strong> 監聽使用者是否觸發瀏覽器「上一頁」按鈕，對 IE、safari 及其他瀏覽器採取不同的處理方式。觸發「上一頁」按鈕後，依照初始化時設定的回傳函數作相對應的處理。<br />
3. <strong>historyLoad()</strong> 在觸發 AJAX 更換內容時，寫入新的歷史紀錄，對 IE、safari 及其他瀏覽器採取不同的處理方式。</p></blockquote>
<p>針對瀏覽器提供的不同處理方式，history plugin 非常貼心的幫我們處理好了；依照官網的說明目前可以相容 IE8、FireFox 4.0、Opera9、Safari 4.0、Chrome 1.0 等多種瀏覽器。所以基本上是不用管 IE 的隱藏 iframe 紀錄，或是 Safari 那一大長串複雜到幾乎看不懂的特殊處理～非常方便！</p>
<p>後記：<br />
原本想要帶入目前專案在用的 ajaxtab，但在 IE 瀏覽器中發現「上一頁」不能流暢的進行；後來才發現可能是 location.hash 與 iframe.location.hash 重複紀錄的關係。因為 IE 已經使用 iframe 進行歷史紀錄，但是 history plugin 仍會利用 location.hash 紀錄。這邊我比較不懂為什麼要紀錄二次，也許有什麼特別的用意吧？因為官網上的範例在 IE 中並沒有這樣的問題，但是 ajaxtab 就會有；如果以後整合 history plugin 的人在 IE 的使用上有問題，請參考不進行 location.hash 紀錄這樣的解決方法吧～</p>
<p>參考資料：</p>
<ul>
<li>RailsFun!! <a href="http://railsfun.tw/redirect.php?tid=82&amp;goto=lastpost" target="_blank">讓Ajax可以正常支援上下頁</a></li>
<li>pansteven 筆記 <a href="http://steven631226.blogspot.com/2009/05/jquery-history.html" target="_blank">jquery -history</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.wabow.com/archives/1527/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>[jQuery Plugin]幻燈片效果 CrossSlide</title>
		<link>http://blog.wabow.com/archives/1513</link>
		<comments>http://blog.wabow.com/archives/1513#comments</comments>
		<pubDate>Thu, 18 Jun 2009 03:28:24 +0000</pubDate>
		<dc:creator>andrew</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[技術分享]]></category>

		<guid isPermaLink="false">http://blog.wabow.com/?p=1513</guid>
		<description><![CDATA[官方網站 / demo http://www.gruppo4.com/~tobia/cross-slide.shtml CrossSlide 是一個幻燈片效果的jQuery Plugin，可以實現多種不同風格的幻燈片展示效果，包括淡入淡出，輪播，放大縮小等等。下面以三個程式碼範例來說明用法。 共同程式碼 1 2 &#38;lt;script type=&#34;text/javascript&#34; src=&#34;jquery.js&#34;&#38;gt;&#38;lt;/script&#38;gt; &#38;lt;script type=&#34;text/javascript&#34; src=&#34;jquery.cross-slide.js&#34;&#38;gt;&#38;lt;/script&#38;gt; 此兩行為載入必要的js檔。 程式碼1--上下滑動效果 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 &#38;lt;script type=&#34;text/javascript&#34;&#38;gt; &#160; $(document).ready(function(){ $('#test1').crossSlide({ speed: 45, fade: 1 }, [ { src: '1.jpg', dir: [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://blog.wabow.com/wp-content/uploads/2009/06/sample-300x75.jpg" alt="sample" width="300" height="75" class="aligncenter size-medium wp-image-1514" /></p>
<p><H3>官方網站 / demo </H3><br />
<a href="http://www.gruppo4.com/~tobia/cross-slide.shtml">http://www.gruppo4.com/~tobia/cross-slide.shtml</a></p>
<p>CrossSlide 是一個幻燈片效果的jQuery Plugin，可以實現多種不同風格的幻燈片展示效果，包括淡入淡出，輪播，放大縮小等等。下面以三個程式碼範例來說明用法。<br />
<span id="more-1513"></span></p>
<p><H3>共同程式碼</H3></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #ddbb00;">&amp;lt;</span>script type=&quot;text/javascript&quot; src=&quot;jquery.js&quot;<span style="color: #ddbb00;">&amp;gt;&amp;lt;</span>/script<span style="color: #ddbb00;">&amp;gt;</span>
<span style="color: #ddbb00;">&amp;lt;</span>script type=&quot;text/javascript&quot; src=&quot;jquery.cross-slide.js&quot;<span style="color: #ddbb00;">&amp;gt;&amp;lt;</span>/script<span style="color: #ddbb00;">&amp;gt;</span></pre></td></tr></table></div>

<p>此兩行為載入必要的js檔。</p>
<p><H3>程式碼1--上下滑動效果</H3></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #ddbb00;">&amp;lt;</span>script type=&quot;text/javascript&quot;<span style="color: #ddbb00;">&amp;gt;</span>
&nbsp;
$(document).ready(function(){
          $('#test1').crossSlide({
          speed: 45,
          fade: 1
          }, [
          { src: '1.jpg', dir: 'up'   },
          { src: '2.jpg',   dir: 'down' }
          ]);
});
<span style="color: #ddbb00;">&amp;lt;</span>/script<span style="color: #ddbb00;">&amp;gt;</span>
<span style="color: #ddbb00;">&amp;lt;</span>style type=&quot;text/css&quot;<span style="color: #ddbb00;">&amp;gt;</span>
  #test1 {
    margin: 1em auto;
    border: 2px solid #555;
    width: 500px;
    height: 200px;
  }
<span style="color: #ddbb00;">&amp;lt;</span>/style<span style="color: #ddbb00;">&amp;gt;</span>
<span style="color: #ddbb00;">&amp;lt;</span>H3<span style="color: #ddbb00;">&amp;gt;</span>SAMPLE1<span style="color: #ddbb00;">&amp;lt;</span>/H3<span style="color: #ddbb00;">&amp;gt;</span>
<span style="color: #ddbb00;">&amp;lt;</span>div id=&quot;test1&quot;<span style="color: #ddbb00;">&amp;gt;</span>Loading…<span style="color: #ddbb00;">&amp;lt;</span>/div<span style="color: #ddbb00;">&amp;gt;</span></pre></td></tr></table></div>

<p>src:代表要使用的圖檔，dir: 'up'則表示往上滑動後變換下一張圖，相對的dir: 'down'即表示向下滑動後變換下一張圖。</p>
<p><H3>程式碼2--淡入淡出效果</H3></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #ddbb00;">&amp;lt;</span>script type=&quot;text/javascript&quot;<span style="color: #ddbb00;">&amp;gt;</span>
&nbsp;
$(document).ready(function(){
          $('#test2').crossSlide({
          sleep: 2,
          fade: 1
          }, [
          { src: '1.jpg' },
          { src: '2.jpg'   }
          ]);
});
<span style="color: #ddbb00;">&amp;lt;</span>/script<span style="color: #ddbb00;">&amp;gt;</span>
<span style="color: #ddbb00;">&amp;lt;</span>style type=&quot;text/css&quot;<span style="color: #ddbb00;">&amp;gt;</span>
  #test2 {
    margin: 1em auto;
    border: 2px solid #555;
    width: 500px;
    height: 200px;
  }
<span style="color: #ddbb00;">&amp;lt;</span>/style<span style="color: #ddbb00;">&amp;gt;</span>
<span style="color: #ddbb00;">&amp;lt;</span>H3<span style="color: #ddbb00;">&amp;gt;</span>SAMPLE2<span style="color: #ddbb00;">&amp;lt;</span>/H3<span style="color: #ddbb00;">&amp;gt;</span>
<span style="color: #ddbb00;">&amp;lt;</span>div id=&quot;test2&quot;<span style="color: #ddbb00;">&amp;gt;</span>Loading…<span style="color: #ddbb00;">&amp;lt;</span>/div<span style="color: #ddbb00;">&amp;gt;</span></pre></td></tr></table></div>

<p>如果在src:後不指定任何動作則呈現淡入淡出的效果。</p>
<p><H3>程式碼3--放大縮小效果</H3></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #ddbb00;">&amp;lt;</span>script type=&quot;text/javascript&quot;<span style="color: #ddbb00;">&amp;gt;</span>
&nbsp;
$(document).ready(function(){
          $('#test3').crossSlide({
          fade: 1
          }, [
          {
          src:  '1.jpg',
          href: 'http://flickr.com/photos/spacetrucker/94209642/',
          from: '100% 80% 1x',
          to:   '100% 0% 1.7x',
          time: 3
          }, {
          src:  '2.jpg',
          href: 'http://flickr.com/photos/hichako/1125341449/',
          from: 'top left',
          to:   'bottom right 1.5x',
          time: 2
          }, {
          src:  '1.jpg',
          href: 'http://flickr.com/photos/spacetrucker/94209642/',
          from: '100% 80% 1.5x',
          to:   '80% 0% 1.1x',
          time: 2
          }, {
          src:  '2.jpg',
          href: 'http://flickr.com/photos/hichako/1125341449/',
          from: '100% 50%',
          to:   '30% 50% 1.5x',
          time: 2
          }
          ]);
});
<span style="color: #ddbb00;">&amp;lt;</span>/script<span style="color: #ddbb00;">&amp;gt;</span>
<span style="color: #ddbb00;">&amp;lt;</span>style type=&quot;text/css&quot;<span style="color: #ddbb00;">&amp;gt;</span>
  #test3 {
    margin: 1em auto;
    border: 2px solid #555;
    width: 500px;
    height: 200px;
  }
<span style="color: #ddbb00;">&amp;lt;</span>/style<span style="color: #ddbb00;">&amp;gt;</span>
<span style="color: #ddbb00;">&amp;lt;</span>H3<span style="color: #ddbb00;">&amp;gt;</span>SAMPLE3<span style="color: #ddbb00;">&amp;lt;</span>/H3<span style="color: #ddbb00;">&amp;gt;</span>
<span style="color: #ddbb00;">&amp;lt;</span>div id=&quot;test3&quot;<span style="color: #ddbb00;">&amp;gt;</span>Loading…<span style="color: #ddbb00;">&amp;lt;</span>/div<span style="color: #ddbb00;">&amp;gt;</span></pre></td></tr></table></div>

<p>這段程式主要呈現放大縮小的效果，src:一樣是要使用的圖檔；href:為點下圖片要連到的位置；from:及to:為一組的設定，表示我們希望這張圖打算從from變換成to後再換下一張圖；time:表示每一個圖片動作持續的秒數。</p>
<p><H3>總結</H3></p>
<p>幻燈片效果經常使用在如商品展示或是廣告等等，CrossSlide提供很簡單的語法便能做到以前必須使用flash才能做到的效果。網路上可以找到很多種幻燈片效果的jQuery Plugin，CrossSlide是我覺得用起簡單又效果不錯的一種，不妨試看看!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.wabow.com/archives/1513/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[jQuery Plugin] Magnify 圖片放大鏡</title>
		<link>http://blog.wabow.com/archives/1504</link>
		<comments>http://blog.wabow.com/archives/1504#comments</comments>
		<pubDate>Thu, 18 Jun 2009 03:24:44 +0000</pubDate>
		<dc:creator>daniel</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[技術分享]]></category>

		<guid isPermaLink="false">http://blog.wabow.com/?p=1504</guid>
		<description><![CDATA[原始網站：Magnify, a jQuery plugin 購物網站中一定會出現商品的陳列與展示；當使用者瀏覽網站時，除了參考圖片愈多愈好，能顯示商品細節的大型圖片更是不可或缺的存在。但如果只是另開視窗，或是用之前曾經介紹過的 LightBox 燈箱特效；在現在這個五光十色，特效滿天飛的各種網站中，似乎顯得有些普通，不太能吸引使用者的注意～這個時候，如果能夠有類似「放大鏡」特效的商品圖片縮放，相信一定更能吸引使用者的目光；茫茫網海上的前輩聽到大家的需求啦，這時候就要用 Magnify囉！ 首先建立簡單的圖片連結： &#60;table&#62; &#60;tr&#62; &#60;td colspan="3" style="background-color: #FFFFCC; "&#62;&#60;h2&#62;magnify&#60;/h2&#62;&#60;/td&#62; &#60;/tr&#62; &#60;tr&#62; &#60;td&#62;&#60;a href="images/mustang.jpg" id="d1"&#62;&#60;img src="images/mustang_small.jpg" alt="mustang" border="0" /&#62;&#60;/a&#62;&#60;/td&#62; &#60;td width="50"&#62;&#60;/td&#62; &#60;td&#62;&#60;a href="images/triumph.jpg" id="d2"&#62;&#60;img src="images/triumph_small.jpg" alt="triumph" border="0" align="center" /&#62;&#60;/a&#62;&#60;/td&#62; &#60;/tr&#62; &#60;/table&#62; 接下來載入 jQuery 以及 Magnify： &#60;script type="text/javascript" src="jquery-1.3.2.min.js"&#62;&#60;/script&#62; &#60;script type="text/javascript" src="jquery.magnify-1.0.2.js"&#62;&#60;/script&#62; 然後插入 JavaScript： &#60;script type="text/javascript"&#62; $(function () { $("#d1").magnify(); [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.wabow.com/wp-content/uploads/2009/06/magnify.png"><img class="aligncenter size-large wp-image-1506" src="http://blog.wabow.com/wp-content/uploads/2009/06/magnify-500x280.png" alt="magnify" width="500" height="280" /></a></p>
<p>原始網站：<a href="http://www.jnathanson.com/index.cfm?page=jquery/magnify/magnify" target="_blank">Magnify, a jQuery plugin</a></p>
<p>購物網站中一定會出現商品的陳列與展示；當使用者瀏覽網站時，除了參考圖片愈多愈好，能顯示商品細節的大型圖片更是不可或缺的存在。但如果只是另開視窗，或是用之前曾經介紹過的 LightBox 燈箱特效；在現在這個五光十色，特效滿天飛的各種網站中，似乎顯得有些普通，不太能吸引使用者的注意～這個時候，如果能夠有類似「放大鏡」特效的商品圖片縮放，相信一定更能吸引使用者的目光；茫茫網海上的前輩聽到大家的需求啦，這時候就要用 Magnify囉！</p>
<p><span id="more-1504"></span>首先建立簡單的圖片連結：</p>
<pre style="color:#d1d1d1;background:#000000;"><span style="color:#ff8906; ">&lt;</span><span style="color:#e66170; font-weight:bold; ">table</span><span style="color:#ff8906; ">&gt;</span>
  <span style="color:#ff8906; ">&lt;</span><span style="color:#e66170; font-weight:bold; ">tr</span><span style="color:#ff8906; ">&gt;</span>
    <span style="color:#ff8906; ">&lt;</span><span style="color:#e66170; font-weight:bold; ">td</span> colspan<span style="color:#d2cd86; ">=</span><span style="color:#00c4c4; ">"3"</span> style<span style="color:#d2cd86; ">=</span><span style="color:#00c4c4; ">"</span><span style="color:#904050; ">background-color</span><span style="color:#d2cd86; ">:</span> <span style="color:#00a800; ">#</span><span style="color:#00a800; ">FFFFCC</span><span style="color:#b060b0; ">;</span> <span style="color:#00c4c4; ">"</span><span style="color:#ff8906; ">&gt;</span><span style="color:#ff8906; ">&lt;</span><span style="color:#e66170; font-weight:bold; ">h2</span><span style="color:#ff8906; ">&gt;</span>magnify<span style="color:#ff8906; ">&lt;/</span><span style="color:#e66170; font-weight:bold; ">h2</span><span style="color:#ff8906; ">&gt;</span><span style="color:#ff8906; ">&lt;/</span><span style="color:#e66170; font-weight:bold; ">td</span><span style="color:#ff8906; ">&gt;</span>
  <span style="color:#ff8906; ">&lt;/</span><span style="color:#e66170; font-weight:bold; ">tr</span><span style="color:#ff8906; ">&gt;</span>
  <span style="color:#ff8906; ">&lt;</span><span style="color:#e66170; font-weight:bold; ">tr</span><span style="color:#ff8906; ">&gt;</span>
    <span style="color:#ff8906; ">&lt;</span><span style="color:#e66170; font-weight:bold; ">td</span><span style="color:#ff8906; ">&gt;</span><span style="color:#ff8906; ">&lt;</span><span style="color:#e66170; font-weight:bold; ">a</span> href<span style="color:#d2cd86; ">=</span><span style="color:#00c4c4; ">"images/mustang.jpg"</span> id<span style="color:#d2cd86; ">=</span><span style="color:#00c4c4; ">"d1"</span><span style="color:#ff8906; ">&gt;</span><span style="color:#ff8906; ">&lt;</span><span style="color:#e66170; font-weight:bold; ">img</span> src<span style="color:#d2cd86; ">=</span><span style="color:#00c4c4; ">"images/mustang_small.jpg"</span> 

alt<span style="color:#d2cd86; ">=</span><span style="color:#00c4c4; ">"mustang"</span> border<span style="color:#d2cd86; ">=</span><span style="color:#00c4c4; ">"0"</span>  <span style="color:#ff8906; ">/&gt;</span><span style="color:#ff8906; ">&lt;/</span><span style="color:#e66170; font-weight:bold; ">a</span><span style="color:#ff8906; ">&gt;</span><span style="color:#ff8906; ">&lt;/</span><span style="color:#e66170; font-weight:bold; ">td</span><span style="color:#ff8906; ">&gt;</span>
    <span style="color:#ff8906; ">&lt;</span><span style="color:#e66170; font-weight:bold; ">td</span> width<span style="color:#d2cd86; ">=</span><span style="color:#00c4c4; ">"50"</span><span style="color:#ff8906; ">&gt;</span><span style="color:#ff8906; ">&lt;/</span><span style="color:#e66170; font-weight:bold; ">td</span><span style="color:#ff8906; ">&gt;</span>
    <span style="color:#ff8906; ">&lt;</span><span style="color:#e66170; font-weight:bold; ">td</span><span style="color:#ff8906; ">&gt;</span><span style="color:#ff8906; ">&lt;</span><span style="color:#e66170; font-weight:bold; ">a</span> href<span style="color:#d2cd86; ">=</span><span style="color:#00c4c4; ">"images/triumph.jpg"</span> id<span style="color:#d2cd86; ">=</span><span style="color:#00c4c4; ">"d2"</span><span style="color:#ff8906; ">&gt;</span><span style="color:#ff8906; ">&lt;</span><span style="color:#e66170; font-weight:bold; ">img</span> src<span style="color:#d2cd86; ">=</span><span style="color:#00c4c4; ">"images/triumph_small.jpg"</span> 

alt<span style="color:#d2cd86; ">=</span><span style="color:#00c4c4; ">"triumph"</span> border<span style="color:#d2cd86; ">=</span><span style="color:#00c4c4; ">"0"</span> align<span style="color:#d2cd86; ">=</span><span style="color:#00c4c4; ">"center"</span> <span style="color:#ff8906; ">/&gt;</span><span style="color:#ff8906; ">&lt;/</span><span style="color:#e66170; font-weight:bold; ">a</span><span style="color:#ff8906; ">&gt;</span><span style="color:#ff8906; ">&lt;/</span><span style="color:#e66170; font-weight:bold; ">td</span><span style="color:#ff8906; ">&gt;</span>
  <span style="color:#ff8906; ">&lt;/</span><span style="color:#e66170; font-weight:bold; ">tr</span><span style="color:#ff8906; ">&gt;</span>
<span style="color:#ff8906; ">&lt;/</span><span style="color:#e66170; font-weight:bold; ">table</span><span style="color:#ff8906; ">&gt;</span></pre>
<p>接下來載入 jQuery 以及 Magnify：</p>
<pre style="color:#d1d1d1;background:#000000;"><span style="color:#ff8906; ">&lt;</span><span style="color:#e66170; font-weight:bold; ">script type="text/javascript" src="jquery-1.3.2.min.js"</span><span style="color:#ff8906; ">&gt;</span><span style="color:#ff8906; ">&lt;/</span><span style="color:#e66170; font-weight:bold; ">script</span><span style="color:#ff8906; ">&gt;</span>
<span style="color:#ff8906; ">&lt;</span><span style="color:#e66170; font-weight:bold; ">script type="text/javascript" src="jquery.magnify-1.0.2.js"</span><span style="color:#ff8906; ">&gt;</span><span style="color:#ff8906; ">&lt;/</span><span style="color:#e66170; font-weight:bold; ">script</span><span style="color:#ff8906; ">&gt;</span></pre>
<p>然後插入 JavaScript：</p>
<pre style="color:#d1d1d1;background:#000000;"><span style="color:#d2cd86; ">&lt;</span>script type<span style="color:#d2cd86; ">=</span><span style="color:#00c4c4; ">"text/javascript"</span><span style="color:#d2cd86; ">&gt;</span>
$<span style="color:#d2cd86; ">(</span><span style="color:#e66170; font-weight:bold; ">function</span> <span style="color:#d2cd86; ">(</span><span style="color:#d2cd86; ">)</span> <span style="color:#b060b0; ">{</span>

    $<span style="color:#d2cd86; ">(</span><span style="color:#00c4c4; ">"#d1"</span><span style="color:#d2cd86; ">)</span><span style="color:#d2cd86; ">.</span>magnify<span style="color:#d2cd86; ">(</span><span style="color:#d2cd86; ">)</span><span style="color:#b060b0; ">;</span>
    $<span style="color:#d2cd86; ">(</span><span style="color:#00c4c4; ">"#d2"</span><span style="color:#d2cd86; ">)</span><span style="color:#d2cd86; ">.</span>magnify<span style="color:#d2cd86; ">(</span><span style="color:#b060b0; ">{</span>
        showEvent<span style="color:#b060b0; ">:</span> <span style="color:#00c4c4; ">'click'</span><span style="color:#d2cd86; ">,</span>
        hideEvent<span style="color:#b060b0; ">:</span> <span style="color:#00c4c4; ">'click'</span><span style="color:#d2cd86; ">,</span>
        lensWidth<span style="color:#b060b0; ">:</span> <span style="color:#008c00; ">60</span><span style="color:#d2cd86; ">,</span>
        lensHeight<span style="color:#b060b0; ">:</span> <span style="color:#008c00; ">60</span><span style="color:#d2cd86; ">,</span>
        preload<span style="color:#b060b0; ">:</span> <span style="color:#0f4d75; ">false</span><span style="color:#d2cd86; ">,</span>
        stagePlacement<span style="color:#b060b0; ">:</span> <span style="color:#00c4c4; ">'left'</span><span style="color:#d2cd86; ">,</span>
        loadingImage<span style="color:#b060b0; ">:</span> <span style="color:#00c4c4; ">'images/ajax-loader.gif'</span><span style="color:#d2cd86; ">,</span>
        lensCss<span style="color:#b060b0; ">:</span> <span style="color:#b060b0; ">{</span>
            backgroundColor<span style="color:#b060b0; ">:</span> <span style="color:#00c4c4; ">'#cc0000'</span><span style="color:#d2cd86; ">,</span>
            border<span style="color:#b060b0; ">:</span> <span style="color:#00c4c4; ">'0px'</span><span style="color:#d2cd86; ">,</span>
            opacity<span style="color:#b060b0; ">:</span> <span style="color:#009f00; ">0.5</span>
        <span style="color:#b060b0; ">}</span><span style="color:#d2cd86; ">,</span>
        stageCss<span style="color:#b060b0; ">:</span> <span style="color:#b060b0; ">{</span> border<span style="color:#b060b0; ">:</span> <span style="color:#00c4c4; ">'4px solid #33cc33'</span> <span style="color:#b060b0; ">}</span>

    <span style="color:#b060b0; ">}</span><span style="color:#d2cd86; ">)</span><span style="color:#b060b0; ">;</span>
<span style="color:#b060b0; ">}</span><span style="color:#d2cd86; ">)</span><span style="color:#b060b0; ">;</span>
<span style="color:#d2cd86; ">&lt;</span><span style="color:#d2cd86; ">/</span>script<span style="color:#d2cd86; ">&gt;</span></pre>
<p>呈現的效果就如同頁首所顯示，非常輕鬆簡單。在看到這個 Plugin 後，我突然想到幾個月前 Suzy 提到的 <a href="http://store.apple.com/tw/product/M9179FE/A" target="_blank">Apple Store</a>，其中商品圖縮放的功能，與 Magnify 非常類似；當初 Jace 還曾經把它加入作業中說（囧）...總之我試著更改 Magnify 的部分原始碼，結果弄出來一個有點類似的感覺的 Plugin～無奈功力不夠，對於縮放時的數學運算部分完全沒有頭緒；索性就用淡入淡出的方式偷懶帶過（噗）...命名為「magnify_kai」（Magnify˙改...因為不是原創所以就沒有用「wa」開頭囉^^|||）</p>
<p>首先建立簡單的圖片連結：</p>
<pre style="color:#d1d1d1;background:#000000;"><span style="color:#ff8906; ">&lt;</span><span style="color:#e66170; font-weight:bold; ">table</span><span style="color:#ff8906; ">&gt;</span>
  <span style="color:#ff8906; ">&lt;</span><span style="color:#e66170; font-weight:bold; ">tr</span><span style="color:#ff8906; ">&gt;</span>
    <span style="color:#ff8906; ">&lt;</span><span style="color:#e66170; font-weight:bold; ">td</span> colspan<span style="color:#d2cd86; ">=</span><span style="color:#00c4c4; ">"3"</span> style<span style="color:#d2cd86; ">=</span><span style="color:#00c4c4; ">"</span><span style="color:#904050; ">background-color</span><span style="color:#d2cd86; ">:</span> <span style="color:#00a800; ">#</span><span style="color:#00a800; ">FFFFCC</span><span style="color:#b060b0; ">;</span> <span style="color:#00c4c4; ">"</span><span style="color:#ff8906; ">&gt;</span><span style="color:#ff8906; ">&lt;</span><span style="color:#e66170; font-weight:bold; ">h2</span><span style="color:#ff8906; ">&gt;</span>magnify_kai<span style="color:#ff8906; ">&lt;/</span><span style="color:#e66170; font-weight:bold; ">h2</span><span style="color:#ff8906; ">&gt;</span><span style="color:#ff8906; ">&lt;/</span><span style="color:#e66170; font-weight:bold; ">td</span><span style="color:#ff8906; ">&gt;</span>
  <span style="color:#ff8906; ">&lt;/</span><span style="color:#e66170; font-weight:bold; ">tr</span><span style="color:#ff8906; ">&gt;</span>
  <span style="color:#ff8906; ">&lt;</span><span style="color:#e66170; font-weight:bold; ">tr</span><span style="color:#ff8906; ">&gt;</span>
    <span style="color:#ff8906; ">&lt;</span><span style="color:#e66170; font-weight:bold; ">td</span><span style="color:#ff8906; ">&gt;</span><span style="color:#ff8906; ">&lt;</span><span style="color:#e66170; font-weight:bold; ">a</span> href<span style="color:#d2cd86; ">=</span><span style="color:#00c4c4; ">"images/mustang.jpg"</span> class<span style="color:#d2cd86; ">=</span><span style="color:#00c4c4; ">"magnify_kai"</span><span style="color:#ff8906; ">&gt;</span><span style="color:#ff8906; ">&lt;</span><span style="color:#e66170; font-weight:bold; ">img</span> 

src<span style="color:#d2cd86; ">=</span><span style="color:#00c4c4; ">"images/mustang_small.jpg"</span> alt<span style="color:#d2cd86; ">=</span><span style="color:#00c4c4; ">"mustang"</span> border<span style="color:#d2cd86; ">=</span><span style="color:#00c4c4; ">"0"</span>  <span style="color:#ff8906; ">/&gt;</span><span style="color:#ff8906; ">&lt;/</span><span style="color:#e66170; font-weight:bold; ">a</span><span style="color:#ff8906; ">&gt;</span><span style="color:#ff8906; ">&lt;/</span><span style="color:#e66170; font-weight:bold; ">td</span><span style="color:#ff8906; ">&gt;</span>
    <span style="color:#ff8906; ">&lt;</span><span style="color:#e66170; font-weight:bold; ">td</span> width<span style="color:#d2cd86; ">=</span><span style="color:#00c4c4; ">"50"</span><span style="color:#ff8906; ">&gt;</span><span style="color:#ff8906; ">&lt;/</span><span style="color:#e66170; font-weight:bold; ">td</span><span style="color:#ff8906; ">&gt;</span>
    <span style="color:#ff8906; ">&lt;</span><span style="color:#e66170; font-weight:bold; ">td</span><span style="color:#ff8906; ">&gt;</span><span style="color:#ff8906; ">&lt;</span><span style="color:#e66170; font-weight:bold; ">a</span> href<span style="color:#d2cd86; ">=</span><span style="color:#00c4c4; ">"images/triumph.jpg"</span> class<span style="color:#d2cd86; ">=</span><span style="color:#00c4c4; ">"magnify_kai"</span><span style="color:#ff8906; ">&gt;</span><span style="color:#ff8906; ">&lt;</span><span style="color:#e66170; font-weight:bold; ">img</span> 

src<span style="color:#d2cd86; ">=</span><span style="color:#00c4c4; ">"images/triumph_small.jpg"</span> alt<span style="color:#d2cd86; ">=</span><span style="color:#00c4c4; ">"triumph"</span> border<span style="color:#d2cd86; ">=</span><span style="color:#00c4c4; ">"0"</span> align<span style="color:#d2cd86; ">=</span><span style="color:#00c4c4; ">"center"</span> <span style="color:#ff8906; ">/&gt;</span><span style="color:#ff8906; ">&lt;/</span><span style="color:#e66170; font-weight:bold; ">a</span><span style="color:#ff8906; ">&gt;</span><span style="color:#ff8906; ">&lt;/</span><span style="color:#e66170; font-weight:bold; ">td</span><span style="color:#ff8906; ">&gt;</span>
  <span style="color:#ff8906; ">&lt;/</span><span style="color:#e66170; font-weight:bold; ">tr</span><span style="color:#ff8906; ">&gt;</span>
<span style="color:#ff8906; ">&lt;</span><span style="color:#e66170; font-weight:bold; ">table</span><span style="color:#ff8906; ">&gt;</span></pre>
<p>接下來載入 jQuery 以及 Magnify_kai：</p>
<pre style="color:#d1d1d1;background:#000000;"><span style="color:#ff8906; ">&lt;</span><span style="color:#e66170; font-weight:bold; ">script type="text/javascript" src="jquery-1.3.2.min.js"</span><span style="color:#ff8906; ">&gt;</span><span style="color:#ff8906; ">&lt;/</span><span style="color:#e66170; font-weight:bold; ">script</span><span style="color:#ff8906; ">&gt;</span>
<span style="color:#ff8906; ">&lt;</span><span style="color:#e66170; font-weight:bold; ">script type="text/javascript" src="magnify_kai.js"</span><span style="color:#ff8906; ">&gt;</span><span style="color:#ff8906; ">&lt;/</span><span style="color:#e66170; font-weight:bold; ">script</span><span style="color:#ff8906; ">&gt;</span></pre>
<p>然後插入 JavaScript：</p>
<pre style="color:#d1d1d1;background:#000000;"><span style="color:#d2cd86; ">&lt;</span>script type<span style="color:#d2cd86; ">=</span><span style="color:#00c4c4; ">"text/javascript"</span><span style="color:#d2cd86; ">&gt;</span>
$<span style="color:#d2cd86; ">(</span><span style="color:#e66170; font-weight:bold; ">function</span> <span style="color:#d2cd86; ">(</span><span style="color:#d2cd86; ">)</span> <span style="color:#b060b0; ">{</span>

    $<span style="color:#d2cd86; ">(</span><span style="color:#00c4c4; ">'.magnify_kai'</span><span style="color:#d2cd86; ">)</span><span style="color:#d2cd86; ">.</span>fadeZoom<span style="color:#d2cd86; ">(</span><span style="color:#b060b0; ">{</span>
        preload<span style="color:#b060b0; ">:</span> <span style="color:#0f4d75; ">false</span><span style="color:#d2cd86; ">,</span>
        loadingImage<span style="color:#b060b0; ">:</span> <span style="color:#00c4c4; ">'images/ajax-loader.gif'</span>
    <span style="color:#b060b0; ">}</span><span style="color:#d2cd86; ">)</span><span style="color:#b060b0; ">;</span>
<span style="color:#b060b0; ">}</span><span style="color:#d2cd86; ">)</span><span style="color:#b060b0; ">;</span>
<span style="color:#d2cd86; ">&lt;</span><span style="color:#d2cd86; ">/</span>script<span style="color:#d2cd86; ">&gt;</span></pre>
<p>呈現的效果如下：<a href="http://blog.wabow.com/wp-content/uploads/2009/06/magnify_kai.png"><img class="aligncenter size-large wp-image-1520" src="http://blog.wabow.com/wp-content/uploads/2009/06/magnify_kai-500x253.png" alt="magnify_kai" width="500" height="253" /></a></p>
<p><a href="http://blog.wabow.com/wp-content/uploads/2009/06/magnify_kai.zip">範例程式下載</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.wabow.com/archives/1504/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[jQuery Plugin] 信用卡資料檢查（簡單版）</title>
		<link>http://blog.wabow.com/archives/1331</link>
		<comments>http://blog.wabow.com/archives/1331#comments</comments>
		<pubDate>Fri, 05 Jun 2009 09:19:56 +0000</pubDate>
		<dc:creator>suzy</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[技術分享]]></category>

		<guid isPermaLink="false">http://blog.wabow.com/?p=1331</guid>
		<description><![CDATA[前幾個星期做了有關 分期付款 的機制，需要 檢查信用卡卡號 的功能。我們都知道信用卡有分很多種，在台灣最常見的大概就是：Visa、MasterCard 以及 JCB 了，而每一種的卡號規則、長短又各有不同，自己寫感覺會非常麻煩。網路上已經有很多前人的成果可以拿來套用，不過都還要稍微修改才能完全符合自己想要的樣子。 而因為信用卡的欄位就那幾個，格式也都一模一樣，所以懶惰的我就想寫一個 jQuery Plugin，方便以後使用囉。就先叫 WaCard.js 好了 .....（初版，因為並沒有做後三碼驗證，也沒有卡片持有人欄位） 提醒：目前僅在 firefox 上測試過！ 功能： 自訂欄位名稱 檢查未填欄位 輸入卡號滿四碼跳下一欄位 檢查卡號 檢查卡片截止日期 [懶人專用] 信用卡類別選單自動生成 - 可自訂信用卡類別 （內建 Visa，Master，JCB，AmEx etc.. 共13種，預設只顯示台灣常用的三種） [懶人專用] 信用卡截止日期選單自動生成 - 列出未來十年的年份選單 自訂錯誤函式 - 預設是跳出 alert()，可以自由運用如何處理錯誤訊息（eg BlockUI etc..）。 自訂檢查通過後函式 - 預設是跳出確認對話框後送出，可客製化處理（eg ajaxSubmit etc..）。 安裝步驟： 1. 所需檔案： &#60;script type="text/javascript" src="jquery-1.3.2.min.js"&#62;&#60;/script&#62; // 在這個版本開發的 &#60;script [...]]]></description>
			<content:encoded><![CDATA[<p>前幾個星期做了有關 分期付款 的機制，需要 檢查信用卡卡號 的功能。我們都知道信用卡有分很多種，在台灣最常見的大概就是：Visa、MasterCard 以及 JCB 了，而每一種的卡號規則、長短又各有不同，自己寫感覺會非常麻煩。網路上已經有很多前人的成果可以拿來套用，不過都還要稍微修改才能完全符合自己想要的樣子。</p>
<p>而因為信用卡的欄位就那幾個，格式也都一模一樣，所以懶惰的我就想寫一個 jQuery Plugin，方便以後使用囉。就先叫 WaCard.js 好了 <img src='http://blog.wabow.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> .....（初版，因為並沒有做後三碼驗證，也沒有卡片持有人欄位）<br />
提醒：目前僅在 firefox 上測試過！</p>
<p><a href="http://blog.wabow.com/wp-content/uploads/2009/06/e59c96e78987-4.png"><img class="size-full wp-image-1371 alignnone" src="http://blog.wabow.com/wp-content/uploads/2009/06/e59c96e78987-4.png" alt="e59c96e78987-4" width="727" height="195" /></a></p>
<p><span id="more-1331"></span></p>
<h3>功能：</h3>
<ul>
<li>自訂欄位名稱</li>
<li>檢查未填欄位</li>
<li>輸入卡號滿四碼跳下一欄位</li>
<li>檢查卡號</li>
<li>檢查卡片截止日期</li>
<li>[懶人專用] 信用卡類別選單自動生成 - 可自訂信用卡類別 （內建 Visa，Master，JCB，AmEx etc.. 共13種，預設只顯示台灣常用的三種）</li>
<li>[懶人專用] 信用卡截止日期選單自動生成 - 列出未來十年的年份選單</li>
<li>自訂錯誤函式 - 預設是跳出 alert()，可以自由運用如何處理錯誤訊息（eg BlockUI etc..）。</li>
<li>自訂檢查通過後函式 - 預設是跳出確認對話框後送出，可客製化處理（eg ajaxSubmit etc..）。</li>
</ul>
<h3>安裝步驟：</h3>
<p>1. 所需檔案：</p>
<div class="wp_syntax">
<div class="code"><code><br />
&lt;script type="text/javascript" src="jquery-1.3.2.min.js"&gt;&lt;/script&gt; // 在這個版本開發的<br />
&lt;script type="text/javascript" src="jquery.selectboxes.js"&gt;&lt;/script&gt; // 懶人作法要用到，非必要<br />
&lt;script type="text/javascript" src="wacard.js"&gt;&lt;/script&gt;<br />
</code></div>
</div>
<p>2. 指定要執行 WaCard 的表單</p>
<div class="wp_syntax">
<div class="code"><code><br />
$(function () {<br />
// 如果一切都照預設，那直接呼叫 wacard 就可以啦～<br />
$('#myform').wacard();<br />
});<br />
</code></div>
</div>
<p>3. 表單HTML</p>
<div class="wp_syntax">
<div class="code"><code><br />
&lt;form id="myform" method="post"&gt;<br />
&lt;fieldset&gt;<br />
&lt;div&gt;<br />
&lt;label&gt;卡號:&lt;/label&gt;<br />
<span style="color: #0000ff;">&lt;select name="cc_type"&gt;&lt;/select&gt;</span><br />
<span style="color: #666;"><br />
&lt;input type="text" name="cc_no1" size="4" maxlength="4" /&gt;<br />
&lt;input type="text" name="cc_no2" size="4" maxlength="4" /&gt;<br />
&lt;input type="text" name="cc_no3" size="4" maxlength="4" /&gt;<br />
&lt;input type="text" name="cc_no4" size="4" maxlength="4" /&gt;<br />
</span><br />
&lt;/div&gt;<br />
&lt;div&gt;<br />
&lt;label&gt;到期日:&lt;/label&gt;<br />
<span style="color: #0000ff;">&lt;select name="cc_m"&gt;&lt;/select&gt;</span> 月<br />
<span style="color: #0000ff;">&lt;select name="cc_y"&gt;&lt;/select&gt;</span> 年<br />
&lt;/div&gt;<br />
&lt;/fieldset&gt;<br />
&lt;div&gt;<br />
&lt;input type="submit" name="submit" value="submit" /&gt;<br />
&lt;/div&gt;<br />
&lt;/form&gt;</code></div>
</div>
<p>註：上面所說的懶人作法是指藍色的部份，WaCard 會判斷若該選單是<strong>空的</strong>，才加入預設的值。不過用了以後，在 JavaScript Disabled 的情況下這個 form 就不是 XHTML Valid 的囉，而且關了 JavaScript 這個 form 就不能正常跑了。</p>
<p><strong><a href="http://www.dodoke.com/testground/wacard/demo.html">DEMO 點我 點我看結果～</a></strong></p>
<p>接下來，我們可以自訂錯誤訊息 跟 檢查通過後的處理，下面的程式碼結合了另外兩個 jQuery Plugins - <a href="http://malsup.com/jquery/block/">BlockUI</a> &amp; <a href="http://malsup.com/jquery/form/">AjaxSubmit</a> ：</p>
<p><a href="http://blog.wabow.com/wp-content/uploads/2009/06/e59c96e78987-5.png"><img class="alignnone size-full wp-image-1372" src="http://blog.wabow.com/wp-content/uploads/2009/06/e59c96e78987-5.png" alt="e59c96e78987-5" width="321" height="147" /></a></p>
<div class="wp_syntax">
<div class="code"><code><br />
$(function () {<br />
<span style="color: #800080;">var customSuccess = function() {<br />
var options = {<br />
dataType:   'json',<br />
success:    function(json) {<br />
if(json.message!=''){<br />
alert(json.message);<br />
}else{<br />
location.reload();<br />
}<br />
}<br />
};<br />
$(this).ajaxSubmit(options);<br />
};</span><br />
<span style="color: #008000;">var customError = function(errorMessages) {<br />
var errorList = '';<br />
if (0 &lt; errorMessages.length) {<br />
for (i=0; i&lt;errorMessages.length; i++) {<br />
errorList += '<br />
&lt;li&gt;'+errorMessages[i]+'&lt;/li&gt;<br />
';<br />
}<br />
} else {<br />
errorList = errorMessages;<br />
}<br />
$.blockUI({<br />
message: '很抱歉，您輸入的信用卡資料有誤！<br />
&lt;ul&gt;'<br />
+ errorList<br />
+ '&lt;/ul&gt;<br />
&lt;button&gt;確認&lt;/button&gt;',<br />
css: {<br />
border: 'none', padding: '15px 25px', backgroundColor: '#333', '-webkit-border-radius': '10px',<br />
'-moz-border-radius': '10px', opacity: '.75', color: '#fff', width: '240px', top: '33%', left: '45%'<br />
}<br />
});<br />
return false;<br />
};</span><br />
$('#myForm').wacard({<br />
onError: <span style="color: #800080;">customError</span>,<br />
onSuccess: <span style="color: #008000;">customSuccess</span>,<br />
});<br />
});<br />
</code></div>
</div>
<p><strong><a href="http://www.dodoke.com/testground/wacard/demo2.html">DEMO 點我 點我看結果～</a></strong></p>
<p>大概就是這樣，有需要的人可以<a href="http://www.dodoke.com/testground/wacard/wacard.js">下載</a>玩玩看囉。 <img src='http://blog.wabow.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h3>信用卡號測式樣本</h3>
<table border="1">
<tbody>
<tr>
<td><strong>Credit Card</strong></td>
<td><strong>Sample Number</strong></td>
</tr>
<tr>
<td>Visa</td>
<td>4111 1111 1111 1111</td>
</tr>
<tr>
<td>MasterCard</td>
<td>5500 0000 0000 0004</td>
</tr>
<tr>
<td>American Express</td>
<td>3400 0000 0000 009</td>
</tr>
<tr>
<td>Diner's Club</td>
<td>3000 0000 0000 04</td>
</tr>
<tr>
<td>Carte Blanche</td>
<td>3000 0000 0000 04</td>
</tr>
<tr>
<td>Discover</td>
<td>6011 0000 0000 0004</td>
</tr>
<tr>
<td>en Route</td>
<td>2014 0000 0000 009</td>
</tr>
<tr>
<td>JCB</td>
<td>3088 0000 0000 0009</td>
</tr>
</tbody>
</table>
<h3>注意事項：</h3>
<ol>
<li>透過網路輸入信用卡資料一定要加密（SSL）。</li>
<li>信用卡若有需要存入資料庫，也一定要先加密後才可存入。</li>
<li>可靠的線上刷卡方式仍是建議透過 銀行 或 第三方刷卡網站代為處理。</li>
</ol>
<h3>參考資料:</h3>
<p><a href="http://doc.async.com.br/formcheck_re/ccnums.html">Sample Valid Credit Card Numbers</a><br />
<a href="http://www.ihwy.com/labs/jquery-validate-credit-card-extension.aspx">jQuery Validate Credit Card Extension</a><br />
BNQ 的 creditcard.js</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.wabow.com/archives/1331/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[jQuery Plugin] LavaLamp</title>
		<link>http://blog.wabow.com/archives/1290</link>
		<comments>http://blog.wabow.com/archives/1290#comments</comments>
		<pubDate>Thu, 04 Jun 2009 04:56:30 +0000</pubDate>
		<dc:creator>abu</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[技術分享]]></category>

		<guid isPermaLink="false">http://blog.wabow.com/?p=1290</guid>
		<description><![CDATA[官網：點我 範例：點我 這是Flash製作的選單 當然不是，是Flash製作的話，就沒什麼好介紹的了，網頁上，常看到花樣多變的選單，幾乎都是用Flash製作的，不過這款LavaLamp plugin，卻可以製作出簡易的滑動選單效果，看到官網範例還真的覺得有Flash的fu，javascript真神奇~ 載入 jQuery 及 LavaLamp &#38;lt;script type=&#34;text/javascript&#34; src=&#34;path/to/jquery.js&#34;&#38;gt;&#38;lt;/script&#38;gt; &#38;lt;script type=&#34;text/javascript&#34; src=&#34;path/to/jquery.lavalamp.js&#34;&#38;gt;&#38;lt;/script&#38;gt; &#38;lt;script type=&#34;text/javascript&#34; src=&#34;path/to/jquery.easing.js&#34;&#38;gt;&#38;lt;/script&#38;gt; html部份 &#60;ul class=&#34;lavaLamp&#34;&#62; &#60;li&#62;&#60;a href=&#34;#&#34;&#62;Home&#60;/a&#62;&#60;/li&#62; &#60;li&#62;&#60;a href=&#34;#&#34;&#62;Plant a tree&#60;/a&#62;&#60;/li&#62; &#60;li&#62;&#60;a href=&#34;#&#34;&#62;Travel&#60;/a&#62;&#60;/li&#62; &#60;li&#62;&#60;a href=&#34;#&#34;&#62;Ride an elephant&#60;/a&#62;&#60;/li&#62; &#60;/ul&#62; css部份 /* Styles for the entire LavaLamp menu */ .lavaLamp { position: relative; height: 29px; width: 421px; background: url(&#34;../image/bg.gif&#34;) no-repeat top; [...]]]></description>
			<content:encoded><![CDATA[<ul>
<li>官網：<a href="http://www.gmarwaha.com/blog/2007/08/23/lavalamp-for-jquery-lovers/">點我</a></li>
<li>範例：<a href="http://www.gmarwaha.com/blog/2007/08/23/lavalamp-for-jquery-lovers/">點我</a></li>
</ul>
<p><img class="aligncenter size-full wp-image-1291" src="http://blog.wabow.com/wp-content/uploads/2009/06/lava1.png" alt="lava1" width="495" height="85" /></p>
<p>這是Flash製作的選單<span id="more-1290"></span></p>
<p>當然不是，是Flash製作的話，就沒什麼好介紹的了，網頁上，常看到花樣多變的選單，幾乎都是用Flash製作的，不過這款LavaLamp plugin，卻可以製作出簡易的滑動選單效果，看到官網範例還真的覺得有Flash的fu，javascript真神奇~</p>
<p>載入 jQuery 及 LavaLamp</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #ddbb00;">&amp;lt;</span>script type=&quot;text/javascript&quot; src=&quot;path/to/jquery.js&quot;<span style="color: #ddbb00;">&amp;gt;&amp;lt;</span>/script<span style="color: #ddbb00;">&amp;gt;</span>
<span style="color: #ddbb00;">&amp;lt;</span>script type=&quot;text/javascript&quot; src=&quot;path/to/jquery.lavalamp.js&quot;<span style="color: #ddbb00;">&amp;gt;&amp;lt;</span>/script<span style="color: #ddbb00;">&amp;gt;</span>
<span style="color: #ddbb00;">&amp;lt;</span>script type=&quot;text/javascript&quot; src=&quot;path/to/jquery.easing.js&quot;<span style="color: #ddbb00;">&amp;gt;&amp;lt;</span>/script<span style="color: #ddbb00;">&amp;gt;</span></pre></div></div>

<p>html部份</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">ul</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;lavaLamp&quot;</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span>&gt;</span>Home<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span>&gt;</span>Plant a tree<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span>&gt;</span>Travel<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span>&gt;</span>Ride an elephant<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">ul</span>&gt;</span></pre></div></div>

<p>css部份</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">/* Styles for the entire LavaLamp menu */
.lavaLamp {
position: relative;
height: 29px; width: 421px;
background: url(&quot;../image/bg.gif&quot;) no-repeat top;
padding: 15px; margin: 10px 0;
overflow: hidden;
}
/* Force the list to flow horizontally */
.lavaLamp li {
float: left;
list-style: none;
}
/* Represents the background of the highlighted menu-item. */
.lavaLamp li.back {
background: url(&quot;../image/lava.gif&quot;) no-repeat right -30px;
width: 9px; height: 30px;
z-index: 8;
position: absolute;
}
.lavaLamp li.back .left {
background: url(&quot;../image/lava.gif&quot;) no-repeat top left;
height: 30px;
margin-right: 9px;
}
/* Styles for each menu-item. */
.lavaLamp li a {
position: relative; overflow: hidden;
text-decoration: none;
text-transform: uppercase;
font: bold 14px arial;
color: #fff; outline: none;
text-align: center;
height: 30px; top: 7px;
z-index: 10; letter-spacing: 0;
float: left; display: block;
margin: auto 10px;
}</pre></div></div>

<p>最後加入</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">$(function() { $(&quot;.lavaLamp&quot;).lavaLamp({ fx: &quot;backout&quot;, speed: 700 })});</pre></div></div>

<p>Flash在介面的自由度還是高很多，可以很天馬行空的設計，不過能多找到幾個類似這樣的plugin來用，個人已經很滿足了 <img src='http://blog.wabow.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.wabow.com/archives/1290/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[jQuery Plugin]一個輕量化的所見即所得文字編輯器-Lightweight RTE</title>
		<link>http://blog.wabow.com/archives/1230</link>
		<comments>http://blog.wabow.com/archives/1230#comments</comments>
		<pubDate>Fri, 22 May 2009 03:11:35 +0000</pubDate>
		<dc:creator>andrew</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[技術分享]]></category>

		<guid isPermaLink="false">http://blog.wabow.com/?p=1230</guid>
		<description><![CDATA[官方網站 / demo http://batiste.dosimple.ch/blog/posts/2007-09-11-1/rich-text-editor-jquery.html Lightweight RTE是一套標榜檔案輕量化的所見即所得的文字編輯器(Rich Text Editors簡稱RTE)，載入方式為jQuery Plugin。Lightweight RTE有以下幾個特點: Super lightweight 7kb uncompressed (超輕量的檔案大小僅僅7kb) Compatible with major browsers (適用於主流瀏覽器)(官網寫適用於IE6, Firefox 2, Opera 9, Safari 3.03不過我用IE7也是正常運作) Degrade gracefully (簡潔) GNU General Public License (符合公共通用授權) 現在就讓我們看一下要怎麼使用吧! 程式碼 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://blog.wabow.com/wp-content/uploads/2009/05/sample-300x173.jpg" alt="sample" width="300" height="173" class="aligncenter size-medium wp-image-1232" /></p>
<p>官方網站 / demo<br />
<a href="http://batiste.dosimple.ch/blog/posts/2007-09-11-1/rich-text-editor-jquery.html">http://batiste.dosimple.ch/blog/posts/2007-09-11-1/rich-text-editor-jquery.html</a></p>
<p><span id="more-1230"></span></p>
<p>Lightweight RTE是一套標榜檔案輕量化的所見即所得的文字編輯器(Rich Text Editors簡稱RTE)，載入方式為jQuery Plugin。Lightweight RTE有以下幾個特點:</p>
<blockquote><p>Super lightweight 7kb uncompressed (超輕量的檔案大小僅僅7kb)<br />
Compatible with major browsers (適用於主流瀏覽器)(官網寫適用於IE6, Firefox 2, Opera 9, Safari 3.03不過我用IE7也是正常運作)<br />
Degrade gracefully (簡潔)<br />
GNU General Public License (符合公共通用授權)
</p></blockquote>
<p>現在就讓我們看一下要怎麼使用吧!</p>
<h3>程式碼</h3>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #ddbb00;">&amp;lt;</span>!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;<span style="color: #ddbb00;">&amp;gt;</span>
<span style="color: #ddbb00;">&amp;lt;</span>html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xml:lang=&quot;fr-ch&quot; lang=&quot;fr-ch&quot;<span style="color: #ddbb00;">&amp;gt;</span>
<span style="color: #ddbb00;">&amp;lt;</span>head<span style="color: #ddbb00;">&amp;gt;</span>
<span style="color: #ddbb00;">&amp;lt;</span>title<span style="color: #ddbb00;">&amp;gt;</span>A light weight RTE jQuery Plugin<span style="color: #ddbb00;">&amp;lt;</span>/title<span style="color: #ddbb00;">&amp;gt;</span>
<span style="color: #ddbb00;">&amp;lt;</span>link type=&quot;text/css&quot; rel=&quot;stylesheet&quot; href=&quot;rte.css&quot; /<span style="color: #ddbb00;">&amp;gt;</span>
<span style="color: #ddbb00;">&amp;lt;</span>/head<span style="color: #ddbb00;">&amp;gt;</span>
<span style="color: #ddbb00;">&amp;lt;</span>body<span style="color: #ddbb00;">&amp;gt;</span>
<span style="color: #ddbb00;">&amp;lt;</span>form<span style="color: #ddbb00;">&amp;gt;</span>
<span style="color: #ddbb00;">&amp;lt;</span>p<span style="color: #ddbb00;">&amp;gt;</span>
    <span style="color: #ddbb00;">&amp;lt;</span>textarea name=&quot;description&quot; id=&quot;id_description&quot; 
    class=&quot;rte-zone&quot;<span style="color: #ddbb00;">&amp;gt;&amp;lt;</span>/textarea<span style="color: #ddbb00;">&amp;gt;</span>
<span style="color: #ddbb00;">&amp;lt;</span>/p<span style="color: #ddbb00;">&amp;gt;</span>
<span style="color: #ddbb00;">&amp;lt;</span>input type=&quot;submit&quot; /<span style="color: #ddbb00;">&amp;gt;</span>
<span style="color: #ddbb00;">&amp;lt;</span>/form<span style="color: #ddbb00;">&amp;gt;</span>
<span style="color: #ddbb00;">&amp;lt;</span>script type=&quot;text/javascript&quot; src=&quot;jquery-1.2.6.min.js&quot;<span style="color: #ddbb00;">&amp;gt;&amp;lt;</span>/script<span style="color: #ddbb00;">&amp;gt;</span>
<span style="color: #ddbb00;">&amp;lt;</span>script type=&quot;text/javascript&quot; src=&quot;jquery.rte.js&quot;<span style="color: #ddbb00;">&amp;gt;&amp;lt;</span>/script<span style="color: #ddbb00;">&amp;gt;</span>
<span style="color: #ddbb00;">&amp;lt;</span>script type=&quot;text/javascript&quot;<span style="color: #ddbb00;">&amp;gt;</span>
    $('.rte-zone').rte(&quot;css url&quot;, &quot;toolbox images url&quot;);
<span style="color: #ddbb00;">&amp;lt;</span>/script<span style="color: #ddbb00;">&amp;gt;</span>
&nbsp;
<span style="color: #ddbb00;">&amp;lt;</span>/body<span style="color: #ddbb00;">&amp;gt;</span>
<span style="color: #ddbb00;">&amp;lt;</span>/html<span style="color: #ddbb00;">&amp;gt;</span></pre></td></tr></table></div>

<h3>程式碼解說</h3>
<p>jQuery-Plugin部份主要是載入jquery.rte.js這隻檔案，而jQuery的程式碼為$('.rte-zone').rte("css url", "toolbox images url");這行。工具列上的小圖示只要檔名一樣可以自行更換自己喜歡的圖案。</p>
<h3>功能解說</h3>
<p>Lightweight RTE的工具列上提供了以下功能:</p>
<blockquote><p>預設字型樣式 : Block Style / Paragraph /  Title / Address<br />
粗體<br />
斜體<br />
項目<br />
超連結<br />
圖片 : 輸入圖片網址<br />
純文字編輯模式 / 所見即所得模式 切換
</p></blockquote>
<h3>總結</h3>
<p>雖然Lightweight RTE與其他的RTE比較起來功能稍顯陽春，但在ㄧ些需求不高的時候不失為一種更方便簡單的方案，檔案輕量更是其特點。不妨試用看看!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.wabow.com/archives/1230/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[jQuery] ajaxFileUpload Plugin</title>
		<link>http://blog.wabow.com/archives/1221</link>
		<comments>http://blog.wabow.com/archives/1221#comments</comments>
		<pubDate>Fri, 22 May 2009 01:57:13 +0000</pubDate>
		<dc:creator>abu</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[技術分享]]></category>

		<guid isPermaLink="false">http://blog.wabow.com/?p=1221</guid>
		<description><![CDATA[官網：http://www.phpletter.com/Our-Projects/AjaxFileUpload/ 範例：http://www.phpletter.com/Demo/AjaxFileUpload-Demo/ 在製作客戶需求的表單時，常會遇到上傳圖片的需求，因為要在同一頁編輯資料，通常會採取另開視窗，完成上傳動作後，再回到原本編輯頁面，繼續完成編輯，而拜ajax所賜，上傳檔案可以更加便利了。  (其實是這次期交所郵件附加檔案要用的) ajaxFileUpload是一個jQuery Plugin，套用上也是相當簡便，只需特別設定處理上傳檔案的後端程式即可 直接來看用法吧~ 1. 載入jQuery和ajaxFileUpload &#60;script src=&#34;jquery.js&#34; type=&#34;text/javascript&#34;&#62;&#60;/script&#62; &#60;script src=&#34;ajaxFileUpload.js&#34; type=&#34;text/javascript&#34;&#62;&#60;/script&#62; 2.綁定某個你想要執行ajax上傳檔案功能的按鈕,以及設定ajaxFileUpload上傳 &#160; $&#40;function&#40;&#41;&#123; &#160; $.ajaxFileUpload &#40; &#123; url:'doajaxfileupload.php', , fileElementId:'fileToUpload', success: function &#40;&#41; &#123; alert&#40;'上傳成功'&#41;; &#125; &#125; &#41; &#160; return false; &#160; &#125; &#160; &#160; &#125;&#41; 3.html碼 &#60;input id=&#34;fileToUpload&#34; type=&#34;file&#34; /&#62; &#60;input id=&#34;uploadButton&#34; type=&#34;button&#34; value=&#34;上傳&#34; /&#62; 4.後端處理PHP (範例為doajaxfileupload.php) &#60;php copy&#40;$_FILES&#91;'fileToUpload'&#93;,$targetFile&#41;; [...]]]></description>
			<content:encoded><![CDATA[<p>官網：<a href="http://www.phpletter.com/Our-Projects/AjaxFileUpload/">http://www.phpletter.com/Our-Projects/AjaxFileUpload/</a><br />
範例：<a href="http://www.phpletter.com/Demo/AjaxFileUpload-Demo/">http://www.phpletter.com/Demo/AjaxFileUpload-Demo/</a></p>
<p>在製作客戶需求的表單時，常會遇到上傳圖片的需求，因為要在同一頁編輯資料，通常會採取另開視窗，完成上傳動作後，再回到原本編輯頁面，繼續完成編輯，而拜ajax所賜，上傳檔案可以更加便利了。  (其實是這次期交所郵件附加檔案要用的)<span id="more-1221"></span></p>
<p>ajaxFileUpload是一個jQuery Plugin，套用上也是相當簡便，只需特別設定處理上傳檔案的後端程式即可</p>
<p>直接來看用法吧~</p>
<p>1. 載入jQuery和ajaxFileUpload</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;jquery.js&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;ajaxFileUpload.js&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span></pre></div></div>

<p>2.綁定某個你想要執行ajax上傳檔案功能的按鈕,以及設定ajaxFileUpload上傳</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">&nbsp;
$<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
$.<span style="color: #660066;">ajaxFileUpload</span>
        <span style="color: #009900;">&#40;</span>
            <span style="color: #009900;">&#123;</span>
                url<span style="color: #339933;">:</span><span style="color: #3366CC;">'doajaxfileupload.php'</span><span style="color: #339933;">,</span> <span style="color: #339933;">,</span>
                fileElementId<span style="color: #339933;">:</span><span style="color: #3366CC;">'fileToUpload'</span><span style="color: #339933;">,</span>
                success<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
                <span style="color: #009900;">&#123;</span>     
                      <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'上傳成功'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>           
                <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#41;</span>
&nbsp;
        <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>  
&nbsp;
&nbsp;
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span></pre></div></div>

<p>3.html碼</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;fileToUpload&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;file&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;uploadButton&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;button&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;上傳&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span></pre></div></div>

<p>4.後端處理PHP (範例為doajaxfileupload.php)</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>php
<span style="color: #990000;">copy</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_FILES</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'fileToUpload'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #000088;">$targetFile</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>以上就完成了簡易的ajax上傳檔案設定，功能上可自行再增加，如圖片大小的判斷，上傳過程中的畫面顯示等等。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.wabow.com/archives/1221/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery 代碼編輯器 markItUp!</title>
		<link>http://blog.wabow.com/archives/1150</link>
		<comments>http://blog.wabow.com/archives/1150#comments</comments>
		<pubDate>Thu, 14 May 2009 07:20:39 +0000</pubDate>
		<dc:creator>suzy</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[技術分享]]></category>

		<guid isPermaLink="false">http://blog.wabow.com/?p=1150</guid>
		<description><![CDATA[今天要介紹的是一款輕量型的文字編輯器 markItUp! Mac 外觀: Live 外觀: (剛剛打的因為電腦當機變成一片空白 &#62;"&#60;) 它是用 jQuery 開發, 核心檔僅有 6.5Kb 的小玩意兒. 為什麼說它是小玩意~因為它的功能並不如 TinyMCE or FCKeditor 般強大, 它的特別在於它不是普通的 HTML 編輯器, 它能夠把代碼轉換成 HTML. 目前它支援的代碼有: Html, Textile, Wiki Syntax, Markdown, BBcode. 支援的編輯功能也僅有: H1-H6, UL OL, URL, 粗體 跟 斜體 還有 Ajax 預覽功能 它可以支援其他的 jQuery Plugins: (紅色框框裡的就是用了 jQuery plugins 的 Farbtastic, SimpleModel, 還有 jQuery UI) 它還可以自訂代碼, [...]]]></description>
			<content:encoded><![CDATA[<p>今天要介紹的是一款輕量型的文字編輯器 <a href="http://markitup.jaysalvat.com/home/">markItUp!</a></p>
<p>Mac 外觀:<br />
<img class="alignnone size-full wp-image-1155" src="http://blog.wabow.com/wp-content/uploads/2009/05/markitup-mac.jpg" alt="markitup-mac" width="675" height="154" /></p>
<p>Live 外觀:<br />
<img class="alignnone size-full wp-image-1156" src="http://blog.wabow.com/wp-content/uploads/2009/05/markitup-live.jpg" alt="markitup-live" width="691" height="180" /></p>
<p><span id="more-1150"></span></p>
<p>(剛剛打的因為電腦當機變成一片空白 &gt;"&lt;)</p>
<p>它是用 jQuery 開發, 核心檔僅有 6.5Kb 的小玩意兒.</p>
<p>為什麼說它是小玩意~因為它的功能並不如 TinyMCE or FCKeditor 般強大, 它的特別在於它不是普通的 HTML 編輯器, 它能夠把代碼轉換成 HTML.</p>
<p>目前它支援的代碼有: Html, Textile, Wiki Syntax, Markdown, BBcode.<br />
支援的編輯功能也僅有: H1-H6, UL OL, URL, 粗體 跟 斜體<br />
還有 Ajax 預覽功能</p>
<p style="text-align: center;"><img class="size-full wp-image-1154 aligncenter" src="http://blog.wabow.com/wp-content/uploads/2009/05/markitup1.jpg" alt="markitup1" width="503" height="750" /></p>
<p>它可以支援其他的 jQuery Plugins:<br />
(紅色框框裡的就是用了 jQuery plugins 的 <a href="http://acko.net/dev/farbtastic">Farbtastic</a>, <a href="http://www.ericmmartin.com/projects/simplemodal/">SimpleModel</a>, 還有 jQuery UI)<br />
<img class="alignnone size-full wp-image-1157" src="http://blog.wabow.com/wp-content/uploads/2009/05/markitup-plugins.jpg" alt="markitup-plugins" width="715" height="317" /></p>
<p>它還可以自訂代碼, 因此我把程式包下載後小小改了一番:</p>
<p>1. 在 set.js 檔裡很輕易地把五個 plurk 支援的代碼套入到此編輯器中</p>
<p>路徑: <em>markitup/sets/plurk/set.js</em></p>
<div class="wp_syntax">
<div class="code"><code><br />
mySettings = {<br />
nameSpace:  "plurk",<br />
markupSet:  [<br />
{name:'Bold', key:'B', closeWith:'**', openWith:'**'},<br />
{name:'Italic', key:'I', closeWith:'*', openWith:'*'},<br />
{name:'Underline', key:'U', closeWith:'__', openWith:'__'},<br />
{name:'Picture', openWith:'', closeWith:'[![Source:!:http://]!] ([![Title]!])'},<br />
{name:'Link', openWith:'', closeWith:'[![Link:!:http://]!] ([![Title]!])'},<br />
]<br />
}<br />
</code></div>
</div>
<p>2. 在 style.css 檔裡管理 Toolbar 上的 icon</p>
<p>路徑: <em>markitup/sets/plurk/style.css</em></p>
<div class="wp_syntax">
<div class="code"><code><br />
.markItUp .markItUpButton1 a {<br />
background-image:url(images/bold.png);<br />
}<br />
.markItUp .markItUpButton2 a {<br />
background-image:url(images/italic.png);<br />
}<br />
.markItUp .markItUpButton3 a {<br />
background-image:url(images/underline.png);<br />
}<br />
.markItUp .markItUpButton4 a {<br />
background-image:url(images/picture.png);<br />
}<br />
.markItUp .markItUpButton5 a {<br />
background-image:url(images/link.png);<br />
}<br />
</code></div>
</div>
<p>3. 同時我只換了 css 檔就可以把外觀換成 Mac Style (當然還有包在css裡的圖)</p>
<p>路徑: <em>markitup/index.html</em></p>
<div class="wp_syntax">
<div class="code">
<p>&lt;!-- jQuery 核心檔 --&gt;<br />
&lt;script type="text/javascript" src="jquery.pack.js"&gt;&lt;/script&gt;<br />
&lt;!-- markItUp! 核心檔 --&gt;<br />
&lt;script type="text/javascript" src="markitup/jquery.markitup.pack.js"&gt;&lt;/script&gt;<br />
&lt;!-- markItUp! toolbar settings 設定檔--&gt;<br />
&lt;script type="text/javascript" src="markitup/sets/plurk/set.js"&gt;&lt;/script&gt;<br />
&lt;!-- markItUp! 外觀檔 --&gt;<br />
&lt;link rel="stylesheet" type="text/css" href="markitup/skins/<strong>macosx</strong>/style.css" /&gt;<br />
&lt;!--  markItUp! Toolbar 外觀檔 --&gt;<br />
&lt;link rel="stylesheet" type="text/css" href="markitup/sets/plurk/style.css" /&gt;</div>
</div>
<p>還滿簡單的. 做了一個 Plurk 的代碼編輯器 <a href="http://www.dodoke.com/testground/markitup/index.html">測試結果在此</a></p>
<p>優點:</p>
<p>速度快, 不佔空間, 俱有擴充潛力: 可以結合其他的 jQuery Plugins (作者有實作如何套用 jQuery的 color picker, dialogue).</p>
<p>簡單易改, 可以輕易的改成自己想要的代碼編輯器.</p>
<p>美中不足:</p>
<p>還太陽春了</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.wabow.com/archives/1150/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[jQuery plugin] waTable的誕生</title>
		<link>http://blog.wabow.com/archives/990</link>
		<comments>http://blog.wabow.com/archives/990#comments</comments>
		<pubDate>Wed, 22 Apr 2009 03:14:35 +0000</pubDate>
		<dc:creator>abu</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[技術分享]]></category>

		<guid isPermaLink="false">http://blog.wabow.com/?p=990</guid>
		<description><![CDATA[作者：Abu 官網：官網 展示：範例 一個平凡的表格，能賦予怎樣的功能？ 記得很久之前，古老記憶中，jace說可以試試看幫比一比擴充一下功能，就是可以自由新增table的欄位，利用這次順便練習jQuery自製plugin，既然是從哇寶誕生的，名稱里所當然就是wa開頭，跟table有關，那就叫做waTable吧！(好草率的命名，要是孩子剛出生要命名的時候，看到了窗外鳥正在大便.......)，好，名稱只是個浮名，也不用太追究了。 卡關部份： 1.首先希望能夠上下左右都能隨意新增，所以新增的按鈕要設在哪呢？就直接出現在table的四面八方吧，而且按鈕大小要隨著table變寬變高而隨時調整。 2.一個普通的表格，沒任何rowspan或是colspan的話，難易度大概是0，如果和(ㄏㄨㄛˋ)上了rowspan和colspan這兩個元素，難度真的是大大提昇，而且上下左右新增的方式，不太有對稱的觀念，就是"往右新增"和"往左新增"，程式基本上是沒辦法複製過來改個函式名稱就打完收工。 大致攻略： 整個概念就是先利用一個div將原本table包住，然後將該table的margin-left、margin-right等等，一些定位的CSS屬性全部移轉到div上，接著創造四個浮動div按鈕，設定好寬度高度，擺放到table的上下左右，在div上使用jQuery的hover方法，讓按鈕可出現隱藏，這樣就完成了基本架構。 剩下的就是大工程了，往上下左右新增，以及當遇到rowspan、colspan要如何計算等等，目前尚在開發中，所以還需要測試更多的表格組合，找出bug，預設值是左右新增遇到colspan的話，會將該欄位直接延伸，上下遇到rowspan一樣是延伸，以後會陸陸續續將設定參數加入plugin，讓使用者能更加活用。 使用方式： 載入 jQuery 及 watable &#60;script src=&#34;jquery.js&#34; type=&#34;text/javascript&#34;&#62;&#60;/script&#62; &#160; &#60;script src=&#34;watable.js&#34; type=&#34;text/javascript&#34;&#62;&#60;/script&#62; html 格式 &#60;table border=&#34;0&#34;&#62; &#60;tbody&#62; &#60;tr&#62; &#60;td rowspan=&#34;2&#34;&#62;1111&#60;/td&#62; &#60;td&#62;1111&#60;/td&#62; &#60;td&#62;1111&#60;/td&#62; &#60;td&#62;1111&#60;/td&#62; &#60;/tr&#62; &#60;tr&#62; &#60;td&#62;1111&#60;/td&#62; &#60;td&#62;1111&#60;/td&#62; &#60;td&#62;1111&#60;/td&#62; &#60;/tr&#62; &#60;tr&#62; &#60;td colspan=&#34;2&#34;&#62;1111&#60;/td&#62; &#60;td&#62;1111&#60;/td&#62; &#60;td&#62;1111&#60;/td&#62; &#60;/tr&#62; &#60;/tbody&#62;&#60;/table&#62; 最後加入 $(function(){ $('table').waTable(); }); 呈現效果： 關於這類的plugin，其實我不知道是不是已經有人寫出來了，如果有的話，就當作練習jQuery的plugin寫法，沒有的話，更應該好好將完成度提昇，像是原本表格中，有填寫的欄位，而且帶有id或是name，需要被送到後台程式做處理，那新增的欄位中，該如何將這些欄位加進去等等，未來陸續還有很多可增加的功能，按鈕外觀設計，以及bug修正，也希望這個小服務能有更多應用的地方？！]]></description>
			<content:encoded><![CDATA[<ul>
<li>作者：Abu</li>
<li>官網：<a href="http://demo.wabow.com/">官網</a></li>
<li>展示：<a href="http://demo.wabow.com/watable">範例</a></li>
</ul>
<p>一個平凡的表格，能賦予怎樣的功能？<br />
<img class="aligncenter size-full wp-image-988" src="http://blog.wabow.com/wp-content/uploads/2009/04/watable1.png" alt="watable1" width="228" height="105" /></p>
<p><span id="more-990"></span>記得很久之前，古老記憶中，jace說可以試試看幫比一比擴充一下功能，就是可以自由新增table的欄位，利用這次順便練習jQuery自製plugin，既然是從哇寶誕生的，名稱里所當然就是wa開頭，跟table有關，那就叫做waTable吧！(好草率的命名，要是孩子剛出生要命名的時候，看到了窗外鳥正在大便.......)，好，名稱只是個浮名，也不用太追究了。</p>
<p>卡關部份：<br />
1.首先希望能夠上下左右都能隨意新增，所以新增的按鈕要設在哪呢？就直接出現在table的四面八方吧，而且按鈕大小要隨著table變寬變高而隨時調整。<br />
2.一個普通的表格，沒任何rowspan或是colspan的話，難易度大概是0，如果和(ㄏㄨㄛˋ)上了rowspan和colspan這兩個元素，難度真的是大大提昇，而且上下左右新增的方式，不太有對稱的觀念，就是"往右新增"和"往左新增"，程式基本上是沒辦法複製過來改個函式名稱就打完收工。</p>
<p>大致攻略：<br />
整個概念就是先利用一個div將原本table包住，然後將該table的margin-left、margin-right等等，一些定位的CSS屬性全部移轉到div上，接著創造四個浮動div按鈕，設定好寬度高度，擺放到table的上下左右，在div上使用jQuery的hover方法，讓按鈕可出現隱藏，這樣就完成了基本架構。 剩下的就是大工程了，往上下左右新增，以及當遇到rowspan、colspan要如何計算等等，目前尚在開發中，所以還需要測試更多的表格組合，找出bug，預設值是左右新增遇到colspan的話，會將該欄位直接延伸，上下遇到rowspan一樣是延伸，以後會陸陸續續將設定參數加入plugin，讓使用者能更加活用。</p>
<p>使用方式：</p>
<p>載入 jQuery 及 watable</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;jquery.js&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;watable.js&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span></pre></div></div>

<p>html 格式</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">table</span> <span style="color: #000066;">border</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;0&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">tbody</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">tr</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">td</span> <span style="color: #000066;">rowspan</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;2&quot;</span>&gt;</span>1111<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">td</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">td</span>&gt;</span>1111<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">td</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">td</span>&gt;</span>1111<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">td</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">td</span>&gt;</span>1111<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">td</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">tr</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">tr</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">td</span>&gt;</span>1111<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">td</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">td</span>&gt;</span>1111<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">td</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">td</span>&gt;</span>1111<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">td</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">tr</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">tr</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">td</span> <span style="color: #000066;">colspan</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;2&quot;</span>&gt;</span>1111<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">td</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">td</span>&gt;</span>1111<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">td</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">td</span>&gt;</span>1111<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">td</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">tr</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">tbody</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">table</span>&gt;</span></pre></div></div>

<p>最後加入</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">$(function(){
	$('table').waTable();
});</pre></div></div>

<p>呈現效果：<br />
<img class="aligncenter size-full wp-image-989" src="http://blog.wabow.com/wp-content/uploads/2009/04/watable2.png" alt="watable2" width="417" height="229" /></p>
<p>關於這類的plugin，其實我不知道是不是已經有人寫出來了，如果有的話，就當作練習jQuery的plugin寫法，沒有的話，更應該好好將完成度提昇，像是原本表格中，有填寫的欄位，而且帶有id或是name，需要被送到後台程式做處理，那新增的欄位中，該如何將這些欄位加進去等等，未來陸續還有很多可增加的功能，按鈕外觀設計，以及bug修正，也希望這個小服務能有更多應用的地方？！</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.wabow.com/archives/990/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[jQuery Plugin] 檔案總管</title>
		<link>http://blog.wabow.com/archives/876</link>
		<comments>http://blog.wabow.com/archives/876#comments</comments>
		<pubDate>Thu, 16 Apr 2009 02:55:17 +0000</pubDate>
		<dc:creator>abu</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[技術分享]]></category>

		<guid isPermaLink="false">http://blog.wabow.com/?p=876</guid>
		<description><![CDATA[官網：官網 展示：DEMO 巴雞絲啼之 檔案總管移植網頁手術！ 記得有陣子一直在研究，如何寫出網頁版的檔案總管，在偶然間逛到這個plugin，試用之後發現很簡便，windows系統測試正常，雖然demo中只能展開資料夾，點擊檔案只會彈出該檔案路徑，我相信只要能結合其他的plugin，例如lightbox2等，更能讓這套plugin更多采多姿，很可惜的中文部份呈現亂碼，不過使用上仍然正常，可謂是殘而不廢，精神可嘉。 使用方式： 1.先下載官網最新版的jqueryFileTree以及jquery easing 2.壓縮檔內附jqueryFileTree.js、jqueryFileTree.css、images(資料夾)、connectors(資料夾) 3.請在connectors找出連結系統程式，在這邊使用的是jqueryFileTree.php，將該檔案copy出來，放在跟jqueryFileTree.js同路徑下 (路徑可自行變換，記得更改設置.fileTree裡面的script屬性) 4.將檔案放置於可執行php環境內，即完成基本安裝 以下是網頁設置 載入 jQuery 、 jqueryFileTree 等 &#60;script src=&#34;jquery.js&#34; type=&#34;text/javascript&#34;&#62;&#60;/script&#62; &#60;script src=&#34;jquery.easing.js&#34; type=&#34;text/javascript&#34;&#62;&#60;/script&#62; &#60;script src=&#34;jqueryFileTree.js&#34; type=&#34;text/javascript&#34;&#62;&#60;/script&#62; &#60;link href=&#34;jqueryFileTree.css&#34; rel=&#34;stylesheet&#34; type=&#34;text/css&#34; media=&#34;screen&#34; /&#62; html部份： 最後加入 $(function(){ $('#filetree').fileTree({ root: '/', script: 'jqueryFileTree.php' }, function(file) { alert(file); }); }) 成果： 我們可以看到，雖然左心室有部份剝離狀態，但是俗話說，好死不如歹活，將就點用也不錯，而且我相信在未來的日子裡，當技術越加成熟，手術會更加簡便，成功率也會隨機大幅提昇，今天手術就到此結束，謝謝大家 (鞠)]]></description>
			<content:encoded><![CDATA[<ul>
<li>官網：<a href="http://abeautifulsite.net/notebook.php?article=58">官網</a></li>
<li>展示：<a href="http://abeautifulsite.net/notebook_files/58/demo/">DEMO</a></li>
</ul>
<p>巴雞絲啼之 檔案總管移植網頁手術！</p>
<p><img class="aligncenter size-full wp-image-875" src="http://blog.wabow.com/wp-content/uploads/2009/04/filetree1.png" alt="filetree2" width="500" height="300" /></p>
<p><span id="more-876"></span></p>
<p>記得有陣子一直在研究，如何寫出網頁版的檔案總管，在偶然間逛到這個plugin，試用之後發現很簡便，windows系統測試正常，雖然demo中只能展開資料夾，點擊檔案只會彈出該檔案路徑，我相信只要能結合其他的plugin，例如lightbox2等，更能讓這套plugin更多采多姿，很可惜的中文部份呈現亂碼，不過使用上仍然正常，可謂是殘而不廢，精神可嘉。</p>
<p>使用方式：<br />
1.先下載官網最新版的<a href="http://abeautifulsite.net/notebook_files/58/jqueryFileTree.zip">jqueryFileTree</a>以及<a href="http://gsgd.co.uk/sandbox/jquery/easing/jquery.easing.1.3.js">jquery easing</a></p>
<p>2.壓縮檔內附jqueryFileTree.js、jqueryFileTree.css、images(資料夾)、connectors(資料夾)</p>
<p>3.請在connectors找出連結系統程式，在這邊使用的是jqueryFileTree.php，將該檔案copy出來，放在跟jqueryFileTree.js同路徑下<br />
(路徑可自行變換，記得更改設置.fileTree裡面的script屬性)</p>
<p>4.將檔案放置於可執行php環境內，即完成基本安裝</p>
<p>以下是網頁設置</p>
<p>載入 jQuery 、 jqueryFileTree 等</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script src<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;jquery.js&quot;</span> type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;&lt;/</span>script<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>script src<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;jquery.easing.js&quot;</span> type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;&lt;/</span>script<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>script src<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;jqueryFileTree.js&quot;</span> type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;&lt;/</span>script<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>link href<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;jqueryFileTree.css&quot;</span> rel<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;stylesheet&quot;</span> type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/css&quot;</span> media<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;screen&quot;</span> <span style="color: #339933;">/&gt;</span></pre></div></div>

<p>html部份：</p>
<p>最後加入</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">$(function(){
	$('#filetree').fileTree({ root: '/', script: 'jqueryFileTree.php' }, function(file) {
		alert(file);
	});
})</pre></div></div>

<p>成果：<br />
<img class="aligncenter size-full wp-image-875" src="http://blog.wabow.com/wp-content/uploads/2009/04/filetree2.png" alt="filetree2" width="500" height="500" /></p>
<p>我們可以看到，雖然左心室有部份剝離狀態，但是俗話說，好死不如歹活，將就點用也不錯，而且我相信在未來的日子裡，當技術越加成熟，手術會更加簡便，成功率也會隨機大幅提昇，今天手術就到此結束，謝謝大家 (鞠)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.wabow.com/archives/876/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery Plugins 星光大道</title>
		<link>http://blog.wabow.com/archives/640</link>
		<comments>http://blog.wabow.com/archives/640#comments</comments>
		<pubDate>Fri, 03 Apr 2009 02:48:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[工作雜談]]></category>

		<guid isPermaLink="false">http://blog.wabow.com/?p=640</guid>
		<description><![CDATA[本周 Jace 舉辦了  jQuery Plugins 星光大道 活動，每個人分享三個  jQuery Plugin ，經過展示及說明後由彼此互相評分。大家都玩的不亦樂乎，不但出現了六分的破表分數，也有被噓到沒分數的 Plugin 。 整個活動進行的過程讓大家更了解 jQuery 許多好玩有趣的 Plugins，同時也激發出更多的想像、創意及應用。即使活動結束後仍然討論的不亦樂乎，相信透過分享能讓大家在技術領域能有更深層、更不受限制的揮灑空間。]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.wabow.com/wp-content/uploads/2009/04/0402_152331-500x3751.jpg"><img src="http://blog.wabow.com/wp-content/uploads/2009/04/0402_152331-500x3751.jpg" alt="0402_152331-500x3751" title="0402_152331-500x3751" width="500" height="375" class="alignnone size-full wp-image-649" /></a></p>
<p>本周 Jace 舉辦了 <strong> jQuery Plugins 星光大道</strong> 活動，每個人分享三個  jQuery Plugin ，經過展示及說明後由彼此互相評分。大家都玩的不亦樂乎，不但出現了六分的破表分數，也有被噓到沒分數的 Plugin 。<span id="more-640"></span></p>
<p>整個活動進行的過程讓大家更了解 jQuery 許多好玩有趣的 Plugins，同時也激發出更多的想像、創意及應用。即使活動結束後仍然討論的不亦樂乎，相信透過分享能讓大家在技術領域能有更深層、更不受限制的揮灑空間。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.wabow.com/archives/640/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[jQuery Plugin] localScroll 特殊換頁效果</title>
		<link>http://blog.wabow.com/archives/605</link>
		<comments>http://blog.wabow.com/archives/605#comments</comments>
		<pubDate>Thu, 02 Apr 2009 03:34:26 +0000</pubDate>
		<dc:creator>abu</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[技術分享]]></category>

		<guid isPermaLink="false">http://blog.wabow.com/?p=605</guid>
		<description><![CDATA[作者：Ariel Flesler 官網：http://flesler.blogspot.com/ 展示：http://demos.flesler.com/jquery/localScroll/ 這是一款很特殊的變換內容plugin，當使用者按下連結，設定的內容會以scroll方式，變換到所選定內容，目前我想到的應用部份，像是lativ、luka有大好評分享、品牌日誌等，純文章分享的內容，若是用這樣的文章換頁效果，應該會讓使用者覺得蠻有趣的 使用方式： 載入 jQuery 及 localscroll &#60;script src=&#34;js/jquery.scrollTo-min.js&#34; type=&#34;text/javascript&#34;&#62;&#60;/script&#62; &#160; &#60;script src=&#34;js/jquery.localscroll-min.js&#34; type=&#34;text/javascript&#34;&#62;&#60;/script&#62; html 格式 &#60;!--選單部份--&#62; &#60;ul&#62; &#60;li class=&#34;sup&#34;&#62; &#60;a href=&#34;#section1&#34;&#62;饕客頭推&#60;/a&#62; &#60;ul&#62; &#60;li&#62;&#60;a href=&#34;#section1b&#34;&#62;雞排飯&#60;/a&#62;&#60;/li&#62; &#60;li&#62;&#60;a href=&#34;#section1c&#34;&#62;剝殼蝦&#60;/a&#62;&#60;/li&#62; &#60;/ul&#62; &#60;/li&#62; &#60;li class=&#34;sup&#34;&#62; &#60;a href=&#34;#section2&#34;&#62;季節景點&#60;/a&#62; &#60;ul&#62; &#60;li&#62;&#60;a href=&#34;#section2b&#34;&#62;水晶纜車&#60;/a&#62;&#60;/li&#62; &#60;li&#62;&#60;a href=&#34;#section2c&#34;&#62;台灣街&#60;/a&#62;&#60;/li&#62; &#60;/ul&#62; &#60;/li&#62; &#60;li class=&#34;sup&#34;&#62; &#60;a href=&#34;#section3&#34;&#62;體育重點&#60;/a&#62; &#60;ul&#62; &#60;li&#62;&#60;a href=&#34;#section3b&#34;&#62;棒球&#60;/a&#62;&#60;/li&#62; &#60;li&#62;&#60;a href=&#34;#section3c&#34;&#62;高爾夫球&#60;/a&#62;&#60;/li&#62; &#60;/ul&#62; &#60;/li&#62; &#60;/ul&#62; [...]]]></description>
			<content:encoded><![CDATA[<ul>
<li>作者：Ariel Flesler</li>
<li>官網：<a href="http://flesler.blogspot.com/">http://flesler.blogspot.com/</a></li>
<li>展示：<a href="http://demos.flesler.com/jquery/localScroll/">http://demos.flesler.com/jquery/localScroll/</a></li>
</ul>
<p><img class="aligncenter size-large wp-image-603" src="http://blog.wabow.com/wp-content/uploads/2009/04/localscroll_sample1-500x327.png" alt="localscroll_sample1" width="500" height="327" /></p>
<p><span id="more-605"></span>這是一款很特殊的變換內容plugin，當使用者按下連結，設定的內容會以scroll方式，變換到所選定內容，目前我想到的應用部份，像是lativ、luka有大好評分享、品牌日誌等，純文章分享的內容，若是用這樣的文章換頁效果，應該會讓使用者覺得蠻有趣的</p>
<p>使用方式：</p>
<p>載入 jQuery 及 localscroll</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script src<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;js/jquery.scrollTo-min.js&quot;</span> type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;&lt;/</span>script<span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #339933;">&lt;</span>script src<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;js/jquery.localscroll-min.js&quot;</span> type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>

<p>html 格式</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">&lt;!--選單部份--&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">ul</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;sup&quot;</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#section1&quot;</span>&gt;</span>饕客頭推<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">ul</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#section1b&quot;</span>&gt;</span>雞排飯<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#section1c&quot;</span>&gt;</span>剝殼蝦<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">ul</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;sup&quot;</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#section2&quot;</span>&gt;</span>季節景點<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">ul</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#section2b&quot;</span>&gt;</span>水晶纜車<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#section2c&quot;</span>&gt;</span>台灣街<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">ul</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;sup&quot;</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#section3&quot;</span>&gt;</span>體育重點<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">ul</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#section3b&quot;</span>&gt;</span>棒球<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#section3c&quot;</span>&gt;</span>高爾夫球<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">ul</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">ul</span>&gt;</span>
<span style="color: #808080; font-style: italic;">&lt;!--文章內容--&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;section&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">ul</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;sub&quot;</span>&gt;</span>(圖文內容)<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">ul</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
．
	．
	．
	(自行增加)
	．
	．<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></pre></div></div>

<p>最後加入</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">$(function(){
	$.localScroll.defaults.axis = 'xy';
	$.localScroll.hash({
		target: '#content', // Could be a selector or a jQuery object too.
		queue:true,
		duration:1500
	});
&nbsp;
	$.localScroll({
		target: '#content', // could be a selector or a jQuery object too.
		queue:true,
		duration:1000,
		hash:true,
		onBefore:function( e, anchor, $target ){
			// The 'this' is the settings object, can be modified
		},
		onAfter:function( anchor, settings ){
			// The 'this' contains the scrolled element (#content)
		}
	});
});</pre></div></div>

<p>呈現效果：<br />
<img class="aligncenter size-large wp-image-604" src="http://blog.wabow.com/wp-content/uploads/2009/04/localscroll_sample2-500x277.png" alt="localscroll_sample2" width="500" height="277" /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.wabow.com/archives/605/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>[jQuery Plugin] dataTables快速完成資料列表</title>
		<link>http://blog.wabow.com/archives/581</link>
		<comments>http://blog.wabow.com/archives/581#comments</comments>
		<pubDate>Thu, 02 Apr 2009 03:16:39 +0000</pubDate>
		<dc:creator>abu</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[技術分享]]></category>

		<guid isPermaLink="false">http://blog.wabow.com/?p=581</guid>
		<description><![CDATA[作者：Allan Jardine 官網：http://sprymedia.co.uk/article/DataTables 展示：http://sprymedia.co.uk/article/DataTables 客戶常會要求在後台要顯示某些數據資料，例如一個月內退貨率高達N%的商品列表，或是指定區間內哪些商品超熱賣，而每當遇到這些"商品列表，就要套用樣板，將欄位、數值設定好，而這款dataTables，正能滿足快速製造小列表，此列表產出出來的同時就擁有了分頁、搜尋、排序的功能，相當方便，算是麻雀雖小，五臟俱全 使用方式： 載入 jQuery 及 dataTables &#60;script src=&#34;js/jquery.js&#34; type=&#34;text/javascript&#34;&#62;&#60;/script&#62; &#160; &#60;script src=&#34;js/dataTables.js&#34; type=&#34;text/javascript&#34;&#62;&#60;/script&#62; html 格式 &#60;table id=&#34;example&#34; class=&#34;display&#34; border=&#34;0&#34; cellspacing=&#34;0&#34; cellpadding=&#34;0&#34;&#62; &#60;thead&#62; &#60;tr&#62; &#60;th&#62;商品編號&#60;/th&#62; &#60;th&#62;商品名稱&#60;/th&#62; &#60;th&#62;分類&#60;/th&#62; &#60;th&#62;顏色&#60;/th&#62; &#60;th&#62;售價&#60;/th&#62; &#60;/tr&#62; &#60;/thead&#62; &#60;tbody&#62; &#60;tr&#62; &#60;td&#62;ZA00102&#60;/td&#62; &#60;td&#62;創意筆捲行李牌-藍色&#60;/td&#62; &#60;td&#62;旅行小物&#60;/td&#62; &#60;td&#62;blue&#60;/td&#62; &#60;td class=&#34;center&#34;&#62;280&#60;/td&#62; &#60;/tr&#62; &#60;tr&#62; &#60;td&#62;ZA00103&#60;/td&#62; &#60;td&#62;創意筆捲行李牌-黃色&#60;/td&#62; &#60;td&#62;旅行小物&#60;/td&#62; &#60;td class=&#34;center&#34;&#62;yellow&#60;/td&#62; &#60;td class=&#34;center&#34;&#62;280&#60;/td&#62; &#60;/tr&#62; ． ． ． [...]]]></description>
			<content:encoded><![CDATA[<ul>
<li>作者：Allan Jardine</li>
<li>官網：<a href="http://sprymedia.co.uk/article/DataTables">http://sprymedia.co.uk/article/DataTables</a></li>
<li>展示：<a href="http://sprymedia.co.uk/article/DataTables">http://sprymedia.co.uk/article/DataTables</a></li>
</ul>
<p><img class="aligncenter size-full wp-image-587" src="http://blog.wabow.com/wp-content/uploads/2009/04/datatable_sample1.png" alt="datatable_sample1" width="668" height="380" /></p>
<p><span id="more-581"></span>客戶常會要求在後台要顯示某些數據資料，例如一個月內退貨率高達N%的商品列表，或是指定區間內哪些商品超熱賣，而每當遇到這些"商品列表，就要套用樣板，將欄位、數值設定好，而這款dataTables，正能滿足快速製造小列表，此列表產出出來的同時就擁有了分頁、搜尋、排序的功能，相當方便，算是麻雀雖小，五臟俱全</p>
<p>使用方式：</p>
<p>載入 jQuery 及 dataTables</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script src<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;js/jquery.js&quot;</span> type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;&lt;/</span>script<span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #339933;">&lt;</span>script src<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;js/dataTables.js&quot;</span> type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>

<p>html 格式</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">table</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;example&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;display&quot;</span> <span style="color: #000066;">border</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000066;">cellspacing</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000066;">cellpadding</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;0&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">thead</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">tr</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">th</span>&gt;</span>商品編號<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">th</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">th</span>&gt;</span>商品名稱<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">th</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">th</span>&gt;</span>分類<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">th</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">th</span>&gt;</span>顏色<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">th</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">th</span>&gt;</span>售價<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">th</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">tr</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">thead</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">tbody</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">tr</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">td</span>&gt;</span>ZA00102<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">td</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">td</span>&gt;</span>創意筆捲行李牌-藍色<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">td</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">td</span>&gt;</span>旅行小物<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">td</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">td</span>&gt;</span>blue<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">td</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">td</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;center&quot;</span>&gt;</span>280<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">td</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">tr</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">tr</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">td</span>&gt;</span>ZA00103<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">td</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">td</span>&gt;</span>創意筆捲行李牌-黃色<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">td</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">td</span>&gt;</span>旅行小物<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">td</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">td</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;center&quot;</span>&gt;</span>yellow<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">td</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">td</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;center&quot;</span>&gt;</span>280<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">td</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">tr</span>&gt;</span>
．
		．
		．
		(可無限增加商品)
		．
		．
		．<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">tbody</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">table</span>&gt;</span></pre></div></div>

<p>最後加入</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">$(document).ready(function() {
	$('#example').dataTable( {
		&quot;fnRowCallback&quot;: function( nRow, aData, iDisplayIndex ) {
			nRow.className = nRow.className + aData[4];
			return nRow;
		},
		&quot;aoData&quot;: [
			null,
			null,
			{ &quot;bVisible&quot;: false, &quot;bSearchable&quot;: false },
			{ &quot;sClass&quot;: &quot;center&quot; },
			{ &quot;sClass&quot;: &quot;center&quot; }
		]
	} );
} );</pre></div></div>

<p>呈現效果：<br />
<img class="aligncenter size-full wp-image-590" src="http://blog.wabow.com/wp-content/uploads/2009/04/datatable_sample2.png" alt="datatable_sample2" width="517" height="390" /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.wabow.com/archives/581/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>[jQuery Plugin] 文字欄與下拉選單的 COMBO組合 - FlexBox</title>
		<link>http://blog.wabow.com/archives/537</link>
		<comments>http://blog.wabow.com/archives/537#comments</comments>
		<pubDate>Thu, 02 Apr 2009 03:07:51 +0000</pubDate>
		<dc:creator>suzy</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[技術分享]]></category>

		<guid isPermaLink="false">http://blog.wabow.com/?p=537</guid>
		<description><![CDATA[作者：Gareth Watts 官網：http://www.fairwaytech.com/flexbox/Default.aspx 展示：http://www.fairwaytech.com/flexbox/Demos.aspx 簡單來說 FlexBox 就是：文字欄位(textfield) 加 下拉選單(dropdown) 的組合。 有時候我們需要“下拉選單”列出所有的選項，但也同時需要 "文字欄位" 保持隨時能新增選項的靈活度。 其實 Autocomplete 已經可以做到大部份的功能。 不過 FlexBox 比較特別之處是它可以在下拉選單設定動態的頁數(可彈性處理大量的搜尋結果) 另一個好處是 它會模擬 &#60;select&#62; tag 以 JSON 方式傳回 option value 的值！ 這個用法剛好可以套用在專案 Fevo Map 的後台：產品頁面 - 輸入品牌的地方。 因為我們希望資料庫的 品牌欄位 是存 品牌id，但另一方面也希望使用者在同一頁就可以新增品牌。 這是原本的做法 有了 FlexBox 就可以把兩個欄位組合起來了 Y(≧▽≦)Y 使用方法 載入 CSS + jQuery 及 相關程式 &#60;script type="text/javascript" src="js/jquery.js" /&#62; [...]]]></description>
			<content:encoded><![CDATA[<ul>
<li>作者：Gareth Watts</li>
<li>官網：<a href="http://www.fairwaytech.com/flexbox/Default.aspx">http://www.fairwaytech.com/flexbox/Default.aspx</a></li>
<li>展示：<a href="http://www.fairwaytech.com/flexbox/Demos.aspx">http://www.fairwaytech.com/flexbox/Demos.aspx</a></li>
</ul>
<p><img src="http://blog.wabow.com/wp-content/uploads/2009/04/flexbox21.jpg" alt="flexbox21" width="425" height="275" class="alignnone size-full wp-image-565" /></p>
<p>
簡單來說 FlexBox 就是：文字欄位(textfield) 加 下拉選單(dropdown) 的組合。
</p>
<p>
有時候我們需要“下拉選單”列出所有的選項，但也同時需要 "文字欄位" 保持隨時能新增選項的靈活度。
</p>
<p>
其實 Autocomplete 已經可以做到大部份的功能。
</p>
<p>
不過 FlexBox 比較特別之處是它可以在下拉選單設定動態的頁數(可彈性處理大量的搜尋結果)<br />
另一個好處是 它會模擬 &lt;select&gt; tag 以 JSON 方式傳回 option value 的值！
</p>
<p><span id="more-537"></span></p>
<p>
這個用法剛好可以套用在專案 Fevo Map 的後台：產品頁面 - 輸入品牌的地方。<br />
因為我們希望資料庫的 品牌欄位 是存 品牌id，但另一方面也希望使用者在同一頁就可以新增品牌。
</p>
<p>這是原本的做法</p>
<p><img src="http://blog.wabow.com/wp-content/uploads/2009/04/flexbox.jpg" alt="flexbox" width="658" height="59" class="alignnone size-full wp-image-546" /></p>
<p>有了 FlexBox 就可以把兩個欄位組合起來了 Y(≧▽≦)Y</p>
<p>使用方法</p>
<p>載入 CSS + jQuery 及 相關程式</p>
<div class="wp_syntax">
<div class="code">
<pre style="font-family: monospace;">
&lt;script type="text/javascript" src="js/jquery.js" /&gt;
&lt;script type="text/javascript" src="js/flexbox.js" /&gt;
&lt;link type="text/css" rel="stylesheet" href="css/flexbox.css" /&gt;
</pre>
</div>
</div>
<p>再來是 html 格式</p>
<div class="wp_syntax">
<div class="code">
<pre style="font-family: monospace;">
&lt;div id="fb"&gt;&lt;/div&gt;
</pre>
</div>
</div>
<p>最後</p>
<div class="wp_syntax">
<div class="code">
<pre style="font-family: monospace;">
$(document).ready(function() {
        $('#fb').flexbox('results.php');
 });
</pre>
</div>
</div>
<p>results.php 以 JSON 格式輸出</p>
<div class="wp_syntax">
<div class="code">
<pre style="font-family: monospace;">
 {"results":[
 {"id":1,"name":"Louis Vuitton "},
 {"id":2,"name":"Burberry"} ,
 {"id":3,"name":"拉拉"}
 ]}
</pre>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.wabow.com/archives/537/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[jQuery Plugin] Step Carousel Viewer 輕鬆完成跑馬燈</title>
		<link>http://blog.wabow.com/archives/505</link>
		<comments>http://blog.wabow.com/archives/505#comments</comments>
		<pubDate>Thu, 02 Apr 2009 02:56:52 +0000</pubDate>
		<dc:creator>abu</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[技術分享]]></category>

		<guid isPermaLink="false">http://blog.wabow.com/?p=505</guid>
		<description><![CDATA[官網：http://www.dynamicdrive.com/dynamicindex4/stepcarousel.htm 展示：http://www.dynamicdrive.com/dynamicindex4/stepcarousel.htm 現在很多網站，首頁常喜歡加上跑馬燈，在小小的空間內，卻可以顯示無數的圖片或是文字，不論是他家廠牌廣告、自家商品展示也由於動感的表現，比起死板板的文字，更能引起使用者的目光，目前訪間有很多種的跑馬燈plugin挑了一款還不錯方便，可設定自動開始瀏覽，或是加上按鈕，由使用者手動click變換 (下載回來後，在setting上加過自設action，讓按鈕變成mouseover動作，感覺上有些怪怪的，例：圖一次跑兩張＠＠，所以還是用原設定click吧) 使用方式： 載入 jQuery 及 stepCarousel &#60;script src=&#34;js/jquery.js&#34; type=&#34;text/javascript&#34;&#62;&#60;/script&#62; &#160; &#60;script src=&#34;js/stepcarousel.js&#34; type=&#34;text/javascript&#34;&#62;&#60;/script&#62;  html 格式 &#60;div class=&#34;stepcarousel&#34;&#62; &#60;div class=&#34;belt&#34;&#62; &#60;div class=&#34;panel&#34;&#62;&#60;img src=&#34;1.jpg&#34; alt=&#34;&#34; /&#62;&#60;/div&#62; &#60;div class=&#34;panel&#34;&#62;&#60;img src=&#34;2.jpg&#34; alt=&#34;&#34; /&#62;&#60;/div&#62; &#60;div class=&#34;panel&#34;&#62;&#60;img src=&#34;3.jpg&#34; alt=&#34;&#34; /&#62;&#60;/div&#62; &#60;div class=&#34;panel&#34;&#62;&#60;img src=&#34;4.jpg&#34; alt=&#34;&#34; /&#62;&#60;/div&#62; &#60;div class=&#34;panel&#34;&#62;&#60;img src=&#34;5.jpg&#34; alt=&#34;&#34; /&#62;&#60;/div&#62; &#60;/div&#62; &#60;/div&#62; 最後加入 $(function(){ stepcarousel.setup({ galleryid: 'mygallery', beltclass: 'belt', [...]]]></description>
			<content:encoded><![CDATA[<ul>
<li>官網：<a href="http://www.dynamicdrive.com/dynamicindex4/stepcarousel.htm">http://www.dynamicdrive.com/dynamicindex4/stepcarousel.htm</a></li>
<li>展示：<a href="http://www.dynamicdrive.com/dynamicindex4/stepcarousel.htm">http://www.dynamicdrive.com/dynamicindex4/stepcarousel.htm</a></li>
</ul>
<p><img class="aligncenter size-medium wp-image-519" src="http://blog.wabow.com/wp-content/uploads/2009/04/carousel-300x120.png" alt="carousel_sample" width="300" height="120" /></p>
<p><span id="more-505"></span>現在很多網站，首頁常喜歡加上跑馬燈，在小小的空間內，卻可以顯示無數的圖片或是文字，不論是他家廠牌廣告、自家商品展示也由於動感的表現，比起死板板的文字，更能引起使用者的目光，目前訪間有很多種的跑馬燈plugin挑了一款還不錯方便，可設定自動開始瀏覽，或是加上按鈕，由使用者手動click變換 (下載回來後，在setting上加過自設action，讓按鈕變成mouseover動作，感覺上有些怪怪的，例：圖一次跑兩張＠＠，所以還是用原設定click吧)</p>
<p>使用方式：</p>
<p>載入 jQuery 及 stepCarousel</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script src<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;js/jquery.js&quot;</span> type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;&lt;/</span>script<span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #339933;">&lt;</span>script src<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;js/stepcarousel.js&quot;</span> type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>

<p> html 格式</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;stepcarousel&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;belt&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;panel&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">img</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;1.jpg&quot;</span> <span style="color: #000066;">alt</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;panel&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">img</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;2.jpg&quot;</span> <span style="color: #000066;">alt</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;panel&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">img</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;3.jpg&quot;</span> <span style="color: #000066;">alt</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;panel&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">img</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;4.jpg&quot;</span> <span style="color: #000066;">alt</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;panel&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">img</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;5.jpg&quot;</span> <span style="color: #000066;">alt</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></pre></div></div>

<p>最後加入</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">$(function(){
	stepcarousel.setup({
		galleryid: 'mygallery',
		beltclass: 'belt', s
		panelclass: 'panel',
		autostep: {enable:true, moveby:1, pause:3000},
		panelbehavior: {speed:500, wraparound:false, persist:true},
		defaultbuttons: {enable: false, action: 'click', moveby: 1, leftnav: ['leftnav.gif', -5, 80], rightnav: ['rightnav.gif', -20, 80]},
		statusvars: ['statusA', 'statusB', 'statusC'],
		contenttype: ['inline']
	})
})</pre></div></div>

<p>呈現效果：(下面圖會自動一直輪撥)<br />
<img class="aligncenter size-large wp-image-548" src="http://blog.wabow.com/wp-content/uploads/2009/04/carousel_21-500x200.png" alt="carousel_21" width="500" height="200" /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.wabow.com/archives/505/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[jQuery Plugin] 按照字母順序排列的索引選單 - ListNav</title>
		<link>http://blog.wabow.com/archives/482</link>
		<comments>http://blog.wabow.com/archives/482#comments</comments>
		<pubDate>Thu, 02 Apr 2009 01:17:29 +0000</pubDate>
		<dc:creator>suzy</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[技術分享]]></category>

		<guid isPermaLink="false">http://blog.wabow.com/?p=482</guid>
		<description><![CDATA[作者：iHwy, Inc. 官網：http://www.ihwy.com/Labs/jquery-listnav-plugin.aspx 展示：http://www.ihwy.com/Labs/Demos/Current/jquery-listnav-plugin.aspx ListNav 是一個抓出所有列表項目重新排序(註1)，再按照數字 0-9、字母 A-Z 排列的 jQuery Plugin。中文網站或許比較沒有用字母排列的需求，但是英文網站十分常用，像 FAQ 或是一些專業術語的頁面都是使用字母排列供使用者尋找的（PHP 寫法的 Glossary）。 雖然我們中文沒有那麼常用到，但是我想還是有機會的，一些外來品牌的產品系列名稱、序號都有可能會以列表的方式呈現。對於大量的資料（圖書館系統、字典系統），我認為 ListNav 也會滿有用的；再者它外觀也很乾淨清爽，所以決定選擇它介紹給大家。 特色 unobtrusive XD (這個字真的很常見到) 對於大量的資料有信心（已調校過 performance) 可用 cookie 儲存特定字母，不會永遠都是“A” 可用 css 自訂風格 滑鼠 hover 字母上頭會顯示項目的數量 ul ol 都適用 來看看 demo 可能更一目瞭然 使用方法： 載入 CSS + jQuery 及 相關程式 &#60;!-- 這是原版css可再自行修改 --&#62; &#60;link rel="stylesheet" href="css/listnav.css" type="text/css" media="screen" /&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>
<img src="http://blog.wabow.com/wp-content/uploads/2009/04/e59c96e78987-7.png" alt="e59c96e78987-7" width="579" height="142" class="alignnone size-full wp-image-490" /></p>
<ul>
<li>作者：iHwy, Inc.</li>
<li>官網：<a href="http://www.ihwy.com/Labs/jquery-listnav-plugin.aspx">http://www.ihwy.com/Labs/jquery-listnav-plugin.aspx</a></li>
<li>展示：<a href="http://www.ihwy.com/Labs/Demos/Current/jquery-listnav-plugin.aspx">http://www.ihwy.com/Labs/Demos/Current/jquery-listnav-plugin.aspx</a></li>
</ul>
<p>
ListNav 是一個抓出所有列表項目重新排序(註1)，再按照數字 0-9、字母 A-Z 排列的 jQuery Plugin。中文網站或許比較沒有用字母排列的需求，但是英文網站十分常用，像 FAQ 或是一些專業術語的頁面都是使用字母排列供使用者尋找的（<a href="http://www.apra.co.nz/html/glossary.php">PHP 寫法的 Glossary</a>）。<br />
雖然我們中文沒有那麼常用到，但是我想還是有機會的，一些外來品牌的產品系列名稱、序號都有可能會以列表的方式呈現。對於大量的資料（圖書館系統、字典系統），我認為 ListNav 也會滿有用的；再者它外觀也很乾淨清爽，所以決定選擇它介紹給大家。
</p>
<p><span id="more-482"></span></p>
<p>特色</p>
<ol>
<li>unobtrusive XD (這個字真的很常見到)</li>
<li>對於大量的資料有信心（已調校過 performance)</li>
<li>可用 cookie 儲存特定字母，不會永遠都是“A”</li>
<li>可用 css 自訂風格</li>
<li>滑鼠 hover 字母上頭會顯示項目的數量</li>
<li>ul ol 都適用</li>
</ol>
<p>來看看 <a href="http://www.ihwy.com/Labs/Demos/Current/jquery-listnav-plugin.aspx">demo</a> 可能更一目瞭然 <img src='http://blog.wabow.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> 
</p>
<p>使用方法：</p>
<p>載入 CSS + jQuery 及 相關程式</p>
<div class="wp_syntax">
<div class="code">
<pre style="font-family: monospace;">
&lt;!-- 這是原版css可再自行修改 --&gt;
&lt;link rel="stylesheet" href="css/listnav.css" type="text/css" media="screen" /&gt;

&lt;script src="js/jquery.js" type="text/javascript"&gt;&lt;/script&gt;
&lt;script src="js/jquery.cookie.js" type="text/javascript"&gt;&lt;/script&gt;&lt;!-- Optional --&gt;
&lt;script src="js/listnav.js" type="text/javascript"&gt;&lt;/script&gt;
</pre>
</div>
</div>
<p>再來是 html 格式，這邊要注意的是命名方式，如 id 取名叫 demo，那麼它的選單必須叫 demo-nav。</p>
<div class="wp_syntax">
<div class="code">
<pre style="font-family: monospace;">
&lt;div id="demo-nav"&gt;&lt;/div&gt;

&lt;ul id="demo"&gt;
&lt;li&gt;&lt;a href="#"&gt;AMCOS&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#"&gt;APRA&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#"&gt;Author&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#"&gt;Assignment&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#"&gt;Copyright&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#"&gt;Dubbing&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#"&gt;Publisher&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#"&gt;PPNZ&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#"&gt;Production Music Libraries&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</pre>
</div>
</div>
<div class="wp_syntax">
<div class="code">
<pre style="font-family: monospace;">
$(document).ready(function() {
	 $('#demo').listnav();
}
</pre>
</div>
</div>
<p>註1：目前不太確定的是從它的 demo 看不出每一個 LI 可以塞多少東西，因為都只有短短的字+連結。還有若我亂數排不知道它會不會自動按照順序？之後會再補上這兩項測試結果。:)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.wabow.com/archives/482/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
