Enyo1.0 provides five services:
System: "palm: // com. palm. systemservice /"
Telephony: "palm: // com. palm. telephony /"
Database: "luna: // com. palm. db /"
Application: "palm: // com. palm. applicationManager /"
Accounts: "palm: // com. palm. service. accounts /"
By calling these services, we can obtain a lot of information related to the webOS system. Why does the JavaScript in webOS (Enyo is a JS framework) support direct operating system information?
All secrets are in enyo \ 1.0 \ framework \ source \ palm \ services \ bridge \ WebosConnect. js.
At the beginning of the 59 lines of this file, there is the following code:
As you can see, enyo inserts an applet tag in the page. Here the jar package webOSconnect_1_3.jar is added and the com. palm. webos. connect. DeviceConnection class in the package will be called.
This jar package is a component that interacts directly with system data. Without the source code entered in the jar package, we cannot implement it in detail.
The second part: "accessing methods and variables in Java Applet from JavaScript" describes the call process in detail.
I paste the sample code below:
Using mytest.htm"
- Function accessApplet ()
- {SetTimeout ("changeText ('I like JavaScript! ') ", 1000 );
- SetTimeout ("changeText ('I like JavaScript and Java! ') ", 2000 );
- SetTimeout ("changeText ('I like Java! ') ", 3000 );
- SetTimeout ("accessapple()", 4000 );
- }
- Function changeText (s)
- {
- Too many Doc ument. testText. setText (s)
- // Call the setText method of the Java applet.
- // Note that the applet name must be identified by the "applet" flag name attribute
- }
- // Call accessApplet to load the Applet
"Testtext. java"
- Import java. applet .*;
- ......
- Public class Testtext extends Applet
- {......
- Public void setText (String s) // setText must be declared as "public"
- {
- Text = s;
- Repaint ();
- }
- }