tag:blogger.com,1999:blog-88475447171536297612024-02-08T12:23:00.300-08:00HungryFools - Stay Hungry, Stay Foolish!It's not rocket science if you put your heart into it.Leihttp://www.blogger.com/profile/00550560377532133506noreply@blogger.comBlogger60125tag:blogger.com,1999:blog-8847544717153629761.post-6750083500701766642011-01-11T19:25:00.000-08:002011-01-11T19:25:33.345-08:00How to update the Gem.lock file for rails 3Inside your app directory, just type in<br />
<blockquote>bundle update</blockquote>Leihttp://www.blogger.com/profile/00550560377532133506noreply@blogger.com0tag:blogger.com,1999:blog-8847544717153629761.post-9564493759991717302010-12-20T21:52:00.000-08:002010-12-20T21:52:18.796-08:00Bundler for ruby applicationsI just found out that Rails3 is using <a href="http://gembundler.com/">Bundler</a> to manage all of the gem dependencies.<br />
<br />
This is just an awesome idea ;-)<br />
<br />
I use to write custom deployment script for all of the new instances that I create in the cloud.<br />
<br />
With this, you can easily manage the dependencies for your ruby application anywhere you choose to run.Leihttp://www.blogger.com/profile/00550560377532133506noreply@blogger.com0tag:blogger.com,1999:blog-8847544717153629761.post-28411508028446799602010-12-20T21:48:00.000-08:002010-12-20T21:48:22.418-08:00Include ruby json gem into Rails3 automaticallyFirst, install the gem from command line.<br />
<blockquote>> sudo gem install json</blockquote>Then, add the following line to Gemfile<br />
<blockquote>gem 'json' </blockquote><blockquote><br />
</blockquote>Leihttp://www.blogger.com/profile/00550560377532133506noreply@blogger.com0tag:blogger.com,1999:blog-8847544717153629761.post-6271726032970820842010-12-20T21:44:00.000-08:002010-12-20T21:44:27.563-08:00How to autoload libraries from lib directory for Rails3Inside application.rb <br />
<blockquote>module ApiServer<br />
class Application < Rails::Application<br />
# Custom directories with classes and modules you want to be autoloadable.<br />
# config.autoload_paths += %W(#{config.root}/extras)<br />
<b>config.autoload_paths += %W(#{config.root}/lib) </b><br />
end<br />
end</blockquote>Leihttp://www.blogger.com/profile/00550560377532133506noreply@blogger.com0tag:blogger.com,1999:blog-8847544717153629761.post-21308866353977503142009-12-31T11:48:00.000-08:002009-12-31T11:56:32.054-08:00How to mimic apache's "!-f" and "!-d" in lighttpdJust a while ago, I was still trying to write a php script to load static content and send them to browser, now that I know apache has a nice rewrite condition like this:<br />
<blockquote><pre>RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d<
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</pre></blockquote>I don't have to use that script of mine any more. However, I hit the wall straight on when I was trying to port the same functionality in lighttpd, and the only thing I found was <br />
<blockquote><pre>url.rewrite-[repeat-]if-not-file
</pre></blockquote>Only half of the solution, and it somehow stopped working for me after working or 2 weeks, and says<br />
<blockquote><pre>WARNING: unknown config-key: url.rewrite-if-not-file (ignored)
</pre></blockquote>gerrr.....<br />
<br />
That did it ;-) I was determined to find the right solution to finish this for good, and here is what I have found:<br />
<br />
Using mod_magnet and a small lua script. For detail, see the following urls.<br />
<br />
<a href="http://www.akelos.org/wiki/setting-up-akelos-on-lighttpd-in-a-mac">http://www.akelos.org/wiki/setting-up-akelos-on-lighttpd-in-a-mac</a><br />
<a href="http://redmine.lighttpd.net/projects/lighttpd/wiki/AbsoLUAtion">http://redmine.lighttpd.net/projects/lighttpd/wiki/AbsoLUAtion</a><br />
<br />
Oh, if you happen to be on ubuntu, you would probably also need to do this<br />
<blockquote><pre>sudo apt-get install lighttpd-mod-magnet
</pre></blockquote>Leihttp://www.blogger.com/profile/00550560377532133506noreply@blogger.com0tag:blogger.com,1999:blog-8847544717153629761.post-3089342828794438922009-12-28T10:49:00.000-08:002009-12-28T10:50:01.503-08:00ubuntu's rc managementI hate to write these down, but I have been using these so often this winter break that I can't allow myself to do another search to find the answers.<br />
<br />
<blockquote>To stop apache2 for this session only:<br />
<b>sudo /etc/init.d/apache2 stop</b><br />
<br />
To remove apache2 permanently from startup scripts:<br />
<b>sudo update-rc.d apache2 remove</b><br />
<br />
To reinstate apache2 in the startup scripts:<br />
<b>sudo update-rc.d apache2 defaults</b><br />
</blockquote>Leihttp://www.blogger.com/profile/00550560377532133506noreply@blogger.com0tag:blogger.com,1999:blog-8847544717153629761.post-52257414814204312932008-04-04T11:35:00.000-07:002008-04-04T11:36:40.748-07:00jsdIScriptI was in the process of trying to figure out how to track the stack frames in javascript through jsd, and naturally, I wanted to see what's in jsdlScript ;-) So I hooked a logging method in the script enumerator, and found out that at least in Mozilla, javascript is counted in the unit of functions. Each function is treated as a jsdlScript object. This makes a lot of sense. (Well, not that it didn't make any sense.) It also explains, if a page has javascript files from different servers, it cannot distinguish the scripts origin based on the url of the file. Well, more fun for me working with the jsd ;-)Leihttp://www.blogger.com/profile/00550560377532133506noreply@blogger.com0tag:blogger.com,1999:blog-8847544717153629761.post-68000914416678967032008-03-26T14:48:00.000-07:002008-03-26T14:57:14.614-07:00How to work with jsd (Javascript Debugger)I was really determined to figure out how firebug and venkman works, so I can write a javascript walker or stepper for my firecruncher plugin. The further I investigate, the more I respect the authors and contributors of these two pieces of seriously written software. <br id="gyav"><br id="h9rz">I started with the UI, and then I headed for the core that interacts with the xpcom compionent jsd (Javascript Debugger). <br id="dm91"><br id="x:_2">It never seamed easy for me, even though there are some sparse documentation in xulplanet, but the only two examples that I was able to consult was <br id="xg7b"><ul id="wo4p"><li id="d:2_"><a title="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-debugger.js" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-debugger.js" id="l8jh">http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-debugger.js</a> </li><li id="fpr0"><a title="http://developer.mozilla.org/en/docs/FirebugInternals#Firebug_Service" href="http://developer.mozilla.org/en/docs/FirebugInternals#Firebug_Service" id="dzwv">http://developer.mozilla.org/en/docs/FirebugInternals#Firebug_Service</a> </li></ul>It really took me a while figuring out how jsd works, as both of the source above have thousands of lines of javascript, a lot of them has interactions with objects outside of the classes or services that are defined in the same file.<br id="s35-"><br id="r_hg">After a week's worth of night reading, prototyping and code porting, I finally got it. Well, most of it. ;-)<br id="e5yh"><br id="hh3l">It turns out that using jsd isn't that hard at all if you know Javascript's event handing mechanism. Well, in jsd, the original designer called them hooks. There are hooks for almost everything from the creation and destruction of a script, errors, to function call and program counters (interrupt or execution). Just think of them as different events that will be fired during a debugger active session. All what we need to do is to write the appropriate handers, and hook back into the jsd.<br id="ognf"><br id="gta1">I will describe a common life cycle of the usage of jsd below:<br id="xtvu"><br id="q-lu">First, we acquire the <a id="s_ny" href="http://www.xulplanet.com/references/xpcomref/comps/c_jsjsddebuggerservice1.html">@mozilla.org/js/jsd/debugger-service;1</a> service.<br id="ptk-"><blockquote id="l-r3"><pre id="iyvp" lang="en"><span id="b1uz" class="ident">var jsd = Components</span>.<span id="if-s" class="ident">classes</span>["@mozilla.org/js/jsd/debugger-service;1"].<span id="ij40" class="ident">getService</span>(<span id="g3h7" class="ident">jsdIDebuggerService</span>);<br id="g4lr">jsd.on();<br id="r3zf"></pre></blockquote>Ref: <a title="http://www.xulplanet.com/references/xpcomref/ifaces/jsdIDebuggerService.html" href="http://www.xulplanet.com/references/xpcomref/ifaces/jsdIDebuggerService.html" id="j_su">http://www.xulplanet.com/references/xpcomref/ifaces/jsdIDebuggerService.html</a> <br id="x2h3">With this, we can turn on, off, pause and unpause the debugger, but how do we set a break point? Ha, we are jumping ahead of ourselves. We need a piece of script first, so we can set the break point on top of it. Here is how you track which script has been created and which one has been destroyed.<br id="ge8j"><blockquote id="jad-"><span id="mk4q" style="font-family: Courier New;">jsd.scriptHook =</span><br style="font-family: Courier New;" id="dkrm"><span id="dsve" style="font-family: Courier New;">{</span><br style="font-family: Courier New;" id="zprs"><span id="diyz" style="font-family: Courier New;"> onScriptCreated: function(script){/* xxx track the scripts xxx */},</span><br style="font-family: Courier New;" id="kmcl"><span id="w:sk" style="font-family: Courier New;"> onScriptDestroyed: function(script){/* xxx track the scripts xxx */}</span><br style="font-family: Courier New;" id="i8jz"><span id="k4:y" style="font-family: Courier New;">};</span><br id="zfki"></blockquote> You can also enumerate all of the existing scripts that are available before the debugger was turned on by:<br id="y8.y"><blockquote id="x:qz"><span id="nslb" style="font-family: Courier New;">jsd.enumerateScripts({enumerateScript: function(script)</span><br style="font-family: Courier New;" id="kiap"><span id="ccg7" style="font-family: Courier New;">{</span><br style="font-family: Courier New;" id="h:08"><span id="nfqx" style="font-family: Courier New;"> /* xxx track the scripts xxx */</span><br style="font-family: Courier New;" id="zpx9"><span id="kmk9" style="font-family: Courier New;">}});</span><br id="pf1q"></blockquote>Now, we have all of the scripts available for us to set the break points. ;-)<br id="wagg">Ref: <a title="http://www.xulplanet.com/references/xpcomref/ifaces/jsdIScript.html" href="http://www.xulplanet.com/references/xpcomref/ifaces/jsdIScript.html" id="e6ve">http://www.xulplanet.com/references/xpcomref/ifaces/jsdIScript.html</a> <br id="ra8i"><br id="pj71">That's all good until we encounter an error while running the script that we have loaded into the debugger. What do we do then? Ha, the ErrorHook comes handy.<br id="znam"><blockquote id="w6ex"><span id="slzd" style="font-family: Courier New;">jsd.errorHook = { onError: function(message, fileName, lineNo, pos, flags, errnum, exc){ /* xxx handle the error here xxx */ }};</span><br id="r_ja"></blockquote>You can do similar things with debuggerHook and debugHook. So what happens when we encounter a break point? Of course, there is a break point hook as well ;-)<br id="t3vb"><blockquote id="qmnd"><span id="bvmj" style="font-family: Courier New;">jsd.breakpointHook = { onExecute: function(frame, type, val){ /* xxx handle the break point xxx */} };</span><br id="ain:"></blockquote>We can do something at a break point now, but how do we temporarily suspend the code execution while we are at a break point, and do something like step over? It took me some search to figure this out ;-) We use enterNestedEventLoop to pause, and exitNestedEventLoop to get out of the paused state.<br id="qy5g"><blockquote style="font-family: Courier New;" id="i8e_">jsd.enterNestedEventLoop({onNest: function() { /* xxx another hook here, so we know that we are in a paused state xxx*/ });<br id="whmr">jsd.exitNestedEventLoop(); // Yeh.. we are happily continuing our course of execution.</blockquote>OK, we now can get a script, handle the error, set the break point, handle the break point, pause at the break point and continue from the break point. So how do we do the stepping? This is done by two other interrupts: functionHook and interruptHook ;-) In the case of step over, we use interruptHook, in the case of step out and step in, we use functionHook. (Ref below is copied from firebug-service.js)<br id="ealo"><blockquote id="y_3w"><span id="c4_7" style="font-family: Courier New;">hookFunctions: function()</span><br style="font-family: Courier New;" id="wgt8"><span id="n.b2" style="font-family: Courier New;"> {</span><br style="font-family: Courier New;" id="p-e-"><span id="k87v" style="font-family: Courier New;"> function functionHook(frame, type)</span><br style="font-family: Courier New;" id="ry7a"><span id="y7_s" style="font-family: Courier New;"> {</span><br style="font-family: Courier New;" id="q5.j"><span id="a7g2" style="font-family: Courier New;"> switch (type)</span><br style="font-family: Courier New;" id="ggxa"><span id="y6.t" style="font-family: Courier New;"> {</span><br style="font-family: Courier New;" id="jdbn"><span id="mese" style="font-family: Courier New;"> case TYPE_FUNCTION_CALL:</span><br style="font-family: Courier New;" id="n5j1"><span id="xg7-" style="font-family: Courier New;"> {</span><br style="font-family: Courier New;" id="ri6e"><span id="oqom" style="font-family: Courier New;"> ++hookFrameCount;</span><br style="font-family: Courier New;" id="bs6m"><br style="font-family: Courier New;" id="ka2w"><span id="qvom" style="font-family: Courier New;"> if (stepMode == STEP_OVER)</span><br style="font-family: Courier New;" id="c5j2"><span id="j3y-" style="font-family: Courier New;"> jsd.interruptHook = null;</span><br style="font-family: Courier New;" id="r1t0"><br style="font-family: Courier New;" id="ht8i"><span id="e8m4" style="font-family: Courier New;"> break;</span><br style="font-family: Courier New;" id="ms86"><span id="pm6-" style="font-family: Courier New;"> }</span><br style="font-family: Courier New;" id="pw65"><span id="n0g8" style="font-family: Courier New;"> case TYPE_FUNCTION_RETURN:</span><br style="font-family: Courier New;" id="jd-p"><span id="ax3c" style="font-family: Courier New;"> {</span><br style="font-family: Courier New;" id="elbs"><span id="yxe6" style="font-family: Courier New;"> --hookFrameCount;</span><br style="font-family: Courier New;" id="sehl"><br style="font-family: Courier New;" id="fy-a"><span id="zz_3" style="font-family: Courier New;"> if (hookFrameCount == 0)</span><br style="font-family: Courier New;" id="at38"><span id="lfu." style="font-family: Courier New;"> fbs.stopStepping();</span><br style="font-family: Courier New;" id="y9jw"><span id="rqr6" style="font-family: Courier New;"> else if (stepMode == STEP_OVER)</span><br style="font-family: Courier New;" id="twtw"><span id="jl9t" style="font-family: Courier New;"> {</span><br style="font-family: Courier New;" id="if6-"><span id="e03_" style="font-family: Courier New;"> if (hookFrameCount <= stepFrameCount)</span><br style="font-family: Courier New;" id="g48a"><span id="izef" style="font-family: Courier New;"> fbs.hookInterrupts();</span><br style="font-family: Courier New;" id="xq2i"><span id="pgqx" style="font-family: Courier New;"> }</span><br style="font-family: Courier New;" id="vua:"><span id="pttp" style="font-family: Courier New;"> else if (stepMode == STEP_OUT)</span><br style="font-family: Courier New;" id="jrid"><span id="q9g6" style="font-family: Courier New;"> {</span><br style="font-family: Courier New;" id="u62q"><span id="knfx" style="font-family: Courier New;"> if (hookFrameCount < stepFrameCount)</span><br style="font-family: Courier New;" id="x7bl"><span id="c2sj" style="font-family: Courier New;"> fbs.hookInterrupts();</span><br style="font-family: Courier New;" id="t96h"><span id="otkf" style="font-family: Courier New;"> }</span><br style="font-family: Courier New;" id="up8j"><br style="font-family: Courier New;" id="mkzl"><span id="xsc1" style="font-family: Courier New;"> break;</span><br style="font-family: Courier New;" id="w:qc"><span id="uzl4" style="font-family: Courier New;"> }</span><br style="font-family: Courier New;" id="b5yo"><span id="d13j" style="font-family: Courier New;"> }</span><br style="font-family: Courier New;" id="l8zp"><span id="uzd-" style="font-family: Courier New;"> }</span><br style="font-family: Courier New;" id="g7_x"><br style="font-family: Courier New;" id="k1cz"><span id="jrh5" style="font-family: Courier New;"> jsd.functionHook = { onCall: functionHook };</span><br style="font-family: Courier New;" id="b3.:"><span id="xc-3" style="font-family: Courier New;"> },</span><br style="font-family: Courier New;" id="a_di"><br style="font-family: Courier New;" id="ulnr"><span id="t7u." style="font-family: Courier New;"> hookInterrupts: function()</span><br style="font-family: Courier New;" id="hmik"><span id="ramd" style="font-family: Courier New;"> {</span><br style="font-family: Courier New;" id="bowo"><span id="f2j3" style="font-family: Courier New;"> function interruptHook(frame, type, rv)</span><br style="font-family: Courier New;" id="f5mx"><span id="h7-4" style="font-family: Courier New;"> {</span><br style="font-family: Courier New;" id="iz4o"><span id="y6ug" style="font-family: Courier New;"> // Sometimes the same line will have multiple interrupts, so check</span><br style="font-family: Courier New;" id="ljzg"><span id="erjw" style="font-family: Courier New;"> // a unique id for the line and don't break until it changes</span><br style="font-family: Courier New;" id="n0r4"><span id="z33s" style="font-family: Courier New;"> var frameLineId = hookFrameCount + frame.script.fileName + frame.line;</span><br style="font-family: Courier New;" id="l_eg"><span id="mq.7" style="font-family: Courier New;"> if (frameLineId != stepFrameLineId)</span><br style="font-family: Courier New;" id="hdid"><span id="tdvy" style="font-family: Courier New;"> return fbs.onBreak(frame, type, rv);</span><br style="font-family: Courier New;" id="obs4"><span id="akbh" style="font-family: Courier New;"> else</span><br style="font-family: Courier New;" id="fhw-"><span id="rldc" style="font-family: Courier New;"> return RETURN_CONTINUE;</span><br style="font-family: Courier New;" id="i235"><span id="m9gp" style="font-family: Courier New;"> }</span><br style="font-family: Courier New;" id="ahvf"><br style="font-family: Courier New;" id="xp_p"><span id="wv9h" style="font-family: Courier New;"> jsd.interruptHook = { onExecute: interruptHook };</span><br style="font-family: Courier New;" id="h1ss"><span id="rsmh" style="font-family: Courier New;"> },</span><br id="p.am"></blockquote>That's it!<br id="yewh">Leihttp://www.blogger.com/profile/00550560377532133506noreply@blogger.com3tag:blogger.com,1999:blog-8847544717153629761.post-41085306401961754332008-03-12T11:18:00.000-07:002008-03-12T11:20:32.854-07:00Firebug's SourceTextYesterday, I went through the source file loading between Firebug and Venkman. Firebug's approach seems to be much simpler, ;-) but I left some detail unexplored since it was already very late.<br><br>The function that I quoted from firebug's source showed how sourceBox was created and added into the panel, but didn't show exactly how source lines are added into the panel. Nothing with <div> or <a> or <span> tags were mentioned in that function. <br><br>Just for the heck of it, I inspected the firebug again using the dom inspector, and found the clue of where the magic might have been. ;-)<br><blockquote>this.SourceText = domplate(Firebug.Rep,<br>{<br> tag:<br> DIV(<br> FOR("line", "$object|lineIterator",<br> DIV({class: "sourceRow"},<br> SPAN({class: "sourceLine"}, "$line.lineNo"),<br> SPAN({class: "sourceRowText"}, "$line.text")<br> )<br> )<br> ),<br><br> lineIterator: function(sourceText)<br> {<br> var maxLineNoChars = (sourceText.lines.length + "").length;<br> var list = [];<br><br> for (var i = 0; i < sourceText.lines.length; ++i)<br> {<br> // Make sure all line numbers are the same width (with a fixed-width font)<br> var lineNo = (i+1) + "";<br> while (lineNo.length < maxLineNoChars)<br> lineNo = " " + lineNo;<br><br> list.push({lineNo: lineNo, text: sourceText.lines[i]});<br> }<br><br> return list;<br> },<br><br> getHTML: function(sourceText)<br> {<br> return getSourceLines(sourceText.lines);<br> }<br>});<br></blockquote> Notice the use of <b>domplate</b> function! It's a sweet little templating system ;-)<br>Leihttp://www.blogger.com/profile/00550560377532133506noreply@blogger.com0tag:blogger.com,1999:blog-8847544717153629761.post-25266122478336954792008-03-11T20:13:00.000-07:002008-03-11T20:14:23.378-07:00Javascript Source View II - Firebug vs VenkmanOK, last time, I was very happy to find out that venkman was using the XUL tree to represent the javascript source, while firebug was using html <a> tag and <span> tags.<br /><br />As I was trying to find the script to load into the source view, I started to wonder how did those two software did it. I would imagine that we need to implement something that will<br /><ol><li>load the file into a stream</li><li>process the stream line by line</li></ol><br />The findings from venkman actually amazed me once again, and along the way, I picked up a few other nice things ;-) So here it goes...<br /><br />First, I was quite confident that I want to do it in xul tree way instead of the html way, so I started to scratch my head and buried my head into the venkman source code once again ;-) But before I went too far, I discovered that there are actually two different source views in venkman! One is called <b>source</b>, another one is called <b>source2</b>. <b>source2</b> is the one that enables us to set breakpoints, and <b>source</b> doesn't do much, and it is hidden by default.<br /><blockquote><pre lang="en"><span class="line">From venkman-views.xul<br /><a name="145" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#145">145</a> </span> <!-- source2 view --><br /><span class="line"> <a name="146" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#146">146</a> </span><br /><span class="line"> <a name="147" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#147">147</a> </span> <floatingview id="source2" title="&Source.label;" flex="1"><br /><span class="line"> <a name="148" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#148">148</a> </span> <vbox flex="1"><br /><span class="line"> <a name="149" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#149">149</a> </span> <tabbox id="source2-tabbox" flex="1"><br /><span class="line"> <a name="150" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#150">150</a> </span> <tabs id="source2-tabs"><br /><span class="line"> <a name="151" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#151">151</a> </span> <!--<br /><span class="line"> <a name="152" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#152">152</a> </span> We've got to put this placeholder tab in the tabs element to avoid<br /><span class="line"> <a name="153" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#153">153</a> </span> bogus strict warnings and exceptions.<br /><span class="line"> <a name="154" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#154">154</a> </span> --><br /><span class="line"> <a name="155" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#155">155</a> </span> <tab id="source2-bloke" hidden="true"/><br /><span class="line"> <a name="156" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#156">156</a> </span> </tabs><br /><span class="line"> <a name="157" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#157">157</a> </span> <tabpanels id="source2-deck" flex="1"/><br /><span class="line"> <a name="158" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#158">158</a> </span> </tabbox><br /><span class="line"> <a name="159" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#159">159</a> </span> <textbox class="plain" id="source2-heading" readonly="true"/><br /><span class="line"> <a name="160" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#160">160</a> </span> </vbox><br /><span class="line"> <a name="161" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#161">161</a> </span> </floatingview><br /><span class="line"> <a name="162" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#162">162</a> </span><br /><span class="line"> <a name="163" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#163">163</a> </span> <!-- source view --><br /><span class="line"> <a name="164" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#164">164</a> </span><br /><span class="line"> <a name="165" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#165">165</a> </span> <floatingview id="source" title="&Source.label;" flex="1"><br /><span class="line"> <a name="166" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#166">166</a> </span> <vbox id="source-view-content" flex="1"><br /><span class="line"> <a name="167" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#167">167</a> </span> <toolbox><br /><span class="line"> <a name="168" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#168">168</a> </span> <toolbar id="source-header" grippytooltiptext="&SourceHeader.tip;"><br /><span class="line"> <a name="169" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#169">169</a> </span> <label id="source-url" flex="1" crop="end"/><br /><span class="line"> <a name="170" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#170">170</a> </span> </toolbar><br /><span class="line"> <a name="171" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#171">171</a> </span> </toolbox><br /><span class="line"> <a name="172" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#172">172</a> </span> <tree id="source-tree" flex="1" persist="width"<br /><span class="line"> <a name="173" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#173">173</a> </span> class="focusring"<br /><span class="line"> <a name="174" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#174">174</a> </span> onclick="console.views.source.onClick(event);"<br /><span class="line"> <a name="175" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#175">175</a> </span> onselect="console.views.source.onSelect(event);"<br /><span class="line"> <a name="176" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#176">176</a> </span> context="context:source"><br /><span class="line"> <a name="177" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#177">177</a> </span><br /><span class="line"> <a name="178" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#178">178</a> </span> <treecols><br /><span class="line"> <a name="179" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#179">179</a> </span> <treecol id="source:col-0" width="20px"<br /><span class="line"> <a name="180" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#180">180</a> </span> display="&SourceCol0.display;" persist="hidden width"/><br /><span class="line"> <a name="181" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#181">181</a> </span> <splitter class="tree-splitter"/><br /><span class="line"> <a name="182" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#182">182</a> </span> <treecol id="source:col-1" width="50px"<br /><span class="line"> <a name="183" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#183">183</a> </span> display="&SourceCol1.display;" persist="hidden width"/><br /><span class="line"> <a name="184" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#184">184</a> </span> <splitter class="tree-splitter"/><br /><span class="line"> <a name="185" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#185">185</a> </span> <treecol id="source:col-2" flex="1" display=""<br /><span class="line"> <a name="186" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#186">186</a> </span> ignoreincolumnpicker="true" persist="hidden width"/><br /><span class="line"> <a name="187" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#187">187</a> </span> </treecols><br /><span class="line"> <a name="188" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#188">188</a> </span><br /><span class="line"> <a name="189" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#189">189</a> </span> <treechildren id="source-tree-body"/><br /><span class="line"> <a name="190" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#190">190</a> </span><br /><span class="line"> <a name="191" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#191">191</a> </span> </tree><br /><span class="line"> <a name="192" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#192">192</a> </span> </vbox><br /><span class="line"> <a name="193" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#193">193</a> </span> </floatingview></pre></blockquote><blockquote>From venkman-views.js<br /><pre lang="en"><span class="line"><a name="2226" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2226">2226</a> </span><span class="comment">/*******************************************************************************</span><br /><span class="line"><a name="2227" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2227">2227</a> </span><span class="comment"> * Source2 View</span><br /><span class="line"><a name="2228" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2228">2228</a> </span><span class="comment"> *******************************************************************************/</span><br /><span class="line"><a name="2229" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2229">2229</a> </span><br /><span class="line"><a name="2230" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2230">2230</a> </span><a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=console">console</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=views">views</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=source2">source2</a> = <span class="verb">new </span><a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=Object">Object</a>();<br /><span class="line"><a name="2231" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2231">2231</a> </span><br /><span class="line"><a name="2232" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2232">2232</a> </span><span class="verb">const </span><a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=VIEW_SOURCE2">VIEW_SOURCE2</a> = <span class="string">"source2"</span>;<br /><span class="line"><a name="2233" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2233">2233</a> </span><a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=console">console</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=views">views</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=source2">source2</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=viewId">viewId</a> = <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=VIEW_SOURCE2">VIEW_SOURCE2</a>;<br /><span class="line"><a name="2234" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2234">2234</a> </span><br /><span class="line"><a name="2235" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2235">2235</a> </span><a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=console">console</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=views">views</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=source2">source2</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=init">init</a> =<br /><span class="line"><a name="2236" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2236">2236</a> </span><span class="verb">function </span><a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=ss_init">ss_init</a> ()<br /><span class="line"><a name="2237" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2237">2237</a> </span>{<br /><br /><span class="line"><a name="3527" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3527">3527</a> </span><span class="comment">/*******************************************************************************</span><br /><span class="line"><a name="3528" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3528">3528</a> </span><span class="comment"> * Source View</span><br /><span class="line"><a name="3529" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3529">3529</a> </span><span class="comment"> *******************************************************************************/</span><br /><span class="line"><a name="3530" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3530">3530</a> </span><a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=console">console</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=views">views</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=source">source</a> = <span class="verb">new </span><a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=BasicOView">BasicOView</a>();<br /><span class="line"><a name="3531" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3531">3531</a> </span><br /><span class="line"><a name="3532" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3532">3532</a> </span><span class="verb">const </span><a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=VIEW_SOURCE">VIEW_SOURCE</a> = <span class="string">"source"</span>;<br /><span class="line"><a name="3533" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3533">3533</a> </span><a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=console">console</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=views">views</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=source">source</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=viewId">viewId</a> = <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=VIEW_SOURCE">VIEW_SOURCE</a>;<br /><span class="line"><a name="3534" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3534">3534</a> </span><br /><span class="line"><a name="3535" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3535">3535</a> </span><a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=console">console</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=views">views</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=source">source</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=details">details</a> = <span class="verb">null;</span><br /><span class="line"><a name="3536" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3536">3536</a> </span><a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=console">console</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=views">views</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=source">source</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=prettyPrint">prettyPrint</a> = <span class="verb">false;</span><br /><span class="line"><a name="3537" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3537">3537</a> </span><br /><span class="line"><a name="3538" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3538">3538</a> </span><a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=console">console</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=views">views</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=source">source</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=init">init</a> =<br /><span class="line"><a name="3539" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3539">3539</a> </span><span class="verb">function </span><a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sv_init">sv_init</a>()<br /><span class="line"><a name="3540" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3540">3540</a> </span>{<span class="line"><a name="3541" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3541"></a></span><br /></pre></blockquote><br />Notice that Source2 is an <b>Object</b>, while Source is a <b>BasicOView</b>. As what I usually do, I first scan the code for possible candidates of the key methods that I am looking for, and these two methods caught my attention.<br /><blockquote><pre lang="en"><span class="line"><a name="3040" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3040"></a></span><a name="3040" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3040"><span class="line"></span></a><a name="3040" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3040">3040</a> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=console">console</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=views">views</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=source2">source2</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=loadSourceTextAtIndex">loadSourceTextAtIndex</a> =<br /><span class="line"><a name="3041" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3041">3041</a> </span><span class="verb">function </span><a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=s2v_loadsource">s2v_loadsource</a> (<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceText">sourceText</a>, <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=index">index</a>)<br /><span class="line"><a name="3042" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3042">3042</a> </span>{<br /><span class="line"><a name="3043" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3043">3043</a> </span> <span class="verb">var </span><a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceTab">sourceTab</a>;<br /><span class="line"><a name="3044" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3044">3044</a> </span> <br /><span class="line"><a name="3045" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3045">3045</a> </span> <span class="verb">if </span>(<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=index">index</a> <span class="atom">in</span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=this">this</a>.<span class="atom">sourceTabList</span>)<br /><span class="line"><a name="3046" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3046">3046</a> </span> {<br /><span class="line"><a name="3047" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3047">3047</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceTab">sourceTab</a> = <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=this">this</a>.<span class="atom">sourceTabList</span>[<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=index">index</a>];<br /><span class="line"><a name="3048" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3048">3048</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceTab">sourceTab</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=content">content</a> = <span class="verb">null;</span><br /><span class="line"><a name="3049" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3049">3049</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceTab">sourceTab</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceText">sourceText</a> = <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceText">sourceText</a>;<br /><span class="line"><a name="3050" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3050">3050</a> </span> <br /><span class="line"><a name="3051" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3051">3051</a> </span> <span class="verb">if </span>(<span class="string">"currentContent"</span> <span class="atom">in</span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=this">this</a>)<br /><span class="line"><a name="3052" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3052">3052</a> </span> {<br /><span class="line"><a name="3053" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3053">3053</a> </span> <span class="verb">if </span>(!<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=ASSERT">ASSERT</a>(<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceTab">sourceTab</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=tab">tab</a>,<br /><span class="line"><a name="3054" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3054">3054</a> </span> <span class="string">"existing sourcetab not fully initialized"</span>))<br /><span class="line"><a name="3055" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3055">3055</a> </span> {<br /><span class="line"><a name="3056" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3056">3056</a> </span> <span class="verb">return </span><span class="verb">null;</span><br /><span class="line"><a name="3057" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3057">3057</a> </span> }<br /><span class="line"><a name="3058" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3058">3058</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceTab">sourceTab</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=tab">tab</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=label">label</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=setAttribute">setAttribute</a>(<span class="string">"value"</span>, <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceText">sourceText</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=shortName">shortName</a>);<br /><span class="line"><a name="3059" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3059">3059</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceTab">sourceTab</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=iframe">iframe</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=setAttribute">setAttribute</a>(<span class="string">"targetSrc"</span>, <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceText">sourceText</a>.<span class="atom">jsdURL</span>);<br /><span class="line"><a name="3060" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3060">3060</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceTab">sourceTab</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=iframe">iframe</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=setAttribute">setAttribute</a>(<span class="string">"raiseOnSync"</span>, <span class="string">"true"</span>);<br /><span class="line"><a name="3061" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3061">3061</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=this">this</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=syncOutputFrame">syncOutputFrame</a>(<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceTab">sourceTab</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=iframe">iframe</a>);<br /><span class="line"><a name="3062" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3062">3062</a> </span> }<br /><span class="line"><a name="3063" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3063">3063</a> </span> <br /><span class="line"><a name="3064" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3064">3064</a> </span> }<br /><span class="line"><a name="3065" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3065">3065</a> </span> <span class="verb">else</span><br /><span class="line"><a name="3066" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3066">3066</a> </span> {<br /><span class="line"><a name="3067" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3067">3067</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceTab">sourceTab</a> = {<br /><span class="line"><a name="3068" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3068">3068</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceText">sourceText</a>: <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceText">sourceText</a>,<br /><span class="line"><a name="3069" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3069">3069</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=tab">tab</a>: <span class="verb">null,</span><br /><span class="line"><a name="3070" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3070">3070</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=iframe">iframe</a>: <span class="verb">null,</span><br /><span class="line"><a name="3071" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3071">3071</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=content">content</a>: <span class="verb">null</span><br /><span class="line"><a name="3072" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3072">3072</a> </span> };<br /><span class="line"><a name="3073" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3073">3073</a> </span><br /><span class="line"><a name="3074" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3074">3074</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=this">this</a>.<span class="atom">sourceTabList</span>[<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=index">index</a>] = <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceTab">sourceTab</a>;<br /><span class="line"><a name="3075" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3075">3075</a> </span> <br /><span class="line"><a name="3076" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3076">3076</a> </span> <span class="verb">if </span>(<span class="string">"currentContent"</span> <span class="atom">in</span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=this">this</a>)<br /><span class="line"><a name="3077" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3077">3077</a> </span> {<br /><span class="line"><a name="3078" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3078">3078</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=this">this</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=createFrameFor">createFrameFor</a>(<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceTab">sourceTab</a>, <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=index">index</a>, <span class="verb">true)</span>;<br /><span class="line"><a name="3079" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3079">3079</a> </span> }<br /><span class="line"><a name="3080" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3080">3080</a> </span> }<br /><span class="line"><a name="3081" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3081">3081</a> </span><br /><span class="line"><a name="3082" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3082">3082</a> </span> <span class="verb">return </span><a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceTab">sourceTab</a>;<br /><span class="line"><a name="3083" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3083">3083</a> </span>}<span class="line"><a name="3040" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3040"></a></span></pre></blockquote><blockquote><pre lang="en"><span class="line"><a name="3085" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3085">3085</a> </span><a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=console">console</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=views">views</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=source2">source2</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=addSourceText">addSourceText</a> =<br /><span class="line"><a name="3086" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3086">3086</a> </span><span class="verb">function </span><a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=s2v_addsource">s2v_addsource</a> (<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceText">sourceText</a>)<br /><span class="line"><a name="3087" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3087">3087</a> </span>{</pre></blockquote><br /><b>addSourceText</b> calls <b>loadSourceTextAtIndex</b> to load a specific javascript source into <b>source2</b>'s tabbed source views. <b>addSourceText</b> function will just happily take the <b>sourceText</b>, and stash it into a tab ;-) Great, the sourceText explains it all! (Grrr...) So what the heck is <b>sourceText</b>? For a while, I thought it was real string, but I quickly had an impression that I am wrong, because strings are not smart enough to be displayed into a <b>xultree</b>. So who calls the <b>addSourceText</b>? I dig on...<br /><blockquote><pre lang="en"><span class="line"><a name="3456" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3456">3456</a> </span><a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=console">console</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=views">views</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=source2">source2</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=hooks">hooks</a>[<span class="string">"hook-display-sourcetext"</span>] =<br /><span class="line"><a name="3457" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3457">3457</a> </span><a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=console">console</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=views">views</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=source2">source2</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=hooks">hooks</a>[<span class="string">"hook-display-sourcetext-soft"</span>] =<br /><span class="line"><a name="3458" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3458">3458</a> </span><span class="verb">function </span><a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=s2v_hookDisplay">s2v_hookDisplay</a> (<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=e">e</a>)<br /><span class="line"><a name="3459" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3459">3459</a> </span>{<br /><span class="line"><a name="3460" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3460">3460</a> </span> <span class="verb">var </span><a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=source2View">source2View</a> = <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=console">console</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=views">views</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=source2">source2</a>;<br /><span class="line"><a name="3461" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3461">3461</a> </span><br /><span class="line"><a name="3462" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3462">3462</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=source2View">source2View</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=unmarkHighlight">unmarkHighlight</a>();<br /><span class="line"><a name="3463" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3463">3463</a> </span> <br /><span class="line"><a name="3464" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3464">3464</a> </span> <span class="verb">var </span><a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceTab">sourceTab</a> = <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=source2View">source2View</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=addSourceText">addSourceText</a> (<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=e">e</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceText">sourceText</a>);<br /><span class="line"><a name="3465" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3465">3465</a> </span> <span class="verb">if </span>(<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=e">e</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=rangeStart">rangeStart</a>)<br /><span class="line"><a name="3466" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3466">3466</a> </span> {<br /><span class="line"><a name="3467" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3467">3467</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=source2View">source2View</a>.<span class="atom">highlightStart</span> = <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=e">e</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=rangeStart">rangeStart</a>;<br /><span class="line"><a name="3468" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3468">3468</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=source2View">source2View</a>.<span class="atom">highlightEnd</span> = <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=e">e</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=rangeEnd">rangeEnd</a>;<br /><span class="line"><a name="3469" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3469">3469</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=source2View">source2View</a>.<span class="atom">highlightTab</span> = <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceTab">sourceTab</a>;<br /><span class="line"><a name="3470" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3470">3470</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=source2View">source2View</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=markHighlight">markHighlight</a>();<br /><span class="line"><a name="3471" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3471">3471</a> </span> }<br /><span class="line"><a name="3472" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3472">3472</a> </span> <br /><span class="line"><a name="3473" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3473">3473</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=source2View">source2View</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=scrollTabTo">scrollTabTo</a> (<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceTab">sourceTab</a>, <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=e">e</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=targetLine">targetLine</a>, 0);<br /><span class="line"><a name="3474" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3474">3474</a> </span>}</pre></blockquote>So it is hooked by an event, which contains its own <b>sourceText</b>. OK, so what exactly does sourceText contain? I couldn't just do a find, since there are too many occurrence of <b>sourceText</b> in the code. Before I give it up for the day, I decided to have a close look at the <b>source2</b> code, and guess what I found in the following function!<br /><blockquote><pre lang="en"><span class="line"><a name="2466" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2466">2466</a> </span><a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=console">console</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=views">views</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=source2">source2</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=getContext">getContext</a> =<br /><span class="line"><a name="2467" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2467">2467</a> </span><span class="verb">function </span><a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=s2v_getcontext">s2v_getcontext</a> (<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=cx">cx</a>)<br /><span class="line"><a name="2468" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2468">2468</a> </span>{<br /><span class="line"><a name="2469" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2469">2469</a> </span> <span class="verb">var </span><a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=source2View">source2View</a> = <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=console">console</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=views">views</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=source2">source2</a>;<br /><span class="line"><a name="2470" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2470">2470</a> </span> <br /><span class="line"><a name="2471" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2471">2471</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=cx">cx</a>.<span class="atom">lineIsExecutable</span> = <span class="verb">false;</span><br /><span class="line"><a name="2472" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2472">2472</a> </span> <span class="verb">var </span><a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceText">sourceText</a>;<br /><span class="line"><a name="2473" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2473">2473</a> </span><br /><span class="line"><a name="2474" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2474">2474</a> </span> <span class="verb">if </span>(<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=document">document</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=popupNode">popupNode</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=localName">localName</a> == <span class="string">"tab"</span>)<br /><span class="line"><a name="2475" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2475">2475</a> </span> {<br /><span class="line"><a name="2476" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2476">2476</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=cx">cx</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=index">index</a> = <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=source2View">source2View</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=getIndexOfTab">getIndexOfTab</a>(<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=document">document</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=popupNode">popupNode</a>);<br /><span class="line"><a name="2477" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2477">2477</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceText">sourceText</a> = <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=source2View">source2View</a>.<span class="atom">sourceTabList</span>[<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=cx">cx</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=index">index</a>].<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceText">sourceText</a>;<br /><span class="line"><a name="2478" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2478">2478</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=cx">cx</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=url">url</a> = <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=cx">cx</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=urlPattern">urlPattern</a> = <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceText">sourceText</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=url">url</a>;<br /><span class="line"><a name="2479" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2479">2479</a> </span> }<br /><span class="line"><a name="2480" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2480">2480</a> </span> <span class="verb">else</span><br /><span class="line"><a name="2481" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2481">2481</a> </span> {<br /><span class="line"><a name="2482" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2482">2482</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=cx">cx</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=index">index</a> = <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=source2View">source2View</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=tabs">tabs</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=selectedIndex">selectedIndex</a>;<br /><span class="line"><a name="2483" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2483">2483</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceText">sourceText</a> = <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=source2View">source2View</a>.<span class="atom">sourceTabList</span>[<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=cx">cx</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=index">index</a>].<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceText">sourceText</a>;<br /><span class="line"><a name="2484" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2484">2484</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=cx">cx</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=url">url</a> = <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=cx">cx</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=urlPattern">urlPattern</a> = <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceText">sourceText</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=url">url</a>;<br /><span class="line"><a name="2485" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2485">2485</a> </span><br /><span class="line"><a name="2486" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2486">2486</a> </span> <span class="verb">var </span><a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=target">target</a> = <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=document">document</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=popupNode">popupNode</a>;<br /><span class="line"><a name="2487" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2487">2487</a> </span> <span class="verb">while </span>(<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=target">target</a>)<br /><span class="line"><a name="2488" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2488">2488</a> </span> {<br /><span class="line"><a name="2489" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2489">2489</a> </span> <span class="verb">if </span>(<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=target">target</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=localName">localName</a> == <span class="string">"line"</span>)<br /><span class="line"><a name="2490" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2490">2490</a> </span> <span class="verb">break;</span><br /><span class="line"><a name="2491" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2491">2491</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=target">target</a> = <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=target">target</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=parentNode">parentNode</a>;<br /><span class="line"><a name="2492" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2492">2492</a> </span> }<br /><span class="line"><a name="2493" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2493">2493</a> </span><br /><span class="line"><a name="2494" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2494">2494</a> </span> <span class="verb">if </span>(<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=target">target</a>)<br /><span class="line"><a name="2495" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2495">2495</a> </span> {<br /><span class="line"><a name="2496" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2496">2496</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=cx">cx</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=lineNumber">lineNumber</a> = <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=parseInt">parseInt</a>(<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=target">target</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=childNodes">childNodes</a>[1].<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=firstChild">firstChild</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=data">data</a>);<br /><span class="line"><a name="2497" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2497">2497</a> </span><br /><span class="line"><a name="2498" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2498">2498</a> </span> <span class="verb">var </span><a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=row">row</a> = <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=cx">cx</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=lineNumber">lineNumber</a> - 1;<br /><span class="line"><a name="2499" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2499">2499</a> </span><br /><span class="line"><a name="2500" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2500">2500</a> </span> <span class="verb">if </span>(<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceText">sourceText</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=lineMap">lineMap</a> && <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceText">sourceText</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=lineMap">lineMap</a>[<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=row">row</a>] & <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=LINE_BREAKABLE">LINE_BREAKABLE</a>)<br /><span class="line"><a name="2501" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2501">2501</a> </span> {<br /><span class="line"><a name="2502" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2502">2502</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=cx">cx</a>.<span class="atom">lineIsExecutable</span> = <span class="verb">true;</span><br /><span class="line"><a name="2503" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2503">2503</a> </span> <span class="verb">if </span>(<span class="string">"scriptInstance"</span> <span class="atom">in</span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceText">sourceText</a>)<br /><span class="line"><a name="2504" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2504">2504</a> </span> {<br /><span class="line"><a name="2505" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2505">2505</a> </span> <span class="verb">var </span><a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=scriptInstance">scriptInstance</a> = <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceText">sourceText</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=scriptInstance">scriptInstance</a>;<br /><span class="line"><a name="2506" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2506">2506</a> </span> <span class="verb">var </span><a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=scriptWrapper">scriptWrapper</a> =<br /><span class="line"><a name="2507" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2507">2507</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=scriptInstance">scriptInstance</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=getScriptWrapperAtLine">getScriptWrapperAtLine</a>(<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=cx">cx</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=lineNumber">lineNumber</a>);<br /><span class="line"><a name="2508" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2508">2508</a> </span> <span class="verb">if </span>(<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=scriptWrapper">scriptWrapper</a> && <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=scriptWrapper">scriptWrapper</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=jsdScript">jsdScript</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=isValid">isValid</a>)<br /><span class="line"><a name="2509" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2509">2509</a> </span> {<br /><span class="line"><a name="2510" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2510">2510</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=cx">cx</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=scriptWrapper">scriptWrapper</a> = <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=scriptWrapper">scriptWrapper</a>;<br /><span class="line"><a name="2511" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2511">2511</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=cx">cx</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=pc">pc</a> =<br /><span class="line"><a name="2512" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2512">2512</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=scriptWrapper">scriptWrapper</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=jsdScript">jsdScript</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=lineToPc">lineToPc</a>(<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=cx">cx</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=lineNumber">lineNumber</a>,<br /><span class="line"><a name="2513" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2513">2513</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=PCMAP_SOURCETEXT">PCMAP_SOURCETEXT</a>);<br /><span class="line"><a name="2514" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2514">2514</a> </span> }<br /><span class="line"><a name="2515" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2515">2515</a> </span> }<br /><span class="line"><a name="2516" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2516">2516</a> </span> <span class="verb">else </span><span class="verb">if </span>(<span class="string">"scriptWrapper"</span> <span class="atom">in</span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceText">sourceText</a> &&<br /><span class="line"><a name="2517" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2517">2517</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceText">sourceText</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=scriptWrapper">scriptWrapper</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=jsdScript">jsdScript</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=isValid">isValid</a>)<br /><span class="line"><a name="2518" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2518">2518</a> </span> {<br /><span class="line"><a name="2519" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2519">2519</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=cx">cx</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=scriptWrapper">scriptWrapper</a> = <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceText">sourceText</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=scriptWrapper">scriptWrapper</a>;<br /><span class="line"><a name="2520" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2520">2520</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=cx">cx</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=pc">pc</a> =<br /><span class="line"><a name="2521" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2521">2521</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=cx">cx</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=scriptWrapper">scriptWrapper</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=jsdScript">jsdScript</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=lineToPc">lineToPc</a>(<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=cx">cx</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=lineNumber">lineNumber</a>,<br /><span class="line"><a name="2522" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2522">2522</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=PCMAP_PRETTYPRINT">PCMAP_PRETTYPRINT</a>);<br /><span class="line"><a name="2523" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2523">2523</a> </span> }<br /><span class="line"><a name="2524" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2524">2524</a> </span> }<br /><span class="line"><a name="2525" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2525">2525</a> </span> <br /><span class="line"><a name="2526" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2526">2526</a> </span> <span class="verb">if </span>(<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceText">sourceText</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=lineMap">lineMap</a> && <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceText">sourceText</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=lineMap">lineMap</a>[<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=row">row</a>] & <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=LINE_BREAK">LINE_BREAK</a>)<br /><span class="line"><a name="2527" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2527">2527</a> </span> {<br /><span class="line"><a name="2528" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2528">2528</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=cx">cx</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=hasBreak">hasBreak</a> = <span class="verb">true;</span><br /><span class="line"><a name="2529" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2529">2529</a> </span> <span class="verb">if </span>(<span class="string">"scriptInstance"</span> <span class="atom">in</span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceText">sourceText</a>)<br /><span class="line"><a name="2530" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2530">2530</a> </span> {<br /><span class="line"><a name="2531" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2531">2531</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=cx">cx</a>.<span class="atom">breakWrapper</span> =<br /><span class="line"><a name="2532" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2532">2532</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceText">sourceText</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=scriptInstance">scriptInstance</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=getBreakpoint">getBreakpoint</a>(<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=cx">cx</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=lineNumber">lineNumber</a>);<br /><span class="line"><a name="2533" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2533">2533</a> </span> }<br /><span class="line"><a name="2534" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2534">2534</a> </span> <span class="verb">else </span><span class="verb">if </span>(<span class="string">"scriptWrapper"</span> <span class="atom">in</span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceText">sourceText</a> && <span class="string">"pc"</span> <span class="atom">in</span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=cx">cx</a>)<br /><span class="line"><a name="2535" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2535">2535</a> </span> {<br /><span class="line"><a name="2536" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2536">2536</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=cx">cx</a>.<span class="atom">breakWrapper</span> =<br /><span class="line"><a name="2537" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2537">2537</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceText">sourceText</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=scriptWrapper">scriptWrapper</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=getBreakpoint">getBreakpoint</a>(<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=cx">cx</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=pc">pc</a>);<br /><span class="line"><a name="2538" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2538">2538</a> </span> }<br /><span class="line"><a name="2539" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2539">2539</a> </span> <br /><span class="line"><a name="2540" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2540">2540</a> </span> <span class="verb">if </span>(<span class="string">"breakWrapper"</span> <span class="atom">in</span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=cx">cx</a> && <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=cx">cx</a>.<span class="atom">breakWrapper</span>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=parentBP">parentBP</a>)<br /><span class="line"><a name="2541" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2541">2541</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=cx">cx</a>.<span class="atom">hasFBreak</span> = <span class="verb">true;</span><br /><span class="line"><a name="2542" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2542">2542</a> </span> }<br /><span class="line"><a name="2543" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2543">2543</a> </span> <span class="verb">else </span><span class="verb">if </span>(<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceText">sourceText</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=lineMap">lineMap</a> && <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceText">sourceText</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=lineMap">lineMap</a>[<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=row">row</a>] & <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=LINE_FBREAK">LINE_FBREAK</a>)<br /><span class="line"><a name="2544" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2544">2544</a> </span> {<br /><span class="line"><a name="2545" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2545">2545</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=cx">cx</a>.<span class="atom">hasFBreak</span> = <span class="verb">true;</span><br /><span class="line"><a name="2546" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2546">2546</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=cx">cx</a>.<span class="atom">breakWrapper</span> = <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=getFutureBreakpoint">getFutureBreakpoint</a>(<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=cx">cx</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=url">url</a>, <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=cx">cx</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=lineNumber">lineNumber</a>);<br /><span class="line"><a name="2547" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2547">2547</a> </span> }<br /><span class="line"><a name="2548" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2548">2548</a> </span> }<br /><span class="line"><a name="2549" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2549">2549</a> </span> } <br /><span class="line"><a name="2550" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2550">2550</a> </span> <br /><span class="line"><a name="2551" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2551">2551</a> </span> <span class="verb">return </span><a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=cx">cx</a>;<br /><span class="line"><a name="2552" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2552">2552</a> </span>}</pre></blockquote><b>getContext</b> is probably written for getting the right context menu. User got to right click on the script for it to show up, right? Hum... for a different line, say having a break point or not, it should probably show a different menu item. Therefore, it's gotta have something to do with the real <b>sourceText</b>! The code confirmed my theory! Line 2500 showed it all "<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceText">sourceText</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=lineMap">lineMap</a>[<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=row">row</a>]". So it contains an attribute called <b>lineMap</b>, and <b>lineMap</b> contains the mapping of line number and actual code for this line!!! This is all cool, but still does explain how it is populated in the xultree... ;-( Oh, wait! Something else caught my attention... The checking of <b>sourceText</b> is to see if it conains a <b>scriptInstance</b> at line 2503, and or a <b>scriptWrapper</b> at line 2516<br /><blockquote><pre lang="en"><span class="string">"scriptInstance"</span> <span class="atom">in</span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceText">sourceText</a><br /><br /><span class="string">"scriptWrapper"</span> <span class="atom">in</span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceText">sourceText</a><br /></pre> </blockquote>leads me to believe that somehow, one of them or both of them are important when it comes to xultree.<br /><br />Just a little side track, I found out that <b>scriptWrapper</b> is less than <b>scriptInstance</b>.<br /><blockquote><pre lang="en"><span class="line"><a name="2506" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2506">2506</a> </span> <span class="verb">var </span><a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=scriptWrapper">scriptWrapper</a> =<br /><span class="line"><a name="2507" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2507">2507</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=scriptInstance">scriptInstance</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=getScriptWrapperAtLine">getScriptWrapperAtLine</a>(<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=cx">cx</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=lineNumber">lineNumber</a>);</pre> </blockquote> Now I recall that I have read something about <b>scriptWrapper</b> and <b>scriptInstance</b> in the mozilla development wiki.<br /><blockquote><a title="http://developer.mozilla.org/en/docs/Venkman_Internals#ScriptWrapper" href="http://developer.mozilla.org/en/docs/Venkman_Internals#ScriptWrapper" id="zclw">http://developer.mozilla.org/en/docs/Venkman_Internals#ScriptWrapper</a> </blockquote>And this led me to <a title="http://lxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-debugger.js#914" href="http://lxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-debugger.js#914" id="wgvo">http://lxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-debugger.js#914</a>. The above document explains pretty clearly how scriptWrapper works. ;-) With the pointed out source, it's even more clear. So I will just continue to move on to my quest... How did the script get to be loaded inside a xultree.<br /><br />I have a feeling that I dug a little too deep, and I must have missed something, since I am already down to the <b>scriptWrapper</b> level, which has already passed the point where the scripts are actually being loaded, so I went back to the declaration of the <b>source2</b>. This time, in detail... and I easy spotted out this array.<br /><blockquote><pre lang="en"><span class="line"><a name="2248" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2248">2248</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=this">this</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=cmdary">cmdary</a> =<br /><span class="line"><a name="2249" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2249">2249</a> </span> [<br /><span class="line"><a name="2250" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2250">2250</a> </span> [<span class="string">"close-source-tab"</span>, <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=cmdCloseTab">cmdCloseTab</a>, <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=CMD_CONSOLE">CMD_CONSOLE</a>],<br /><span class="line"><a name="2251" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2251">2251</a> </span> [<span class="string">"find-string"</span>, <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=cmdFindString">cmdFindString</a>, <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=CMD_CONSOLE">CMD_CONSOLE</a>],<br /><span class="line"><a name="2252" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2252">2252</a> </span> [<span class="string">"save-source-tab"</span>, <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=cmdSaveTab">cmdSaveTab</a>, <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=CMD_CONSOLE">CMD_CONSOLE</a>],<br /><span class="line"><a name="2253" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2253">2253</a> </span> [<span class="string">"reload-source-tab"</span>, <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=cmdReloadTab">cmdReloadTab</a>, <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=CMD_CONSOLE">CMD_CONSOLE</a>],<br /><span class="line"><a name="2254" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2254">2254</a> </span> [<span class="string">"source-coloring"</span>, <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=cmdToggleColoring">cmdToggleColoring</a>, 0],<br /><span class="line"><a name="2255" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2255">2255</a> </span> [<span class="string">"toggle-source-coloring"</span>, <span class="string">"source-coloring toggle"</span>, 0]<br /><span class="line"><a name="2256" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#2256">2256</a> </span> ];</pre></blockquote>Notice the command that's called "reload-source-tab", and there is no command called "load-source-tab" ;-) Well, I don't quite care how come there isn't a "load-source-tab" method, as long as the "reload-source-tab" tells me how it is done, I will be happy ;-)<br /><br />So I looked up <b>cmdReloadTab</b>, and in the very end of the function, I saw<br /><blockquote><pre lang="en"><a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceTab">sourceTab</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceText">sourceText</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=reloadSource">reloadSource</a>(<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=cb">cb</a>);</pre></blockquote>Well, we are back at <b>sourceText</b> again. ;-( Maybe we over looked at this eariler. Time to check out the <b>sourceText</b>. I tried and tried, I suddenly got use to using the mxr site, and found out how to find a function's declaration. Looking up code is becoming a breeze for me now. ;-)<br /><br />Without much effort, I found the right SourceText's declaration in venkman-static.js. It is truly the starting point of the venkman ;-) (The all mighty <b>console</b> object is declared there ;-))<br /><blockquote><pre lang="en"><span class="line"><a name="1108" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1108">1108</a> </span><span class="verb">function </span><a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=SourceText">SourceText</a> (<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=scriptInstance">scriptInstance</a>)<br /><span class="line"><a name="1109" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1109">1109</a> </span>{</pre></blockquote>Of course, there is the<br /><blockquote><pre lang="en"><span class="line"><a name="1191" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1191">1191</a> </span><a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=SourceText">SourceText</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=prototype">prototype</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=reloadSource">reloadSource</a> =<br /><span class="line"><a name="1192" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1192">1192</a> </span><span class="verb">function </span><a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=st_reloadsrc">st_reloadsrc</a> (<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=cb">cb</a>)<br /><span class="line"><a name="1193" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1193">1193</a> </span>{</pre></blockquote>Which calls<br /><blockquote><pre lang="en"><span class="line"><a name="1313" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1313">1313</a> </span><a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=SourceText">SourceText</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=prototype">prototype</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=loadSource">loadSource</a> =<br /><span class="line"><a name="1314" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1314">1314</a> </span><span class="verb">function </span><a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=st_loadsrc">st_loadsrc</a> (<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=cb">cb</a>)<br /><span class="line"><a name="1315" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1315">1315</a> </span>{<br /><span class="line"><a name="1316" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1316">1316</a> </span> <span class="verb">var </span><a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceText">sourceText</a> = <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=this">this</a>;<br /><span class="line"><a name="1317" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1317">1317</a> </span> <br /><span class="line"><a name="1318" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1318">1318</a> </span> <span class="verb">function </span><a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=onComplete">onComplete</a> (<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=data">data</a>, <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=url">url</a>, <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=status">status</a>)<br /><span class="line"><a name="1319" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1319">1319</a> </span> {<br /><span class="line"><a name="1320" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1320">1320</a> </span> <span class="comment">//dd ("loaded " + url + " with status " + status + "n" + data);</span><br /><span class="line"><a name="1321" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1321">1321</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceText">sourceText</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=onSourceLoaded">onSourceLoaded</a> (<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=data">data</a>, <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=url">url</a>, <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=status">status</a>);<br /><span class="line"><a name="1322" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1322">1322</a> </span> };<br /><span class="line"><a name="1323" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1323">1323</a> </span><br /><span class="line"><a name="1324" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1324">1324</a> </span> <span class="verb">if </span>(<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=this">this</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=isLoaded">isLoaded</a>)<br /><span class="line"><a name="1325" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1325">1325</a> </span> {<br /><span class="line"><a name="1326" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1326">1326</a> </span> <span class="comment">/* if we're loaded, callback right now, and return. */</span><br /><span class="line"><a name="1327" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1327">1327</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=cb">cb</a> (<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=Components">Components</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=results">results</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=NS_OK">NS_OK</a>);<br /><span class="line"><a name="1328" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1328">1328</a> </span> <span class="verb">return;</span><br /><span class="line"><a name="1329" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1329">1329</a> </span> }<br /><span class="line"><a name="1330" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1330">1330</a> </span><br /><span class="line"><a name="1331" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1331">1331</a> </span> <span class="verb">if </span>(<span class="string">"isLoading"</span> <span class="atom">in</span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=this">this</a>)<br /><span class="line"><a name="1332" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1332">1332</a> </span> {<br /><span class="line"><a name="1333" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1333">1333</a> </span> <span class="comment">/* if we're in the process of loading, make a note of the callback, and</span><br /><span class="line"><a name="1334" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1334">1334</a> </span><span class="comment"> * return. */</span><br /><span class="line"><a name="1335" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1335">1335</a> </span> <span class="verb">if </span>(<span class="verb">typeof </span><a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=cb">cb</a> == <span class="string">"function"</span>)<br /><span class="line"><a name="1336" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1336">1336</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=this">this</a>.<span class="atom">loadCallbacks</span>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=push">push</a> (<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=cb">cb</a>);<br /><span class="line"><a name="1337" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1337">1337</a> </span> <span class="verb">return;</span><br /><span class="line"><a name="1338" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1338">1338</a> </span> }<br /><span class="line"><a name="1339" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1339">1339</a> </span> <span class="verb">else</span><br /><span class="line"><a name="1340" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1340">1340</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=this">this</a>.<span class="atom">loadCallbacks</span> = <span class="verb">new </span><a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=Array">Array</a>();<br /><span class="line"><a name="1341" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1341">1341</a> </span><br /><span class="line"><a name="1342" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1342">1342</a> </span> <span class="verb">if </span>(<span class="verb">typeof </span><a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=cb">cb</a> == <span class="string">"function"</span>)<br /><span class="line"><a name="1343" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1343">1343</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=this">this</a>.<span class="atom">loadCallbacks</span>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=push">push</a> (<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=cb">cb</a>);<br /><span class="line"><a name="1344" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1344">1344</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=this">this</a>.<span class="atom">isLoading</span> = <span class="verb">true;</span> <br /><span class="line"><a name="1345" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1345">1345</a> </span> <br /><span class="line"><a name="1346" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1346">1346</a> </span> <span class="verb">var </span><a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=ex">ex</a>;<br /><span class="line"><a name="1347" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1347">1347</a> </span> <span class="verb">var </span><a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=src">src</a>;<br /><span class="line"><a name="1348" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1348">1348</a> </span> <span class="verb">var </span><a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=url">url</a> = <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=this">this</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=url">url</a>;<br /><span class="line"><a name="1349" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1349">1349</a> </span> <span class="verb">if </span>(<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=url">url</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=search">search</a> (/^<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=javascript">javascript</a>:/<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=i">i</a>) == 0)<br /><span class="line"><a name="1350" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1350">1350</a> </span> {<br /><span class="line"><a name="1351" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1351">1351</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=src">src</a> = <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=url">url</a>;<br /><span class="line"><a name="1352" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1352">1352</a> </span> <span class="verb">delete </span><a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=this">this</a>.<span class="atom">isLoading</span>;<br /><span class="line"><a name="1353" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1353">1353</a> </span> }<br /><span class="line"><a name="1354" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1354">1354</a> </span> <span class="verb">else</span><br /><span class="line"><a name="1355" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1355">1355</a> </span> {<br /><span class="line"><a name="1356" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1356">1356</a> </span> <span class="verb">try</span><br /><span class="line"><a name="1357" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1357">1357</a> </span> {<br /><span class="line"><a name="1358" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1358">1358</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=loadURLAsync">loadURLAsync</a> (<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=url">url</a>, { <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=onComplete">onComplete</a>: <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=onComplete">onComplete</a> });<br /><span class="line"><a name="1359" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1359">1359</a> </span> <span class="verb">return;</span><br /><span class="line"><a name="1360" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1360">1360</a> </span> }<br /><span class="line"><a name="1361" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1361">1361</a> </span> <span class="verb">catch </span>(<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=ex">ex</a>)<br /><span class="line"><a name="1362" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1362">1362</a> </span> {<br /><span class="line"><a name="1363" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1363">1363</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=display">display</a> (<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=getMsg">getMsg</a>(<span class="atom">MSN_ERR_SOURCE_LOAD_FAILED</span>, [<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=url">url</a>, <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=ex">ex</a>]), <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=MT_ERROR">MT_ERROR</a>);<br /><span class="line"><a name="1364" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1364">1364</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=onComplete">onComplete</a> (<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=src">src</a>, <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=url">url</a>, <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=Components">Components</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=results">results</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=NS_ERROR_FAILURE">NS_ERROR_FAILURE</a>);<br /><span class="line"><a name="1365" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1365">1365</a> </span> <span class="verb">return;</span><br /><span class="line"><a name="1366" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1366">1366</a> </span> }<br /><span class="line"><a name="1367" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1367">1367</a> </span> }<br /><span class="line"><a name="1368" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1368">1368</a> </span><br /><span class="line"><a name="1369" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1369">1369</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=onComplete">onComplete</a> (<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=src">src</a>, <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=url">url</a>, <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=Components">Components</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=results">results</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=NS_OK">NS_OK</a>);<br /><span class="line"><a name="1370" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1370">1370</a> </span>}</pre></blockquote>Great! see the critical function <b>loadURLAsync</b>? Oh, well, before I dig too deep and get so excited about not too closely related code again, I did also see the call back of <b>onComplete</b>. It turns out that onComplete did the dirty work of parsing the scripts by line and pack them into <b>sourceText.lines</b>.<br /><blockquote><pre lang="en"><span class="line"><a name="1207" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1207">1207</a> </span><a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=SourceText">SourceText</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=prototype">prototype</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=onSourceLoaded">onSourceLoaded</a> =<br /><span class="line"><a name="1208" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1208">1208</a> </span><span class="verb">function </span><a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=st_oncomplete">st_oncomplete</a> (<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=data">data</a>, <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=url">url</a>, <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=status">status</a>)<br /><span class="line"><a name="1209" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1209">1209</a> </span>{<br />...<br /><span class="line"><a name="1267" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1267">1267</a> </span> <span class="verb">var </span><a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=ary">ary</a> = <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=data">data</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=split">split</a>(/<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=r">r</a><a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=n">n</a>|<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=n">n</a>|<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=r">r</a>/<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=m">m</a>); <br /><span class="line"><a name="1268" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1268">1268</a> </span><span class="line"><br />...<a name="1269" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1269"></a></span><br /><span class="line"><a name="1287" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1287">1287</a> </span> <br /><span class="line"><a name="1288" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-static.js#1288">1288</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=this">this</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=lines">lines</a> = <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=ary">ary</a>;<br />...<br /></pre></blockquote>Hum... How come no trace of xultree is found? This leads me to believe that my assumption is wrong. I went back and scan through all of the code that I have just looked, and arrived back at<br /><blockquote><pre lang="en"><span class="line"><a name="3040" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3040">3040</a> </span><a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=console">console</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=views">views</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=source2">source2</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=loadSourceTextAtIndex">loadSourceTextAtIndex</a> =<br /><span class="line"><a name="3041" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3041">3041</a> </span><span class="verb">function </span><a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=s2v_loadsource">s2v_loadsource</a> (<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceText">sourceText</a>, <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=index">index</a>)<br /><span class="line"><a name="3042" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3042">3042</a> </span>{<br /><span class="line"><a name="3043" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3043">3043</a> </span> <span class="verb">var </span><a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceTab">sourceTab</a>;<br /><span class="line"><a name="3044" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3044">3044</a> </span> <br /><span class="line"><a name="3045" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3045">3045</a> </span> <span class="verb">if </span>(<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=index">index</a> <span class="atom">in</span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=this">this</a>.<span class="atom">sourceTabList</span>)<br /><span class="line"><a name="3046" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3046">3046</a> </span> {<br /><span class="line"><a name="3047" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3047">3047</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceTab">sourceTab</a> = <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=this">this</a>.<span class="atom">sourceTabList</span>[<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=index">index</a>];<br /><span class="line"><a name="3048" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3048">3048</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceTab">sourceTab</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=content">content</a> = <span class="verb">null;</span><br /><span class="line"><a name="3049" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3049">3049</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceTab">sourceTab</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceText">sourceText</a> = <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceText">sourceText</a>;<br /><span class="line"><a name="3050" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3050">3050</a> </span> <br /><span class="line"><a name="3051" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3051">3051</a> </span> <span class="verb">if </span>(<span class="string">"currentContent"</span> <span class="atom">in</span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=this">this</a>)<br /><span class="line"><a name="3052" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3052">3052</a> </span> {<br /><span class="line"><a name="3053" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3053">3053</a> </span> <span class="verb">if </span>(!<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=ASSERT">ASSERT</a>(<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceTab">sourceTab</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=tab">tab</a>,<br /><span class="line"><a name="3054" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3054">3054</a> </span> <span class="string">"existing sourcetab not fully initialized"</span>))<br /><span class="line"><a name="3055" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3055">3055</a> </span> {<br /><span class="line"><a name="3056" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3056">3056</a> </span> <span class="verb">return </span><span class="verb">null;</span><br /><span class="line"><a name="3057" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3057">3057</a> </span> }<br /><span class="line"><a name="3058" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3058">3058</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceTab">sourceTab</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=tab">tab</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=label">label</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=setAttribute">setAttribute</a>(<span class="string">"value"</span>, <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceText">sourceText</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=shortName">shortName</a>);<br /><span class="line"><a name="3059" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3059">3059</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceTab">sourceTab</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=iframe">iframe</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=setAttribute">setAttribute</a>(<span class="string">"targetSrc"</span>, <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceText">sourceText</a>.<span class="atom">jsdURL</span>);<br /><span class="line"><a name="3060" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3060">3060</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceTab">sourceTab</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=iframe">iframe</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=setAttribute">setAttribute</a>(<span class="string">"raiseOnSync"</span>, <span class="string">"true"</span>);<br /><span class="line"><a name="3061" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3061">3061</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=this">this</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=syncOutputFrame">syncOutputFrame</a>(<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceTab">sourceTab</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=iframe">iframe</a>);<br /><span class="line"><a name="3062" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3062">3062</a> </span> }<br /><span class="line"><a name="3063" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3063">3063</a> </span> <br /><span class="line"><a name="3064" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3064">3064</a> </span> }<br /><span class="line"><a name="3065" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3065">3065</a> </span> <span class="verb">else</span><br /><span class="line"><a name="3066" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3066">3066</a> </span> {<br /><span class="line"><a name="3067" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3067">3067</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceTab">sourceTab</a> = {<br /><span class="line"><a name="3068" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3068">3068</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceText">sourceText</a>: <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceText">sourceText</a>,<br /><span class="line"><a name="3069" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3069">3069</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=tab">tab</a>: <span class="verb">null,</span><br /><span class="line"><a name="3070" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3070">3070</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=iframe">iframe</a>: <span class="verb">null,</span><br /><span class="line"><a name="3071" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3071">3071</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=content">content</a>: <span class="verb">null</span><br /><span class="line"><a name="3072" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3072">3072</a> </span> };<br /><span class="line"><a name="3073" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3073">3073</a> </span><br /><span class="line"><a name="3074" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3074">3074</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=this">this</a>.<span class="atom">sourceTabList</span>[<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=index">index</a>] = <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceTab">sourceTab</a>;<br /><span class="line"><a name="3075" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3075">3075</a> </span> <br /><span class="line"><a name="3076" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3076">3076</a> </span> <span class="verb">if </span>(<span class="string">"currentContent"</span> <span class="atom">in</span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=this">this</a>)<br /><span class="line"><a name="3077" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3077">3077</a> </span> {<br /><span class="line"><a name="3078" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3078">3078</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=this">this</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=createFrameFor">createFrameFor</a>(<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceTab">sourceTab</a>, <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=index">index</a>, <span class="verb">true)</span>;<br /><span class="line"><a name="3079" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3079">3079</a> </span> }<br /><span class="line"><a name="3080" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3080">3080</a> </span> }<br /><span class="line"><a name="3081" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3081">3081</a> </span><br /><span class="line"><a name="3082" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3082">3082</a> </span> <span class="verb">return </span><a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceTab">sourceTab</a>;<br /><span class="line"><a name="3083" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3083">3083</a> </span>}</pre></blockquote>So this function is really trying to load source text into a tag with index defined by the index variable. If you take a closer look, you will find<br /><blockquote><pre lang="en"><span class="line"><a name="3058" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3058">3058</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceTab">sourceTab</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=tab">tab</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=label">label</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=setAttribute">setAttribute</a>(<span class="string">"value"</span>, <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceText">sourceText</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=shortName">shortName</a>);<br /><span class="line"><a name="3059" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3059">3059</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceTab">sourceTab</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=iframe">iframe</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=setAttribute">setAttribute</a>(<span class="string">"targetSrc"</span>, <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceText">sourceText</a>.<span class="atom">jsdURL</span>);<br /><span class="line"><a name="3060" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js#3060">3060</a> </span> <a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=sourceTab">sourceTab</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=iframe">iframe</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=setAttribute">setAttribute</a>(<span class="string">"raiseOnSync"</span>, <span class="string">"true"</span>);</pre> </blockquote>So it is an iframe, and the file is loaded through <b>sourceText.jsdURL</b>. So it is not an xultree like other views, but an <b>iframe</b>!!! And of cource, there are utilities to create frame<br /><blockquote><pre lang="en"><a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=console">console</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=views">views</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=source2">source2</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=createFrameFor">createFrameFor</a></pre></blockquote>and update margins<br /><blockquote><pre lang="en"><a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=console">console</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=views">views</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=source2">source2</a>.<a class="ident" href="http://mxr.mozilla.org/mozilla/ident?i=updateLineMargin">updateLineMargin</a></pre></blockquote>etc, etc. Phew... My initial xultree assumption was wrong, and it is implemented using iframe.<br /><br />Just to make the quest more complete, I am including how firebug is implementing the source text area ;-) This didn't take me nearly as long to figure out.<br /><br />in debugger.js' ScriptPanel class, you will find a function called <b>createSourceBox</b>.<blockquote>createSourceBox: function(sourceFile)<br /> {<br /> var lines = loadScriptLines(sourceFile, this.context);<br /> if (!lines)<br /> return null;<br /><br /> var maxLineNoChars = (lines.length + "").length;<br /><br /> var sourceBox = this.document.createElement("div");<br /> sourceBox.repObject = sourceFile;<br /> setClass(sourceBox, "sourceBox");<br /> collapse(sourceBox, true);<br /> this.panelNode.appendChild(sourceBox);<br /><br /> // For performance reason, append script lines in large chunks using the throttler,<br /> // otherwise displaying a large script will freeze up the UI<br /> var min = 0;<br /> do<br /> {<br /> var max = min + scriptBlockSize;<br /> if (max > lines.length)<br /> max = lines.length;<br /><br /> var args = [lines, min, max-1, maxLineNoChars, sourceBox];<br /> this.context.throttle(appendScriptLines, top, args);<br /><br /> min += scriptBlockSize;<br /> } while (max < lines.length);<br /><br /> this.context.throttle(setLineBreakpoints, top, [sourceFile, sourceBox]);<br /><br /> if (sourceFile.text)<br /> this.anonSourceBoxes.push(sourceBox);<br /> else<br /> this.sourceBoxes[sourceFile.href] = sourceBox;<br /><br /> return sourceBox;<br /> },<br /></blockquote>OK! That was a long day for me... ;-)Leihttp://www.blogger.com/profile/00550560377532133506noreply@blogger.com1tag:blogger.com,1999:blog-8847544717153629761.post-10983377119910604952008-03-10T13:40:00.000-07:002008-03-10T13:40:55.188-07:00Javascript Source View - Firebug vs VenkmanContinuing from the last post, where I foud out how Firebug's panel works, I continued to drill down, and found out how firebug's source view is implemented.<br /><br />Basically, inside the Panel, there is a standard browser, and panel is implemented using good old HTML ;-) Inside this HTML document, we have one <a> tag and one <span> tag to represent one line of loaded javascript code. The <a> tag contains the line number, and is hooked up with the debugger to enable user to set or unset break points, while the <span> tag contains the actual line of javascript code.<br /><br />Ok, that's cool, but it's not using the normal xul elements, and having a separate browser object created for each tab in the tab browser seems a little expensive to me ;-(<br /><br />That led me to question, how did the Venkman Javascript Debugger actually implemented its source view.<br /><br />It turns out that Venkman's code is extremely well organized, and it didn't take long for me to find out how it implemented the source view.<br /><br />Just search for the 'source view' in <a title="venkman-views.xul" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul" id="kcu6">venkman-views.xul</a>, and <a title="venkman-views.js" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.js" id="u8t3">venkman-views.js</a>, you will see that the script source view is actually implemented in XUL Tree!<br /><blockquote><pre lang="en"><span class="line"> <a name="163" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#163">163</a> </span> <!-- source view --><br /><span class="line"> <a name="164" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#164">164</a> </span><br /><span class="line"> <a name="165" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#165">165</a> </span> <floatingview id="source" title="&Source.label;" flex="1"><br /><span class="line"> <a name="166" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#166">166</a> </span> <vbox id="source-view-content" flex="1"><br /><span class="line"> <a name="167" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#167">167</a> </span> <toolbox><br /><span class="line"> <a name="168" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#168">168</a> </span> <toolbar id="source-header" grippytooltiptext="&SourceHeader.tip;"><br /><span class="line"> <a name="169" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#169">169</a> </span> <label id="source-url" flex="1" crop="end"/><br /><span class="line"> <a name="170" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#170">170</a> </span> </toolbar><br /><span class="line"> <a name="171" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#171">171</a> </span> </toolbox><br /><span class="line"> <a name="172" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#172">172</a> </span> <<b>tree</b> id="source-tree" flex="1" persist="width"<br /><span class="line"> <a name="173" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#173">173</a> </span> class="focusring"<br /><span class="line"> <a name="174" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#174">174</a> </span> onclick="console.views.source.onClick(event);"<br /><span class="line"> <a name="175" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#175">175</a> </span> onselect="console.views.source.onSelect(event);"<br /><span class="line"> <a name="176" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#176">176</a> </span> context="context:source"><br /><span class="line"> <a name="177" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#177">177</a> </span><br /><span class="line"> <a name="178" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#178">178</a> </span> <treecols><br /><span class="line"> <a name="179" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#179">179</a> </span> <treecol id="source:col-0" width="20px"<br /><span class="line"> <a name="180" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#180">180</a> </span> display="&SourceCol0.display;" persist="hidden width"/><br /><span class="line"> <a name="181" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#181">181</a> </span> <splitter class="tree-splitter"/><br /><span class="line"> <a name="182" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#182">182</a> </span> <treecol id="source:col-1" width="50px"<br /><span class="line"> <a name="183" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#183">183</a> </span> display="&SourceCol1.display;" persist="hidden width"/><br /><span class="line"> <a name="184" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#184">184</a> </span> <splitter class="tree-splitter"/><br /><span class="line"> <a name="185" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#185">185</a> </span> <treecol id="source:col-2" flex="1" display=""<br /><span class="line"> <a name="186" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#186">186</a> </span> ignoreincolumnpicker="true" persist="hidden width"/><br /><span class="line"> <a name="187" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#187">187</a> </span> </treecols><br /><span class="line"> <a name="188" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#188">188</a> </span><br /><span class="line"> <a name="189" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#189">189</a> </span> <treechildren id="source-tree-body"/><br /><span class="line"> <a name="190" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#190">190</a> </span><br /><span class="line"> <a name="191" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#191">191</a> </span> </<b>tree</b>><br /><span class="line"> <a name="192" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#192">192</a> </span> </vbox><br /><span class="line"> <a name="193" href="http://mxr.mozilla.org/mozilla/source/extensions/venkman/resources/content/venkman-views.xul#193">193</a> </span> </floatingview></pre></blockquote> Just for the heck of it, I wanted to see how xul tree can be implemented to represent a script source, I checked <a title="http://www.xulplanet.com/tutorials/xultu/treeview.html" href="http://www.xulplanet.com/tutorials/xultu/treeview.html" id="ty-y">http://www.xulplanet.com/tutorials/xultu/treeview.html</a>, and found out that xul tree is more like an advanced table with some of the UI tree's functionality if you choose to use them. Otherwise, we can treat it as if it is a table ;-)<br /><br />That's awesome! It is probably going to save lots more memory! I guess what I will do next is to get a tree to load source code working ;-)Leihttp://www.blogger.com/profile/00550560377532133506noreply@blogger.com0tag:blogger.com,1999:blog-8847544717153629761.post-2379561105897850632008-03-07T18:19:00.000-08:002008-03-07T18:51:28.741-08:00Firebug's PanelI have always wondered how firebug implemented it's debugger panel. After some more code digging, I found out that it was defined as a ScriptPanel in debugger.js,<br /><blockquote><pre>function ScriptPanel() {}<br /><br />ScriptPanel.prototype = extend(Firebug.Panel,<br />{...<br />}</pre></blockquote> but the ScriptPanel is a child class of Panel. Hum... Where is the Panel defined? It turns out that Panel class is defined in firebug.js, and it has all of the basic methods that all firebug panel should have.<br /><blockquote>Firebug.Panel =<br />{...<br />}<br /></blockquote>However, it doesn't tell much about how exactly the things inside the panel is rendered, so I dug and dug... nothing particular is suggesting me how it is done...<br /><br />So I launched DOM Inspector, and started to my my luck there. And...<br /><div id="hqfx" style="padding: 1em 0pt; text-align: center;"><img style="width: 987px; height: 858px;" src="http://docs.google.com/File?id=ddw95c2m_34gz668mdc" /></div><br />There is a xul:browser ;-) So... there is a separate browser window there... It's got to be overlayed, and... if you search for xul:browser in firebug's source, guess what will you get?<br />bindings.xml:31<br /><br /><blockquote><binding id="panelBar"><br /> <content><br /> <xul:hbox anonid="tabBox" class="panelTabBox" collapsed="true"><br /> <children includes="panelTab"/>/><br /> <xul:spacer flex="1"/><br /> <children/><br /> <xul:toolbarbutton type="menu" class="toolbar-text-menubutton panelOptionsButton" label="&firebug.Options;"><br /> <xul:menupopup anonid="optionsPopup"/><br /> </xul:toolbarbutton><br /> </xul:hbox><br /> <xul:deck anonid="deck" flex="1"><br /> <xul:browser anonid="browser"<br /> xbl:inherits="tooltip=paneltooltip,contextmenu=panelcontextmenu"/><br /> </xul:deck><br /> </content><br /></blockquote><br />Haha! it's a browser which contains all of the dynamically generate debug contents!Leihttp://www.blogger.com/profile/00550560377532133506noreply@blogger.com0tag:blogger.com,1999:blog-8847544717153629761.post-14241070893244074352008-03-05T16:24:00.000-08:002008-03-07T19:09:08.603-08:00Firebug OverlaysHere are the stuff that I found out while hacking firebug.<br /><br />There are 3 main xul files in firebug.<br /><ul> <li><b> browserOverlay.xul</b> - overlay of fb to the bottom part of the browser </li> </ul> <ul> <li><b> firebug.xul</b> - fb window itself when detached into it's own app window </li> </ul> <ul> <li><b> firebugOverlay.xul</b> - this is shared by both browserOverlay.xul and firebug.xul. You can overlay on top of this file, and changes that you make to this file will show in both fb's browser mode, and detached mode. </li> </ul>Leihttp://www.blogger.com/profile/00550560377532133506noreply@blogger.com0tag:blogger.com,1999:blog-8847544717153629761.post-12370530809457213452007-11-30T10:50:00.000-08:002008-02-27T10:51:34.971-08:00Ruby, Schedule, Reoccurrence, Date, Range, Runt<div class="entry-content"> <p>Almost all of the application that I worked with has something to do with dates and time, and most of those has something to do with scheduling as well, say <a href="http://soccermap.org/">SoccerMap</a>, where the user can schedule a reoccurring soccer game on google map.</p> <p>But after all of the research that I have done for how to solve this problem from google, it generally comes down to 2 routes. First is to compute them, and the second is to pre-populate them in the database or file, and perform selects from it.</p> <p>While the first solution seems to be efficient on the data storage, it might require more time and cpu to crank out the right occurrence dates. The second one seems to be much faster, as everything is almost a lookup away, it will hit the wall once user wants to know what happens in year 3000 ;-)</p> <p>After lots of mind wrestling and discussion with other programmers, I decided to find a way to compute the occurrence either with a simple algorithm or a library that does it already.</p> <p>To my surprise, even a problem as universal as this didn’t have a lot of good implementations in various languages. It’s usually provided through a module or external library, and there aren’t many good answers that surfaces google.</p> <p>Luckily, I found one for the language that I prefer, <a href="http://runt.rubyforge.org/doc/files/doc/tutorial_te_rdoc.html">runt</a> for ruby ;-)</p> Following is the code to get a series of reoccurring dates from a schedule. <pre><code class="ruby"><br /><span class="keywords">require</span> <span class="string">'runt'</span><br /><span class="keywords">require</span> <span class="string">'date'</span><br /><br />include Runt<br />include DPrecision<br /><br />last_thursday = DIMonth.new<span class="brackets">(</span>Last_of,Thursday<span class="brackets">)</span><br />august = REYear.new<span class="brackets">(</span>8<span class="brackets">)</span><br />expr = last_thursday & august<br /><br />>> <span class="brackets">(</span>Date.new<span class="brackets">(</span>2004,1,1<span class="brackets">)</span>..Date.new<span class="brackets">(</span>2004,12,31<span class="brackets">)</span><span class="brackets">)</span>.select {|d| expr.include? d }<br />=> [Thu, 26 Aug 2004]<br />>> <span class="brackets">(</span>Date.new<span class="brackets">(</span>2004,1,1<span class="brackets">)</span>..Date.new<span class="brackets">(</span>2004,12,31<span class="brackets">)</span><span class="brackets">)</span>.select {|d| last_thursday.include? d }<br />=> [Thu, 29 Jan 2004, Thu, 26 Feb 2004, Thu, 25 Mar 2004, Thu, 29 Apr 2004, Thu, 27 May 2004, Thu, 24 Jun 2004, Thu, 29 Jul 2004, Thu, 26 Aug 2004, Thu, 30 Sep 2004, Thu, 28 Oct 2004, Thu, 25 Nov 2004, Thu, 30 Dec 2004]<br /></code> </pre> References: <ul><li><a href="http://redhanded.hobix.com/inspect/methodCheckDateSucc.html">http://redhanded.hobix.com/inspect/methodCheckDateSucc.html</a></li><li><a href="http://www.ruby-doc.org/core/classes/Range.html">Range</a> </li><li><a href="http://suttree.com/2006/08/14/runt-on-ruby-on-rails/">runt-on-ruby-on-rails</a></li><li><a href="http://ruby-doc.org/core/classes/Proc.html">Proc</a> </li><li><a href="http://www.ruby-doc.org/docs/ProgrammingRuby/html/ref_m_enumerable.html" org="" docs="" programmingruby="" html="" html="">enumerable</a></li></ul> </div>Leihttp://www.blogger.com/profile/00550560377532133506noreply@blogger.com0tag:blogger.com,1999:blog-8847544717153629761.post-19577619710553694082007-10-20T18:40:00.000-07:002008-03-07T18:52:09.389-08:00Automatic Client Browser TimeZone Detection for Rails using Javascript and Ajax<div class="entry-content"> <p>After 2+ months of extensive development of Compliance at work, I finally had some spare time to throw into the second version of my pet project <a href="http://soccermap.org/">SoccerMap</a>.</p> <p>As usual, the timezone issue came up again, as soccer players can schedule games in their own time zones. After consulting with several existing solutions, <a href="http://tzinfo.rubyforge.org/">TZInfo</a> seems to be the way to go, but I didn’t quite like the fact that users have to explicitly set their own time zones. Like many other busy (or lazy) guys, I’d rather having everything just work out of the box without having me trying to customize it. Plus, what if I just traveled from west coast to east coast? All of the scheduled events will show up as west coast time in the application instead of east coast time.</p> <p>My solution is actually quite simple ;-) Use javascript to notice the server as needed. This way, it doesn’t matter where you go, if the computer you are using has the local time zone set correctly, then we are good. User doesn’t have to do a thing.</p> 1. Have the layout call a helper method get_local_time_zone, which will try to get the time zone if needed. <pre><code class="ruby"><br /><%= get_local_time_zone %><br /></code> </pre> 2. Implement the helper method in application_helper.rb. If we don’t see the gmtoffset stored in the session, then we would want to use a piece of javascript to get that information. <pre><code class="ruby"><br /><span class="keywords">def</span> get_local_time_zone<br />return <span class="string">''</span> <span class="keywords">if</span> session<span class="symbol">[:gmtoffset</span>].nil?<br /><span class="keywords">end</span><br /></code> </pre>3. How do we get the time from javascript? We first get the client side time zone using javascript, and then use an ajax call to send it to the server. <pre><code class="javascript"><br />Event.observe<span class="brackets">(</span><span class="global">window</span>, <span class="string">'load'</span>, <span class="keywords">function</span><span class="brackets">(</span>e<span class="brackets">)</span> {<br /><span class="keywords">var</span> now = <span class="keywords">new</span> Date<span class="brackets">(</span><span class="brackets">)</span>;<br /><span class="keywords">var</span> gmtoffset = now.getTimezoneOffset<span class="brackets">(</span><span class="brackets">)</span>;<br /><span class="comment">// use ajax to set the time zone here.<br /></span> <span class="keywords">var</span> set_time = <span class="keywords">new</span> Ajax.Request<span class="brackets">(</span><span class="string">'/gmtoffset/?gmtoffset='</span>+gmtoffset, {<br />onSuccess: <span class="keywords">function</span><span class="brackets">(</span>transport<span class="brackets">)</span> {}<br />}<span class="brackets">)</span>;<br />}<span class="brackets">)</span>;<br /></code> </pre> 4. OK, It’s pretty obvious now that we need to implement the gmtoffset controller to take the ajax call. <pre><code class="ruby"><br /><span class="keywords">def</span> gmtoffset<br />session<span class="symbol">[:gmtoffset</span>] = -params<span class="symbol">[:gmtoffset</span>].to_i*60 <span class="keywords">if</span> !params<span class="symbol">[:gmtoffset</span>].nil? <span class="comment"># notice that the javascript version of gmtoffset is in minutes ;-)</span><br />render<span class="symbol"> :nothing</span> => true <span class="comment"># this can be improved by being able to return xml or json output to inform the client side whether the offset was successfully set on the server or not.</span><br /><span class="keywords">end</span><br /></code> </pre> 5. The rest is simple ;-) Just follow <a href="http://www.caboo.se/articles/2007/2/23/adding-timezone-to-your-rails-app">http://www.caboo.se/articles/2007/2/23/adding-timezone-to-your-rails-app</a>, except in your application.rb, it should look like: <pre><code class="ruby"><br />private<br /><span class="keywords">def</span> set_timezone<br />TzTime.zone = TimeZone[session<span class="symbol">[:gmtoffset</span>]] <span class="keywords">if</span> session<span class="symbol">[:gmtoffset</span>]<br /><span class="keywords">yield</span><br />TzTime.reset!<br /><span class="keywords">end</span><br /></code> </pre> Reference: <ul><li><a href="http://tzinfo.rubyforge.org/">http://tzinfo.rubyforge.org/</a></li><li><a href="http://weblog.jamisbuck.org/2007/2/2/introducing-tztime">http://weblog.jamisbuck.org/2007/2/2/introducing-tztime</a></li><li><a href="http://www.caboo.se/articles/2007/2/23/adding-timezone-to-your-rails-app">http://www.caboo.se/articles/2007/2/23/adding-timezone-to-your-rails-app</a></li></ul> </div>Leihttp://www.blogger.com/profile/00550560377532133506noreply@blogger.com1tag:blogger.com,1999:blog-8847544717153629761.post-44607882530103988762007-09-11T10:49:00.000-07:002008-02-27T10:49:46.748-08:00Model Diagram for Rails?<div class="entry-content"> <p>I have been kept busy ever since the end of August, working on soccermap.org, a place where you can find and play more pickup soccer games.</p> <p>Everything went smoothly when I worked on the first version. The application was small, and things are very clear and extremely easy to find. It didn’t take long for me to receive many feature requests, a total of 16 of them from my soccer buddies just from the first use. I was darn happy about it, and before the launch day has barely passed, I was already venturing into the development of the soccermap.org v2.</p> <p>Two days into the soccermap v2, I found myself with a total of 16+ different models and soon 18+ controllers. With many many-to-many relationships and polymorphic relationships, it’s getting a little over of my head ;-), and my development progress has slowed dramatically, mainly due to the re-adjustments, revisions and refactoring of the earlier work.</p> <p>My note book by now, is full of scratches, omits, crosses, circles, checks, underlines, lines that fly across 3 pages, and through the back of 1 page. Oh, yeah! Believe me, I am a very creative note taker. ;-)</p> <p>As the design is gradually becoming more solid and stable, I want to have something that I can visualize the skeletons of the application other than my ‘precious’ note book, so what’s out there?</p> <p>I looked into the tools that are directly coming from mysql, but I didn’t get much luck there, they either cost money, or not exactly what I wanted. With a last desperate search before I had to leave for work, I hit the ‘RailRoad’:http://railroad.rubyforge.org. Haha, without dying of course ;-)</p> <p>It’s a really nice tool created just for rails! So it shouldn’t matter if you are using mysql. It should support all of the db that’s supported by rails! Take that!</p> <p>Within minutes, I was able to create my shining model and controller diagrams without having to bug my wife to jog them all down in a spreadsheet. That’s the last thing I want to do. ;-)</p> <p>Remember to go to <a href="http://www.graphviz.org/">http://www.graphviz.org/</a> and find out how to install it to your OS first! Without it, you can only get metadata from Activerecord.</p> <p>Enjoy!</p> <p>Reference: <a href="http://railroad.rubyforge.org/">http://railroad.rubyforge.org/</a></p> </div>Leihttp://www.blogger.com/profile/00550560377532133506noreply@blogger.com0tag:blogger.com,1999:blog-8847544717153629761.post-61889170170202763832007-08-27T10:48:00.000-07:002008-02-27T10:49:06.579-08:00Installing RMagick on Ubuntu<div class="entry-content"> <p>Well, I ran into this when I was trying to use the <a href="http://svn.techno-weenie.net/projects/plugins/attachment_fu/README">attachment_fu</a> plugin from techno-weenie.</p> <p>Even though RMagick was a little more heavy on the memory comparing to the other alternatives, I still chose it, as a lot of people are using RMagick, and I can find a lot of help on the web if I just google it.</p> <p>But things aren’t always as easy as it seems ;-)</p> I got errors like this on my first attempt to install the RMagick gem: <pre># gem install rmagick<br />Building native extensions. This could take a while...<br />configure: error: Can't install RMagick. Can't find Magick-config or GraphicsMagick-config program.<br /><br />ERROR: While executing gem ... (RuntimeError)<br /> ERROR: Failed to build gem native extension.<br />Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/rmagick-1.15.9 for inspection.<br /><br />Results logged to /usr/lib/ruby/gems/1.8/gems/rmagick-1.15.9/gem_make.out<br /></pre> <p>Thanks to google and ruby community ;-) I found <a href="http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/246996">this reference</a> in less than 10 seconds on google!</p> <p>Basically, you need to install “libmagick9-dev” package to your ubuntu first.</p> <p>That’s it!</p> </div>Leihttp://www.blogger.com/profile/00550560377532133506noreply@blogger.com0tag:blogger.com,1999:blog-8847544717153629761.post-8657878025359344632007-08-23T10:45:00.000-07:002008-02-27T10:48:13.499-08:00Using Javascript to parse XML text<p>As I was and still am heavily involved in my company’s next major product release, I a kinda slacked off on writing valuable things down when I encounter them.</p>To make it up, here is something that I was trying to do yesterday.<br /><p>I need to parse a complex data structure in <span class="caps">JSON</span>, and inside the <span class="caps">JSON</span>, I would have to deal with some values that are xml, So xml within <span class="caps">JSON</span> ;-)<br /> </p><p>First thing I thought is to create a node using document.createElement, and set the innerHTML of the element to be the value of the <span class="caps">JSON</span> xml, then I should be able to access the nodes inside the element that I created just like normal node traversing. (parentNode, childNodes, firstChild, etc…).</p> <p>It worked with Firefox ;-), but not IE.</p> <p>I remembered that the library <a href="http://dev.abiss.gr/sarissa">sarissa</a> can do the xslt transformation, so I should be able to find the code in there which handles the string to traversable xml tree conversion.</p> <p>Guess what, I didn’t have enough time to look through all of the docs to see exactly how it was done, and something else hit me when I was searching through the web.</p> <p>I was so glad that I don’t have to copy over the 23k lib just to turn the text into xml in IE after reading <a href="http://www.w3schools.com/xml/xml_parser.asp"><span class="caps">XML</span> Parser</a>.</p>So here is the code snippets:<br /><pre><code class="javascript"> if (window.ActiveXObject) { // ie<br /> xml=new ActiveXObject("Microsoft.XMLDOM");<br /> xml.async="false";<br /> xml.loadXML(XMLSTRING);<br /> } else { // mozilla <br /> var parser=new DOMParser();<br /> xml=parser.parseFromString(XMLSTRING,"text/xml");<br /> }<br /></code><br /></pre>Leihttp://www.blogger.com/profile/00550560377532133506noreply@blogger.com0tag:blogger.com,1999:blog-8847544717153629761.post-28263122045034160382007-07-29T10:42:00.000-07:002008-02-27T10:45:08.862-08:00Dynamic Date in Rails Fixture<p>While I was happily creating a fixture to test my newly created Article model, I found out that the <strong><%= Time.now %></strong> that I used in the fixture was dumping nil’s into the db. ;-(</p> <p>That was suppose to work, at least long time ago… I still recall reading the first Rails book… The <a href="http://api.rubyonrails.org/classes/Fixtures.html">rails api</a> didn’t say much about the dates in dynamic fixtures…</p> <p>Well, let’s be a little skeptical, and say… <strong>Time.now.strftime(“%Y-%m-%d %H:%M:%S”)</strong>.</p> <p>Ha! It worked!</p> <p>But it’s a kinda too long…<br /> </p><p>Hum… what else does google has to offer?</p> <p>There was a ticket open with the same issue: <a href="http://dev.rubyonrails.org/ticket/6137">Time.now in a fixture return nil</a>. Guess I am not the first ;-)</p> <p><strong><%= Time.now.to_s(:db) %></strong></p> <p>There, this is much prettier ;-)</p> <p>Oh, here is a bonus link for more <a href="http://wiki.rubyonrails.org/rails/pages/ActiveRecordYamlFixtures">Dynamic Fixture</a> stuff!</p><ul><li>Update: <a href="http://railscasts.com/episodes/31">Formatting Time</a></li></ul>Leihttp://www.blogger.com/profile/00550560377532133506noreply@blogger.com0tag:blogger.com,1999:blog-8847544717153629761.post-18267784952735672652007-07-28T10:41:00.000-07:002008-02-27T10:42:37.633-08:00Turning off Activerecord timestamp<p>Context: I was trying to increment an article’s views column every time when a reader has viewed the article.</p>Problem: Whenever I increment the article.views, article.updated_at will be updated by the rails through magic column. That’s not what I want, since updated_at should mean it was last updated by the author of the article, not the reader?!<br /><br />I could stay with the new meaning of the updated_at, really last_viewed_at, but being a little stubborn, I decided to try out my luck on google.<br /><br />Ref 1: <a href="http://blog.evanweaver.com/articles/2006/12/26/hacking-activerecords-automatic-timestamps">hacking activerecord’s automatic timestamps</a><br /><br />A lot of good stuff, but a lot of errors, too… didn’t work for me.<br /><br />Ref 2: <a href="http://www.railsweenie.com/forums/1/topics/688" title="updated_at, etc...">Turning off Magic Columns</a><br /><br />Ahh… But it’s not so thread safe, is it? ;-) The good thing that I learned from Ref 1.<br /><br />Ref 3: <a href="http://rails.raaum.org/database-conventions.html">Database Conventions</a><br /><br />A lot of good info, but doesn’t totally solve my problem. At least I know that meta class is very useful in this threading scenario. ;-)<br /><br />Ref 4: <a href="http://www.whytheluckystiff.net/articles/seeingMetaclassesClearly.html">Seeing Metaclasses Clearly</a><br /><br />Aha… That’s really tricky ;-)<br /><br />Ref 5: <a href="http://www.ruby-doc.org/core/classes/Module.html#M001674">So how do I use remove_method?</a><br /><br />Ref 6: This one is coming from me ;-)<br /><pre><code class="ruby"> def increment_views<br /> class << self<br /> def record_timestamps; false; end<br /> end<br /><br /> self.increment! :views<br /><br /> class << self<br /> remove_method :record_timestamps<br /> end<br /> end<br /></code><br /></pre>Leihttp://www.blogger.com/profile/00550560377532133506noreply@blogger.com1tag:blogger.com,1999:blog-8847544717153629761.post-79956541936559893682007-07-28T10:37:00.000-07:002008-02-27T10:38:16.536-08:00Javascript get the local file path in Mozilla<p>This function gives you the local file path of the file (nsIFile).<br /></p><pre><code class="javascript">function getLocalFilePath(file) {<br /> // file is nsIFile<br /> var ios = Components.classes["@mozilla.org/network/io-service;1"]<br /> .getService(Components.interfaces.nsIIOService);<br /> var fileHandler = ios.getProtocolHandler("file")<br /> .QueryInterface(Components.interfaces.nsIFileProtocolHandler);<br /> var URL = fileHandler.getURLSpecFromFile(file);<br /> return URL;<br />}<br /></code><br /></pre>Leihttp://www.blogger.com/profile/00550560377532133506noreply@blogger.com0tag:blogger.com,1999:blog-8847544717153629761.post-78533275880467218892007-07-19T10:40:00.000-07:002008-02-27T10:41:17.007-08:00svn ignore files and directoriesIgnore files and directories<br />The svn:ignore property can be set on filename patterns and directories.<br /><pre><br />svn propset svn:ignore PATTERN directory PATH<br />svn propset svn:ignore directory PATH<br /></pre><br />Edit property setting<br />Subversion properties can be edited using svn’s propedit function.<br /><pre><br />svn propedit svn:ignore PATH<br />svn propget svn:ignore PATH<br /></pre><br /><span class="caps">PATH</span> is assumed current working directory if not specified. If <span class="caps">PATTERN</span> is not specified, an editor window will open and let you edit patterns.Leihttp://www.blogger.com/profile/00550560377532133506noreply@blogger.com0tag:blogger.com,1999:blog-8847544717153629761.post-88351715125796642582007-07-18T10:39:00.000-07:002008-02-27T10:40:26.248-08:00ActiveRecord Session for Rails<p>I know that this is probably all over the Internet, this is just an entry for my own convenience.</p><ul><li>Uncomment the ‘config.action_controller.session_store = :active_record_store’ from the app/config/environment.rb</li> <li>rake db:sessions:create</li> <li>rake migrate</li> </ul> <p>Restart your server, and you are done!</p>Leihttp://www.blogger.com/profile/00550560377532133506noreply@blogger.com0tag:blogger.com,1999:blog-8847544717153629761.post-77020771976498024662007-07-15T10:38:00.000-07:002008-02-27T10:39:25.463-08:00XUL Tree<ul><br /> <li><a href="http://www.xulplanet.com/tutorials/xultu/seltree.html">http://www.xulplanet.com/tutorials/xultu/seltree.html</a></li> <li><a href="http://xulplanet.com/references/objref/TreeContentView.html">http://xulplanet.com/references/objref/TreeContentView.html</a></li> <li><a href="http://xulplanet.com/references/objref/TreeColumn.html">http://xulplanet.com/references/objref/TreeColumn.html</a></li> <li><a href="http://xulplanet.com/references/objref/TreeSelection.html">http://xulplanet.com/references/objref/TreeSelection.html</a></li> <li><a href="http://developer.mozilla.org/en/docs/Code_snippets:Tree">http://developer.mozilla.org/en/docs/Code_snippets:Tree</a></li> <li><a href="http://kb.mozillazine.org/Category:Example_code">http://kb.mozillazine.org/Category:Example_code</a></li></ul>Leihttp://www.blogger.com/profile/00550560377532133506noreply@blogger.com0tag:blogger.com,1999:blog-8847544717153629761.post-9655525934746070482007-07-11T10:26:00.000-07:002008-02-27T10:37:07.440-08:00Firefox Extension file I/OReference:<br /> <ul><li><a href="http://developer.mozilla.org/en/docs/Code_snippets:File_I/O">http://developer.mozilla.org/en/docs/Code_snippets:File_I/O</a></li> <li><a href="http://developer.mozilla.org/en/docs/Creating_Custom_Firefox_Extensions_with_the_Mozilla_Build_System#Accessing_Data_Files_From_Components">Accessing_Data_Files_From_Components</a></li> <li><a href="http://www.rietta.com/firefox/Tutorial/prefs.html">http://www.rietta.com/firefox/Tutorial/prefs.html</a></li> <li><a href="http://jslib.mozdev.org/">http://jslib.mozdev.org/</a></li><br /> </ul>Leihttp://www.blogger.com/profile/00550560377532133506noreply@blogger.com0