<?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>JavaScript Infected</title>
	<atom:link href="http://www.julianwong.net/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.julianwong.net/blog</link>
	<description>Do everything with javascript</description>
	<lastBuildDate>Sat, 15 May 2010 05:22:31 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>When my mind is made up?</title>
		<link>http://www.julianwong.net/blog/2010/05/when-my-mind-is-made-up/</link>
		<comments>http://www.julianwong.net/blog/2010/05/when-my-mind-is-made-up/#comments</comments>
		<pubDate>Sat, 15 May 2010 05:22:14 +0000</pubDate>
		<dc:creator>julian</dc:creator>
				<category><![CDATA[雜碎]]></category>

		<guid isPermaLink="false">http://www.julianwong.net/blog/?p=260</guid>
		<description><![CDATA[Just saw the video from hulu which is same as http://www.theartistsden.com/episodes/swellseason.shtml
When your mind is made up,
When your mind is made up,
There&#8217;s no point try to change it,
There&#8217;s no point try to stop it,
There&#8217;s no point try to talking,
There&#8217;s no point try to fight it.
So what have I made up~?
Have been working quite hard for the [...]]]></description>
			<content:encoded><![CDATA[<p>Just saw the video from hulu which is same as http://www.theartistsden.com/episodes/swellseason.shtml</p>
<p>When your mind is made up,<br />
When your mind is made up,<br />
There&#8217;s no point try to change it,<br />
There&#8217;s no point try to stop it,<br />
There&#8217;s no point try to talking,<br />
There&#8217;s no point try to fight it.</p>
<p>So what have I made up~?</p>
<p>Have been working quite hard for the past month, and when it is free in this weekend, I am losing myself. So, what have I made up? what I am up to?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.julianwong.net/blog/2010/05/when-my-mind-is-made-up/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My damn last minute habit</title>
		<link>http://www.julianwong.net/blog/2010/03/my-damn-last-minute-habit/</link>
		<comments>http://www.julianwong.net/blog/2010/03/my-damn-last-minute-habit/#comments</comments>
		<pubDate>Tue, 23 Mar 2010 15:37:11 +0000</pubDate>
		<dc:creator>julian</dc:creator>
				<category><![CDATA[雜碎]]></category>

		<guid isPermaLink="false">http://www.julianwong.net/blog/?p=253</guid>
		<description><![CDATA[星期日就要飛. 行理未拾, 房未拾, 野未買曬, data 未backup. 我應該都係會pk ga la&#8230;&#8230;
May the god of last minute be with me!
]]></description>
			<content:encoded><![CDATA[<p>星期日就要飛. 行理未拾, 房未拾, 野未買曬, data 未backup. 我應該都係會pk ga la&#8230;&#8230;</p>
<p>May the god of last minute be with me!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.julianwong.net/blog/2010/03/my-damn-last-minute-habit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>It&#8217;s been a long time&#8230;</title>
		<link>http://www.julianwong.net/blog/2010/03/its-been-a-long-time/</link>
		<comments>http://www.julianwong.net/blog/2010/03/its-been-a-long-time/#comments</comments>
		<pubDate>Sun, 21 Mar 2010 17:48:08 +0000</pubDate>
		<dc:creator>julian</dc:creator>
				<category><![CDATA[雜碎]]></category>

		<guid isPermaLink="false">http://www.julianwong.net/blog/?p=250</guid>
		<description><![CDATA[好像已經有兩年多沒寫下什麼. 之前blogger 的blog 都已經荒廢了. 今天又想從新再寫自己的事. 2009 年, 行屍走肉的一年. 工作上沒方向, 沒前進, 沒後退. 僵著腿站著, 一動不動. 生活更是不知所謂, 總是找一些東西讓自己沈溺, 什麼都不去想, 讓烏雲把自己遮蓋, 消失於世上&#8230;為什麼!? 我也不能明白&#8230;.
現在座下來, 重新再思考自己的事, 感覺很不一樣. 久違了的msn&#8230;.我再次看到frd list 上的朋友和他們的status, 找人聊天再次讓自己跟別人連繫上. 希望能把烏雲抺去一點. 希望再給自己一點動力, 重新上路.
還有一個星期就要到美國, 感覺有點像按reset button. 29 歲去一個完全陌生的地方, 帶住135磅肥肉同二三十公斤行李, 沒有其他&#8230; 現在還不算胖, 來一個up side down 的轉變, 應該可以吧.
]]></description>
			<content:encoded><![CDATA[<p>好像已經有兩年多沒寫下什麼. 之前blogger 的blog 都已經荒廢了. 今天又想從新再寫自己的事. 2009 年, 行屍走肉的一年. 工作上沒方向, 沒前進, 沒後退. 僵著腿站著, 一動不動. 生活更是不知所謂, 總是找一些東西讓自己沈溺, 什麼都不去想, 讓烏雲把自己遮蓋, 消失於世上&#8230;為什麼!? 我也不能明白&#8230;.</p>
<p>現在座下來, 重新再思考自己的事, 感覺很不一樣. 久違了的msn&#8230;.我再次看到frd list 上的朋友和他們的status, 找人聊天再次讓自己跟別人連繫上. 希望能把烏雲抺去一點. 希望再給自己一點動力, 重新上路.</p>
<p>還有一個星期就要到美國, 感覺有點像按reset button. 29 歲去一個完全陌生的地方, 帶住135磅肥肉同二三十公斤行李, 沒有其他&#8230; 現在還不算胖, 來一個up side down 的轉變, 應該可以吧.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.julianwong.net/blog/2010/03/its-been-a-long-time/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Dumping Firefox XUL object</title>
		<link>http://www.julianwong.net/blog/2009/11/dumping-firefox-xul-object/</link>
		<comments>http://www.julianwong.net/blog/2009/11/dumping-firefox-xul-object/#comments</comments>
		<pubDate>Tue, 24 Nov 2009 07:22:01 +0000</pubDate>
		<dc:creator>julian</dc:creator>
				<category><![CDATA[Firefox Addon]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://www.julianwong.net/blog/?p=222</guid>
		<description><![CDATA[I am not sure is it correct to call it XUL object, what I mean to do is transversing javascript object. It sounds silly as we got firebug but it makes sense when working on firefox addon where the script debugger in firebug doesn&#8217;t work for javascript running in chrome.
There is a XUL reference in [...]]]></description>
			<content:encoded><![CDATA[<p>I am not sure is it correct to call it XUL object, what I mean to do is transversing javascript object. It sounds silly as we got firebug but it makes sense when working on firefox addon where the script debugger in firebug doesn&#8217;t work for javascript running in chrome.</p>
<p>There is a XUL reference in MDC(<a href="https://developer.mozilla.org/en/XUL_Reference">https://developer.mozilla.org/en/XUL_Reference</a>). It listing out objects and its associated attributes, properties, and methods, but seems not all the reference are update and complete. Sometimes I don&#8217;t even know what kind of xul object I am dealing with, I need to have something like var_dump or print_r in PHP. And I have written my own object dumping function.<br />
<span id="more-222"></span><br />
My dump function:</p>
<pre style="height:500px;overflow:auto;">
myUtil = {
dump:function(o,depth,name,filter,filterMode) {
    var doc = gBrowser.contentDocument,
        el = doc.getElementById("fduDump"),
        str = "" || name + "\n",
        depthLimit = depth || 1,
        filterDefaultMode = filterMode || 1;
    // filterMode is either 1 or -1.
    // 1 =&gt; Like the iptable Allow all, it dig into all object exclude object name in the filter object
    // -1 =&gt; Like the iptable Deny all, it will not dig into any object unless object name is inside the filter

    if ( !el ) {
        el = doc.createElement("pre");
        el.id = "fduDump";
        doc.body.appendChild(el);
    }

    var transverse = function(o,thisLv,name,filter) {
        var indent = "", i, tmp, filterMode, dig, f;
        if ( filter &amp;&amp; filter.__mode ) {
            filterMode = filter.__mode;
        } else {
            filterMode = filterDefaultMode;
        }
        for ( i = 0 ; i &lt; thisLv ; i++ ) {
            indent += "    ";
        }

        if ( name ) {
            str += "\n" + indent + "=== lv "+thisLv+", Start "+name+" ===\n";
        }

        if ( o &amp;&amp; thisLv &lt; depthLimit ) {
            for ( k in o ) {
                try{
                    tmp = o[k] + "";
                    tmp = tmp.split("\n");
                    tmp = tmp.join("\n"+indent);
                    str += indent + k + " : " + tmp + "\n";
                    if (typeof(o[k]) === "object" &amp;&amp; o[k] &amp;&amp; thisLv + 1 &lt; depthLimit ) {
                        if ( filter &amp;&amp; typeof filter[k] !== "undefined") {
                            dig = (filterMode === -1);
                        } else {
                            dig = (filterMode === 1);
                        }
                        if ( dig ) {
                            if ( filter &amp;&amp; filter[k] ) {
                                f = filter;
                            } else {
                                f = null;
                            }
                            transverse(o[k], thisLv + 1, k, f);
                        }
                    }
                } catch (e) {
                }
            }
        }

        if ( name ) {
            str += indent + "=== lv "+thisLv+", End "+name+" ===\n\n";
        }
    }
    transverse(o,0,"",filter);
    el.innerHTML = str;
}
}</pre>
<p>Calling the dump function:</p>
<pre>
// e.g. here I amd dumping the event object form a "TabSelect" event
// 1st param is object to be dumped
// 2nd param is the depth (optional, default = 1)
// 3rd is just a string to be shown in the first line of the dump (optional default = "")
// 4th is filter (optional)
// 5th is default filter mode (optional default = 1, dump all properties exclude specified in filter object)
myUtil.dump(evt,2,"tabEvent",{"__mode":-1,"target":null});

// if you just want to dump an object itself, you can simply: myUtil.dump(evt);
</pre>
<p>Sample output of the dump</p>
<pre>tabEvent
originalTarget : [object XULElement]
preventCapture : function preventCapture() {
    [native code]
}
target : [object XULElement]

    === lv 1, Start target ===
    _tPos : 0
    linkedBrowser : [object XULElement]
    ...
    selected : true
    _selected : undefined
    linkedPanel : panel1259045062233
    ...
    tagName : xul:tab
    ...
    nodeName : xul:tab
    ...
    className : tabbrowser-tab
    ...
    === lv 1, End target ===

cancelable : false
currentTarget : [object XULElement]
timeStamp : 1172581376
bubbles : true
type : TabSelect
eventPhase : 3
preventDefault : function preventDefault() {
    [native code]
}
initEvent : function initEvent() {
    [native code]
}
stopPropagation : function stopPropagation() {
    [native code]
}
CAPTURING_PHASE : 1
AT_TARGET : 2
BUBBLING_PHASE : 3
explicitOriginalTarget : [object XULElement]
preventBubble : function preventBubble() {
    [native code]
}
...
</pre>
<p>By dumping the event object and the target in the event object, there are something useful can be found. In the TabSelect Event, there is target, originalTarget, currentTarget, explicitOriginalTarget!?<br />
And in the target object, it has a tagName and nodeName equals to &#8220;xul:tab&#8221;, so now I can be sure it is a &#8220;tab&#8221; object instead of tabPanel, tabbox, or tabbrowser&#8230;.Also it has a linkedBrowser object which is the browser object contained in the tab. This is not documented in the xul reference&#8230;maybe they don&#8217;t want us to use it? Have fun dumping.</p>
<p>Other resources on message logging and debugging in writing Firefox addon:</p>
<p>https://developer.mozilla.org/en/JavaScript_Console</p>
<p>http://www.borngeek.com/firefox/toolbar-tutorial/chapter-8/</p>
]]></content:encoded>
			<wfw:commentRss>http://www.julianwong.net/blog/2009/11/dumping-firefox-xul-object/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rackspace cloud hosting (256MB Ram) and wordpress performance issue</title>
		<link>http://www.julianwong.net/blog/2009/10/rackspace-cloud-hosting-256mb-ram-and-wordpress-performance-issu/</link>
		<comments>http://www.julianwong.net/blog/2009/10/rackspace-cloud-hosting-256mb-ram-and-wordpress-performance-issu/#comments</comments>
		<pubDate>Sat, 24 Oct 2009 11:50:55 +0000</pubDate>
		<dc:creator>julian</dc:creator>
				<category><![CDATA[Admin]]></category>

		<guid isPermaLink="false">http://www.julianwong.net/blog/?p=212</guid>
		<description><![CDATA[Any one out there is using rackspace cloud hosting with 256MB Ram and hosting a wordpress? I was doing fine with it, but after I install the subversion on the Fedora VM, I found my apache become very very slow and take over 60s to serve a request&#8230;. 
Actually this is the second time for [...]]]></description>
			<content:encoded><![CDATA[<p>Any one out there is using rackspace cloud hosting with 256MB Ram and hosting a wordpress? I was doing fine with it, but after I install the subversion on the Fedora VM, I found my apache become very very slow and take over 60s to serve a request&#8230;. </p>
<p>Actually this is the second time for me to head into this performance issue. I did a rebuild on the VM and setup the whole thing again last time. Everything goes fine with the new build right before I install subversion. This time I tried to upgrade the machine to 512MB Ram package without any configuration change, everything just back to normal. Not sure if other peoples are having the same experience or just me had the problem&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.julianwong.net/blog/2009/10/rackspace-cloud-hosting-256mb-ram-and-wordpress-performance-issu/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Nice way to check dom node className</title>
		<link>http://www.julianwong.net/blog/2009/10/nice-way-to-check-dom-node-classname/</link>
		<comments>http://www.julianwong.net/blog/2009/10/nice-way-to-check-dom-node-classname/#comments</comments>
		<pubDate>Wed, 21 Oct 2009 09:43:58 +0000</pubDate>
		<dc:creator>julian</dc:creator>
				<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://www.julianwong.net/blog/?p=196</guid>
		<description><![CDATA[It happen quite often to me that I need to check the element className in the event handler and to determine what function to trigger. element.className contains all the class name separated by space. e.g. &#8220;classA classB classCCC&#8221;. So it is bad to check the className like:
if (element.className === "classA") {...}
 or
if (element.className.indexOf("classC") > -1) [...]]]></description>
			<content:encoded><![CDATA[<p>It happen quite often to me that I need to check the element className in the event handler and to determine what function to trigger. element.className contains all the class name separated by space. e.g. &#8220;classA classB classCCC&#8221;. So it is bad to check the className like:</p>
<pre>if (element.className === "classA") {...}</pre>
<p> or
<pre>if (element.className.indexOf("classC") > -1) {...}</pre>
<p>Sure we can do it with regular expression but there are faster way to do it.</p>
<p>I use YUI all the time and there is a YAHOO.util.Dom.hasClass, I read the source code and found they got a clever way to do it. It just add space in front and behide the className and do a indexOf. But one thing to note that you should not add the space to the className property directly instead you obtain a copy of the className string by getAttribute.</p>
<p>The code will look like:</p>
<pre>
function hasClass(el, class_to_match) {
    var c;
    if (el &#038;&#038; el.className &#038;&#038; typeof class_to_match === "string") {
        c = el.getAttribute("class");
        c = " "+ c + " ";
        return c.indexOf(" " + class_to_match + " ") > -1;
    } else {
        return false;
    }
}
</pre>
<p>Tidy and neat!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.julianwong.net/blog/2009/10/nice-way-to-check-dom-node-classname/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Detecting page dimension with Javascript</title>
		<link>http://www.julianwong.net/blog/2009/10/detectinge-page-dimension-with-javascript/</link>
		<comments>http://www.julianwong.net/blog/2009/10/detectinge-page-dimension-with-javascript/#comments</comments>
		<pubDate>Tue, 20 Oct 2009 12:26:48 +0000</pubDate>
		<dc:creator>julian</dc:creator>
				<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://www.julianwong.net/blog/?p=179</guid>
		<description><![CDATA[I just come to a problem that need to create a canvas element the will cover on top of the whole page. This prevented me from using style.width and style.height as the drawing will become scaled by the style setting. So I have to calculate the exact page width and height then assign it to [...]]]></description>
			<content:encoded><![CDATA[<p>I just come to a problem that need to create a canvas element the will cover on top of the whole page. This prevented me from using style.width and style.height as the drawing will become scaled by the style setting. So I have to calculate the exact page width and height then assign it to the canvas element.</p>
<p>IE 6 had a handy <code>document.body.scrollWidth</code> and <code>document.body.scrollHeight</code> to check the size of body element. Just one thing to note with <code>document.body.scrollHeight</code> is that If the total height of the content is less than the view port / screen size, you will need to use <code>document.body.clientHeight</code>.</p>
<p>While for Firefox, I just need to go through different properties in the window object and body element to find the correct numbers for the calculation.</p>
<pre>width = window.scrollMaxX + document.body.clientWidth;
height = window.scrollMaxY + document.body.clientHeight;
</pre>
<p>Do not mistaken <code>window.innerWidth</code> and <code>window.innerHeight</code> into above as innerWidth and innerHeight will include the scrollbar (if there aren&#8217;t any scrollbar, <code>window.innerWidth</code> will equals to <code>document.body.clientWidth</code> and <code>window.innerHeight</code> will equals to <code>document.body.clientHeight</code>)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.julianwong.net/blog/2009/10/detectinge-page-dimension-with-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Just found i was wrong on MACD</title>
		<link>http://www.julianwong.net/blog/2009/09/just-found-i-was-wrong-on-macd/</link>
		<comments>http://www.julianwong.net/blog/2009/09/just-found-i-was-wrong-on-macd/#comments</comments>
		<pubDate>Tue, 15 Sep 2009 17:26:57 +0000</pubDate>
		<dc:creator>julian</dc:creator>
				<category><![CDATA[Investment]]></category>

		<guid isPermaLink="false">http://www.julianwong.net/blog/?p=164</guid>
		<description><![CDATA[It is common to see financial site providing MACD in (12,26,9). I was so confused on what those number mean and finally I resolved it today.
12 &#8211; is the 12 day moving average of the stock
26 &#8211; is the 26 day moving average of the stock
9 &#8211; is the 9 day moving average of the [...]]]></description>
			<content:encoded><![CDATA[<p>It is common to see financial site providing MACD in (12,26,9). I was so confused on what those number mean and finally I resolved it today.<br />
12 &#8211; is the 12 day moving average of the stock<br />
26 &#8211; is the 26 day moving average of the stock<br />
9 &#8211; is the 9 day moving average of the <span style="color: #ff0000;">MACD!</span></p>
<p>MACD = 12 day MA &#8211; 26 day MA.<br />
When MACD cross above 9 day MA of MACD is buying signal, while MACD cross under the 9 day MA of MACD is selling signal. </p>
<p>This is like taking me an hour to search and read on the detail and finally discover the last number 9 is 9 day MA of MACD instead of 9 day MA of the stock&#8230;..</p>
]]></content:encoded>
			<wfw:commentRss>http://www.julianwong.net/blog/2009/09/just-found-i-was-wrong-on-macd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using custom event on jQuery</title>
		<link>http://www.julianwong.net/blog/2009/09/using-custom-event-on-jquery/</link>
		<comments>http://www.julianwong.net/blog/2009/09/using-custom-event-on-jquery/#comments</comments>
		<pubDate>Wed, 09 Sep 2009 08:04:33 +0000</pubDate>
		<dc:creator>julian</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://julianwong.net/blog/?p=155</guid>
		<description><![CDATA[When doing Javascript, it is common to handle different DOM event like click, mouseover, keydown&#8230; This is cool that with the DOM triggering those events, we can create custom handling / behaviors on it. Say, when user click on the button, a edit panel fade in. But this is not good enough when we have [...]]]></description>
			<content:encoded><![CDATA[<p>When doing Javascript, it is common to handle different DOM event like click, mouseover, keydown&#8230; This is cool that with the DOM triggering those events, we can create custom handling / behaviors on it. Say, when user click on the button, a edit panel fade in. But this is not good enough when we have to deal with a complex / feature rich interface. For instance, if a feature require a series of action on different components, how can we do it in a proper way? Here is custom event come into play.</p>
<p>There are different ways of making custom event to works, following will show:<br />
1. Using jQuery.bind and jQuery.trigger<br />
2. Using the jQuery plugin jQuery.mhub<br />
<span id="more-155"></span></p>
<h3>Using jQuery.bind and jQuery.trigger</h3>
<p>Have searched for how to have custom event on jQuery, found that <a href="http://yoan.dosimple.ch/blog/2008/04/30/">yoan&#8217;s Introduction to jQuery’s custom event</a> had some good insight. He had achieved it by using the bind and trigger function in jQuery. I have referenced his blog and the API from jQuery and created a rather primitive sample.</p>
<pre>var count = 0;
var elLog = document.getElementById("log");

// trigger the ticker event into body element
setInterval(function() {
    <strong>$("body").trigger("ticker",{name:"my name is foo",count:count++});</strong>
},3000);

<strong>$("body").bind("ticker",gFunc);</strong>

function gFunc(evt,msg) {
    elLog.innerHTML += "gFunc triggered&lt;br/&gt;&lt;br/&gt;";
}

var myApp = {
    name:"app1",

    init:function() {
        var that = this;
        // bind the _handlerTicker function to the ticker event of body element
        <strong>$("body").bind("ticker",function() {that._handlerTicker.apply(that,arguments)});</strong>
    },

    _handlerTicker:function(evt,msg) {
        elLog.innerHTML += this.name + "&lt;br/&gt;";
        elLog.innerHTML += "event name: " + evt.type + "&lt;br/&gt;";
        elLog.innerHTML += "msg content: name = " + msg.name + ", count = " + msg.count + "&lt;br/&gt;&lt;br/&gt;";
    }
}
myApp.init();</pre>
<p><a href="http://julianwong.net/samples/custom-event/dom.html">The sample in action</a></p>
<p>My sample code above works but with some draw backs:<br />
1. The custom event need to associated with a dom element which have nothing to do with it, here is the body element.<br />
2. When dealing with a large application / working with different plugin / mashup, we could end up with a name collision on the custom event.<br />
<a name="jQuery.mhub"></a></p>
<h3>Using the jQuery plugin jQuery.mhub</h3>
<p>To tackle the problems listed above, I created a <a href="http://plugins.jquery.com/project/mhub">message hub plugin, jQuery.mhub</a>. This jQuery.mhub employ a factory design. It only contains one single method:</p>
<pre>var demoHub = jQuery.mhub.create();</pre>
<p>Which return a message hub object with the following methods:</p>
<pre>demoHub.add(String NAME);
demoHub.remove(String NAME);
demoHub.send(String NAME, Object MESSAGE );
demoHub.listen(String NAME, Function HANDLE_FN, Object SCOPE );</pre>
<p>Here is a <a href="http://www.julianwong.net/samples/custom-event/mhub.html">sample</a> to see how the jQuery.mhub works. By using the jQuery.mhub, the above 2 problems state can be solved.</p>
<p>1. The custom event no longer tide up with a dom element.<br />
2. mhub object are created from jQuery.mhub.create();, you can get your own mhub without sharing it to other component and avoid name collision</p>
<p>A primitive <a href="http://www.julianwong.net/samples/custom-event/mhub.html">sample of jQuery.mhub</a>.</p>
<p>The source code:</p>
<pre>var count = 0;
var elLog = document.getElementById("log");
var demoHub = jQuery.mhub.create();

<strong>demoHub.add("ticker");</strong>

setInterval(function() {
    <strong>demoHub.send("ticker",{name:"my name is foo",count:count++});</strong>
},3000);

<strong>demoHub.listen("ticker", globalFunc);</strong>

function globalFunc(evt,msg) {
    elLog.innerHTML += "globalFunc triggered&lt;br/&gt;&lt;br/&gt;";
}

var myApp = {
    name:"app1",

    init:function() {
        <strong>demoHub.listen("ticker", this._handlerTicker, this);</strong>
    },

    _handlerTicker:function(name,msg) {
        elLog.innerHTML += this.name + "&lt;br/&gt;";
        elLog.innerHTML += "event name: " + name + "&lt;br/&gt;";
        elLog.innerHTML += "msg content: name = " + msg.name + ", count = " + msg.count + "&lt;br/&gt;";
    }
}

myApp.init();</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.julianwong.net/blog/2009/09/using-custom-event-on-jquery/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>A classname to save, using negative magin to remove the &quot;first&quot; / &quot;last&quot; class in your list</title>
		<link>http://www.julianwong.net/blog/2009/08/a-classname-to-save-using-negative-magin-to-remove-the-first-last-in-your-list/</link>
		<comments>http://www.julianwong.net/blog/2009/08/a-classname-to-save-using-negative-magin-to-remove-the-first-last-in-your-list/#comments</comments>
		<pubDate>Wed, 26 Aug 2009 09:06:17 +0000</pubDate>
		<dc:creator>julian</dc:creator>
				<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://julianwong.net/blog/?p=131</guid>
		<description><![CDATA[It is common to create a list with a separator in between like this:
Item 1 &#124; Item 2 &#124; Item 3
One common way of doing this is create a list (ol / ul) then apply the border-left and add a class &#8220;first&#8221; to the first li setting the border to 0px. This is good, but [...]]]></description>
			<content:encoded><![CDATA[<p>It is common to create a list with a separator in between like this:<br />
Item 1 | Item 2 | Item 3</p>
<p>One common way of doing this is create a list (ol / ul) then apply the border-left and add a class &#8220;first&#8221; to the first li setting the border to 0px. This is good, but this can be done in a better way.</p>
<p><span id="more-131"></span></p>
<p>Let start with an ordered list, and applying css border-left on it.<br />
&lt;ol id=&#8221;sample-list&#8221;&gt;<br />
&lt;li&gt;Item 1&lt;/li&gt;<br />
&lt;li&gt;Item 2&lt;/li&gt;<br />
&lt;li&gt;Item 3&lt;/li&gt;<br />
&lt;/ol&gt;</p>
<p>With the style:<br />
/* reset the li element */<br />
ol{margin:0px;padding:0px;}<br />
li{margin:0px;padding:0px;list-style:none;}</p>
<p>#sample-list li{border-left:1px solid #ccc;float:left;padding: 2px 5px;}</p>
<p>The result will become:<br />
| Item 1 | Item 2 | Item 3</p>
<p>Which shown an extra border at the left. One simple way to eliminate the first border is adding a classname to the first li and clear our the border, but this will add extra logic in your PHP code. So that will be nice if we can solve in CSS and keep the PHP code a bit cleaner.</p>
<p>By using negative margin, the item list above can be shown nicely without the extra class.</p>
<p>&lt;ol id=&#8221;sample-list&#8221;&gt;<br />
&lt;li&gt;Item 1&lt;/li&gt;<br />
&lt;li&gt;Item 2&lt;/li&gt;<br />
&lt;li&gt;Item 3&lt;/li&gt;<br />
&lt;/ol&gt;</p>
<p>With the style:<br />
/* reset the li element */<br />
ol{margin:0px;padding:0px;}<br />
li{margin:0px;padding:0px;list-style:none;}</p>
<p>#sample-list {overflow:hidden;display:block;}<br />
#sample-list li{border-left:1px solid #ccc;float:left;padding: 2px 5px;margin-left:-1px;}</p>
<p>In the CSS above, by setting li with margin-left:-1px; the first border-left will fall out of the ol. With ol#sample-list  set to overflow:hidden, that extra line will be wipe out from screen and leave all the other separators there.</p>
<p>This technique can works in a vertical list with horizontal separator. Just set the border to top and margin-top:-1px then set the container&#8217;s overflow to hidden. Done!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.julianwong.net/blog/2009/08/a-classname-to-save-using-negative-magin-to-remove-the-first-last-in-your-list/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
