User Tools

Site Tools


sample_code:digital_clock

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

sample_code:digital_clock [2016/09/02 19:28]
titus
sample_code:digital_clock [2017/06/14 17:13]
Line 1: Line 1:
-**Clock** 
  
-This is a simple clock. 
- 
-<code JavaScript Clock.js> 
- 
-//Called when application is started. 
-function OnStart() 
-{ 
-    //Create a layout with objects vertically centered. 
-    lay = app.CreateLayout( "linear", "VCenter,FillXY" );  
-    lay.SetBackColor("#ff665578"   
-    //Create a text label and add it to layout. 
-    txtd = app.CreateText( "Digital Clock" ); 
-    txtd.SetTextSize( 45 ); 
-    txtd.SetMargins(0,0,0,0.03) 
-    lay.AddChild( txtd ); 
-     //Create Text 
-  text = app.CreateText( "" ); 
-    text.SetTextSize( 25 ); 
-    text.SetTextColor("#ff879964") 
-    lay.AddChild( text ); 
-    //Create a text label and add it to layout. 
-    txt = app.CreateText( "" ); 
-    txt.SetTextSize( 32 ); 
-    lay.AddChild( txt ); 
-     
-    //Add layout to app.     
-    app.AddLayout( lay ); 
-setInterval("Clock()",1000) 
-} 
-function Clock()  
- 
-  var day =["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"] 
- var today = new Date(); 
-    var y = today.getFullYear() 
-    var h = today.getHours(); 
-    var m = today.getMinutes(); 
-    var s = today.getSeconds(); 
-    var mi = today.getMilliseconds(); 
-    var mon =today.getMonth() 
- var d = today.getDay() 
-var mon = today.getMonth()+1 
-var dt = today.getDate() 
-text.SetText(day[d]+" "+dt+"/"+mon+"/"+y) 
- 
-if(s<10&&m<10&&h<10){ 
-     txt.SetText("0"+h+":"+"0"+m+":"+"0"+s) 
-  } 
-else{ 
- 
- if(s<10&&h<10){ 
-     txt.SetText("0"+h+":"+m+":"+"0"+s) 
-  } 
-else if(h<10&&m<10){ 
-     txt.SetText("0"+h+":"+"0"+m+":"+s) 
-  } 
-else if(m<10&&s<10){ 
-    
-     txt.SetText(h+":"+"0"+m+":"+"0"+s) 
-  } 
-else{ 
-if(h<10){ 
-     txt.SetText("0"+h+":"+m+":"+s) 
-  } 
-else if(m<10){ 
-   
-     txt.SetText(h+":"+"0"+m+":"+s) 
-  } 
- 
-else if(s<10){ 
-     txt.SetText(h+":"+m+":"+"0"+s) 
-  } 
- 
-else{ 
-txt.SetText(h+":"+m+":"+s) 
-    } 
-  } 
- } 
-} 
- 
-</code> 
- 
-[[:|Home]]>>[[sample_code:|Sample Code]]\\ 
sample_code/digital_clock.txt ยท Last modified: 2017/06/14 17:13 (external edit)