This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Clock
#1
Hi,

Found an answer for this question some weeks ago, but can't find it any more.

I got a script wich write time (hour, min & sec) to a group address. How can I make it show only hour & min?
Reply
#2
You need to use string/text data type, but this way it will be a read-only value.
Code:
time = os.date('%H:%M')
grp.checkwrite('1/1/1', time)

Or you can use SVG image, which will display client time:
https://forum.logicmachine.net/showthread.php?tid=1634
Reply
#3
(20.11.2018, 07:48)admin Wrote: You need to use string/text data type, but this way it will be a read-only value.
Code:
time = os.date('%H:%M')
grp.checkwrite('1/1/1', time)

Or you can use SVG image, which will display client time:
https://forum.logicmachine.net/showthread.php?tid=1634

Can't make this work... Something I'm doing wrong for sure...
Data type "250 byte String" I have to use? All I get is an empty value.
Reply
#4
What kind of script have you created? You need to create a resident script with at least 1 second sleep time.
Reply
#5
(20.11.2018, 11:24)admin Wrote: What kind of script have you created? You need to create a resident script with at least 1 second sleep time.

Resident script, 1 second sleep time

time = os.date('%H:%M')
grp.checkwrite('32/1/8', time)

Some how made it work, but the object just keeps on flashing, 1 sec on - 1 sec off
Reply
#6
Check if any other script is writing there. You can search all scripts in Scripting > Tools > Print script listing.
Reply
#7
Thank you!

Another one, can I auto close widgets after som seconds if there is no user action?
Reply
#8
(20.11.2018, 16:21)paalidar Wrote: Thank you!

Another one, can I auto close widgets after som seconds if there is no user action?

Check this, it is kind of what you are looking for
https://forum.logicmachine.net/showthrea...54#pid1254
------------------------------
Ctrl+F5
Reply
#9
Hi,

Here is a full working sample to auto close widgets based on the back to startpage JS script:

Code:
$(function(){
 
 var SE_Timeout = 15000; // adjust this timer value if needed (15 seconds in miliseconds)
 var eventlist = 'click mousedown mouseout touchend';
 var OpenWidget = 0;
 
 setInterval(function() {
   var WidgetNumber = 0;
   $('.layer-widget').each(function( index, element ) {
     if ( $(this).is(':visible') == true) {
       fields = $(this)[0].id.split(/-/);
       WidgetNumber = Number(fields[1]);
     }      
   });
   if (WidgetNumber > 0 && OpenWidget != WidgetNumber){
     OpenWidget = WidgetNumber;
   }
 }, 1000);      
 
 // Timer function no usage detected
 function No_Usage_Detected(callback, timeout, _this) {
   var timer;
   return function(e) {
       var _that = this;
       if (timer)
           clearTimeout(timer);
       timer = setTimeout(function() {
           callback.call(_this || _that, e);
       }, timeout);
   }
 }

 // Close widget function when timer elapsed
 var SE_CloseWidget = No_Usage_Detected(function(e) {
        $("#widget-" + OpenWidget).addClass("hide");
 }, SE_Timeout);
 
 // Add event listener to document to detect user input
 $(document).on(eventlist, function() {
   SE_CloseWidget();
 });

 // Add event listener to all iframes to detect user input inside iframes
 $('iframe').load(function() {
   var iframe = $('iframe').contents().find('html');
   iframe.on(eventlist, function(event) {
    SE_CloseWidget();
   });
 });
 
});  
BR,

Erwin
Reply


Forum Jump: