Logic Machine Forum
Adding to the Pull Down menu in Touch - 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: Adding to the Pull Down menu in Touch (/showthread.php?tid=5448)



Adding to the Pull Down menu in Touch - GCXO - 02.06.2024

Hi,

Is there a way to add an option in the pulldown menu in the touch interface to perform an action as setting a Objectvalue to a certain value or maybe run a function in javascript?

   


For example I would like to add under General , Turn off alarms, which I need to send a value do an grpip.

Thanks,

Gabe


RE: Adding to the Pull Down menu in Touch - GCXO - 02.06.2024

I've figured it out. For anyone else who needs to do this



Code:
document.addEventListener('DOMContentLoaded', function() {
        var container = document.querySelector('.sidebar');
        var ul = container.querySelector('ul');
        var li = document.createElement("li");
        var span = document.createElement("span");
        span.classList.add('a');
     
        var link = document.createElement("a");
        link.href = "#"; 
        link.textContent = "Nuevo Link"; 
       
        span.appendChild(link);
 
        li.addEventListener('click', HaceClick);
        li.classList.add('level-1');
        li.appendChild(span);
     
 
        var referenceNode = ul.getElementsByTagName("li")[3]; // Insert before 3rd in the list
        ul.insertBefore(li, referenceNode);   
  });

function HaceClick() {
        alert('Ha pulsado Nuevo Link!');
     
    }


It will appear in the left sidebar menu