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

FHEMWEB console

git-svn-id: https://svn.fhem.de/fhem/trunk@1296 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2012-02-26 13:36:53 +00:00
parent 89236aa1be
commit 924e4b58a3
4 changed files with 74 additions and 25 deletions

View File

@ -16,6 +16,7 @@
- feature: webCmd in smallScreen added
- feature: TRX modules by Willi
- feature: FHEMWEB icons (by Joerg)
- feature: FHEMWEB console (== inform timer)
- 2011-12-31 (5.2)
- bugfix: applying smallscreen attributes to firefox/opera

View File

@ -417,7 +417,7 @@ FW_AnswerCall($)
$FW_cmdret = $docmd ? FW_fC($cmd) : "";
if($FW_inform) { # Longpoll header
$me->{inform} = $FW_room;
$me->{inform} = ($FW_room ? $FW_room : $FW_inform);
# NTFY_ORDER is larger than the normal order (50-)
$me->{NTFY_ORDER} = $FW_cname; # else notifyfn won't be called
my $c = $me->{CD};
@ -806,6 +806,7 @@ FW_roomOverview($)
# "Examples", "$FW_ME/cmd=style%20examples",
"Edit files", "$FW_ME/cmd=style%20list",
"Select style","$FW_ME/cmd=style%20select",
"Console", "$FW_ME/cmd=style%20console",
"", "");
my $lastname = ","; # Avoid double "".
for(my $idx = 0; $idx < @list; $idx+= 2) {
@ -1576,6 +1577,12 @@ FW_style($$)
}
FW_pO "</table></div>";
} elsif($a[1] eq "console") {
FW_pO "<script type=\"text/javascript\" src=\"$FW_ME/console.js\"></script>";
FW_pO "<div id=\"content\">";
FW_pO "<div id=\"console\">";
FW_pO "</div>";
FW_pO "</div>";
}
}
@ -1849,10 +1856,10 @@ FW_Notify($$)
return undef if(!$filter);
my $ln = $ntfy->{NAME};
my $dn = $dev->{NAME};
return undef if($filter ne "all" && AttrVal($dn, "room", "") ne $filter);
my $data;
if($filter eq "all" || AttrVal($dn, "room", "") eq $filter) {
FW_ReadIcons();
my @old = ($FW_wname, $FW_ME, $FW_longpoll, $FW_ss, $FW_tp);
@ -1863,12 +1870,30 @@ FW_Notify($$)
$FW_tp = AttrVal($FW_wname, "touchpad", $FW_ss);
my ($allSet, $cmdlist, $txt) = FW_devState($dn, "");
($FW_wname, $FW_ME, $FW_longpoll, $FW_ss, $FW_tp) = @old;
$data = "$dn;$dev->{STATE};$txt\n";
} elsif($filter eq "console") {
if($dev->{CHANGED}) { # It gets deleted sometimes (?)
my $tn = TimeNow();
if($attr{global}{mseclog}) {
my ($seconds, $microseconds) = gettimeofday();
$tn .= sprintf(".%03d", $microseconds/1000);
}
my $max = int(@{$dev->{CHANGED}});
my $dt = $dev->{TYPE};
for(my $i = 0; $i < $max; $i++) {
$data .= "$tn $dt $dn ".$dev->{CHANGED}[$i]."<br>\n";
}
}
}
if($data) {
# Collect multiple changes (e.g. from noties) into one message
$ntfy->{INFORMBUF} = "" if(!defined($ntfy->{INFORMBUF}));
$ntfy->{INFORMBUF} .= "$dn;$dev->{STATE};$txt\n";
$ntfy->{INFORMBUF} .= $data;
RemoveInternalTimer($ln);
InternalTimer(gettimeofday()+0.1, "FW_FlushInform", $ln, 0);
}
return undef;
}
@ -1881,6 +1906,7 @@ FW_FlushInform($)
return if(!$hash);
my $c = $hash->{CD};
print $c $hash->{INFORMBUF};
$hash->{INFORMBUF}="";
CommandDelete(undef, $name);
}

View File

@ -0,0 +1,30 @@
var consConn;
function
consUpdate()
{
if(consConn.readyState != 4 || consConn.status != 200)
return;
var el = document.getElementById("console");
if(el)
el.innerHTML=el.innerHTML+consConn.responseText;
consConn.abort();
consFill();
}
function
consFill()
{
consConn = new XMLHttpRequest();
consConn.open("GET", document.location.pathname+"?XHR=1&inform=console", true);
consConn.onreadystatechange = consUpdate;
consConn.send(null);
}
function
consStart()
{
setTimeout("consFill()", 1000);
}
window.onload = consStart;

View File

@ -1,13 +1,5 @@
var pollConn;
function
cmd(arg)
{
var req = new XMLHttpRequest();
req.open("GET", arg, true);
req.send(null);
}
function
doUpdate()
{