XWidgetSoft Forum https://www.bbs.xwidget.com/ |
|
Text should say good morning, good evening, good afternoon https://www.bbs.xwidget.com/viewtopic.php?f=8&t=6969 |
Page 1 of 1 |
Author: | Commander-Zero [ December 19th, 2018, 3:44 am ] |
Post subject: | Text should say good morning, good evening, good afternoon |
Hi, Text should say good morning, good evening, good afternoon but how? ![]() that's what i found out if (curHr < 12) { console.log('good morning') } else if (curHr < 18) { console.log('good afternoon') } else { console.log('good evening') } how can I integrate this here and relode it every hour function widgetOnLoad() { text1.text = } Thank for Help PS. is there any Documentation for the funktions example text1.text = ? Thanks Again ![]() |
Author: | Jimking [ December 20th, 2018, 1:02 am ] |
Post subject: | Re: Text should say good morning, good evening, good afterno |
Hi! You can use two ways: 1 way = java script Took it as example from here: https://www.deviantart.com/jimking/art/ ... -365686066 create 3 texts: text1 = good morning text2 = good evening text3 = good afternoon and add this js as base (this is for two components) Code: function datetimecore1OnUpdate(Sender) { var mydate = new Date(); var h = mydate.getHours(); if(h>19||h<6) //night { text1.visible = true; text2.visible = false: } else //day 6:00~20:00 { text1.visible = false; text2.visible = true; } } or modifying this kind of js: https://www.deviantart.com/jimking/art/ ... -370894930 or create 3 pngs with these words and add 24 images in a folder, and rename the corrisponding image to an hour 1,2,3,4....23 so create "good morning" image with name 7,8,9,10,11,12,13,14,15 etc |
Author: | Commander-Zero [ December 21st, 2018, 1:54 am ] |
Post subject: | Re: Text should say good morning, good evening, good afterno |
Thank for you anwser i will try it ![]() |
Author: | Commander-Zero [ January 2nd, 2019, 4:33 am ] |
Post subject: | Re: Text should say good morning, good evening, good afterno |
Hi, i used this, and it looks like it works function datetimecore1OnUpdate(Sender) { var mydate = new Date(); var curHr = mydate.getHours(); if(curHr<12) //morning { morning.visible = true; evening.visible = false; afternoon.visible = false; hello.visible = false; } else if(curHr<16) //Hallo { morning.visible = false; evening.visible = false; afternoon.visible = false; hello.visible = true; } else if(curHr<18) //evening { morning.visible = false; evening.visible = true; afternoon.visible = false; hello.visible = false; } else //afternoon { morning.visible = false; evening.visible = false; afternoon.visible = true; hello.visible = false; } } any objections or suggestions for improvement. Thanks |
Page 1 of 1 | All times are UTC - 8 hours |
Powered by phpBB® Forum Software © phpBB Group http://www.phpbb.com/ |