From ec1c596bab775282bcd153048a6749bf5be6f968 Mon Sep 17 00:00:00 2001 From: phenning <> Date: Mon, 9 Oct 2017 17:07:06 +0000 Subject: [PATCH] alarm.js: Aktualisierte Version, angepasst an das aktuelle 95_Alarm.pm git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@15218 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- www/pgm2/alarm.js | 80 ++++++++++++++++++----------------------------- 1 file changed, 31 insertions(+), 49 deletions(-) diff --git a/www/pgm2/alarm.js b/www/pgm2/alarm.js index 435f3faf5..cd71bf6fa 100644 --- a/www/pgm2/alarm.js +++ b/www/pgm2/alarm.js @@ -4,55 +4,16 @@ // See 95_Alarm for licensing //######################################################################################## //# Prof. Dr. Peter A. Henning - -function HashTable() { - this.length = 0; - this.items = new Array(); - for (var i = 0; i < arguments.length; i += 2) { - if (typeof(arguments[i + 1]) != 'undefined') { - this.items[arguments[i]] = arguments[i + 1]; - this.length++; - } - } - - this.removeItem = function(in_key) { - var tmp_value; - if (typeof(this.items[in_key]) != 'undefined') { - this.length--; - var tmp_value = this.items[in_key]; - delete this.items[in_key]; - } - return tmp_value; - } - - this.getItem = function(in_key) { - return this.items[in_key]; - } - - this.setItem = function(in_key, in_value) - { - if (typeof(in_value) != 'undefined') { - if (typeof(this.items[in_key]) == 'undefined') { - this.length++; - } - this.items[in_key] = in_value; - } - return in_value; - } - - this.hasItem = function(in_key) { - return typeof(this.items[in_key]) != 'undefined'; - } - } function encodeParm(oldval) { var newval; - newval=oldval.replace('+', '%2B'); - newval=newval.replace('#', '%23'); + newval = oldval.replace(/\+/g, '%2B'); + newval = newval.replace(/#/g, '%23'); + newval = newval.replace(/"/g, '%27'); return newval; } -var ah = new HashTable('l0s','','l0e',''); +//var ah = new HashTable('l0s','','l0e',''); //------------------------------------------------------------------------------------------------------ // Write the Attribute Value @@ -90,6 +51,27 @@ function alarm_arm(name,level){ FW_cmd(url+'?XHR=1&cmd.'+name+'={Alarm_Arm("'+name+'",'+level+',"web","button","'+command+'")}'); } + +function alarm_testaction(name,dev,type){ + var cmd; + var nam; + if(type == 'set'){ + cmd = document.getElementById(dev).parentElement.children[2].children[0].value; + }else{ + cmd = document.getElementById(dev).parentElement.children[3].children[0].value; + } + var cmds; + cmds = cmd.replace(/\\/g, '\\'); + cmds = cmds.replace(/\'/g, '\"'); + cmds = cmds.replace(/\$/g, '\\$'); + alert( cmds ); + + var location = document.location.pathname; + if (location.substr(location.length-1,1) == '/') {location = location.substr(0,location.length-1);} + var url = document.location.protocol+"//"+document.location.host+location; + + FW_cmd(url+'?XHR=1&cmd.'+name+'={Alarm_Test("'+name+'","' + cmds + '")}'); + } function alarm_set(name){ @@ -119,9 +101,9 @@ function alarm_set(name){ } FW_cmd(url+'?XHR=1&cmd.'+name+'=attr '+name+' level'+i+'xec ' + val); } - for (var k in ah.items) { - ah.setItem(k,document.getElementById(k).value); - } + //for (var k in ah.items) { + // ah.setItem(k,document.getElementById(k).value); + //} // acquiring data for each sensor var sarr = document.getElementsByName('sensor'); @@ -134,8 +116,8 @@ function alarm_set(name){ } } val += "|"+sarr[k].children[2].children[0].value; - val += "|"+sarr[k].children[2].children[1].value; - val += "|"+sarr[k].children[3].children[0].options[sarr[k].children[3].children[0].selectedIndex].value; + val += "|"+sarr[k].children[3].children[0].value; + val += "|"+sarr[k].children[4].children[0].options[sarr[k].children[4].children[0].selectedIndex].value; FW_cmd(url+'?XHR=1&cmd.'+nam+'=attr '+nam+' alarmSettings ' + encodeParm(val)); } @@ -151,8 +133,8 @@ function alarm_set(name){ } } val += "|"+aarr[k].children[2].children[0].value; - val += "|"+aarr[k].children[2].children[1].value; val += "|"+aarr[k].children[3].children[0].value; + val += "|"+aarr[k].children[4].children[0].value; FW_cmd(url+'?XHR=1&cmd.'+nam+'=attr '+nam+' alarmSettings ' + encodeParm(val)); }