change icon based on another object - 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 icon based on another object (/showthread.php?tid=4091) |
change icon based on another object - khalil - 15.06.2022 Hello, I have this case: Fan will be controlled by object (fan control) Fan status based on Contactor (binary input) IF the overload is tripped the contactor still operate leads to unreal feedback. I want to change the fan icon to stop instead of run if the overload tripped previously solved by tags and resident or event based scrip, but I am looking for more efficient way especially when having lot of these. Could this case be solved by JS RE: change icon based on another object - admin - 15.06.2022 Custom JS - adds off class to <body> element when 1/1/1 is off. Code: $(function(){ Custom CSS - applies to additional class global-off. When <body> element has off class it hides the icon image and sets the background image to a custom icon (change URL as needed). Code: body.off .global-off .icon { RE: change icon based on another object - khalil - 15.06.2022 Thank you very much admin. but instead of grp.listen('1/1/1', function(object), I want it to be variable while each fan has its overload signal. is it possible to make it some thing like global depend on the additional classes of the overload objects and the action will affect the fan icon something like: global-off_1,2,3,4,... body_1,2,3,4,... Also if it possible to add additional calss to make the icon read only when overload is off. another thing I notice is that the icon doesn't fit to the current size, please see the image. RE: change icon based on another object - admin - 15.06.2022 You can duplicate the script and CSS with different classes as needed. See if this works for the background image not sizing correctly: Code: body.off .global-off .icon { For read-only use this: Code: body.off .global-off { RE: change icon based on another object - khalil - 20.06.2022 Hello admin Is it possible to optimize it with for loop and additional classes with because I have about 50 of these objects, it will not be easy to duplicate 50 JS and CSS. If there is a solution please advise Best Regards RE: change icon based on another object - admin - 21.06.2022 JavaScript: Code: $(function(){ CSS: Code: .off { Use additional class off-1, off-2, etc up to off-50. Objects start with 1/1/1 up to 1/1/50. RE: change icon based on another object - khalil - 22.06.2022 Thanks admin this is the code I used I used two for loop because first digit of the grp-addr changed while the addresses are not in series there are some addresses in the for loop not used, is there any issue in this case? Code: $(function(){ Another case: some devices has to alarm objects, I added two additional classes like (off-40 off-41) but it didn't work as logic or, moreover when refresh the page its updated correct! Is there a solution for this case BR, RE: change icon based on another object - admin - 22.06.2022 grp.listen will skip unknown group addresses. This does not produce any errors so it won't affect other groups. AND logic can de defined via CSS but you need to assign a different class in each grp.listen callback. For example this rule only applies to elements that have both off-a and off-b classes. Code: .off-a.off-b { RE: change icon based on another object - khalil - 22.06.2022 Thank you admin great but I need to use OR Logic how? RE: change icon based on another object - admin - 22.06.2022 The same way with two different classes but define CSS like this: Code: .off-a, RE: change icon based on another object - khalil - 22.06.2022 (22.06.2022, 14:19)admin Wrote: The same way with two different classes but define CSS like this:how to implement or in this example? Quote:.pumpoff-a.pumpoff-b .icon { RE: change icon based on another object - admin - 22.06.2022 Like this: Code: .pumpoff-a .icon, RE: change icon based on another object - khalil - 22.06.2022 (22.06.2022, 14:25)admin Wrote: Like this: many thanks work perfect |