diff --git a/fhem/contrib/YAF/FHEM/01_YAF.pm b/fhem/contrib/YAF/FHEM/01_YAF.pm index 3bd92e4c7..cc08d5056 100644 --- a/fhem/contrib/YAF/FHEM/01_YAF.pm +++ b/fhem/contrib/YAF/FHEM/01_YAF.pm @@ -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; diff --git a/fhem/contrib/YAF/FHEM/YAF/YAFConfig.pm b/fhem/contrib/YAF/FHEM/YAF/YAFConfig.pm index 657339e59..171451544 100644 --- a/fhem/contrib/YAF/FHEM/YAF/YAFConfig.pm +++ b/fhem/contrib/YAF/FHEM/YAF/YAFConfig.pm @@ -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; diff --git a/fhem/contrib/YAF/FHEM/YAF/widgets/fht80/fht80.pm b/fhem/contrib/YAF/FHEM/YAF/widgets/fht80/fht80.pm index 69ed02965..1c313b88c 100644 --- a/fhem/contrib/YAF/FHEM/YAF/widgets/fht80/fht80.pm +++ b/fhem/contrib/YAF/FHEM/YAF/widgets/fht80/fht80.pm @@ -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; diff --git a/fhem/contrib/YAF/FHEM/YAF/widgets/generic/generic.pm b/fhem/contrib/YAF/FHEM/YAF/widgets/generic/generic.pm index 9cce2a166..12c18b0be 100644 --- a/fhem/contrib/YAF/FHEM/YAF/widgets/generic/generic.pm +++ b/fhem/contrib/YAF/FHEM/YAF/widgets/generic/generic.pm @@ -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 .= "
"; + $output .= "
"; + $output .= "
"; + $output .= "
"; + $output .= "
"; + 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/( )/ /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; diff --git a/fhem/contrib/YAF/FHEM/YAF/www/js/yaf-basics.js b/fhem/contrib/YAF/FHEM/YAF/www/js/yaf-basics.js index 8c391308d..1aa68b132 100644 --- a/fhem/contrib/YAF/FHEM/YAF/www/js/yaf-basics.js +++ b/fhem/contrib/YAF/FHEM/YAF/www/js/yaf-basics.js @@ -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" diff --git a/fhem/contrib/YAF/FHEM/YAF/www/js/yaf-dialogs.js b/fhem/contrib/YAF/FHEM/YAF/www/js/yaf-dialogs.js index 9e48565a9..5782f4ba1 100644 --- a/fhem/contrib/YAF/FHEM/YAF/www/js/yaf-dialogs.js +++ b/fhem/contrib/YAF/FHEM/YAF/www/js/yaf-dialogs.js @@ -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(); + } + }); } }); diff --git a/fhem/contrib/YAF/FHEM/YAF/www/yaf.htm b/fhem/contrib/YAF/FHEM/YAF/www/yaf.htm index edc725fc7..fa0bc9213 100755 --- a/fhem/contrib/YAF/FHEM/YAF/www/yaf.htm +++ b/fhem/contrib/YAF/FHEM/YAF/www/yaf.htm @@ -36,34 +36,28 @@ - +