diff --git a/fhem/FHEM/01_FHEMWEB.pm b/fhem/FHEM/01_FHEMWEB.pm index 67f5a735a..0b3f36885 100644 --- a/fhem/FHEM/01_FHEMWEB.pm +++ b/fhem/FHEM/01_FHEMWEB.pm @@ -186,7 +186,7 @@ FHEMWEB_Initialize($) ploteditor:always,onClick,never plotfork:1,0 plotmode:gnuplot-scroll,gnuplot-scroll-svg,SVG - plotEmbed:0,1 + plotEmbed:2,1,0 plotsize plotWeekStartDay:0,1,2,3,4,5,6 nrAxis @@ -548,7 +548,8 @@ FW_Read($$) $arg = "" if(!defined($arg)); Log3 $FW_wname, 4, "$name $method $arg; BUFLEN:".length($hash->{BUF}); - my $pf = AttrVal($FW_wname, "plotfork", 0); + my $pf = AttrVal($FW_wname, "plotfork", undef); + $pf = 1 if(!defined($pf) && AttrVal($FW_wname, "plotEmbed", 0) == 2); if($pf) { # 0 disables # Process SVG rendering as a parallel process my $p = $data{FWEXT}; @@ -3953,9 +3954,11 @@ FW_show($$)
  • plotEmbed
    - If set (to 1), SVG plots will be rendered as part of <embed> + If set to 1, SVG plots will be rendered as part of <embed> tags, as in the past this was the only way to display SVG. Setting plotEmbed to 0 (the default) will render SVG in-place.
    + Setting plotEmbed to 2 will load the SVG via JavaScript, in order to + enable parallelization without the embed tag.

  • @@ -4690,11 +4693,13 @@ FW_show($$)
    -
  • plotEmbed 0
    - Falls gesetzt (auf 1), dann werden SVG Grafiken mit <embed> Tags +
  • plotEmbed
    + Falls 1, dann werden SVG Grafiken mit <embed> Tags gerendert, da auf älteren Browsern das die einzige Möglichkeit war, SVG dastellen zu können. Falls 0 (die Voreinstellung), dann werden die SVG Grafiken "in-place" gezeichnet. + Falls 2, dann werden die Grafiken per JavaScript nachgeladen, um eine + Parallelisierung auch ohne embed Tags zu ermöglichen.

  • diff --git a/fhem/FHEM/98_SVG.pm b/fhem/FHEM/98_SVG.pm index ffc456961..6cfc98b7c 100644 --- a/fhem/FHEM/98_SVG.pm +++ b/fhem/FHEM/98_SVG.pm @@ -49,6 +49,9 @@ sub SVG_getControlPoints($); sub SVG_calcControlPoints($$$$$$); my %SVG_devs; # hash of from/to entries per device +my $SVG_hdr = 'version="1.1" xmlns="http://www.w3.org/2000/svg" '. + 'xmlns:xlink="http://www.w3.org/1999/xlink" '. + 'data-origin="FHEM"'; ##################################### @@ -185,7 +188,7 @@ SVG_getplotsize($) } sub -SVG_isEmbed($) +SVG_embed() { return AttrVal($FW_wname, "plotEmbed", 0); } @@ -238,10 +241,16 @@ SVG_FwFn($$$$) if($pm eq "SVG") { $ret .= "
    "; - if(SVG_isEmbed($FW_wname)) { + my $embed = SVG_embed(); + if($embed) { my ($w, $h) = split(",", SVG_getplotsize($d)); - $ret .= "\n"; + if($embed == 1) { + $ret .= "\n"; + } else { + $ret .= "\n"; + } } else { my $oret=$FW_RET; $FW_RET=""; @@ -1081,9 +1090,9 @@ SVG_doShowLog($$$$;$) if($pm && $pm =~ m/SVG/) { # FW_fatal for SVG: $FW_RETTYPE = "image/svg+xml"; - FW_pO ''; - FW_pO ''.$msg.''; - FW_pO ''; + FW_pO ""; + FW_pO "$msg"; + FW_pO ""; return ($FW_RETTYPE, $FW_RET); } else { @@ -1389,15 +1398,14 @@ SVG_render($$$$$$$$$$) ###################### # SVG Header - my $svghdr = 'version="1.1" xmlns="http://www.w3.org/2000/svg" '. - 'xmlns:xlink="http://www.w3.org/1999/xlink" '. - "id='SVGPLOT_$name' $filter data-origin='FHEM'"; + my $svghdr = "$SVG_hdr id='SVGPLOT_$name' $filter"; + my $style = "style='width:${ow}px; height:${oh}px;'"; if(!$noHeader) { SVG_pO ''; SVG_pO ''; - SVG_pO ""; + SVG_pO ""; } else { - SVG_pO ""; + SVG_pO ""; } my $prf = AttrVal($parent_name, "stylesheetPrefix", ""); @@ -2218,10 +2226,13 @@ SVG_render($$$$$$$$$$) $txtoff2 += $th; } - my $fnName = SVG_isEmbed($FW_wname) ? "parent.window.svg_init" : "svg_init"; - - SVG_pO ""; return $SVG_RET; } diff --git a/fhem/www/pgm2/f18.js b/fhem/www/pgm2/f18.js index 43cc0e628..4851cd4d7 100644 --- a/fhem/www/pgm2/f18.js +++ b/fhem/www/pgm2/f18.js @@ -66,7 +66,6 @@ $(document).ready(function(){ }); f18_menu(); f18_tables(); - f18_svgSetCols(); if(typeof svgCallback != "undefined") svgCallback.f18 = f18_svgSetCols; $("[data-name]").each(function(){ f18_setPos(this) }); @@ -798,7 +797,7 @@ f18_svgSetCols(svg) { function col(n) { return f18_getAttr("cols."+n, true) }; - if(!svg || !svg.getAttribute("data-origin")) + if(!svg || !$(svg).attr("data-origin")) return; var style = $(svg).find("> style").first(); diff --git a/fhem/www/pgm2/svg.js b/fhem/www/pgm2/svg.js index be1830004..c8d081ccd 100644 --- a/fhem/www/pgm2/svg.js +++ b/fhem/www/pgm2/svg.js @@ -421,6 +421,19 @@ svg_init(par) // also called directly from perl, in race condition return; svg_init_one(e, sTag); }); + + if(par) + return; + + $("svg.plotembed_2[data-src]").each(function(){ + var svgThis = this; + var src = $(this).attr("data-src"); + var dev = FW_escapeSelector($(this).attr("data-dev")); + FW_cmd(src, function(data){ + $(svgThis).replaceWith(data.substr(data.indexOf('