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(""); $.each(views, function (index, view) { - $("#dialog_manageviews-table").append("" + view[1] + ""); + $("#dialog_manageviews-table").append("" + view[1] + "   " ); }); $(".button_edit").button({ icons: { @@ -352,9 +350,18 @@ function init_dialogs() { return false; }); $(".button_edit").click(function (ui) { - edit_view_name = $(ui.currentTarget.parentNode.parentNode.firstChild).html(); + edit_view_id = $(ui.currentTarget).attr("id").substr(12); + + $.each(views, function (index, view) { //this is quite ineffective and should be redone + if(view[0] == edit_view_id) { + edit_view_name = view[1]; + edit_view_image = view[2]; + } + }); + $("#dialog_editview_name").val(edit_view_name); + $("#dialog_editview_image").val(edit_view_image); $("#dialog_editview").dialog("open"); return false; }); diff --git a/fhem/contrib/YAF/FHEM/YAF/www/yaf.htm b/fhem/contrib/YAF/FHEM/YAF/www/yaf.htm index fa0bc9213..440108be2 100755 --- a/fhem/contrib/YAF/FHEM/YAF/www/yaf.htm +++ b/fhem/contrib/YAF/FHEM/YAF/www/yaf.htm @@ -140,7 +140,8 @@

Hier können Sie die bestehende Sicht ändern.

- +
+
diff --git a/fhem/contrib/YAF/controls_yaf.txt b/fhem/contrib/YAF/controls_yaf.txt index 6b66fde4d..6757b5db7 100644 --- a/fhem/contrib/YAF/controls_yaf.txt +++ b/fhem/contrib/YAF/controls_yaf.txt @@ -17,7 +17,7 @@ DIR FHEM/YAF/www/smoothness/images DIR FHEM/YAF/www/img DIR FHEM/YAF/www/js DIR FHEM/YAF/xml -UPD 2013-08-14_21:30:00 12046 FHEM/01_YAF.pm +UPD 2013-09-12_22:30:00 12062 FHEM/01_YAF.pm UPD 2013-05-15_20:00:00 6590 FHEM/YAF/widgets/fs20st/fs20st.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 @@ -27,9 +27,9 @@ 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-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-09-12_22:30:00 12310 FHEM/YAF/www/js/yaf-basics.js +UPD 2013-09-12_22:30:00 12076 FHEM/YAF/www/js/yaf-dialogs.js +UPD 2013-09-12_22:30:00 7594 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-09-10_22:20:00 15962 FHEM/YAF/YAFConfig.pm +UPD 2013-09-12_22:30:00 16597 FHEM/YAF/YAFConfig.pm UPD 2013-05-15_20:00:00 3439 FHEM/YAF/YAFWidgets.pm