',a+="",a+="",a+=n.Enabled?"Tap to DISABLE program":"Tap to ENABLE program",a+="",a+=""}}$("#config_automation_automationlist").append(a),$("#config_automation_automationlist").listview("refresh"),$("#config_automation_automationlist li").unbind("click"),$("#config_automation_automationlist li").bind("click",function(){$("#config_automation_automationlist").attr("data-program-id",$(this).attr("data-program-id"))}),null!=e&&e()},Ha.WebApp.Configure.ReloadAutomationList=function(e){Ha.Data.ServiceCall("Config/AutomationGroup/List",null,"GET",function(a){Ha.Data.AutomationGroups=a,Ha.WebApp.Configure.RenderAutomationList(e)})},Ha.WebApp.Configure.GetProgramById=function(e){for(var a=0;a";$("#program_error_message_text").html("
Errors:
"+msg+'
Program disabled, fix errors first.
'),$("#program_error_message").popup().popup("open")}})},Ha.WebApp.Configure.InitGeneralSettings=function(){},Ha.WebApp.Configure.InitSmsinterface=function(){$("#configure_smsinterface_enabled").unbind("slidestop"),Ha.Data.ServiceCall("Config/Smsinterface/GetEnabled",null,"GET",function(e){$("#configure_smsinterface_enabled").val(e).slider("refresh")}),$("#configure_smsinterface_enabled").on("slidestop",function(){Ha.Data.ServiceCall("Config/Smsinterface/SetEnabled/"+$("#configure_smsinterface_enabled").val(),null,"POST",function(e){$("#configure_smsinterface_enabled").val(e).slider("refresh")})}),$("#configure_smsinterface_port").unbind("change"),Ha.Data.ServiceCall("Config/Smsinterface/GetPort",null,"GET",function(e){$("#configure_smsinterface_port").val(e)}),$("#configure_smsinterface_port").on("change",function(){Ha.Data.ServiceCall("Config/Smsinterface/SetPort/"+$("#configure_smsinterface_port").val(),null,"POST",function(e){$("#configure_smsinterface_port").val(e)})}),$("#configure_smsinterface_alowed_sender").unbind("change"),Ha.Data.ServiceCall("Config/Smsinterface/GetAlowedSender",null,"GET",function(e){$("#configure_smsinterface_alowed_sender").val(e)}),$("#configure_smsinterface_alowed_sender").on("change",function(){Ha.Data.ServiceCall("Config/Smsinterface/SetAlowedSender/"+$("#configure_smsinterface_alowed_sender").val(),null,"POST",function(e){$("#configure_smsinterface_alowed_sender").val(e)})}),$("#configure_smsinterface_debug").unbind("slidestop"),Ha.Data.ServiceCall("Config/Smsinterface/GetDebugMode",null,"GET",function(e){$("#configure_smsinterface_debug").val(e).slider("refresh")}),$("#configure_smsinterface_debug").on("slidestop",function(){Ha.Data.ServiceCall("Config/Smsinterface/SetDebugMode/"+$("#configure_smsinterface_debug").val(),null,"POST",function(e){$("#configure_smsinterface_debug").val(e).slider("refresh")})}),$("#add_sms_shortcut").unbind("click"),$("#add_sms_shortcut").on("click",function(){Ha.Data.ServiceCall("Config/Smsinterface/Add/"+$("#sms_shortcut").val(),$("#sms_comamnd").val(),"POST",function(e){"1"==e?($("#sms_shortcut").val(""),$("#sms_comamnd").val("")):alert("Error ading new user. The shortcut "+$("#sms_shortcut").val()+" already exist!")})}),$("#sms_shotcut_remove_popup").unbind("popupbeforeposition"),$("#sms_shotcut_remove_popup").on("popupbeforeposition",function(){Ha.WebApp.Configure.SmsinterfaceRemoveShortcutViewItems(function(e){$("#sms_shortcut_remove").empty(),$("#sms_shortcut_remove").append(e),$("#sms_shortcut_remove").selectmenu("refresh")})}),$("#sms_shortcut_button").unbind("click"),$("#sms_shortcut_button").on("click",function(){var e=$("#sms_shortcut_remove").find(":selected"),a=e.attr("data-context-value");Ha.Data.ServiceCall("Config/Smsinterface/Remove/"+a,null,"POST",null)})},Ha.WebApp.Configure.SmsinterfaceRemoveShortcutViewItems=function(e){var a="";Ha.Data.ServiceCall("Config/Smsinterface/List/",null,"GET",function(i){for(users=i,m=0;m'+o.Shortcut+" => "+o.Command+""}null!=e&&e(a)})},Ha.WebApp.Configure.UpdateResistor=function(e,a){var i="configure_gpio_"+e+"_resistor";"0"==a?($("#"+i+"_off").prop("checked",!0),$("#"+i+"_pull_up").prop("checked",!1),$("#"+i+"_pull_down").prop("checked",!1)):"2"==a?($("#"+i+"_off").prop("checked",!1),$("#"+i+"_pull_up").prop("checked",!0),$("#"+i+"_pull_down").prop("checked",!1)):"1"==a&&($("#"+i+"_off").prop("checked",!1),$("#"+i+"_pull_up").prop("checked",!1),$("#"+i+"_pull_down").prop("checked",!0)),$("input:radio[name="+i+"]").checkboxradio("refresh")},Ha.WebApp.Configure.UpdateDirection=function(e,a){var i="configure_gpio_"+e+"_direction",o="configure_gpio_"+e+"_resistor_group",t="configure_gpio_"+e+"_resistor";"0"==a?($("#"+i+"_input").prop("checked",!0),$("#"+i+"_output").prop("checked",!1),$("[id="+o+"]").each(function(){$(this).show()}),$("input:radio[name="+t+"]").unbind("click"),Ha.Data.ServiceCall("Config/Driver/RPiGPIO/GetPinProperty/"+e+"/GPIOResistor/",null,"GET",function(a){Ha.WebApp.Configure.UpdateResistor(e,a)}),$("input:radio[name="+t+"]").on("click",function(){Ha.Data.ServiceCall("Config/Driver/RPiGPIO/SetPinProperty/"+e+"/GPIOResistor/"+$("input[name="+t+"]:checked").val(),null,"POST",function(a){Ha.WebApp.Configure.UpdateResistor(e,a)})})):($("#"+i+"_input").prop("checked",!1),$("#"+i+"_output").prop("checked",!0),$("[id="+o+"]").each(function(){$(this).hide()})),$("input:radio[name="+i+"]").checkboxradio("refresh")},Ha.WebApp.Configure.UpdateEnabled=function(e,a){var i="configure_gpio_"+e+"_enabled_group",o="#configure_driver_rpigpio_"+e+"_enable",t="configure_gpio_"+e+"_direction";$(o).val(a).slider("refresh"),"0"!=$(o).val()?($("[id="+i+"]").each(function(){$(this).show()}),$("input:radio[name="+t+"]").unbind("click"),Ha.Data.ServiceCall("Config/Driver/RPiGPIO/GetPinProperty/"+e+"/IsOutput/",null,"GET",function(a){Ha.WebApp.Configure.UpdateDirection(e,a)}),$("input:radio[name="+t+"]").on("click",function(){Ha.Data.ServiceCall("Config/Driver/RPiGPIO/SetPinProperty/"+e+"/IsOutput/"+$("input[name="+t+"]:checked").val(),null,"POST",function(a){Ha.WebApp.Configure.UpdateDirection(e,a)})})):$("[id="+i+"]").each(function(){$(this).hide()})},Ha.WebApp.Configure.InitRPiGPIOPin=function(e){var a="#configure_driver_rpigpio_"+e+"_enable";$(a).unbind("slidestop"),Ha.Data.ServiceCall("Config/Driver/RPiGPIO/GetPinProperty/"+e+"/Enabled/",null,"GET",function(a){Ha.WebApp.Configure.UpdateEnabled(e,a)}),$(a).on("slidestop",function(){Ha.Data.ServiceCall("Config/Driver/RPiGPIO/SetPinProperty/"+e+"/Enabled/"+$(a).val()+"/",null,"POST",function(a){Ha.WebApp.Configure.UpdateEnabled(e,a)})})},Ha.WebApp.Configure.InitRPiGPIOPins=function(e){Ha.WebApp.Configure.InitRPiGPIOPin("Pin_P1_03"),Ha.WebApp.Configure.InitRPiGPIOPin("Pin_P1_05"),Ha.WebApp.Configure.InitRPiGPIOPin("Pin_P1_07"),Ha.WebApp.Configure.InitRPiGPIOPin("Pin_P1_08"),Ha.WebApp.Configure.InitRPiGPIOPin("Pin_P1_10"),Ha.WebApp.Configure.InitRPiGPIOPin("Pin_P1_11"),Ha.WebApp.Configure.InitRPiGPIOPin("Pin_P1_12"),Ha.WebApp.Configure.InitRPiGPIOPin("Pin_P1_13"),Ha.WebApp.Configure.InitRPiGPIOPin("Pin_P1_15"),Ha.WebApp.Configure.InitRPiGPIOPin("Pin_P1_16"),Ha.WebApp.Configure.InitRPiGPIOPin("Pin_P1_18"),Ha.WebApp.Configure.InitRPiGPIOPin("Pin_P1_19"),Ha.WebApp.Configure.InitRPiGPIOPin("Pin_P1_21"),Ha.WebApp.Configure.InitRPiGPIOPin("Pin_P1_22"),Ha.WebApp.Configure.InitRPiGPIOPin("Pin_P1_23"),Ha.WebApp.Configure.InitRPiGPIOPin("Pin_P1_24"),Ha.WebApp.Configure.InitRPiGPIOPin("Pin_P1_26"),"0"==e&&($("[id=gpio_pin_group2]").each(function(){$(this).hide()}),$("[id=gpio_pin_group3]").each(function(){$(this).hide()})),"1"==e?($("[id=gpio_pin_group2]").each(function(){$(this).show()}),$("[id=gpio_pin_group3]").each(function(){$(this).hide()}),Ha.WebApp.Configure.InitRPiGPIOPin("Pin_P5_03"),Ha.WebApp.Configure.InitRPiGPIOPin("Pin_P5_04"),Ha.WebApp.Configure.InitRPiGPIOPin("Pin_P5_05"),Ha.WebApp.Configure.InitRPiGPIOPin("Pin_P5_06")):"2"==e&&($("[id=gpio_pin_group2]").each(function(){$(this).hide()}),$("[id=gpio_pin_group3]").each(function(){$(this).show()}),Ha.WebApp.Configure.InitRPiGPIOPin("Pin_P1_29"),Ha.WebApp.Configure.InitRPiGPIOPin("Pin_P1_31"),Ha.WebApp.Configure.InitRPiGPIOPin("Pin_P1_32"),Ha.WebApp.Configure.InitRPiGPIOPin("Pin_P1_33"),Ha.WebApp.Configure.InitRPiGPIOPin("Pin_P1_35"),Ha.WebApp.Configure.InitRPiGPIOPin("Pin_P1_36"),Ha.WebApp.Configure.InitRPiGPIOPin("Pin_P1_37"),Ha.WebApp.Configure.InitRPiGPIOPin("Pin_P1_40"))},Ha.WebApp.Configure.InitRPiGPIOEnabled=function(e){$("#configure_driver_rpigpio_enabled").val(e).slider("refresh"),"0"!=$("#configure_driver_rpigpio_enabled").val()?($("[id=configure_driver_rpigpiooptions]").each(function(){$(this).show()}),$("#configure_driver_rpigpio_debug").unbind("slidestop"),Ha.Data.ServiceCall("Config/Driver/RPiGPIO/GetDebugMode/",null,"GET",function(e){$("#configure_driver_rpigpio_debug").val(e).slider("refresh")}),$("#configure_driver_rpigpio_debug").on("slidestop",function(){Ha.Data.ServiceCall("Config/Driver/RPiGPIO/SetDebugMode/"+$("#configure_driver_rpigpio_debug").val()+"/",null,"POST",function(e){$("#configure_driver_rpigpio_debug").val(e).slider("refresh")})}),$("#configure_driver_rpigpio_revision").unbind("change"),Ha.Data.ServiceCall("Config/Driver/RPiGPIO/GetRevision/",null,"GET",function(e){$("#configure_driver_rpigpio_revision").val(e),$("#configure_driver_rpigpio_revision").selectmenu("refresh"),Ha.WebApp.Configure.InitRPiGPIOPins(e)}),$("#configure_driver_rpigpio_revision").on("change",function(){Ha.Data.ServiceCall("Config/Driver/RPiGPIO/SetRevision/"+$("#configure_driver_rpigpio_revision").val(),null,"POST",function(e){$("#configure_driver_rpigpio_revision").val(e),$("#configure_driver_rpigpio_revision").selectmenu("refresh"),Ha.WebApp.Configure.InitRPiGPIOPins(e)})})):$("[id=configure_driver_rpigpiooptions]").each(function(){$(this).hide()})},Ha.WebApp.Configure.InitRPiGPIODriver=function(){$("#configure_driver_rpigpio_enabled").unbind("slidestop"),Ha.Data.ServiceCall("Config/Driver/RPiGPIO/GetIsEnabled/",null,"GET",function(e){Ha.WebApp.Configure.InitRPiGPIOEnabled(e)}),$("#configure_driver_rpigpio_enabled").on("slidestop",function(){Ha.Data.ServiceCall("Config/Driver/RPiGPIO/SetIsEnabled/"+$("#configure_driver_rpigpio_enabled").val()+"/",null,"POST",function(e){Ha.WebApp.Configure.InitRPiGPIOEnabled(e)})})},Ha.WebApp.Configure.Esp8266EasyIoTNodeAdd=function(){$("#configure_driver_esp8266easyiotaddnode_popup").popup("open"),$("#configure_driver_esp8266easyiot_nodeid").html(""),$("#configure_driver_esp8266easyiot_message").html("This operation will timeout in 30 seconds."),$("#configure_driver_esp8266easyiot_close_button").addClass("ui-disabled"),Ha.Data.ServiceCall("Config/Driver/Esp8266/AddNode/",null,"POST",function(e){0!=e?($("#configure_driver_esp8266easyiot_nodeid").html(e),$("#configure_driver_esp8266easyiot_message").html("node added.")):($("#configure_driver_esp8266easyiot_nodeid").html('timed out'),$("#configure_driver_esp8266easyiot_message").html("Operation falied.")),$("#configure_driver_esp8266easyiot_instructions").html(""),$("#configure_driver_esp8266easyiot_close_button").removeClass("ui-disabled")})},Ha.WebApp.Configure.Esp8266EasyIoTNodeRemovePopup=function(){$("#configure_driver_esp8266easyiotremovenode_popup").popup("open")},Ha.WebApp.Configure.VirtualNodeAdd=function(){$("#configure_driver_virtual_addnode_popup").popup("open"),$("#configure_driver_virtual_nodeid").html(""),$("#configure_driver_virtual_message").html(""),$("#configure_driver_virtual_close_button").addClass("ui-disabled"),Ha.Data.ServiceCall("Config/Driver/Virtual/AddNode/",null,"POST",function(e){0!=e?($("#configure_driver_virtual_nodeid").html(e),$("#configure_driver_virtual_message").html("node added.")):($("#configure_driver_virtual_nodeid").html('timed out'),$("#configure_driver_virtual_message").html("Operation falied.")),$("#configure_driver_virtual_instructions").html(""),$("#configure_driver_virtual_close_button").removeClass("ui-disabled")})},Ha.WebApp.Configure.VirtualRemovePopup=function(){$("#configure_driver_virtual_removenode_popup").popup("open")},Ha.WebApp.Events=Ha.WebApp.Events||{},Ha.WebApp.Events._statuspopupTimeout=null,Ha.WebApp.Events.es=null,Ha.WebApp.Events.InitializePage=function(){setTimeout(function(){Ha.WebApp.Events.SetupListener(),$(window).bind("scroll resize",function(){$("#statuspopup").css("top",$(this).scrollTop())})},2e3)},Ha.WebApp.Events.SetupListener=function(){Ha.WebApp.Events.es=new EventSource("/Api/EasyIoT/Events/RealTime.EventStream/"),Ha.WebApp.Events.es.onmessage=function(e){var event=eval("["+e.data+"]")[0],module=Ha.Data.Module.GetModuleByDomainAddress(event.Domain,event.Address);if(null!=module){var curprop=Ha.WebApp.Utility.GetModulePropertyByName(module,event.Property);Ha.WebApp.Utility.SetModulePropertyByName(module,event.Property,event.Value,event.Timestamp),Ha.WebApp.Control.SendEventToUi(module,event);var group="",gr=Ha.Data.Group.GetModuleGroup(module);null!=gr&&(group=gr.GroupName);var data=Ha.WebApp.Control.GetWidgetUIData(module),popupdata={icon:data.icon,title:''+group+" "+module.Description+" ",text:data.status,timestamp:Ha.WebApp.Control.GetWidgetDateTime(data.timestamp)};null!=popupdata&&Ha.WebApp.Events.ShowEventPopup(popupdata)}}},Ha.WebApp.Events.ShowEventPopup=function(e){var a='