mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-10 09:16:53 +00:00
98_weekprofile: build in function 'weekprofile_getEditLNK_MasterDev' to create a html link to edit a weekprofile
git-svn-id: https://svn.fhem.de/fhem/trunk@10367 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
8f840deac0
commit
f00a9dc176
@ -708,6 +708,48 @@ sub weekprofile_editOnNewpage(@)
|
||||
$html .= "</html>";
|
||||
return $html;
|
||||
}
|
||||
##############################################
|
||||
#search device weekprofile from a assoziated master device
|
||||
sub weekprofile_findPRFDev($)
|
||||
{
|
||||
my ($device) = @_;
|
||||
|
||||
foreach my $d (keys %defs)
|
||||
{
|
||||
my $module = $defs{$d}{TYPE};
|
||||
|
||||
next if ("$module" ne "weekprofile");
|
||||
|
||||
my $masterDev = $defs{$d}->{MASTERDEV}->{NAME};
|
||||
next unless(defined($masterDev));
|
||||
next if ($masterDev ne $device);
|
||||
|
||||
return $defs{$d}{NAME};
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
##############################################
|
||||
# get a web link to edit a profile from weekprofile from a assoziated master device
|
||||
sub weekprofile_getEditLNK_MasterDev($$)
|
||||
{
|
||||
my ($aszDev, $prf) = @_;
|
||||
|
||||
my $device = weekprofile_findPRFDev($aszDev);
|
||||
return "" if (!defined($device));
|
||||
|
||||
my $iconName = AttrVal($device, "icon", "edit_settings");
|
||||
|
||||
my $editIcon = FW_iconName($iconName) ? FW_makeImage($iconName,$iconName,"icon") : "";
|
||||
my $script = '<script type="text/javascript">';
|
||||
$script.= "function jump_edit_weekprofile_$aszDev() {";
|
||||
$script.= 'var url;var pos = location.href.indexOf("?"); if (pos>=0) {url = location.href.substr(pos);}';
|
||||
$script.= "window.location.assign('$FW_ME?cmd={weekprofile_editOnNewpage(";
|
||||
$script.= "\"$device\",\"$prf\",\"'+url+'\");;}')};";
|
||||
$script.= "</script>";
|
||||
|
||||
my $lnk = "$script<a onclick=\"jump_edit_weekprofile_$aszDev()\" href=\"javascript:void(0)\">$editIcon</a>";
|
||||
return ($lnk,0);
|
||||
}
|
||||
1;
|
||||
|
||||
=pod
|
||||
|
Loading…
x
Reference in New Issue
Block a user