您的位置:首页 > 移动开发

转载Desktop Applications using JavaScript engines (Dashboard)

2008-05-31 18:40 351 查看
I joined a mini-project recently focused on widget application developement stuffs, we wanna a cool UI, so dashboard is mentioned, i think it is a good introduction to dashboard, so paste it here. 
With all the recent interest in AJAX applications, all manner of JavaScript related technologies have the potential to take to the spotlight. Yahoo!'s Konfabulator and Apple's Dashboard are two such fascinating applications. They serve up small desktop applications called Widgets. A widget could be a clock, RSS feed, a search engine, a CPU monitor and other fun little desktop distractions (think XTeddy and XEyes from the Unix days of yore). As you might expect of a product originating from the Mac arena some widget designs are close to aesthetic perfection. Konfabulator and Dashboard offer the same sort of functionality and are both based on an underlying JavaScript engine but are implemented in slightly different ways. Konfabulator and Dashboard files use the .widget file extension, this is only an alias for the ZIP file format and this means that anybody can look at the source for any widget and learn from the masters. I want to sidestep the Dashboard versus Konfabulator debates if I may as despite all the arguments they are sufficiently different internally to both have unique merit. startClock(); This is what a Widget looks like: this example is a butchered DHTML version based on the Flip Clock Dashboard widget from Neometric Software. It looks best on browsers with good PNG support.
Apple's Dashboard
Apple Dashboard widgets are created from HTML, Images, JavaScript and CSS. The Dashboard server uses the same engine as the Safari browser. The engine called WebKit is open source and consists of WebCore and JavaScriptCore; an HTML/CSS renderer and JavaScript engine based on KDE's KHTML and KJS. Widgets use and Safari supports certain non-W3C standards such as the <canvas> element. A Dashboard specific JavaScript mechanism called the widget object is available that allows a widget to run system commands, access other desktop applications and obtain online content.
Yahoo!'s Konfabulator
 Konfabulator widgets are composed of JavaScript, Images and driven by an XML document (written in a Konfabulator specific XML dialect). Unlike Dashboard, Konfabulator has been written to be both Mac and Windows compatible. Konfabulator utilises Mozilla SpiderMonkey (written in C) as its JavaScript engine, this is the same JavaScript engine used in the Mozilla and Firefox browsers. Konfabulator provides specialised extensions to JavaScript to enable system interaction and widgets call the same API irrespective of what platform they are on (only the server implementation actually differs).
Thinking about Clones...
There is already a Dashboard clone called dotWidget and although it looks quite similar to Dashboard the underlying mechanism uses VBScript rather than any kind of JavaScript engine. Now being a Java sort of person I couldn't help but speculate how one might go about producing a Widget type of application using Java technologies. I'm not a Swing or AWT programmer so an actual implementation is probably beyond me but nonetheless it is interesting to think about the possibilities.
Musing about a Java Konfabulator clone...
SpiderMonkey is not the only JavaScript engine that Mozilla have produced. The now defunct codename Xena project, sometimes called Javagator, attempted to create a 100% Java version of the Mozilla browser. Xena produced a couple of interesting subprojects including a newsreader Grendel and a fully equipped Java based JavaScript engine called Rhino. Rhino would be a particularly good choice for any XML handling application because it now includes the power of E4X which makes XML programming very easy. Rhino is very easily embedded in other Java applications and so it would be quite feasible to produce a Konfabulator clone based on Rhino.
Musing about a Java Dashboard clone...
Since Dashboard widgets utilize HTML and CSS, a HTML renderer of some sort would be needed. There are some interesting HTML renderers about including Flying Saucer XHTML renderer but this does not currently integrate the JavaScript engine that we would also require. So I would think that a more suitable approach would be to use a Java browser wrapper. Via Joshua Marinacci's The HTML Renderer Shootout articles (Part 1 and Part 2) I found two projects that might fit the bill, JRex and Blackwood Webclient, both based on the Mozilla browser codebase. Using either of these would essentially harness the power of Mozilla in the same way as Dashboard harnesses the power of Safari. There is also a possibility that a Mozilla based browser could even support the <canvas> element. Specialised system JavaScript objects could also be supported using something like JRex's JRexLiveConnectSession. So at least in principle it would seem that it would be possible to create a Dashboard clone using Java.
Roundup
A Java, JavaScript engine based clone of Apple's Dashboard and/or Yahoo's Konfabulator is within the realms of possibility. I also got the distinct impression that widgets are not that different to their web counterparts such as JSR168 portlets. Indeed there are already some widgets for the web types of application such as the Flash based OpenLaslo and AJAX based Bindows. Given the growing popularity of toolkits like Direct Web Remoting (DWR) to produce AJAX applications and quality of the JavaScript engines available a resurgence of server side JavaScript might be on the cards
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息