From 6b1bda504877a0a6e501d22946d224c08f7aa26a Mon Sep 17 00:00:00 2001 From: rudolfkoenig Date: Tue, 15 Aug 2017 20:06:05 +0000 Subject: [PATCH] fhemweb.js: add attributeName to dropdown if not present (Forum #75457) git-svn-id: https://svn.fhem.de/fhem/trunk@14906 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/www/pgm2/fhemweb.js | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/fhem/www/pgm2/fhemweb.js b/fhem/www/pgm2/fhemweb.js index 5a70b60ed..65ff2d343 100644 --- a/fhem/www/pgm2/fhemweb.js +++ b/fhem/www/pgm2/fhemweb.js @@ -236,9 +236,12 @@ FW_jqueryReadyFn() .html(''+$(this).html()+'') .css({cursor:"pointer"}) .click(function(){ - var aname = "#sel_attr"+$(this).attr("data-name").replace(/\./g,'_'); - $(aname).val($(this).text()); - FW_detailSelect(aname); + var attrName = $(this).text(); + var sel = "#sel_attr"+$(this).attr("data-name").replace(/\./g,'_'); + if($(sel+" option[value='"+attrName+"']").length == 0) + $(sel).append(''); + $(sel).val(attrName); + FW_detailSelect(sel, true); }); }); @@ -991,7 +994,7 @@ FW_longpoll() /*************** WIDGETS START **************/ /*************** "Double" select in detail window ****/ function -FW_detailSelect(selEl) +FW_detailSelect(selEl, mayMissing) { if(selEl.target) selEl = selEl.target; @@ -1003,18 +1006,21 @@ FW_detailSelect(selEl) devName = $(div).attr("dev"), cmd = $(div).attr("cmd"); - for(var i1=0; i1 selVal.length) - vArr = arg.substr(selVal.length+1).split(","); + if(i1==listArr.length && !mayMissing) + return; + if(i1 selVal.length) + vArr = arg.substr(selVal.length+1).split(","); + } var newEl = FW_replaceWidget($(selEl).next(), devName, vArr,undefined,selVal); if(cmd == "attr")