2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 18:59:33 +00:00

YAF: Activated modify-dialog for generic widget.

* generic widget: allow modify, allow click actions
* Foundations for widget modify
* Code optimization
* Code formating



git-svn-id: https://svn.fhem.de/fhem/trunk@3699 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
marcproe 2013-08-14 19:28:55 +00:00
parent ebaf5c1b07
commit a829409cd6
8 changed files with 282 additions and 160 deletions

View File

@ -32,112 +32,112 @@ use warnings;
use lib qw(YAF);
use YAF::YAFWidgets;
use YAF::YAFConfig;
use vars qw(%data);
use vars qw(%_GET);
use vars qw(%defs);
use vars qw($FW_cname);
use vars qw($FW_RET);
use vars qw($FW_dir);
use vars qw($FW_dir);
sub YAF_Request($@);
sub YAF_Request($@);
my $fhem_url;
my $yaf_version=0.41;
my $yafw_encoding = "UTF-8";
my $mp = AttrVal("global", "modpath", ".");
my $yafw_encoding = "UTF-8";
my $mp = AttrVal("global", "modpath", ".");
my $yaf_www_directory = $mp."/FHEM/YAF/www";
########################################################################################
#
# YAF_Initialize - register YAF with FHEM
#
# Parameter hash
#
# Parameter hash
#
########################################################################################
sub YAF_Initialize ($) {
my ($hash) = @_;
$hash->{DefFn} = "YAF_define";
$hash->{AttrList} = "views backgrounds refresh_interval";
my $name = "YAF";
$fhem_url = "/" . $name;
$data{FWEXT}{$fhem_url}{FUNC} = "YAF_Request";
$data{FWEXT}{$fhem_url}{LINK} = "YAF/www/global/yaf.htm";
$data{FWEXT}{$fhem_url}{NAME} = "YAF";
#-- load widgets
YAF_requireWidgets();
}
########################################################################################
#
# YAF_Print
#
# Parameter hash
#
# Parameter hash
#
########################################################################################
sub YAF_Print($@) {
if ($_[0]) {
$FW_RET .= $_[0];
$FW_RET .= $_[0];
}
}
########################################################################################
#
# YAF_Clean - clear output buffer
#
#
# no parameter
#
########################################################################################
sub YAF_Clean() {
$FW_RET = "";
$FW_RET = "";
}
########################################################################################
#
# YAF_LoadResource - Load a file from YAF directory
#
# Parameter hash
#
# Parameter hash
#
########################################################################################
sub YAF_LoadResource($@) {
my $absoluteFilePath = $_[0];
my $absoluteFilePath = $_[0];
my $filebuffer = "";
my $fh;
# Filename
my @absoluteFilePathSplitted = split(/\//, $absoluteFilePath);
my $filename = $absoluteFilePathSplitted[scalar(@absoluteFilePathSplitted)-1];
# Extension
my @filenameSplitted = split(/\./, $filename);
my $extension = $filenameSplitted[scalar(@filenameSplitted)-1];
#Log 1,"YAF_LoadResource absoluteFilePath $absoluteFilePath filename $filename extension $extension";
# Datei laden
if ((-f $absoluteFilePath) && open($fh, "<", $absoluteFilePath)) {
binmode $fh;
my ($data, $n);
while (($n = read $fh, $data, 4) != 0) {
$filebuffer .= $data;
$filebuffer .= $data;
}
}
else {
# Datei nicht gefunden
Log 1,"YAF_LoadResource: file $filename not found";
return YAF_NotFound($absoluteFilePath);
}
return YAF_NotFound($absoluteFilePath);
}
close($fh);
if ($extension eq "htm" || $extension eq "html") {
if ($extension eq "htm" || $extension eq "html") {
if ($filename eq "yaf.htm") {
# replace:
# ###widget_css###
@ -147,39 +147,39 @@ sub YAF_LoadResource($@) {
$filebuffer =~ s/###widget_css###/$widget_css/g;
$filebuffer =~ s/###widget_js###/$widget_js/g;
}
YAF_Print($filebuffer);
YAF_Print($filebuffer);
return ("text/html; charset=$yafw_encoding", $FW_RET);
}
elsif ($extension eq "gif") {
YAF_Print($filebuffer);
return ("image/gif; charset=$yafw_encoding", $FW_RET);
YAF_Print($filebuffer);
return ("image/gif; charset=$yafw_encoding", $FW_RET);
}
elsif ($extension eq "jpg" || $extension eq "jpeg") {
YAF_Print($filebuffer);
return ("image/jpeg; charset=$yafw_encoding", $FW_RET);
}
YAF_Print($filebuffer);
return ("image/jpeg; charset=$yafw_encoding", $FW_RET);
}
elsif ($extension eq "png") {
YAF_Print($filebuffer);
return ("image/png; charset=$yafw_encoding", $FW_RET);
}
YAF_Print($filebuffer);
return ("image/png; charset=$yafw_encoding", $FW_RET);
}
elsif ($extension eq "css") {
YAF_Print($filebuffer);
return ("text/css; charset=$yafw_encoding", $FW_RET);
}
YAF_Print($filebuffer);
return ("text/css; charset=$yafw_encoding", $FW_RET);
}
elsif ($extension eq "js") {
YAF_Print($filebuffer);
return ("text/javascript; charset=$yafw_encoding", $FW_RET);
}
YAF_Print($filebuffer);
return ("text/javascript; charset=$yafw_encoding", $FW_RET);
}
else {
YAF_Print($filebuffer);
return ("text/plain; charset=$yafw_encoding", $FW_RET);
YAF_Print($filebuffer);
return ("text/plain; charset=$yafw_encoding", $FW_RET);
}
}
########################################################################################
#
# YAF_define
#
#
# Parameter hash
#
########################################################################################
@ -191,22 +191,22 @@ sub YAF_define ($@) {
########################################################################################
#
# YAF_LoadView
#
# YAF_LoadView
#
# Parameter hash
#
########################################################################################
sub YAF_LoadView($@) {
my ($view) = @_;
YAF_Print("ddd");
return ("text/html; charset=$yafw_encoding", $FW_RET);
YAF_Print("ddd");
return ("text/html; charset=$yafw_encoding", $FW_RET);
}
########################################################################################
#
# YAF_Request - http://fhemurl:fhemport/YAF is processed here
#
#
# Parameter hash, request-string
#
########################################################################################
@ -215,10 +215,10 @@ sub YAF_Request ($@) {
my ($htmlarg) = @_;
# %20 durch Leerzeichen ersetzen
$htmlarg =~ s/%20/ /g;
# GET Parameter
my @params = split(/\?/, $htmlarg);
if (scalar(@params) > 1) {
my @attributesArray = split("&",$params[1]);
my @attributePair;
@ -227,25 +227,25 @@ sub YAF_Request ($@) {
$_GET{$attributePair[0]} = $attributePair[1];
}
}
@params = split(/\//, $params[0]);
#-- clean output buffer
YAF_Clean();
#-- take URI apart
my $controler_count = scalar(@params);
#Log 1,"YAF_Request: arguments $htmlarg params ".join(' ',@params);
#-- examples are
#/YAF/global/yaf.htm
#/YAF/global/js/yaf-dialogs.js
#/YAF/ajax/global/getRefreshTime
my $control_1 = $params[1];
my $control_2 = $params[2];
my $control_3 = $params[3];
if ($controler_count > 3) {
#-- either global, widget or ajax
if ($control_2 eq "global") {
@ -259,21 +259,21 @@ sub YAF_Request ($@) {
return YAF_LoadResource($request_file);
}
elsif ($control_2 eq "widget") {
return ("text/plain; charset=$yafw_encoding", $FW_RET);
return ("text/plain; charset=$yafw_encoding", $FW_RET);
}
elsif ($control_2 eq "ajax") {
if ($control_3 eq "global") {
if ($controler_count > 4) {
my $function = "";
$function = $params[4];
$function = $params[4];
if ($function eq "getViews") {
YAF_FHEMConfig();
my $views = encode_json(YAF_getViews());
YAF_Print($views);
YAF_Print($views);
}
#-- adds a View
elsif ($function eq "addView") {
if ($_GET{"name"} && (YAF_addView($_GET{"name"}) == 1)) {
if ($_GET{"name"} && (YAF_addView($_GET{"name"}) == 1)) {
YAF_Print("1");
}
else {
@ -282,7 +282,7 @@ sub YAF_Request ($@) {
}
#-- deletes a View
elsif ($function eq "deleteView") {
if ($_GET{"id"} && (YAF_deleteView($_GET{"id"}) == 1)) {
if ($_GET{"id"} && (YAF_deleteView($_GET{"id"}) == 1)) {
YAF_Print("1");
}
else {
@ -291,25 +291,25 @@ sub YAF_Request ($@) {
}
#-- returns all Widgets of a View
elsif ($function eq "getView") {
if ($_GET{"id"}) {
if ($_GET{"id"}) {
YAF_Print(encode_json(YAF_getView($_GET{"id"})));
}
else {
YAF_Print("0");
}
}
}
#-- changes the name of a View
elsif ($function eq "editView") {
if ($_GET{"id"} && $_GET{"name"}) {
if ($_GET{"id"} && $_GET{"name"}) {
YAF_Print(YAF_editView($_GET{"id"}, $_GET{"name"}));
}
else {
YAF_Print("0");
}
}
}
#-- modify position of a Widget
elsif ($function eq "setWidgetPosition") {
if ($_GET{"view_id"} && $_GET{"widget_id"} && $_GET{"x_pos"} && $_GET{"y_pos"}) {
if ($_GET{"view_id"} && $_GET{"widget_id"} && $_GET{"x_pos"} && $_GET{"y_pos"}) {
YAF_setWidgetPosition($_GET{"view_id"}, $_GET{"widget_id"}, $_GET{"x_pos"}, $_GET{"y_pos"});
YAF_Print("1");
}
@ -317,7 +317,7 @@ sub YAF_Request ($@) {
YAF_Print("0");
}
}
#-- get Widgets
#-- get Widgets
elsif ($function eq "getWidgets") {
my @widgets = YAF_getWidgetArray();
YAF_Print(encode_json(\@widgets));
@ -330,15 +330,31 @@ sub YAF_Request ($@) {
$_GET{"attributes"} =~ s/%22/"/g;
my @attributes_array = @{decode_json($_GET{"attributes"})};
my $widgetId = YAF_addWidget($_GET{"view_id"},$_GET{"widget"}, 28, 69, \@attributes_array);
YAF_Print($widgetId);
YAF_Print($widgetId);
}
else {
YAF_Print("0");
YAF_Print("0");
}
}
#-- delete Widget
elsif($function eq "deleteWidget"){
if ($_GET{"view_id"} && $_GET{"widget_id"} && (YAF_deleteWidget($_GET{"view_id"}, $_GET{"widget_id"}) == 1)) {
if ($_GET{"view_id"} && $_GET{"widget_id"} && (YAF_deleteWidget($_GET{"view_id"}, $_GET{"widget_id"}) == 1)) {
YAF_Print("1");
}
else {
YAF_Print("0");
}
}
#-- edit Widget // more or less: set widget attributes
elsif($function eq "editWidget"){
if ($_GET{"view_id"} && $_GET{"widget_id"} && $_GET{"keys"} && $_GET{"vals"}) {
my $viewid = $_GET{"view_id"};
my $widgetid = $_GET{"widget_id"};
my @keys = split(/,/,$_GET{"keys"});
my @vals = split(/,/,$_GET{"vals"});
for my $i (0 .. $#keys) {
YAF_setWidgetAttribute($viewid,$widgetid,$keys[$i],$vals[$i]);
}
YAF_Print("1");
}
else {
@ -367,13 +383,13 @@ sub YAF_Request ($@) {
YAF_Print("1");
}
else {
YAF_Print("0");
}
YAF_Print("0");
}
}
else {
YAF_Print("1");
YAF_Print("1");
}
return ("text/plain; charset=$yafw_encoding", $FW_RET);
return ("text/plain; charset=$yafw_encoding", $FW_RET);
}
#-- evaluation of a widget function
elsif ($control_3 eq "widget") {
@ -383,19 +399,19 @@ sub YAF_Request ($@) {
YAF_Print(eval($widget."_".$function."();")) or YAF_Print("0");
}
else {
YAF_Print("0");
YAF_Print("0");
}
#Log 1,"++++++++++++> Widget $widget called with function $function, length of return was ".length($FW_RET);
return ("text/plain; charset=$yafw_encoding", $FW_RET);
return ("text/plain; charset=$yafw_encoding", $FW_RET);
}
else {
Log 1,"YAF_Request: B response not found $control_1 $control_2";
return YAF_NotFound($htmlarg);
return YAF_NotFound($htmlarg);
}
}
else {
Log 1,"YAF_Request: C response not found $control_1 $control_2";
return YAF_NotFound($htmlarg);
return YAF_NotFound($htmlarg);
}
}
else {
@ -407,16 +423,16 @@ sub YAF_Request ($@) {
########################################################################################
#
# YAF_NotFound - Return a 404 Error
#
#
# Parameter hash, request-string
#
########################################################################################
sub YAF_NotFound{
my $file = $_[0];
YAF_Print("Error 404: $file");
YAF_Print("\n");
return ("text/html; charset=$yafw_encoding", $FW_RET);
YAF_Print("Error 404: $file");
YAF_Print("\n");
return ("text/html; charset=$yafw_encoding", $FW_RET);
}
1;

View File

@ -179,7 +179,6 @@ sub YAF_editView{
#save new config
fhem ("attr yaf views $newview");
#fhem("save");
return 1;
}
@ -252,8 +251,6 @@ sub YAF_deleteView{
fhem ("attr global userattr $newuserattr");
}
#fhem("save");
return 1;
}
@ -298,7 +295,6 @@ sub YAF_addView{
fhem ("attr yaf views $newview");
fhem ("attr yaf backgrounds $newbackground");
fhem ("attr global userattr $newuserattr");
#fhem("save");
return 1;
}
@ -354,7 +350,6 @@ sub YAF_addWidget{
$newId = 0;
} else {
fhem("attr $fhemname yaf_$viewId $widgetString");
#fhem("save");
}
return $newId;
@ -383,7 +378,6 @@ sub YAF_deleteWidget{
delete $fhemwidgets{$viewId}{$widgetId};
fhem("deleteattr $widgetname yaf_$viewId");
#fhem("save");
return 1;
}
@ -446,7 +440,6 @@ sub YAF_setWidgetPosition{
}
fhem("attr $widgetname yaf_$viewId $newattr");
#fhem("save");
}
#######################################################################################
@ -494,7 +487,6 @@ sub YAF_getWidgetAttribute{
}
}
}
if(length $retAttr > 0) {
return $retAttr; #return the found config
} else {
@ -517,7 +509,6 @@ sub YAF_getRefreshTime{
} else {
Log 1,"YAF_getRefreshTime: refresh_interval attribute was not found (so it will be created with a default value)";
fhem("attr yaf refresh_interval 60");
fhem("save");
return 60;
}
}
@ -534,7 +525,6 @@ sub YAF_setRefreshTime{
if($newRefreshInterval =~ /^\d+$/) {
fhem("attr yaf refresh_interval $newRefreshInterval");
#fhem("save");
return 1;
} else {
Log 1,"YAF_setRefreshTime: no valid refresh value or refresh attribute was not found";
@ -542,4 +532,29 @@ sub YAF_setRefreshTime{
}
}
sub YAF_setWidgetAttribute{
my $viewId = $_[0];
my $widgetId = $_[1];
my $key = $_[2];
my $val = $_[3];
my $widgetname = $fhemwidgets{$viewId}{$widgetId};
my %attrhash = ();
foreach my $attrs (split (/,/,AttrVal($widgetname, "yaf_".$viewId, undef))) {
my @attr = split(/=/,$attrs);
$attrhash{$attr[0]} = $attr[1];
}
$attrhash{$key} = $val;
my $newattr = "id=" . $widgetId . ",";
foreach my $ckey (keys %attrhash) {
if ($ckey ne "id" and defined $attrhash{$ckey}) {
$newattr .= $ckey."=".$attrhash{$ckey}.",";
}
}
fhem("attr $widgetname yaf_$viewId $newattr");
}
1;

View File

@ -165,6 +165,11 @@ sub fht80_get_addwidget_prepare_attributes() {
return $output;
}
sub fht80_get_editwidget_setup_html() {
my $output = "";
$output .= "TEST!";
return $output;
}
########################################################################################
#
# fht80t_getwidget_html - HTML code for this widget. DO WE NEED THIS ? SEE ABOVE
@ -201,12 +206,12 @@ sub fht80_get_temp() {
}
# get all the needed data
my $temp = fht80_isdef($defs{$fhemname}{READINGS}{temperature}{VAL}, 0);
my $temptimestamp = fht80_isdef($defs{$fhemname}{READINGS}{temperature}{TIME}, "");
my $actuator = fht80_isdef($defs{$fhemname}{READINGS}{actuator}{VAL}, "");
my $mode = fht80_isdef($defs{$fhemname}{READINGS}{mode}{VAL}, "none");
my $desi = fht80_isdef($defs{$fhemname}{READINGS}{"desired-temp"}{VAL}, "");
my $battery = fht80_isdef($defs{$fhemname}{READINGS}{battery}{VAL}, "");
my $temp = ReadingsVal($fhemname, "temperature", 0);
my $temptimestamp = ReadingsTimestamp($fhemname, "temperature", "big-bang");
my $actuator = ReadingsVal($fhemname, "actuator", "");
my $mode = ReadingsVal($fhemname, "mode", "none");
my $desi = ReadingsVal($fhemname, "desired-temp", "");
my $battery = ReadingsVal($fhemname, "battery", "");
my $nomode = YAF_getWidgetAttribute($viewid, $widgetid, "nomode", 0);
my $labeltype = YAF_getWidgetAttribute($viewid, $widgetid, "labeltype", "");
$ret[1] = YAF_getWidgetAttribute($viewid, $widgetid, "size", 1); #we don't process the size, so put it in the return array right away.
@ -238,8 +243,4 @@ sub fht80_get_temp() {
return encode_json(\@ret);
}
sub fht80_isdef() {
return ((defined $_[0]) ? $_[0] : $_[1]);
}
1;

View File

@ -72,8 +72,26 @@ sub generic_get_widgetjs() {
}
return str.indexOf(suffix, str.length - suffix.length) !== -1;
}
function generic_on_click(view_id, widget_id) {
$.ajax({
type: "GET",
async: true,
url: "../../ajax/widget/generic/on_click",
data: "view_id="+view_id+"&widget_id="+widget_id,
context: document.body,
success: function(data){
var mydata = jQuery.parseJSON(data);
if(mydata[0] == "redirect") {
window.location.href = mydata[1];
} else {
generic_update_widget(view_id, widget_id);
}
}
});
}
function generic_update_widget(view_id, widget_id) {
$.ajax({
type: "GET",
@ -188,6 +206,25 @@ sub generic_get_addwidget_setup_html() {
# return encode_json(\@ret);
# }
sub generic_get_editwidget_setup_html() {
my $viewId = $_GET{"view_id"};
my $widgetId = $_GET{"widget_id"};
my $output = "";
my $fhemname = YAF_getWidgetAttribute($viewId, $widgetId, "fhemname", "");
my $labeltype = YAF_getWidgetAttribute($viewId, $widgetId, "labeltype","");
my $statetype = YAF_getWidgetAttribute($viewId, $widgetId, "statetype","");
my $showlabel = YAF_getWidgetAttribute($viewId, $widgetId, "showlabel","1");
my $showicon = YAF_getWidgetAttribute($viewId, $widgetId, "showicon","1");
$output .= "<label title='Name des Devices'>Name:</label><input class='input_edit_widget' disabled='disabled' name='fhemname' value='" . $fhemname . "' /><br />";
$output .= "<label title='Welches Attributfeld soll als Label des Widgets gezeigt werden?'>Label (Attribut):</label><input class='input_edit_widget' name='labeltype' value='" . $labeltype . "' /><br />";
$output .= "<label title='Welches Reading soll als Status gezeigt werden?'>Status (Reading):</label><input class='input_edit_widget' name='statetype' value='" . $statetype . "' /><br />";
$output .= "<label title='Soll das Label angezeigt werden?'>Label anzeigen? (1/0):</label><input class='input_edit_widget' name='showlabel' value='" . $showlabel . "' /><br />";
$output .= "<label title='Soll das Icon angezeigt werden?'>Icon anzeigen? (1/0):</label><input class='input_edit_widget' name='showicon' value='" . $showicon . "' /><br />";
return $output;
}
########################################################################################
#
# generic_get_addwidget_prepare_attributes -
@ -231,15 +268,18 @@ sub generic_getwidget_html() {
########################################################################################
sub generic_get_state() {
my $fhemname = YAF_getWidgetAttribute($_GET{"view_id"}, $_GET{"widget_id"}, "fhemname");
my $labeltype = YAF_getWidgetAttribute($_GET{"view_id"}, $_GET{"widget_id"}, "labeltype","");
my $statetype = YAF_getWidgetAttribute($_GET{"view_id"}, $_GET{"widget_id"}, "statetype","");
my $showlabel = YAF_getWidgetAttribute($_GET{"view_id"}, $_GET{"widget_id"}, "showlabel","1");
my $showicon = YAF_getWidgetAttribute($_GET{"view_id"}, $_GET{"widget_id"}, "showicon","1");
my $viewId = $_GET{"view_id"};
my $widgetId = $_GET{"widget_id"};
my $fhemname = YAF_getWidgetAttribute($viewId, $widgetId, "fhemname", "");
my $labeltype = YAF_getWidgetAttribute($viewId, $widgetId, "labeltype","");
my $statetype = YAF_getWidgetAttribute($viewId, $widgetId, "statetype","");
my $showlabel = YAF_getWidgetAttribute($viewId, $widgetId, "showlabel","1");
my $showicon = YAF_getWidgetAttribute($viewId, $widgetId, "showicon","1");
my $d = $defs{$fhemname};
my $state = $d->{STATE};
my $iconpath = "/fhem/images/default/";
my $iconpath = "";
my @ret = ();
if(!defined $state) {
@ -251,8 +291,9 @@ sub generic_get_state() {
if(defined $devStateIcon) {
foreach my $entry (split (/ /,$devStateIcon)) {
my @keyval = split(/:/,$entry);
if($keyval[0] =~ $state) {
$iconpath .= $keyval[1] . ".png";
my $regex = $keyval[0];
if($state =~ m/$regex/) {
$iconpath = "/fhem/images/default/" . $keyval[1] . ".png";
}
}
$ret[1] = $iconpath;
@ -266,7 +307,7 @@ sub generic_get_state() {
$ret[0] =~ s/( )/&nbsp;/g;
if($statetype ne "") {
$ret[2] = generic_isdef($defs{$fhemname}{READINGS}{$statetype}{VAL}, "no-reading");
$ret[2] = ReadingsVal($fhemname, $statetype, "no-reading");
} else {
$ret[2] = $state;
}
@ -289,8 +330,30 @@ sub generic_get_state() {
}
}
sub generic_isdef() {
return ((defined $_[0]) ? $_[0] : $_[1]);
sub generic_on_click() {
my $fhemname = YAF_getWidgetAttribute($_GET{"view_id"}, $_GET{"widget_id"}, "fhemname");
my $d = $defs{$fhemname};
my $clicklink = YAF_getWidgetAttribute($_GET{"view_id"}, $_GET{"widget_id"}, "clicklink", "");
my @ret = ();
if($clicklink ne "") {
if($clicklink eq "_detail") {
$ret[0] = "redirect";
$ret[1] = "/fhem?detail=" . $fhemname;
} else {
$ret[0] = "redirect";
$ret[1] = $clicklink;
}
return encode_json(\@ret);
}
my $setstate = YAF_getWidgetAttribute($_GET{"view_id"}, $_GET{"widget_id"}, "_".$d->{STATE}, "");
if($setstate ne "") {
fhem("set " . $fhemname . " " . $setstate);
return encode_json(\@ret);
}
}
1;

View File

@ -422,15 +422,12 @@ function init_handlers() {
});
$("#button_saveconfig").click(function () {
//window.location.href = "../../../../fhem?cmd=save";
//return false;
$.ajax({
type: "GET",
async: true,
url: "../../ajax/global/saveconfig",
context: document.body,
success: function (jsondata) {
//console.log("Config saved " + jsondata);
$("#button_saveconfig").button({
icons: {
secondary: "ui-icon-check"

View File

@ -265,16 +265,53 @@ function init_dialogs() {
$("#dialog_editwidget").dialog({
autoOpen: false,
resizable: true,
height: 300,
width: 400,
height: 400,
width: 500,
modal: true,
buttons: {
"Speichern": function (ui) {
"Speichern": function (ui) {
var keys = new Array();
var vals = new Array();
keys[0] = "id";
vals[0] = current_widget_id;
$('.input_edit_widget').each(function(i, obj) {
keys[i+1] = obj.name;
vals[i+1] = obj.value;
});
$.ajax({
type: "GET",
async: false,
url: "../../ajax/global/editWidget",
data: "view_id="+current_view_id+"&widget_id="+current_widget_id+"&keys="+keys+"&vals="+vals,
context: document.body,
success: function (jsondata) {
}
});
$(this).dialog("close");
},
"Abbrechen": function () {
$(this).dialog("close");
}
},
open: function (event, ui) {
$("#dialog_addwidget_loading").show();
$.ajax({
type: "GET",
async: false,
url: "../../ajax/widget/generic/get_editwidget_setup_html",
data: "view_id="+current_view_id+"&widget_id="+current_widget_id,
context: document.body,
success: function (jsondata) {
//var myform = jQuery.parseJSON(jsondata);
$("#dialog_editwidget_setup_form").html(jsondata);
$("#dialog_addwidget_loading").hide();
}
});
}
});

View File

@ -36,34 +36,28 @@
<script type="text/javascript" src="js/jquery.ui.touch-punch.min.js"></script>
<script type="text/javascript" src="js/yaf-dialogs.js"></script>
<script type="text/javascript" src="js/yaf-basics.js"></script>
<script>
// Array mit den Namen und den zugehörigen Id's der Sichten
var views = new Array();
var widgets = new Array();
var current_view_id = null;
var current_widget_id = null;
var refreshTime = null;
// Modus in der Sich YAF befindet
// modus=0: Live Modus
// modus=1: Positionierungs Modus
// modus=1: Positionierungs Modus
var view_mode = 0;
var widgetWasMoved = false;
var close_widget_menue = true;
// Speichert die Id der View, die gelöscht werden soll
var delete_view_id = null;
var edit_view_name = null;
var edit_view_id = null;
var add_widget_name = null;
// Initialisiert die Oberfläche
function init() {
$.ajaxSetup({ cache: false });
@ -76,23 +70,22 @@
init_RefreshWidgets();
if(window.location != window.parent.location) {
$('#menue').toggle();
}
}
return;
}
###widget_js###
$(document).ready(function() {
$(document).ready(function() {
init();
});
$(document).keydown(function(e){
if (e.keyCode == 32) {
$(document).keydown(function(e){
if (e.keyCode == 32) {
$('#menue').toggle();
return false;
}
});
});
</script>
<style>
###widget_css###
@ -106,7 +99,7 @@
</div>
<div class="menue_block">
<button id="button_saveconfig" class="menue_button">Config speichern</button>
</div>
</div>
<div class="menue_block">
<button id="button_settings" class="menue_button">Einstellungen</button>
</div>
@ -131,30 +124,30 @@
<button id="widget_menue_delete" class="widget_menue"></button>
</div>
<div id="tabs_error"></div>
<ul id="views">
<ul id="views">
</ul>
</div>
</div>
</div>
<div id="dialog_addview" title="Sicht hinzufügen">
<div class="loading_animation" id="dialog_addview_loading"></div>
<p>Hier können Sie YAF eine neue Sicht hinzufügen.</p>
<label>Name: </label><input id="dialog_addview_name" name="dialog_addview_name"/>
</div>
</div>
<div id="dialog_editview" title="Sicht bearbeiten">
<div class="loading_animation" id="dialog_addview_loading"></div>
<p>Hier können Sie die bestehende Sicht ändern.</p>
<label>Name: </label><input id="dialog_editview_name" name="dialog_editview_name" value="" />
</div>
</div>
<div id="dialog_deleteview" title="Sicht löschen">
<div class="loading_animation" id="dialog_deleteview_loading"></div>
<p>Sind Sie sicher, dass Sie die Sicht "<span><b id="label_deleteview"></b></span>" löschen Möchten? Es gehen alle Widgets verloren, die auf dieser Sicht verankert sind!</p>
</div>
<div id="dialog_manageviews" title="Sichten verwalten">
<div class="loading_animation" id="dialog_manageviews_loading"></div>
<p>Hier können Sie einzelne Sichten löschen oder bearbeiten. Gelöschte Sichten können nicht wiederhergestellt werden!</p>
@ -167,25 +160,25 @@
<p>Hier können Sie Widgets zur ausgewählten Sicht hinzufügen.</p>
<table id="dialog_addwidget_table">
</table>
</div>
</div>
<div id="dialog_addwidget_setup" title="Widget hinzufügen">
<div class="loading_animation" id="dialog_addwidget_setup_loading"></div>
<p>Widget vom Typ <b id="dialog_addwidget_setup_widget"></b> hinzufügen: </p>
<div id="dialog_addwidget_setup_form" />
</div>
<div id="dialog_editwidget" title="Widget bearbeiten">
<div class="loading_animation" id="dialog_editwidget_loading"></div>
<p>Widget "<span><b id="label_editwidget"></b></span>" bearbeiten:</p>
<div id="dialog_editwidget_setup_form" />
</div>
<div id="dialog_deletewidget" title="Widget löschen">
<div class="loading_animation" id="dialog_deletewidget_loading"></div>
<p>Sind Sie sicher, dass Sie das Widget "<span><b id="label_deletewidget"></b></span>" löschen möchten?</p>
</div>
<div id="dialog_settings" title="Einstellungen">
<div class="loading_animation" id="dialog_settings_loading"></div>
<p>Einstellungen</p>

View File

@ -17,19 +17,19 @@ DIR FHEM/YAF/www/smoothness/images
DIR FHEM/YAF/www/img
DIR FHEM/YAF/www/js
DIR FHEM/YAF/xml
UPD 2013-08-01_11:10:00 11623 FHEM/01_YAF.pm
UPD 2013-08-14_21:30:00 12046 FHEM/01_YAF.pm
UPD 2013-05-15_20:00:00 6590 FHEM/YAF/widgets/fs20st/fs20st.pm
UPD 2013-07-31_15:30:00 7548 FHEM/YAF/widgets/fht80/fht80.pm
UPD 2013-08-14_21:30:00 7471 FHEM/YAF/widgets/fht80/fht80.pm
UPD 2013-07-31_15:30:00 6534 FHEM/YAF/widgets/fhttk/fhttk.pm
UPD 2013-07-31_15:30:00 8834 FHEM/YAF/widgets/generic/generic.pm
UPD 2013-08-14_21:30:00 11361 FHEM/YAF/widgets/generic/generic.pm
UPD 2013-05-15_20:00:00 6617 FHEM/YAF/widgets/fs20easylamp/fs20easylamp.pm
UPD 2013-05-15_20:00:00 2608 FHEM/YAF/www/img/loading.gif
UPD 2013-05-15_20:00:00 766 FHEM/YAF/www/img/lamp_off.png
UPD 2013-05-15_20:00:00 19226 FHEM/YAF/www/img/background.png
UPD 2013-05-15_20:00:00 831 FHEM/YAF/www/img/lamp_on.png
UPD 2013-08-01_11:10:00 12433 FHEM/YAF/www/js/yaf-basics.js
UPD 2013-07-31_15:30:00 10727 FHEM/YAF/www/js/yaf-dialogs.js
UPD 2013-08-02_22:15:00 7596 FHEM/YAF/www/yaf.htm
UPD 2013-08-14_21:30:00 12312 FHEM/YAF/www/js/yaf-basics.js
UPD 2013-08-14_21:30:00 11737 FHEM/YAF/www/js/yaf-dialogs.js
UPD 2013-08-14_21:30:00 7489 FHEM/YAF/www/yaf.htm
UPD 2013-05-15_20:00:00 3433 FHEM/YAF/www/js/combobox.js
UPD 2013-05-15_20:00:00 4593 FHEM/YAF/www/js/jquery.ui.touch-punch.min.js
UPD 2013-05-15_20:00:00 237176 FHEM/YAF/www/js/jquery-ui-1.9.1.custom.min.js
@ -53,5 +53,5 @@ UPD 2013-05-15_20:00:00 101 FHEM/YAF/www/css/smoothness/images/ui-bg_highlight-s
UPD 2013-05-15_20:00:00 26086 FHEM/YAF/www/css/smoothness/jquery-ui-1.9.1.custom.min.css
UPD 2013-05-15_20:00:00 3641 FHEM/YAF/xml/xmlSchema.xsd
UPD 2013-05-15_20:00:00 1690 FHEM/YAF/xml/yafConfig.xml
UPD 2013-07-28_17:00:00 15329 FHEM/YAF/YAFConfig.pm
UPD 2013-08-14_21:30:00 15797 FHEM/YAF/YAFConfig.pm
UPD 2013-05-15_20:00:00 3439 FHEM/YAF/YAFWidgets.pm