From 4efb260c8d5426bbb033ba3e8845f58e4b153abc Mon Sep 17 00:00:00 2001 From: marcproe <> Date: Thu, 12 Sep 2013 20:34:49 +0000 Subject: [PATCH] YAF: path to background image is now configurable via the YAF interface (marcproe) git-svn-id: https://svn.fhem.de/fhem/trunk@3900 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/contrib/YAF/CHANGED | 3 ++- fhem/contrib/YAF/FHEM/01_YAF.pm | 2 +- fhem/contrib/YAF/FHEM/YAF/YAFConfig.pm | 22 +++++++++++++++++++ .../contrib/YAF/FHEM/YAF/www/js/yaf-basics.js | 2 +- .../YAF/FHEM/YAF/www/js/yaf-dialogs.js | 17 +++++++++----- fhem/contrib/YAF/FHEM/YAF/www/yaf.htm | 3 ++- fhem/contrib/YAF/controls_yaf.txt | 10 ++++----- 7 files changed, 45 insertions(+), 14 deletions(-) diff --git a/fhem/contrib/YAF/CHANGED b/fhem/contrib/YAF/CHANGED index 23a05cad5..f6f0fb78e 100644 --- a/fhem/contrib/YAF/CHANGED +++ b/fhem/contrib/YAF/CHANGED @@ -1,4 +1,5 @@ -- Added regex capability for generic widget onclick function +- path to background image is now configurable via the YAF interface (marcproe) +- Added regex capability for generic widget onclick function (marcproe) - Added foundation for modify dialog and modify dialog for generic widget (marcproe) - Added Conig Save button (marcproe) - Added widget generic (marcproe) diff --git a/fhem/contrib/YAF/FHEM/01_YAF.pm b/fhem/contrib/YAF/FHEM/01_YAF.pm index cc08d5056..0c12034ee 100644 --- a/fhem/contrib/YAF/FHEM/01_YAF.pm +++ b/fhem/contrib/YAF/FHEM/01_YAF.pm @@ -301,7 +301,7 @@ sub YAF_Request ($@) { #-- changes the name of a View elsif ($function eq "editView") { if ($_GET{"id"} && $_GET{"name"}) { - YAF_Print(YAF_editView($_GET{"id"}, $_GET{"name"})); + YAF_Print(YAF_editView($_GET{"id"}, $_GET{"name"}, $_GET{"image"})); } else { YAF_Print("0"); diff --git a/fhem/contrib/YAF/FHEM/YAF/YAFConfig.pm b/fhem/contrib/YAF/FHEM/YAF/YAFConfig.pm index 1708f0eff..ff0bbf498 100644 --- a/fhem/contrib/YAF/FHEM/YAF/YAFConfig.pm +++ b/fhem/contrib/YAF/FHEM/YAF/YAFConfig.pm @@ -31,6 +31,7 @@ my $yaf_version=0.41; my %fhemwidgets; my %fhemviews; +my %fhemviewbgs; my $isInit = 0; ####################################################################################### @@ -45,11 +46,17 @@ my $isInit = 0; sub YAF_FHEMConfig { #this is called via ajax when the page is loaded. #get the views my $views = AttrVal("yaf","views",undef); + my $backgrounds = AttrVal("yaf", "backgrounds", undef); if(defined $views and $isInit == 0) { foreach my $view (split (/;/,$views)) { my @aview = split(/,/,$view); $fhemviews{$aview[0]} = $aview[1]; } + + foreach my $bg (split (/;/,$backgrounds)) { + my @abg = split(/,/,$bg); + $fhemviewbgs{$abg[0]} = $abg[3]; + } my $retAttr = ""; foreach my $viewId (keys %fhemviews) { @@ -89,6 +96,7 @@ sub YAF_getViews{ foreach my $view (keys %fhemviews){ $viewsArray[$index][0] = $view; $viewsArray[$index][1] = $fhemviews{$view}; + $viewsArray[$index][2] = $fhemviewbgs{$view}; $index++; } @@ -159,26 +167,40 @@ sub YAF_getView{ sub YAF_editView{ my $viewId = $_[0]; my $viewName = $_[1]; + my $viewImage = $_[2]; my %viewhash = (); + my %viewbghash = (); #load current config foreach my $views (split(/;/,AttrVal("yaf","views",undef))) { my @view = split(/,/,$views); $viewhash{$view[0]} = $view[1]; } + + foreach my $bgs (split(/;/,AttrVal("yaf","backgrounds",undef))) { + my @bg = split(/,/,$bgs); + $viewbghash{$bg[0]} = $bg[3]; + } #set new config value $viewhash{$viewId} = $viewName; + $viewbghash{$viewId} = $viewImage; #create new config my $newview = ""; foreach my $key (keys %viewhash) { $newview .= $key . "," . $viewhash{$key} . ";;"; } + + my $newbg = ""; + foreach my $key (keys %viewbghash) { + $newbg .= $key . ",1,1," . $viewbghash{$key} . ";;"; + } #save new config fhem ("attr yaf views $newview"); + fhem ("attr yaf backgrounds $newbg"); return 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 1aa68b132..f2bed510e 100644 --- a/fhem/contrib/YAF/FHEM/YAF/www/js/yaf-basics.js +++ b/fhem/contrib/YAF/FHEM/YAF/www/js/yaf-basics.js @@ -80,7 +80,7 @@ function load_views(callback) { context: document.body, success: function (jsondata) { views = jQuery.parseJSON(jsondata); - //console.log(views); + console.log(views); if (callback) { callback(); } 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 5782f4ba1..87cd41b19 100644 --- a/fhem/contrib/YAF/FHEM/YAF/www/js/yaf-dialogs.js +++ b/fhem/contrib/YAF/FHEM/YAF/www/js/yaf-dialogs.js @@ -99,7 +99,7 @@ function init_dialogs() { type: "GET", async: true, url: "../../ajax/global/editView", - data: "id=" + edit_view_id + "&name=" + $("#dialog_editview_name").val(), + data: "id=" + edit_view_id + "&name=" + $("#dialog_editview_name").val() + "&image=" + $("#dialog_editview_image").val(), context: document.body, success: function (jsondata) { load_views(show_views); @@ -116,7 +116,6 @@ function init_dialogs() { } }); - $("#dialog_addwidget").dialog({ autoOpen: false, resizable: true, @@ -315,7 +314,6 @@ function init_dialogs() { } }); - $("#dialog_manageviews").dialog({ autoOpen: false, resizable: true, @@ -330,7 +328,7 @@ function init_dialogs() { open: function (event, ui) { $("#dialog_manageviews-table").html("
Hier können Sie die bestehende Sicht ändern.
- +