This shows you the differences between two versions of the page.
sample_code:digital_clock [2016/08/29 06:19] titus |
sample_code:digital_clock [2017/06/14 17:13] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | **Clock** | ||
- | This is a simple clock. | ||
- | |||
- | <code JavaScript> | ||
- | |||
- | //Called when application is started. | ||
- | function OnStart() | ||
- | { | ||
- | //Create a layout with objects vertically centered. | ||
- | lay = app.CreateLayout( " | ||
- | lay.SetBackColor("# | ||
- | //Create a text label and add it to layout. | ||
- | txtd = app.CreateText( " | ||
- | txtd.SetTextSize( 45 ); | ||
- | txtd.SetMargins(0, | ||
- | lay.AddChild( txtd ); | ||
- | // | ||
- | text = app.CreateText( "" | ||
- | text.SetTextSize( 25 ); | ||
- | text.SetTextColor("# | ||
- | 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(" | ||
- | } | ||
- | function Clock() | ||
- | { | ||
- | var day =[" | ||
- | 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]+" | ||
- | |||
- | if(s< | ||
- | | ||
- | } | ||
- | else{ | ||
- | |||
- | | ||
- | | ||
- | } | ||
- | else if(h< | ||
- | | ||
- | } | ||
- | else if(m< | ||
- | |||
- | | ||
- | } | ||
- | else{ | ||
- | if(h< | ||
- | | ||
- | } | ||
- | else if(m< | ||
- | | ||
- | | ||
- | } | ||
- | |||
- | else if(s< | ||
- | | ||
- | } | ||
- | |||
- | else{ | ||
- | txt.SetText(h+":" | ||
- | } | ||
- | } | ||
- | } | ||
- | } | ||
- | |||
- | </ | ||
- | |||
- | [[: |