function mkmMultiOutSet(outs){ outs.forEach(oDev => { mkmOutSet(oDev.dev_id, oDev.out_id, oDev.action, oDev.autoOff); }); } function mkmOutSet(dev_id, id, action, autoOff = 0){ $.ajaxSetup({ cache: false }); $.ajax({ url: "mkm_out_set.php", type: "GET", data: "dev_id=" +dev_id+ "&id=" +id+ "&s="+action+"&autoOff="+autoOff, timeout: 30000, // sets timeout for the request (30 seconds) beforeSend: function(){ var key = 'D' + dev_id + 'O' + id; $("img#" + key).attr("src","img/loading2.gif"); }, error: function( jqXHR, textStatus, errorThrown ){ alert("Error: " + textStatus); }, success: function(xml){ $(xml).find("OUT").each(function(){ var xmlDevId = parseInt($(this).attr("dev_id")); var xmlId = parseInt($(this).attr("out_id")); var xmlRet = parseInt($(this).attr("return")); var key = 'D' + xmlDevId + 'O' + xmlId; if( xmlId == id && xmlDevId == dev_id ){ if( action == 1 && xmlRet == 1 ){ $("img#" + key).attr("src","img/icon_16_led_green_on.png"); $("img#" + key).attr("title","Zapnuto"); $("div#" + key + " input#mkm_out_off").show(); $("div#" + key + " input#mkm_out_on").hide(); if( autoOff > 0 ){ setTimeout(() => { $("img#" + key).attr("src","img/icon_16_led_red_on.png"); }, (autoOff * 1000) ); setTimeout(() => { $("img#" + key).attr("src","img/icon_16_led_red_on.png"); }, (autoOff * 1000) ); } }else if( action == 0 && xmlRet == 1 ){ $("img#" + key).attr("src","img/icon_16_led_red_on.png"); $("img#" + key).attr("title","Vypnuto"); $("div#" + key + " input#mkm_out_on").show(); $("div#" + key + " input#mkm_out_off").hide(); }else{ $("img#" + key).attr("src","img/icon_16_led_red_off.png"); $("img#" + key).attr("title","Nevim "+xmlRet); $("div#" + key + " input#mkm_out_off").show(); $("div#" + key + " input#mkm_out_on").show(); } } }); } }); } function mkmOutSetColor(dev_id, id){ $.ajaxSetup({ cache: false }); var color = $("#D" + dev_id + "O" + id + " input.color").val(); var brightness = $("#D" + dev_id + "O" + id + " input.brightness").val(); $.ajax({ url: "mkm_out_led_color_set.php", type: "GET", data: "dev_id=" +dev_id+ "&id=" +id+ "&color="+encodeURIComponent(color)+"&brightness="+brightness, timeout: 30000, // sets timeout for the request (30 seconds) beforeSend: function(){}, error: function( jqXHR, textStatus, errorThrown ){ alert("Error: " + textStatus); }, success: function(xml){} }); } function mkmLedSet(dev_id, id, action){ $.ajaxSetup({ cache: false }); $.ajax({ url: "mkm_led_set.php", type: "GET", data: "dev_id=" +dev_id+ "&id=" +id+ "&s="+action, timeout: 30000, // sets timeout for the request (30 seconds) beforeSend: function(){ var key = 'D' + dev_id + 'O' + id; $("img#" + key).attr("src","img/loading2.gif"); }, error: function( jqXHR, textStatus, errorThrown ){ alert("Error: " + textStatus); }, success: function(xml){ $(xml).find("LED").each(function(){ var xmlDevId = parseInt($(this).attr("dev_id")); var xmlId = parseInt($(this).attr("out_id")); var xmlRet = parseInt($(this).attr("return")); var key = 'D' + xmlDevId + 'O' + xmlId; if( xmlId == id && xmlDevId == dev_id ){ if( action == 1 && xmlRet == 1 ){ $("img#" + key).attr("src","img/icon_16_led_green_on.png"); $("img#" + key).attr("title","Zapnuto"); $("div#" + key + " input#mkm_out_off").show(); $("div#" + key + " input#mkm_out_on").hide(); }else if( action == 0 && xmlRet == 0 ){ $("img#" + key).attr("src","img/icon_16_led_red_on.png"); $("img#" + key).attr("title","Vypnuto"); $("div#" + key + " input#mkm_out_on").show(); $("div#" + key + " input#mkm_out_off").hide(); }else{ $("img#" + key).attr("src","img/icon_16_led_red_off.png"); $("img#" + key).attr("title","Nevim "+xmlRet); $("div#" + key + " input#mkm_out_off").show(); $("div#" + key + " input#mkm_out_on").show(); } } }); } }); } function mkmOutSettings(dev_id, out_id){ iMyWidth = window.screenX + (window.outerWidth/2) - (800/2); iMyHeight = window.screenY + (window.outerHeight/2) - (450/2); okno = window.open('mkmOutSettings.php?dev_id='+dev_id+'&out_id='+out_id+'', '_blank', 'width=800,height=450,left=' + iMyWidth + ',screenX=' + iMyWidth + ',top=' + iMyHeight + ',screenY=' + iMyHeight + ''); okno.focus(); }function grafDayNakup(){ iMyWidth = window.screenX + (window.outerWidth/2) - (800/2); iMyHeight = window.screenY + (window.outerHeight/2) - (450/2); okno = window.open('grafDayNakup.php', '_blank', 'width=800,height=450,left=' + iMyWidth + ',screenX=' + iMyWidth + ',top=' + iMyHeight + ',screenY=' + iMyHeight + ''); okno.focus(); }function grafDayVyroba(){ iMyWidth = window.screenX + (window.outerWidth/2) - (800/2); iMyHeight = window.screenY + (window.outerHeight/2) - (450/2); okno = window.open('grafDayVyroba.php', '_blank', 'width=800,height=450,left=' + iMyWidth + ',screenX=' + iMyWidth + ',top=' + iMyHeight + ',screenY=' + iMyHeight + ''); okno.focus(); }function grafDayProdej(){ iMyWidth = window.screenX + (window.outerWidth/2) - (800/2); iMyHeight = window.screenY + (window.outerHeight/2) - (450/2); okno = window.open('grafDayProdej.php', '_blank', 'width=800,height=450,left=' + iMyWidth + ',screenX=' + iMyWidth + ',top=' + iMyHeight + ',screenY=' + iMyHeight + ''); okno.focus(); }function grafDayZatez(){ iMyWidth = window.screenX + (window.outerWidth/2) - (800/2); iMyHeight = window.screenY + (window.outerHeight/2) - (450/2); okno = window.open('grafDayZatez.php', '_blank', 'width=800,height=450,left=' + iMyWidth + ',screenX=' + iMyWidth + ',top=' + iMyHeight + ',screenY=' + iMyHeight + ''); okno.focus(); }function grafDayNakupSum(){ iMyWidth = window.screenX + (window.outerWidth/2) - (800/2); iMyHeight = window.screenY + (window.outerHeight/2) - (450/2); okno = window.open('grafDayNakupSum.php', '_blank', 'width=800,height=450,left=' + iMyWidth + ',screenX=' + iMyWidth + ',top=' + iMyHeight + ',screenY=' + iMyHeight + ''); okno.focus(); }function grafDayVyrobaSum(){ iMyWidth = window.screenX + (window.outerWidth/2) - (800/2); iMyHeight = window.screenY + (window.outerHeight/2) - (450/2); okno = window.open('grafDayVyrobaSum.php', '_blank', 'width=800,height=450,left=' + iMyWidth + ',screenX=' + iMyWidth + ',top=' + iMyHeight + ',screenY=' + iMyHeight + ''); okno.focus(); }function grafDayProdejSum(){ iMyWidth = window.screenX + (window.outerWidth/2) - (800/2); iMyHeight = window.screenY + (window.outerHeight/2) - (450/2); okno = window.open('grafDayProdejSum.php', '_blank', 'width=800,height=450,left=' + iMyWidth + ',screenX=' + iMyWidth + ',top=' + iMyHeight + ',screenY=' + iMyHeight + ''); okno.focus(); }function grafHourZatez(){ iMyWidth = window.screenX + (window.outerWidth/2) - (800/2); iMyHeight = window.screenY + (window.outerHeight/2) - (450/2); okno = window.open('grafHourZatez.php', '_blank', 'width=800,height=450,left=' + iMyWidth + ',screenX=' + iMyWidth + ',top=' + iMyHeight + ',screenY=' + iMyHeight + ''); okno.focus(); }function zatezEdit(key){ iMyWidth = window.screenX + (window.outerWidth/2) - (800/2); iMyHeight = window.screenY + (window.outerHeight/2) - (450/2); okno = window.open('zatezEdit.php?key='+key+'', '_blank', 'width=800,height=450,left=' + iMyWidth + ',screenX=' + iMyWidth + ',top=' + iMyHeight + ',screenY=' + iMyHeight + ''); okno.focus(); }function inputEdit(key){ iMyWidth = window.screenX + (window.outerWidth/2) - (800/2); iMyHeight = window.screenY + (window.outerHeight/2) - (450/2); okno = window.open('inputEdit.php?key='+key+'', '_blank', 'width=800,height=450,left=' + iMyWidth + ',screenX=' + iMyWidth + ',top=' + iMyHeight + ',screenY=' + iMyHeight + ''); okno.focus(); }function termEdit(key){ iMyWidth = window.screenX + (window.outerWidth/2) - (800/2); iMyHeight = window.screenY + (window.outerHeight/2) - (450/2); okno = window.open('termEdit.php?key='+key+'', '_blank', 'width=800,height=450,left=' + iMyWidth + ',screenX=' + iMyWidth + ',top=' + iMyHeight + ',screenY=' + iMyHeight + ''); okno.focus(); }function grafDayTeplota(key){ iMyWidth = window.screenX + (window.outerWidth/2) - (800/2); iMyHeight = window.screenY + (window.outerHeight/2) - (450/2); okno = window.open('grafDayTeplota.php?key='+key+'', '_blank', 'width=800,height=450,left=' + iMyWidth + ',screenX=' + iMyWidth + ',top=' + iMyHeight + ',screenY=' + iMyHeight + ''); okno.focus(); }function grafDayMeteo(){ iMyWidth = window.screenX + (window.outerWidth/2) - (800/2); iMyHeight = window.screenY + (window.outerHeight/2) - (450/2); okno = window.open('grafDayMeteo.php', '_blank', 'width=800,height=450,left=' + iMyWidth + ',screenX=' + iMyWidth + ',top=' + iMyHeight + ',screenY=' + iMyHeight + ''); okno.focus(); }