LogicMachine Forum
Clock - Printable Version

+- LogicMachine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: OLD visualization (https://forum.logicmachine.net/forumdisplay.php?fid=9)
+--- Thread: Clock (/showthread.php?tid=1730)



Clock - paalidar - 19.11.2018

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?


RE: Clock - admin - 20.11.2018

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


RE: Clock - paalidar - 20.11.2018

(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.


RE: Clock - admin - 20.11.2018

What kind of script have you created? You need to create a resident script with at least 1 second sleep time.


RE: Clock - paalidar - 20.11.2018

(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


RE: Clock - admin - 20.11.2018

Check if any other script is writing there. You can search all scripts in Scripting > Tools > Print script listing.


RE: Clock - paalidar - 20.11.2018

Thank you!

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


RE: Clock - Daniel - 20.11.2018

(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/showthread.php?tid=275&pid=1254#pid1254


RE: Clock - Erwin van der Zwart - 20.11.2018

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