2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 06:39:11 +00:00

fhem.pl: addToDevAttrList: add optional source for fhemweb help (Forum #120779)

git-svn-id: https://svn.fhem.de/fhem/trunk@24714 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2021-07-09 17:18:55 +00:00
parent 084267bf91
commit 6594c04659
3 changed files with 27 additions and 21 deletions

View File

@ -218,7 +218,7 @@ FHEMWEB_Initialize($)
###############
# Initialize internal structures
map { addToAttrList($_) } (
map { addToAttrList($_, "FHEMWEB") } (
"cmdIcon",
"devStateIcon:textField-long",
"devStateStyle",

View File

@ -104,10 +104,10 @@ sub Value($);
sub WriteStatefile();
sub XmlEscape($);
sub addEvent($$;$);
sub addToDevAttrList($$);
sub addToDevAttrList($$;$);
sub applyGlobalAttrFromEnv();
sub delFromDevAttrList($$);
sub addToAttrList($);
sub addToAttrList($;$);
sub delFromAttrList($);
sub addToWritebuffer($$@);
sub attrSplit($);
@ -388,8 +388,8 @@ my @attrList = qw(
timestamp-on-change-reading
);
$readingFnAttributes = join(" ", @attrList);
my %framework_attrList = map { s/:.*//; $_ => 1 } @attrList;
map { $framework_attrList{$_} = 1 } qw(
my %attrSource = map { s/:.*//; $_ => "framework" } @attrList;
map { $attrSource{$_} = "framework" } qw(
ignore
disable
disabledForIntervals
@ -2802,7 +2802,7 @@ getAllAttr($;$$)
$list .= " " if($list);
$list .= $v;
map { s/:.*//;
$typeHash->{$_} = $framework_attrList{$_} ? "framework" : $type }
$typeHash->{$_} = $attrSource{$_} ? $attrSource{$_} : $type }
split(" ",$v) if($typeHash);
};
@ -4276,10 +4276,11 @@ AddDuplicate($$)
}
# Add an attribute to the userattr list, if not yet present
# module is the source, needed when searching for help
sub
addToDevAttrList($$)
addToDevAttrList($$;$)
{
my ($dev,$arg) = @_;
my ($dev,$arg,$module) = @_;
my $ua = $attr{$dev}{userattr};
$ua = "" if(!$ua);
@ -4287,6 +4288,7 @@ addToDevAttrList($$)
grep { " $AttrList " !~ m/ $_ / }
split(" ", "$ua $arg");
$attr{$dev}{userattr} = join(" ", sort keys %hash);
map { s/:.*//; $attrSource{$_} = $module; } split(" ", $arg) if($module);
}
# The counterpart: delete it.
@ -4308,9 +4310,10 @@ delFromDevAttrList($$)
sub
addToAttrList($)
addToAttrList($;$)
{
addToDevAttrList("global", shift);
my ($arg,$module) = @_;
addToDevAttrList("global", $arg, $module);
}
sub

View File

@ -309,7 +309,8 @@ FW_jqueryReadyFn()
return;
$("#devSpecHelp").remove();
var sel=this, devName=m[2], selType=m[1];
FW_displayHelp(devName, sel, selType, val, 1);
var group = $(this).parent().find(':selected').parent().attr('label');
FW_displayHelp(devName, sel, selType, val, group);
});
FW_smallScreenCommands();
@ -334,8 +335,17 @@ FW_jqueryReadyFn()
}
function
FW_displayHelp(devName, sel, selType, val, level)
FW_displayHelp(devName, sel, selType, val, group)
{
if(group) {
if(group.indexOf("userattr") >= 0)
return;
if(group == "framework")
devName = "commandref";
else if(group != "Module")
devName = group;
}
FW_getHelp(devName, function(data) { // show either the next or the outer li
$("#content")
.append("<div id='workbench' style='display:none'></div>");
@ -345,7 +355,8 @@ FW_displayHelp(devName, sel, selType, val, level)
var mtype = wb.find("a[id]").attr("id"), aTag;
if(!mtype)
mtype = wb.find("a[name]").attr("name");
if(level == 3) // commandref
if(devName == "commandref")
mtype = "";
if(mtype) { // current syntax: FHEMWEB-attr-webCmd
@ -384,14 +395,6 @@ FW_displayHelp(devName, sel, selType, val, level)
}
wb.remove();
if(!$(aTag).length) {
while(++level <= 3) {
if(level == 2 && devName != "FHEMWEB")
return FW_displayHelp("FHEMWEB", sel, selType, val, level);
if(level == 3 && devName != "commandref")
return FW_displayHelp("commandref", sel, selType, val, level);
}
}
});
}