mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 12:49:34 +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:
parent
084267bf91
commit
6594c04659
@ -218,7 +218,7 @@ FHEMWEB_Initialize($)
|
|||||||
|
|
||||||
###############
|
###############
|
||||||
# Initialize internal structures
|
# Initialize internal structures
|
||||||
map { addToAttrList($_) } (
|
map { addToAttrList($_, "FHEMWEB") } (
|
||||||
"cmdIcon",
|
"cmdIcon",
|
||||||
"devStateIcon:textField-long",
|
"devStateIcon:textField-long",
|
||||||
"devStateStyle",
|
"devStateStyle",
|
||||||
|
21
fhem/fhem.pl
21
fhem/fhem.pl
@ -104,10 +104,10 @@ sub Value($);
|
|||||||
sub WriteStatefile();
|
sub WriteStatefile();
|
||||||
sub XmlEscape($);
|
sub XmlEscape($);
|
||||||
sub addEvent($$;$);
|
sub addEvent($$;$);
|
||||||
sub addToDevAttrList($$);
|
sub addToDevAttrList($$;$);
|
||||||
sub applyGlobalAttrFromEnv();
|
sub applyGlobalAttrFromEnv();
|
||||||
sub delFromDevAttrList($$);
|
sub delFromDevAttrList($$);
|
||||||
sub addToAttrList($);
|
sub addToAttrList($;$);
|
||||||
sub delFromAttrList($);
|
sub delFromAttrList($);
|
||||||
sub addToWritebuffer($$@);
|
sub addToWritebuffer($$@);
|
||||||
sub attrSplit($);
|
sub attrSplit($);
|
||||||
@ -388,8 +388,8 @@ my @attrList = qw(
|
|||||||
timestamp-on-change-reading
|
timestamp-on-change-reading
|
||||||
);
|
);
|
||||||
$readingFnAttributes = join(" ", @attrList);
|
$readingFnAttributes = join(" ", @attrList);
|
||||||
my %framework_attrList = map { s/:.*//; $_ => 1 } @attrList;
|
my %attrSource = map { s/:.*//; $_ => "framework" } @attrList;
|
||||||
map { $framework_attrList{$_} = 1 } qw(
|
map { $attrSource{$_} = "framework" } qw(
|
||||||
ignore
|
ignore
|
||||||
disable
|
disable
|
||||||
disabledForIntervals
|
disabledForIntervals
|
||||||
@ -2802,7 +2802,7 @@ getAllAttr($;$$)
|
|||||||
$list .= " " if($list);
|
$list .= " " if($list);
|
||||||
$list .= $v;
|
$list .= $v;
|
||||||
map { s/:.*//;
|
map { s/:.*//;
|
||||||
$typeHash->{$_} = $framework_attrList{$_} ? "framework" : $type }
|
$typeHash->{$_} = $attrSource{$_} ? $attrSource{$_} : $type }
|
||||||
split(" ",$v) if($typeHash);
|
split(" ",$v) if($typeHash);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -4276,10 +4276,11 @@ AddDuplicate($$)
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Add an attribute to the userattr list, if not yet present
|
# Add an attribute to the userattr list, if not yet present
|
||||||
|
# module is the source, needed when searching for help
|
||||||
sub
|
sub
|
||||||
addToDevAttrList($$)
|
addToDevAttrList($$;$)
|
||||||
{
|
{
|
||||||
my ($dev,$arg) = @_;
|
my ($dev,$arg,$module) = @_;
|
||||||
|
|
||||||
my $ua = $attr{$dev}{userattr};
|
my $ua = $attr{$dev}{userattr};
|
||||||
$ua = "" if(!$ua);
|
$ua = "" if(!$ua);
|
||||||
@ -4287,6 +4288,7 @@ addToDevAttrList($$)
|
|||||||
grep { " $AttrList " !~ m/ $_ / }
|
grep { " $AttrList " !~ m/ $_ / }
|
||||||
split(" ", "$ua $arg");
|
split(" ", "$ua $arg");
|
||||||
$attr{$dev}{userattr} = join(" ", sort keys %hash);
|
$attr{$dev}{userattr} = join(" ", sort keys %hash);
|
||||||
|
map { s/:.*//; $attrSource{$_} = $module; } split(" ", $arg) if($module);
|
||||||
}
|
}
|
||||||
|
|
||||||
# The counterpart: delete it.
|
# The counterpart: delete it.
|
||||||
@ -4308,9 +4310,10 @@ delFromDevAttrList($$)
|
|||||||
|
|
||||||
|
|
||||||
sub
|
sub
|
||||||
addToAttrList($)
|
addToAttrList($;$)
|
||||||
{
|
{
|
||||||
addToDevAttrList("global", shift);
|
my ($arg,$module) = @_;
|
||||||
|
addToDevAttrList("global", $arg, $module);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub
|
sub
|
||||||
|
@ -309,7 +309,8 @@ FW_jqueryReadyFn()
|
|||||||
return;
|
return;
|
||||||
$("#devSpecHelp").remove();
|
$("#devSpecHelp").remove();
|
||||||
var sel=this, devName=m[2], selType=m[1];
|
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();
|
FW_smallScreenCommands();
|
||||||
@ -334,8 +335,17 @@ FW_jqueryReadyFn()
|
|||||||
}
|
}
|
||||||
|
|
||||||
function
|
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
|
FW_getHelp(devName, function(data) { // show either the next or the outer li
|
||||||
$("#content")
|
$("#content")
|
||||||
.append("<div id='workbench' style='display:none'></div>");
|
.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;
|
var mtype = wb.find("a[id]").attr("id"), aTag;
|
||||||
if(!mtype)
|
if(!mtype)
|
||||||
mtype = wb.find("a[name]").attr("name");
|
mtype = wb.find("a[name]").attr("name");
|
||||||
if(level == 3) // commandref
|
|
||||||
|
if(devName == "commandref")
|
||||||
mtype = "";
|
mtype = "";
|
||||||
|
|
||||||
if(mtype) { // current syntax: FHEMWEB-attr-webCmd
|
if(mtype) { // current syntax: FHEMWEB-attr-webCmd
|
||||||
@ -384,14 +395,6 @@ FW_displayHelp(devName, sel, selType, val, level)
|
|||||||
}
|
}
|
||||||
wb.remove();
|
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user