Add button(s) to visualisation using javascript - 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: Add button(s) to visualisation using javascript (/showthread.php?tid=4290) |
Add button(s) to visualisation using javascript - jamesng - 10.10.2022 Hi I'd like to create a widget which only display buttons for the lights which are switched on - similar in style to Apple's Home application which has a pop-up window from the dashboard which displays buttons for the active lights only. Is there some sample javascript to dynamically add buttons to a visualisation using the value, name & address info from grp.all()? I can see how I can hide or disable buttons already placed on a visualisation using JavaScript, however I'd prefer a compact layout which only includes buttons for lights that are switched on. The number of buttons displayed on the visu would neeed to change - somewhere between 1 and 20 buttons displayed as a list from about 50 lighting groups. Kind Regards James RE: Add button(s) to visualisation using javascript - admin - 10.10.2022 You can use this CSS to display all elements in a row (manual placement is ignored) inside a certain widget. Then you can combine it with show/hide script. Code: #widget-5 > div.item { RE: Add button(s) to visualisation using javascript - jamesng - 10.10.2022 I've been experimenting with your CSS suggestion this afternoon, however am running into two issues: 1: the item-labels are not linked to the item-controls resulting in a jumble of buttons in the UI 2: there doesn't appear a way to identify specific item-controls from the HTML so that a javascript can hide those which are switched off - I can't see the the group address or name in the HTML. Am I missing something here? Attached is the HTML Code: <div class="layer layer-centered layer-widget transparent" id="widget-67" style="width: 300px; height: 500px; position: absolute; background-image: url("/scada/resources/img/background.png?1663484962"); background-color: transparent; top: 0px; left: 895px; opacity: 1; display: block; background-repeat: no-repeat no-repeat;"> Is there a way to turn on display of the control-name on the usermode (ipad view) - or to generate a similar object HTML structure from the touch mode with object titles? Or if this approach is not possible, can I use javascript to dynamically add only the active buttons to the widget on page load? Many thanks Kind Regards, James RE: Add button(s) to visualisation using javascript - admin - 10.10.2022 You can use Additional class to target certain elements. You can create labels using CSS (these won't be visible in the editor). This example uses three classes: obj1, obj2, obj3. Label position and other properties can be freely adjusted. Code: #widget-5 > div.item:after { RE: Add button(s) to visualisation using javascript - jamesng - 10.10.2022 I've used CSS to add labels in the past, however in this instance there are a lot of buttons (one for each light in the building / 50 or so per floor) so it would be preferable to dynamically add this based on the Custom Name applied to the object on this Widget. Can't this be achieved by pulling this info from the data object on the page? I'm just not quite sure how to access the info from the object as yet. I'm using the following javascript to dynamically hide buttons based on their value Code: $(function() { Many thanks Kind Regards James RE: Add button(s) to visualisation using javascript - admin - 10.10.2022 Object name is not exposed anywhere in the current firmware. This will be changed in the next release: group address and name will be accessible via data attributes. |