//------------------------------------------------------------------------------ // CM - Hauptfunktion //------------------------------------------------------------------------------ var config = {} //-----------------------------------------------------------------------------------// function bodyDataAction () //-----------------------------------------------------------------------------------// { var menuButtons = document.getElementById("navbarBtn"). getElementsByTagName("button"); for (var i = 0; i < menuButtons.length; i++) { menuButtons[i].onclick = function(evt) { var res = evt.target.id; menu(res); }; } } //-----------------------------------------------------------------------------------// function menu (message, request=null) //-----------------------------------------------------------------------------------// { var selectedId = $(".selected").attr('id'); switch (message) { case 'pageDevices': console.log( "pageDevices") //loadContent('html/devices.html'); generateDevices(); document.getElementById('pageDevices').className = "btn btn-outline-light text-dark active"; document.getElementById('pageSettings').className = "btn btn-outline-light text-dark"; break; case 'pageSettings': console.log( "pageDevices") //loadContent('html/settings.html'); document.getElementById('pageDevices').className = "btn btn-outline-light text-dark"; document.getElementById('pageSettings').className = "btn btn-outline-light text-dark active"; break; case 'switchRequest': console.log( request ) switchRequest(request); break; default: alert ('[CM] Unbekannte Anfrage: ' + message); } } //-----------------------------------------------------------------------------------// function switchRequest (request) //-----------------------------------------------------------------------------------// { var req = request.split("."); switch (req[0]) { case 'yeelight': var bulb = req[1] var type = req[2] var value = req[3] var cmd = {}; cmd[bulb] = {}; cmd[bulb][type] = value; postYeelight(cmd); break; default: alert ('[POST] Unbekannte Anfrage: ' + req[0]); } } //-----------------------------------------------------------------------------------// function generateYeelightBulbs ( data , type) //-----------------------------------------------------------------------------------// { $( ".content" ).append($('