2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-10 03:06:37 +00:00

01_FHEMWEB.pm: remove trailing spaces

git-svn-id: https://svn.fhem.de/fhem/trunk@23295 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2020-12-05 11:45:39 +00:00
parent b00dc521c9
commit db0e89a370

View File

@ -264,7 +264,7 @@ FHEMWEB_Initialize($)
}
}
$cmds{show} = {
$cmds{show} = {
Fn=>"FW_show", ClientFilter=>"FHEMWEB",
Hlp=>"<devspec>, show temporary room with devices from <devspec>"
};
@ -505,8 +505,8 @@ FW_Read($$)
# Need to send set-cookie (if set) after succesful authentication
my $ah = $FW_chash->{".httpAuthHeader"};
$FW_headerlines .= $ah if($ah);
delete $FW_chash->{".httpAuthHeader"};
delete $FW_chash->{".httpAuthHeader"};
} else {
my $ah = $FW_chash->{".httpAuthHeader"};
TcpServer_WriteBlocking($hash,
@ -534,7 +534,7 @@ FW_Read($$)
$FW_ME = "/" . AttrVal($FW_wname, "webname", "fhem");
$FW_CSRF = (defined($defs{$FW_wname}{CSRFTOKEN}) ?
"&fwcsrf=".$defs{$FW_wname}{CSRFTOKEN} : "");
if($FW_use{sha} && $method eq 'GET' &&
$FW_httpheader{Connection} && $FW_httpheader{Connection} =~ /Upgrade/i &&
$FW_httpheader{Upgrade} && $FW_httpheader{Upgrade} =~ /websocket/i &&
@ -622,7 +622,7 @@ FW_finishRead($$$)
my $length = length($FW_RET);
my $expires = ($cacheable ?
"Expires: ".FmtDateTimeRFC1123($hash->{LASTACCESS}+900)."\r\n" :
"Expires: ".FmtDateTimeRFC1123($hash->{LASTACCESS}+900)."\r\n" :
"Cache-Control: no-cache, no-store, must-revalidate\r\n");
FW_log($arg, $length) if(AttrVal($FW_wname, "logDevice", undef));
Log3 $FW_wname, 4,
@ -637,7 +637,7 @@ FW_finishRead($$$)
if(!$hash->{isChild});
FW_closeConn($hash);
TcpServer_Close($hash, 1);
}
}
$FW_RET="";
}
@ -938,7 +938,7 @@ FW_answerCall($)
delete $me->{BUF};
$me->{isChild} = 1;
}
}
}
$FW_cmdret = $docmd ? FW_fC($cmd, $cmddev) : undef;
@ -1168,7 +1168,7 @@ FW_answerCall($)
$FW_room = AttrVal($FW_wname, "defaultRoom", '');
if($FW_room ne '') {
$srVal = FW_showRoom();
$srVal = FW_showRoom();
} else {
my $motd = AttrVal("global", "motd", "");
@ -1324,7 +1324,7 @@ FW_updateHashes()
if(AttrVal($FW_wname, "sortRooms", "")) { # Slow!
my @sortBy = split( " ", AttrVal( $FW_wname, "sortRooms", "" ) );
my %sHash;
my %sHash;
map { $sHash{$_} = FW_roomIdx(\@sortBy,$_) } keys %FW_rooms;
@FW_roomsArr = sort { $sHash{$a} cmp $sHash{$b} } @FW_roomsArr;
}
@ -1531,12 +1531,13 @@ FW_doDetail($)
FW_makeTable("Readings", $d, $h->{READINGS});
my $attrList = getAllAttr($d);
my $roomList = "multiple,".join(",",
my $roomList = "multiple,".join(",",
sort map { $_ =~ s/ /#/g ;$_} keys %FW_rooms);
my $groupList = "multiple,".join(",",
sort map { $_ =~ s/ /#/g ;$_} keys %FW_groups);
my $groupList = "multiple,".join(",",
sort map { $_ =~ s/ /#/g ;$_} keys %FW_groups);
$attrList =~ s/\broom\b/room:$roomList/;
$attrList =~ s/\bgroup\b/group:$groupList/;
$attrList = FW_widgetOverride($d, $attrList);
$attrList =~ s/\\/\\\\/g;
$attrList =~ s/'/\\'/g;
@ -1556,7 +1557,7 @@ FW_doDetail($)
if($d ne "global");
my $sfx = AttrVal("global", "language", "EN");
$sfx = ($sfx eq "EN" ? "" : "_$sfx");
FW_pH "$FW_ME/docs/commandref${sfx}.html#${t}", "Device specific help",
FW_pH "$FW_ME/docs/commandref${sfx}.html#${t}", "Device specific help",
undef, "detLink devSpecHelp";
FW_pO "<br><br>";
FW_pO "</div>";
@ -1591,15 +1592,15 @@ FW_makeTableFromArray($$@) {
sub
FW_roomIdx($$)
{
my ($arr,$v) = @_;
my ($arr,$v) = @_;
my ($index) = grep { $v =~ /^$arr->[$_]$/ } 0..$#$arr;
if( !defined($index) ) {
if( !defined($index) ) {
$index = 9999;
} else {
$index = sprintf( "%03i", $index );
}
return "$index-$v";
}
@ -1788,7 +1789,7 @@ FW_roomOverview($)
FW_pO FW_hidden("fw_id", $FW_id) if($FW_id);
FW_pO FW_hidden("room", $FW_room) if($FW_room);
FW_pO FW_hidden("fwcsrf", $defs{$FW_wname}{CSRFTOKEN}) if($FW_CSRF);
FW_pO FW_textfield("cmd",
FW_pO FW_textfield("cmd",
AttrVal($FW_wname, "mainInputLength", $FW_ss ? 25 : 40), "maininput");
FW_pO "</form>";
FW_pO "</td></tr></table>";
@ -1842,7 +1843,7 @@ FW_makeDeviceLine($$$$$)
# Commands, slider, dropdown
my $smallscreenCommands = AttrVal($FW_wname, "smallscreenCommands", "");
if((!$FW_ss || $smallscreenCommands) && $cmdlist) {
my @a = split("[: ]", AttrVal($d, "cmdIcon",
my @a = split("[: ]", AttrVal($d, "cmdIcon",
$defs{$d}{cmdIcon} ? $defs{$d}{cmdIcon} : ""));
Log 1, "ERROR: bad cmdIcon definition for $d" if(@a % 2);
my %cmdIcon = @a;
@ -1872,7 +1873,7 @@ FW_makeDeviceLine($$$$$)
if($htmlTxt) {
$htmlTxt =~ s,^<td[^>]*>(.*)</td>$,$1,;
} else {
my $nCmd = $cmdIcon{$cmd} ?
my $nCmd = $cmdIcon{$cmd} ?
FW_makeImage($cmdIcon{$cmd},$cmd,"webCmd") : $cmd;
$htmlTxt = FW_pH "cmd.$d=set $d $cmd$rf", $nCmd, 0, "", 1, 1;
}
@ -1929,7 +1930,7 @@ FW_showRoom()
{
return 0 if(!$FW_room ||
AttrVal($FW_wname,"forbiddenroom","") =~ m/\b$FW_room\b/);
%FW_hiddengroup = ();
foreach my $r (split(",",AttrVal($FW_wname, "hiddengroup", ""))) {
$FW_hiddengroup{$r} = 1;
@ -1965,7 +1966,7 @@ FW_showRoom()
}
next if(!$FW_types{$dev}); # FHEMWEB connection, missed due to caching
foreach my $grp (split(",", AttrVal($dev, "group", $FW_types{$dev}))) {
next if($FW_hiddengroup{$grp});
next if($FW_hiddengroup{$grp});
next if($hge && $grp =~ m/$hge/);
$sortIndex{$dev} = FW_sortIndex($dev);
$group{$grp}{$dev} = 1;
@ -1983,7 +1984,7 @@ FW_showRoom()
for(my $col=1; $col < ($maxc==-1 ? 2 : $maxc); $col++) {
FW_pO "<td><table class=\"column tblcol_$col\">" if($maxc != -1);
# iterate over the distinct groups
# iterate over the distinct groups
foreach my $g (sort { $maxc==-1 ?
$a cmp $b :
($columns->{$a} ? $columns->{$a}->[0] : 99) <=>
@ -2187,7 +2188,7 @@ FW_returnFileAsStream($$$$$)
if(!open(FH, $path)) {
Log3 $FW_wname, 4, "FHEMWEB $FW_wname $path: $!";
TcpServer_WriteBlocking($FW_chash,
TcpServer_WriteBlocking($FW_chash,
"HTTP/1.1 404 Not Found\r\n".
"Content-Length:0\r\n\r\n");
FW_closeConn($FW_chash);
@ -2377,7 +2378,7 @@ FW_style($$)
my $start = '><table><tr><td';
my $end = "</td></tr></table></div>";
if($a[1] eq "list") {
FW_addContent($start);
FW_pO "$msg<br><br>" if($msg);
@ -2436,7 +2437,7 @@ FW_style($$)
FW_pO "Reload the page in the browser.$end";
} elsif($a[1] eq "edit") {
my $fileName = $a[2];
my $fileName = $a[2];
my $data = "";
my $cfgDB = defined($a[3]) ? $a[3] : "";
my $forceType = ($cfgDB eq 'configDB') ? $cfgDB : "file";
@ -2596,10 +2597,10 @@ FW_pH(@)
$link .= $FW_CSRF if($link =~ m/cmd/ &&
$link !~m/cmd=style%20(list|select|eventMonitor)/);
$link = ($link =~ m,^/,) ? $link : "$FW_ME$FW_subdir?$link";
# Using onclick, as href starts safari in a webapp.
# Known issue: the pointer won't change
if($FW_ss || $FW_tp) {
if($FW_ss || $FW_tp) {
$ret = "<a onClick=\"location.href='$link'\">$txt</a>";
} else {
$ret = "<a href=\"$link\">$txt</a>";
@ -2689,7 +2690,7 @@ FW_makeImage(@)
####
sub
FW_IconURL($)
FW_IconURL($)
{
my ($name)= @_;
return "$FW_ME/icons/$name";
@ -3147,7 +3148,7 @@ FW_Notify($$)
for(my $i = 0; $i < $max; $i++) {
my $t = (($ct && $ct->[$i]) ? $ct->[$i] : $tn);
my $line = "$t $dt $dn ".$events->[$i]."<br>";
eval {
eval {
my $ok;
if($h->{filterType} && $h->{filterType} eq "notify") {
$ok = ($dn =~ m/^$h->{filter}$/ ||
@ -3189,7 +3190,7 @@ FW_directNotify($@) # Notify without the event overhead (Forum #31293)
!$ntfy->{inform}{devices}{$dev} ||
$ntfy->{inform}{type} ne "status");
next if($filter && $ntfy->{inform}{filter} !~ m/$filter/);
if(!FW_addToWritebuffer($ntfy,
if(!FW_addToWritebuffer($ntfy,
FW_longpollInfo($ntfy->{inform}{fmt}, @_)."\n")) {
my $name = $ntfy->{NAME};
Log3 $name, 4, "Closing connection $name due to full buffer in FW_Notify";
@ -3231,7 +3232,7 @@ FW_devState($$@)
$cmdList = "desired-temp" if(!$cmdList);
} elsif(!$dsi && $allSets =~ m/\bdesiredTemperature:/) {
$txt = ReadingsVal($d, "temperature", "");
$txt = ReadingsVal($d, "temperature", "");
$txt =~ s/ .*//;
$txt .= "&deg;C";
$cmdList = "desiredTemperature" if(!$cmdList);
@ -3414,7 +3415,7 @@ FW_htmlEscape($)
###########################
# Widgets START
sub
sub
FW_widgetFallbackFn()
{
my ($FW_wname, $d, $FW_room, $cmd, $values) = @_;
@ -3447,25 +3448,25 @@ FW_widgetFallbackFn()
sub
FW_visibleDevices(;$)
{
my($FW_wname) = @_;
my($FW_wname) = @_;
my %devices = ();
my %devices = ();
foreach my $d (sort keys %defs) {
next if(!defined($defs{$d}));
my $h = $defs{$d};
next if(!$h->{TEMPORARY});
next if($h->{TYPE} ne "FHEMWEB");
next if(defined($FW_wname) && $h->{SNAME} ne $FW_wname);
next if(!defined($h->{inform}));
@devices{ keys %{$h->{inform}->{devices}} } =
@devices{ keys %{$h->{inform}->{devices}} } =
values %{$h->{inform}->{devices}};
}
return %devices;
}
sub
sub
FW_ActivateInform($;$)
{
my ($cl, $arg) = @_;
@ -3665,14 +3666,14 @@ FW_log($$)
confirm delete actions with a dialog. Default is 1, set it to 0 to
disable the feature.
</li>
<br>
<br>
<a name="confirmJSError"></a>
<li>confirmJSError<br>
JavaScript errors are reported in a dialog as default.
Set this attribute to 0 to disable the reporting.
</li>
<br>
<br>
<a name="CORS"></a>
<li>CORS<br>
@ -3713,7 +3714,7 @@ FW_log($$)
<a name="cmdIcon"></a>
<li>cmdIcon<br>
Space separated list of cmd:iconName pairs. If set, the webCmd text is
replaced with the icon. An easy method to set this value is to use
replaced with the icon. An easy method to set this value is to use
"Extend devStateIcon" in the detail-view, and copy its value.<br>
Example:<ul>
attr lamp cmdIcon on:control_centr_arrow_up off:control_centr_arrow_down
@ -3726,7 +3727,7 @@ FW_log($$)
commands. If set hides the <a href="#motd">motd</a>. Example:<br>
attr WEB defaultRoom Zentrale
</li>
<br>
<br>
<a name="devStateIcon"></a>
<li>devStateIcon<br>
@ -3737,7 +3738,7 @@ FW_log($$)
If the STATE of the device matches regexp, then icon-name will be
displayed as the status icon in the room, and (if specified) clicking
on the icon executes cmd. If FHEM cannot find icon-name, then the
STATE text will be displayed.
STATE text will be displayed.
Example:<br>
<ul>
attr lamp devStateIcon on:closed off:open<br>
@ -3976,7 +3977,7 @@ FW_log($$)
<a name="longpollSVG"></a>
<li>longpollSVG<br>
Reloads an SVG weblink, if an event should modify its content. Since
Reloads an SVG weblink, if an event should modify its content. Since
an exact determination of the affected events is too complicated, we
need some help from the definition in the .gplot file: the filter used
there (second parameter if the source is FileLog) must either contain
@ -4061,8 +4062,8 @@ FW_log($$)
The plots are created with the <a href="#SVG">SVG</a> module.
This is the default.</li>
<li>gnuplot-scroll<br>
The plots are created with the gnuplot program. The gnuplot
output terminal PNG is assumed. Scrolling to historical values
The plots are created with the gnuplot program. The gnuplot
output terminal PNG is assumed. Scrolling to historical values
is also possible, just like with SVG.</li>
<li>gnuplot-scroll-svg<br>
Like gnuplot-scroll, but the output terminal SVG is assumed.</li>
@ -4153,7 +4154,7 @@ FW_log($$)
attr WEB sortRooms DG OG EG Keller
</li>
<br>
<li>sslVersion<br>
See the global attribute sslVersion.
</li><br>
@ -4232,7 +4233,7 @@ FW_log($$)
attr lamp webCmd on:off:on-for-timer 10<br>
</ul>
<br>
The first specified command is looked up in the "set device ?" list
(see the <a href="#setList">setList</a> attribute for dummy devices).
If <b>there</b> it contains some known modifiers (colon, followed
@ -4243,12 +4244,12 @@ FW_log($$)
attr d1 webCmd state<br>
attr d1 readingList state<br>
attr d1 setList state:on,off<br><br>
define d2 dummy<br>
attr d2 webCmd state<br>
attr d2 readingList state<br>
attr d2 setList state:slider,0,1,10<br><br>
define d3 dummy<br>
attr d3 webCmd state<br>
attr d3 readingList state<br>
@ -4412,11 +4413,11 @@ FW_log($$)
<ul><code>
attr WEB column LivingRoom:FS20,notify|FHZ,notify DiningRoom:FS20|FHZ
</code></ul>
In diesem Beispiel werden im Raum LivingRoom die FS20 sowie die notify
Gruppe in der ersten Spalte, die FHZ und das notify in der zweiten
Spalte angezeigt.<br>
Anmerkungen: einige Elemente, wie SVG Plots und readingsGroup
k&ouml;nnen nur dann Teil einer Spalte sein wenn sie in <a
href="#group">group</a> stehen. Dieses Attribut kann man zum sortieren
@ -4431,15 +4432,15 @@ FW_log($$)
L&ouml;schaktionen weden mit einem Dialog best&auml;tigt.
Falls dieses Attribut auf 0 gesetzt ist, entf&auml;llt das.
</li>
<br>
<br>
<a name="confirmJSError"></a>
<li>confirmJSError<br>
JavaScript Fehler werden per Voreinstellung in einem Dialog gemeldet.
Durch setzen dieses Attributes auf 0 werden solche Fehler nicht
Durch setzen dieses Attributes auf 0 werden solche Fehler nicht
gemeldet.
</li>
<br>
<br>
<a name="CORS"></a>
<li>CORS<br>
@ -4485,7 +4486,7 @@ FW_log($$)
wurde. Achtung: falls gesetzt, wird motd nicht mehr angezeigt.
Beispiel:<br>
attr WEB defaultRoom Zentrale
</li><br>
</li><br>
<a name="devStateIcon"></a>
<li>devStateIcon<br>
@ -4498,7 +4499,7 @@ FW_log($$)
wird als icon-name das entsprechende Status Icon angezeigt, und (falls
definiert), l&ouml;st ein Klick auf das Icon das entsprechende cmd aus.
Wenn FHEM icon-name nicht finden kann, wird STATE als Text
angezeigt.
angezeigt.
Beispiel:<br>
<ul>
attr lamp devStateIcon on:closed off:open<br>
@ -4624,7 +4625,7 @@ FW_log($$)
<a name="hiddenroom"></a>
<li>hiddenroom<br>
Eine Komma getrennte Liste, um R&auml;ume zu verstecken, d.h. nicht
Eine Komma getrennte Liste, um R&auml;ume zu verstecken, d.h. nicht
anzuzeigen. Besondere Werte sind input, detail und save. In diesem
Fall werden diverse Eingabefelder ausgeblendent. Durch direktes Aufrufen
der URL sind diese R&auml;ume weiterhin erreichbar!<br>