2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-02-07 16:59:18 +00:00

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
This commit is contained in:
rudolfkoenig 2017-08-15 20:06:05 +00:00
parent 5b36d0fa59
commit 0e111244a3

View File

@ -236,9 +236,12 @@ FW_jqueryReadyFn()
.html('<a>'+$(this).html()+'</a>') .html('<a>'+$(this).html()+'</a>')
.css({cursor:"pointer"}) .css({cursor:"pointer"})
.click(function(){ .click(function(){
var aname = "#sel_attr"+$(this).attr("data-name").replace(/\./g,'_'); var attrName = $(this).text();
$(aname).val($(this).text()); var sel = "#sel_attr"+$(this).attr("data-name").replace(/\./g,'_');
FW_detailSelect(aname); if($(sel+" option[value='"+attrName+"']").length == 0)
$(sel).append('<option value="'+attrName+'">'+attrName+'</option>');
$(sel).val(attrName);
FW_detailSelect(sel, true);
}); });
}); });
@ -991,7 +994,7 @@ FW_longpoll()
/*************** WIDGETS START **************/ /*************** WIDGETS START **************/
/*************** "Double" select in detail window ****/ /*************** "Double" select in detail window ****/
function function
FW_detailSelect(selEl) FW_detailSelect(selEl, mayMissing)
{ {
if(selEl.target) if(selEl.target)
selEl = selEl.target; selEl = selEl.target;
@ -1003,18 +1006,21 @@ FW_detailSelect(selEl)
devName = $(div).attr("dev"), devName = $(div).attr("dev"),
cmd = $(div).attr("cmd"); cmd = $(div).attr("cmd");
for(var i1=0; i1<listArr.length; i1++) { var i1;
for(i1=0; i1<listArr.length; i1++) {
arg = listArr[i1]; arg = listArr[i1];
if(arg.indexOf(selVal) == 0 && if(arg.indexOf(selVal) == 0 &&
(arg.length == selVal.length || arg[selVal.length] == ':')) (arg.length == selVal.length || arg[selVal.length] == ':'))
break; break;
} }
if(i1==listArr.length)
return;
var vArr = []; var vArr = [];
if(arg.length > selVal.length) if(i1==listArr.length && !mayMissing)
vArr = arg.substr(selVal.length+1).split(","); return;
if(i1<listArr.length) {
if(arg.length > selVal.length)
vArr = arg.substr(selVal.length+1).split(",");
}
var newEl = FW_replaceWidget($(selEl).next(), devName, vArr,undefined,selVal); var newEl = FW_replaceWidget($(selEl).next(), devName, vArr,undefined,selVal);
if(cmd == "attr") if(cmd == "attr")