29.12.2019, 14:19
(This post was last modified: 29.12.2019, 15:03 by Erwin van der Zwart.)
Hi,
See this topic: https://forum.logicmachine.net/showthrea...62#pid3962
Or use this custom JS as a starting point, i created this for screen cleaning
PS: I don’t think address 0/250/59 is possible (:
BR,
Erwin
See this topic: https://forum.logicmachine.net/showthrea...62#pid3962
Or use this custom JS as a starting point, i created this for screen cleaning
Code:
$(function(){
// Set your listener address and value here
var grpaddress = '1/1/4';
var objvalue = true;
// Set your screenclean time here
var screencleantime = 30;
// Set your text here
var screenclean_message = 'Screen cleaning mode is now active';
var screenclean_remaining_prefix = 'remaining time';
var screenclean_remaining_suffix = 'seconds';
// Add screencleaner and listener to your visu
if (typeof grp != 'undefined') {
grp.listen(grpaddress, function(object, state) {
var value = object.value;
if(value == objvalue && state === 'value'){
// Set start time
var counter = screencleantime;
// Function to count down the timer
function countdown() {
var el = document.getElementById('countertext');
var intervalId = setInterval(function() {
counter = counter - 1;
$('#screencleantime').text(screenclean_remaining_prefix + ' ' + counter + ' ' + screenclean_remaining_suffix);
if (counter === 5 || counter === 3 || counter === 1) {
$('#screencleantime').css("color", "#ff0000");
} else {
$('#screencleantime').css("color", "#ffffff");
}
if (counter === 0 || counter < 0) {
clearInterval(intervalId);
// Remove overlay from visu
$('#screenclean').remove();
}
}, 1000);
};
// Add dynamicly the overlay to visu
$('body').append('<div id="screenclean" style="position:absolute;width:100%;height:100%;opacity:0.3;z-index:100;background:#000;"><div id="screenmessage" style="text-align:center;position:absolute;left:calc(50% - 200px);top:calc(50% - 100px);color:#ffffff;opacity:1;z-index:0;"><div><h4 id="screencleanmessage" style="min-width:100px;"></h4></div><div><h4 id="screencleantime" style="min-width:100px;"></h4></div></div>');
$('#screencleanmessage').text(screenclean_message);
$('#screencleantime').text(screenclean_remaining_prefix + ' ' + counter + ' ' + screenclean_remaining_suffix);
// Start Countdown
countdown();
} else {
// Remove overlay from visu on any other value
$('#screenclean').remove();
}
}, true); // Set to true if you want to trigger again on same object value
}
});
PS: I don’t think address 0/250/59 is possible (:
BR,
Erwin