Logic Machine Forum
change value to ## when condition meet - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Visualization (https://forum.logicmachine.net/forumdisplay.php?fid=9)
+--- Thread: change value to ## when condition meet (/showthread.php?tid=4095)



change value to ## when condition meet - khalil - 16.06.2022

Hello 
I read data from generator, but when its off some values gives unreal measurements.
so I want to convert these values to ## when generator is off.
BR,


RE: change value to ## when condition meet - admin - 17.06.2022

Similar to this example: https://forum.logicmachine.net/showthread.php?tid=4091

When <body> element has generator-off class then all elements with generator-status additional class will have the current value hidden by setting the text color to transparent and showing a pseudo-element with ## before the value text.
Code:
body.generator-off .generator-status.item-value,
body.generator-off .generator-status .value {
  color: transparent;  
}
body.generator-off .generator-status.item-value:before,
body.generator-off .generator-status .value:before {
  color: #333;
  content: '##';
}



RE: change value to ## when condition meet - khalil - 17.06.2022

Thank you admin
So I need the JS from the example before?
But what is the <body> element? Do I need to change it? Is it a variable?
I am not familiar with JS and CSS


RE: change value to ## when condition meet - khalil - 18.06.2022

Code:
$(function(){
  if (window.grp) {
    grp.listen('62/7/0', function(object) {
      $('body').toggleClass('generator-off', object.value == false);
    });
  }
});
this is the JS Used with the CSS code:
Code:
body.generator-off .generator-status.item-value,
body.generator-off .generator-status .value {
  color: transparent; 
}
body.generator-off .generator-status.item-value:before,
body.generator-off .generator-status .value:before {
  color: #333;
  content: '##';
}
 
and this is what I got:


RE: change value to ## when condition meet - admin - 20.06.2022

You've probably set custom text color in element properties.
Use this CSS instead:
Code:
body.generator-off .generator-status.item-value,
body.generator-off .generator-status .value {
  color: transparent !important;  
}

body.generator-off .generator-status.item-value:before,
body.generator-off .generator-status .value:before {
  color: #000;
  content: '##';
}



RE: change value to ## when condition meet - khalil - 20.06.2022

Thanks Admin
Work Perfect