//config.xml
<widget id="2be1b89d-a25b-4c83-a7c6-e8d7df246eed" version="1.00.beta" height="450" width="320">
<name>Clock</name>
<description>Hello World, This is my first Widget.</description>
<author email="myname@host">myname</author>
<license href="http://www.apache.org/licenses/LICENSE-2.0.html">Apache v2</license>
<maximum_display_mode height="450" width="320"/>
<update href="http://www.jil.org/widgets/helloworld" period="2"/>
<icon src="Icon.png"/>
<content src="Clock.html"/>
<access network="true" localfs="true" remote_scripts="false"/>
<billing required="true"/>
<feature name="http://jil.org/jil/api/1.1/deviceInfo" required="false"/>
</widget>
//Clock.css
#front {
position: absolute;
top:80px;
left: 20px;
width: 290px;
height: 320px;
}
//Clock.js
function showFront() {
}
function showBack() {
}
var NumSrc="images/c0.gif";
for(var i=0;i<=9;i++){
eval("var c"+i+"=new Image();c"+i+".src=NumSrc.replace('c0.gif','c'+i+'.gif');");
}
document.write('<table border="0" cellspacing="0" bgcolor=black height=1><tr>');
document.write('<td><img src='+NumSrc+' id="lch1"></td>');
document.write('<td><img src='+NumSrc+' id="lch2"></td>');
document.write('<td><img src='+NumSrc.replace("c0.gif","colon.gif")+'></td>');
document.write('<td><img src='+NumSrc+' id="lcm1"></td>');
document.write('<td><img src='+NumSrc+' id="lcm2"></td>');
document.write('<td><img src='+NumSrc.replace("c0.gif","colon.gif")+'></td>');
document.write('<td><img src='+NumSrc+' id="lcs1"></td>');
document.write('<td><img src='+NumSrc+' id="lcs2"></td>');
document.write('<td><img src='+NumSrc.replace("c0.gif","cam.gif")+' id="lcapm"></td>');
document.write('</tr></table>');
function timerun(){
now=new Date();
myhour=now.getHours();
myminute=now.getMinutes();
mysecond=now.getSeconds();
if(myhour<12) lcapm.src=NumSrc.replace("c0.gif","cam.gif");
else lcapm.src=NumSrc.replace("c0.gif","cpm.gif");
if(myhour>12) myhour-=12;
lch1.src=eval("c"+Math.floor(myhour/10)+".src");
lch2.src=eval("c"+myhour%10+".src");
lcm1.src=eval("c"+Math.floor(myminute/10)+".src");
lcm2.src=eval("c"+myminute%10+".src");
lcs1.src=eval("c"+Math.floor(mysecond/10)+".src");
lcs2.src=eval("c"+mysecond%10+".src");
setTimeout("timerun()",500);
}
//Clock.html
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Test</title>
<link href="Clock.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="Clock.js"></script>
</head>
<body>
<script>
timerun();
</script>
</body>
</html>
//+ Clock.png
打包,改后缀名为 .wgt
adb push /sdcard