Tuesday, December 11, 2007

Make a "toaster" in firefox

(Refer to http://developer.mozilla.org/en/docs/nsIAlertsService#Example .)
The nsIAlertsService works great on Mac (firefox 3 only) and Windows.

Sample:

var alertsService = Components.classes["@mozilla.org/alerts-service;1"]
.getService(Components.interfaces.nsIAlertsService);
alertsService.showAlertNotification(
"chrome://mozapps/skin/downloads/downloadIcon.png",
"Alert title", "Alert text goes here.",
false, "", null);


But in firefox 2, we have to use showPopup() and hidePopup() as workaround:

popBox.showPopup(pop, xPos, yPos, 'popup', 'bottompright');
setTimeout(function(popBox){
popBox.hidePopup(pop);
}, 2000, popBox);

Wednesday, November 21, 2007

Javascript : tricky thing for setTimeout

I have this:

function callme() {
alert('can you hear me?');
}

What's the difference among these calls?
1) setTimeout(alert('can you hear me?'), 1000);
2) setTimeout(callme(), 1000);
3) setTimeout(function () { callme(); }, 1000);

1) and 2) are the same, callme() will be executed when setTimeout processing its parameter.
3) will be called after 1000ms, likely asynchronized.

---
Roger says:
"the arguments are evaluated when setTimeout is called, so is that init function, what might work is just passing callme which is an object.

the latter (case 2) preserves the variables so to speak... scope, context"

Firefox3 has a problem.

"xul-overlay-merged observer is notified before script elements within the overlay are processed"

https://bugzilla.mozilla.org/show_bug.cgi?id=392515

Well, I guess this could be a work around.

In the <overlay id=...>, we should have <prefpane id=... onpaneload="myInit();">.
So after something like '<script type="application/x-javascript" src="chrome://..." />, 

we use

    <script type="application/x-javascript">
    <![CDATA[
    // UI-specific code
        setTimeout(function () {/*whatever*/},100);
    ]]>
    </script>

Just the onpaneload has no use here.

Friday, March 30, 2007

Installing Oracle 10g on OpenSolaris

There will be a problem... Oracle 10g claims itself to support Soalris 10 (5.10) only, but not Solaris Nevada (5.11). The trick is that there's a hidden file ".oui" in the "install" folder and the runInstaller script will call it with option "-oneclick".

The workaround is to add "-skipsyscheck" option to "runInstaller", iirc. It'll bypass the "5.10" issue and continue the installation, but ... there's no guarantee that the installation will work...

Choose style for my blog.

It's not easy to choose a style for a blog...
Well, this template let me recall the happy days in the past few years but we have to live in tomorrow, right?