mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-04 22:19:38 +00:00
Some attribute values are selectable via dropdown
git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@1458 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
ab566b94fd
commit
bd6d8388af
@ -21,7 +21,7 @@ sub FW_makeEdit($$$);
|
|||||||
sub FW_makeTable($$@);
|
sub FW_makeTable($$@);
|
||||||
sub FW_ReadIcons();
|
sub FW_ReadIcons();
|
||||||
sub FW_roomOverview($);
|
sub FW_roomOverview($);
|
||||||
sub FW_select($$$$);
|
sub FW_select($$$$@);
|
||||||
sub FW_showLog($);
|
sub FW_showLog($);
|
||||||
sub FW_showRoom();
|
sub FW_showRoom();
|
||||||
sub FW_showWeblink($$$$);
|
sub FW_showWeblink($$$$);
|
||||||
@ -396,23 +396,13 @@ FW_AnswerCall($)
|
|||||||
$FW_tp ? "640,160" : "800,160");
|
$FW_tp ? "640,160" : "800,160");
|
||||||
##############################
|
##############################
|
||||||
# Axels FHEMWEB modules...
|
# Axels FHEMWEB modules...
|
||||||
my $fwextPtr;
|
|
||||||
if(defined($data{FWEXT})) {
|
if(defined($data{FWEXT})) {
|
||||||
foreach my $k (sort keys %{$data{FWEXT}}) {
|
foreach my $k (sort keys %{$data{FWEXT}}) {
|
||||||
if($arg =~ m/^$k/) {
|
if($arg =~ m/^$k/) {
|
||||||
|
no strict "refs";
|
||||||
if($data{FWEXT}{$k}{EMBEDDED}) {
|
($FW_RETTYPE, $FW_RET) = &{$data{FWEXT}{$k}{FUNC}}($arg);
|
||||||
$fwextPtr = $data{FWEXT}{$k};
|
use strict "refs";
|
||||||
last;
|
return 0;
|
||||||
|
|
||||||
} else {
|
|
||||||
no strict "refs";
|
|
||||||
($FW_RETTYPE, $FW_RET) = &{$data{FWEXT}{$k}{FUNC}}($arg);
|
|
||||||
use strict "refs";
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -497,7 +487,6 @@ FW_AnswerCall($)
|
|||||||
if($FW_tp || $FW_ss) {
|
if($FW_tp || $FW_ss) {
|
||||||
FW_pO '<link rel="apple-touch-icon-precomposed" href="'.$FW_ME.'/fhemicon.png"/>';
|
FW_pO '<link rel="apple-touch-icon-precomposed" href="'.$FW_ME.'/fhemicon.png"/>';
|
||||||
FW_pO '<meta name="apple-mobile-web-app-capable" content="yes"/>';
|
FW_pO '<meta name="apple-mobile-web-app-capable" content="yes"/>';
|
||||||
#FW_pO '<meta name="viewport" content="width=device-width"/>'
|
|
||||||
if($FW_ss) {
|
if($FW_ss) {
|
||||||
FW_pO '<meta name="viewport" content="width=320"/>';
|
FW_pO '<meta name="viewport" content="width=320"/>';
|
||||||
} elsif($FW_tp) {
|
} elsif($FW_tp) {
|
||||||
@ -511,15 +500,11 @@ FW_AnswerCall($)
|
|||||||
$prf = "smallscreen" if(!$prf && $FW_ss);
|
$prf = "smallscreen" if(!$prf && $FW_ss);
|
||||||
$prf = "touchpad" if(!$prf && $FW_tp);
|
$prf = "touchpad" if(!$prf && $FW_tp);
|
||||||
FW_pO "<link href=\"$FW_ME/".$prf."style.css\" rel=\"stylesheet\"/>";
|
FW_pO "<link href=\"$FW_ME/".$prf."style.css\" rel=\"stylesheet\"/>";
|
||||||
FW_pO "<link href=\"$fwextPtr->{STYLESHEET}\" rel=\"stylesheet\"/>"
|
|
||||||
if($fwextPtr && $fwextPtr->{STYLESHEET});
|
|
||||||
FW_pO "<script type=\"text/javascript\" src=\"$FW_ME/svg.js\"></script>"
|
FW_pO "<script type=\"text/javascript\" src=\"$FW_ME/svg.js\"></script>"
|
||||||
if($FW_plotmode eq "SVG");
|
if($FW_plotmode eq "SVG");
|
||||||
FW_pO "<script type=\"text/javascript\" src=\"$FW_ME/longpoll.js\"></script>"
|
FW_pO "<script type=\"text/javascript\" src=\"$FW_ME/fhemweb.js\"></script>";
|
||||||
if($FW_longpoll);
|
my $onload = $FW_longpoll ? "onload=\"FW_delayedStart()\"" : "";
|
||||||
FW_pO "<script type=\"text/javascript\" src=\"$fwextPtr->{JAVASCRIPT}\"></script>"
|
FW_pO "</head>\n<body name=\"$t\" $onload>";
|
||||||
if($fwextPtr && $fwextPtr->{JAVASCRIPT});
|
|
||||||
FW_pO "</head>\n<body name=\"$t\">";
|
|
||||||
|
|
||||||
if($FW_cmdret) {
|
if($FW_cmdret) {
|
||||||
$FW_detail = "";
|
$FW_detail = "";
|
||||||
@ -538,8 +523,7 @@ FW_AnswerCall($)
|
|||||||
}
|
}
|
||||||
|
|
||||||
FW_roomOverview($cmd);
|
FW_roomOverview($cmd);
|
||||||
if($fwextPtr) { &{$fwextPtr->{FUNC}}($arg); }
|
if($cmd =~ m/^style /) { FW_style($cmd,undef); }
|
||||||
elsif($cmd =~ m/^style /) { FW_style($cmd,undef); }
|
|
||||||
elsif($FW_detail) { FW_doDetail($FW_detail); }
|
elsif($FW_detail) { FW_doDetail($FW_detail); }
|
||||||
elsif($FW_room) { FW_showRoom(); }
|
elsif($FW_room) { FW_showRoom(); }
|
||||||
elsif($cmd =~ /^logwrapper/) { FW_logWrapper($cmd); }
|
elsif($cmd =~ /^logwrapper/) { FW_logWrapper($cmd); }
|
||||||
@ -681,13 +665,14 @@ FW_makeSelect($$$$)
|
|||||||
{
|
{
|
||||||
my ($d, $cmd, $list,$class) = @_;
|
my ($d, $cmd, $list,$class) = @_;
|
||||||
return if(!$list || $FW_hiddenroom{input});
|
return if(!$list || $FW_hiddenroom{input});
|
||||||
my @al = sort map { s/[:;].*//;$_ } split(" ", $list);
|
my @al = sort map { s/:.*//;$_ } split(" ", $list);
|
||||||
|
|
||||||
FW_pO "<form method=\"get\" action=\"$FW_ME$FW_subdir\">";
|
FW_pO "<form method=\"get\" action=\"$FW_ME$FW_subdir\">";
|
||||||
FW_pO FW_hidden("detail", $d);
|
FW_pO FW_hidden("detail", $d);
|
||||||
FW_pO FW_hidden("dev.$cmd$d", $d);
|
FW_pO FW_hidden("dev.$cmd$d", $d);
|
||||||
FW_pO FW_submit("cmd.$cmd$d", $cmd) . " $d";
|
FW_pO FW_submit("cmd.$cmd$d", $cmd) . " $d";
|
||||||
FW_pO FW_select("arg.$cmd$d",\@al,undef,$class);
|
FW_pO FW_select("arg.$cmd$d",\@al, undef, $class,
|
||||||
|
"FW_selChange(this.options[selectedIndex].text,'$list','val.$cmd$d')");
|
||||||
FW_pO FW_textfield("val.$cmd$d", 30, $class);
|
FW_pO FW_textfield("val.$cmd$d", 30, $class);
|
||||||
FW_pO "</form>";
|
FW_pO "</form>";
|
||||||
}
|
}
|
||||||
@ -721,7 +706,11 @@ FW_doDetail($)
|
|||||||
FW_makeTable($d, $defs{$d});
|
FW_makeTable($d, $defs{$d});
|
||||||
FW_pO "Readings" if($defs{$d}{READINGS});
|
FW_pO "Readings" if($defs{$d}{READINGS});
|
||||||
FW_makeTable($d, $defs{$d}{READINGS});
|
FW_makeTable($d, $defs{$d}{READINGS});
|
||||||
FW_makeSelect($d, "attr", getAllAttr($d),"attr");
|
my $attrList = getAllAttr($d);
|
||||||
|
my $roomList = join(",", sort keys %FW_rooms);
|
||||||
|
$roomList=~s/ /\ /g;
|
||||||
|
$attrList =~ s/room /room:$roomList /;
|
||||||
|
FW_makeSelect($d, "attr", $attrList,"attr");
|
||||||
FW_makeTable($d, $attr{$d}, "deleteattr");
|
FW_makeTable($d, $attr{$d}, "deleteattr");
|
||||||
|
|
||||||
|
|
||||||
@ -1287,10 +1276,11 @@ FW_hidden($$)
|
|||||||
##################
|
##################
|
||||||
# Generate a select field with option list
|
# Generate a select field with option list
|
||||||
sub
|
sub
|
||||||
FW_select($$$$)
|
FW_select($$$$@)
|
||||||
{
|
{
|
||||||
my ($n, $va, $def,$class) = @_;
|
my ($n, $va, $def,$class,$jfn) = @_;
|
||||||
my $s = "<select name=\"$n\" class=\"$class\">";
|
$jfn = ($jfn ? "onchange=\"$jfn\"" : "");
|
||||||
|
my $s = "<select $jfn name=\"$n\" class=\"$class\">";
|
||||||
|
|
||||||
foreach my $v (@{$va}) {
|
foreach my $v (@{$va}) {
|
||||||
if($def && $v eq $def) {
|
if($def && $v eq $def) {
|
||||||
@ -2068,7 +2058,7 @@ FW_devState($$)
|
|||||||
$link .= "&room=$room";
|
$link .= "&room=$room";
|
||||||
}
|
}
|
||||||
if($FW_longpoll) {
|
if($FW_longpoll) {
|
||||||
$txt = "<a onClick=\"cmd('$FW_ME$FW_subdir?XHR=1&$link')\">$txt</a>";
|
$txt = "<a onClick=\"FW_cmd('$FW_ME$FW_subdir?XHR=1&$link')\">$txt</a>";
|
||||||
|
|
||||||
} elsif($FW_ss || $FW_tp) {
|
} elsif($FW_ss || $FW_tp) {
|
||||||
$txt = "<a onClick=\"location.href='$FW_ME$FW_subdir?$link$rf'\">$txt</a>";
|
$txt = "<a onClick=\"location.href='$FW_ME$FW_subdir?$link$rf'\">$txt</a>";
|
||||||
|
78
webfrontend/pgm2/fhemweb.js
Normal file
78
webfrontend/pgm2/fhemweb.js
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
/*************** LONGPOLL START **************/
|
||||||
|
var FW_pollConn;
|
||||||
|
|
||||||
|
function
|
||||||
|
FW_cmd(arg) /* see also FW_devState */
|
||||||
|
{
|
||||||
|
var req = new XMLHttpRequest();
|
||||||
|
req.open("GET", arg, true);
|
||||||
|
req.send(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
function
|
||||||
|
FW_doUpdate()
|
||||||
|
{
|
||||||
|
if(FW_pollConn.readyState != 4 || FW_pollConn.status != 200)
|
||||||
|
return;
|
||||||
|
var lines = FW_pollConn.responseText.split("\n");
|
||||||
|
for(var i=0; i < lines.length; i++) {
|
||||||
|
var d = lines[i].split(";", 3); // Complete arg
|
||||||
|
if(d.length != 3)
|
||||||
|
continue;
|
||||||
|
var el = document.getElementById(d[0]);
|
||||||
|
if(el)
|
||||||
|
el.innerHTML=d[2];
|
||||||
|
}
|
||||||
|
FW_pollConn.abort();
|
||||||
|
FW_longpoll();
|
||||||
|
}
|
||||||
|
|
||||||
|
function
|
||||||
|
FW_longpoll()
|
||||||
|
{
|
||||||
|
FW_pollConn = new XMLHttpRequest();
|
||||||
|
var room="room=all";
|
||||||
|
var sa = document.location.search.substring(1).split("&");
|
||||||
|
for(var i = 0; i < sa.length; i++) {
|
||||||
|
if(sa[i].substring(0,5) == "room=")
|
||||||
|
room=sa[i];
|
||||||
|
}
|
||||||
|
var query = document.location.pathname+"?"+room+"&XHR=1&inform=1";
|
||||||
|
FW_pollConn.open("GET", query, true);
|
||||||
|
FW_pollConn.onreadystatechange = FW_doUpdate;
|
||||||
|
FW_pollConn.send(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
function
|
||||||
|
FW_delayedStart()
|
||||||
|
{
|
||||||
|
setTimeout("FW_longpoll()", 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
function
|
||||||
|
FW_selChange(sel, list, elName)
|
||||||
|
{
|
||||||
|
var value;
|
||||||
|
var l = list.split(" ");
|
||||||
|
for(var i=0; i < l.length; i++) {
|
||||||
|
var nv = l[i].split(":",2);
|
||||||
|
if(nv[0] == sel) {
|
||||||
|
value = nv[1]; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var el = document.getElementsByName(elName)[0];
|
||||||
|
if(value==undefined) {
|
||||||
|
newEl = document.createElement('input');
|
||||||
|
newEl.type='text'; newEl.size=30;
|
||||||
|
} else {
|
||||||
|
newEl = document.createElement('select');
|
||||||
|
var vArr = value.split(",");
|
||||||
|
for(var j=0; j < vArr.length; j++) {
|
||||||
|
newEl.options[j] = new Option(vArr[j], vArr[j]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
newEl.class=el.class; newEl.name=el.name;
|
||||||
|
el.parentNode.replaceChild(newEl, el);
|
||||||
|
}
|
||||||
|
/*************** LONGPOLL END **************/
|
@ -1,51 +0,0 @@
|
|||||||
var pollConn;
|
|
||||||
|
|
||||||
function
|
|
||||||
cmd(arg)
|
|
||||||
{
|
|
||||||
var req = new XMLHttpRequest();
|
|
||||||
req.open("GET", arg, true);
|
|
||||||
req.send(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
function
|
|
||||||
doUpdate()
|
|
||||||
{
|
|
||||||
if(pollConn.readyState != 4 || pollConn.status != 200)
|
|
||||||
return;
|
|
||||||
var lines = pollConn.responseText.split("\n");
|
|
||||||
for(var i=0; i < lines.length; i++) {
|
|
||||||
var d = lines[i].split(";", 3); // Complete arg
|
|
||||||
if(d.length != 3)
|
|
||||||
continue;
|
|
||||||
var el = document.getElementById(d[0]);
|
|
||||||
if(el)
|
|
||||||
el.innerHTML=d[2];
|
|
||||||
}
|
|
||||||
pollConn.abort();
|
|
||||||
longpoll();
|
|
||||||
}
|
|
||||||
|
|
||||||
function
|
|
||||||
longpoll()
|
|
||||||
{
|
|
||||||
pollConn = new XMLHttpRequest();
|
|
||||||
var room="room=all";
|
|
||||||
var sa = document.location.search.substring(1).split("&");
|
|
||||||
for(var i = 0; i < sa.length; i++) {
|
|
||||||
if(sa[i].substring(0,5) == "room=")
|
|
||||||
room=sa[i];
|
|
||||||
}
|
|
||||||
var query = document.location.pathname+"?"+room+"&XHR=1&inform=1";
|
|
||||||
pollConn.open("GET", query, true);
|
|
||||||
pollConn.onreadystatechange = doUpdate;
|
|
||||||
pollConn.send(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
function
|
|
||||||
delayedStart()
|
|
||||||
{
|
|
||||||
setTimeout("longpoll()", 1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
window.onload = delayedStart;
|
|
Loading…
x
Reference in New Issue
Block a user