2015-01-10 16:54:23 +00:00
|
|
|
"use strict";
|
2017-01-13 17:14:34 +00:00
|
|
|
|
|
|
|
if(!svgNS) {
|
|
|
|
var svgNS = "http://www.w3.org/2000/svg";
|
|
|
|
var svg_initialized={}, lastHidden;
|
|
|
|
var svg_db, svg_dbtbl = "SVG_KEYVALUE", svg_pastedata, svgCounter=0;
|
|
|
|
}
|
2015-01-10 16:54:23 +00:00
|
|
|
|
2010-07-05 10:03:55 +00:00
|
|
|
function
|
2015-07-03 16:53:17 +00:00
|
|
|
svg_initDb(nextFn)
|
2010-07-05 10:03:55 +00:00
|
|
|
{
|
2015-07-03 16:53:17 +00:00
|
|
|
if(window.indexedDB == undefined)
|
|
|
|
return;
|
2017-01-13 17:14:34 +00:00
|
|
|
var dbreq = indexedDB.open("FHEM", 1);
|
2015-07-03 16:53:17 +00:00
|
|
|
dbreq.onsuccess = function(op) { svg_db = op.target.result; nextFn() }
|
2017-01-13 17:14:34 +00:00
|
|
|
dbreq.onerror = function(op) {
|
|
|
|
var oldfn = window.onerror;
|
|
|
|
window.onerror = undefined; // stupid FireFox private mode (Forum #64541)
|
|
|
|
log("indexedDB.open Error: " + op.message);
|
|
|
|
setTimeout(function(){window.onerror = oldfn;}, 100);
|
|
|
|
}
|
2015-07-03 16:53:17 +00:00
|
|
|
dbreq.onupgradeneeded = function(op) {
|
|
|
|
svg_db = op.target.result;
|
|
|
|
svg_db.createObjectStore(svg_dbtbl, { keyPath:"key" });
|
|
|
|
};
|
2010-07-05 10:03:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function
|
2015-07-03 16:53:17 +00:00
|
|
|
svg_save(key, value)
|
2010-07-05 10:03:55 +00:00
|
|
|
{
|
2015-07-03 16:53:17 +00:00
|
|
|
if(!svg_db)
|
|
|
|
return;
|
|
|
|
var os = svg_db.transaction([svg_dbtbl],"readwrite")
|
|
|
|
.objectStore(svg_dbtbl);
|
|
|
|
os.put({key:key, val:value});
|
2010-07-05 10:03:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function
|
2015-07-03 16:53:17 +00:00
|
|
|
svg_load(key, nextFn)
|
2010-07-05 10:03:55 +00:00
|
|
|
{
|
2015-07-03 16:53:17 +00:00
|
|
|
if(!svg_db)
|
|
|
|
return;
|
|
|
|
var req = svg_db.transaction([svg_dbtbl],"readonly")
|
|
|
|
.objectStore(svg_dbtbl)
|
|
|
|
.get(key);
|
|
|
|
req.onsuccess = function(e) { if(req.result) nextFn(req.result.val); }
|
2010-07-05 10:03:55 +00:00
|
|
|
}
|
|
|
|
|
2015-07-03 16:53:17 +00:00
|
|
|
|
2010-07-05 10:03:55 +00:00
|
|
|
function
|
2015-01-10 16:54:23 +00:00
|
|
|
svg_prepareHash(el)
|
2010-07-05 10:03:55 +00:00
|
|
|
{
|
2016-05-18 10:15:20 +00:00
|
|
|
var obj = { y_mul:0,y_h:0,y_min:0, decimals:0,
|
|
|
|
t_mul:0,x_off:0,x_min:0, x_mul:0, log_scale:undefined };
|
2015-01-10 16:54:23 +00:00
|
|
|
for(var name in obj)
|
|
|
|
obj[name] = parseFloat($(el).attr(name));
|
|
|
|
return obj;
|
2010-07-05 10:03:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function
|
2015-01-10 16:54:23 +00:00
|
|
|
svg_click(evt)
|
2010-07-05 10:03:55 +00:00
|
|
|
{
|
2015-01-10 16:54:23 +00:00
|
|
|
var t = evt.target;
|
|
|
|
var o = svg_prepareHash(t);
|
2010-07-05 10:03:55 +00:00
|
|
|
|
2015-01-10 16:54:23 +00:00
|
|
|
var y_org = (((o.y_h-evt.clientY)/o.y_mul)+o.y_min).toFixed(o.decimals);
|
2016-05-18 10:15:20 +00:00
|
|
|
var d = new Date((((evt.clientX-o.x_min)/o.t_mul)+o.x_off) * 1000);
|
2015-01-10 16:54:23 +00:00
|
|
|
var ts = (d.getHours() < 10 ? '0' : '') + d.getHours() + ":"+
|
|
|
|
(d.getMinutes() < 10 ? '0' : '') + d.getMinutes();
|
|
|
|
|
|
|
|
|
|
|
|
var tl = t.ownerDocument.getElementById('svg_title');
|
|
|
|
tl.firstChild.nodeValue = t.getAttribute("title")+": "+y_org+" ("+ts+")";
|
2010-07-05 10:03:55 +00:00
|
|
|
}
|
|
|
|
|
2012-01-21 09:47:01 +00:00
|
|
|
function
|
2015-01-10 16:54:23 +00:00
|
|
|
sv_menu(evt, embed)
|
2012-01-21 09:47:01 +00:00
|
|
|
{
|
2015-01-10 16:54:23 +00:00
|
|
|
var label = evt.target;
|
|
|
|
var svg = $(label).closest("svg");
|
|
|
|
var svgNode = $(svg).get(0);
|
|
|
|
var lid = $(label).attr("line_id");
|
|
|
|
var sel = $(svg).find("#"+lid);
|
|
|
|
var selNode = $(sel).get(0);
|
|
|
|
var tl = $(svg).find("#svg_title");
|
|
|
|
var par = svgNode.par;
|
|
|
|
|
2015-02-07 08:07:31 +00:00
|
|
|
var lines = $(svg).find("[line_id]");
|
|
|
|
var hidden = $(svg).find(".hidden");
|
|
|
|
|
2016-02-12 15:44:13 +00:00
|
|
|
function
|
|
|
|
myPathSegList(node) // chrome 48+ removed the pathSegList interface
|
|
|
|
{
|
|
|
|
this.arr = $(node).attr("d").split(/ */);
|
|
|
|
this.arr.splice(0,1); // remove M
|
|
|
|
this.arr.splice(1,1); // remove L/Q/etc
|
|
|
|
this.numberOfItems = this.arr.length;
|
|
|
|
this.getItem = function(pos)
|
|
|
|
{
|
|
|
|
var xy = this.arr[pos].split(",");
|
|
|
|
return { x:parseFloat(xy[0]), y:parseFloat(xy[1]) };
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-07 08:07:31 +00:00
|
|
|
function
|
|
|
|
showValOff() {
|
|
|
|
$(svg).find("[id]").each(function(){delete($(this).get(0).showVal)});
|
|
|
|
$(svg).off("mousemove");
|
|
|
|
|
|
|
|
if(par && par.circle) {
|
|
|
|
$(par.circle).remove();
|
|
|
|
$(par.div).remove();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-19 22:03:17 +00:00
|
|
|
var sn = selNode.nodeName,
|
|
|
|
pn = (sn=="path" ? "d" : "points"),
|
|
|
|
arrName = (sn=="path" ? "pathSegList" : "points");
|
2015-01-10 16:54:23 +00:00
|
|
|
FW_menu(evt, label,
|
|
|
|
["Copy", "Paste",
|
2015-02-07 08:07:31 +00:00
|
|
|
selNode.isHidden ? "Show line" : "Hide line",
|
|
|
|
"Hide other lines",
|
|
|
|
"Show all lines",
|
2015-01-10 16:54:23 +00:00
|
|
|
selNode.showVal ? "Stop displaying values" : "Display plot values" ],
|
2015-07-03 16:53:17 +00:00
|
|
|
[undefined, svg_pastedata == undefined,
|
2015-02-07 08:07:31 +00:00
|
|
|
!selNode.isHidden && (lines.length - hidden.length) == 1,
|
|
|
|
!selNode.isHidden && (lines.length - hidden.length) == 1,
|
|
|
|
hidden.length==0,
|
|
|
|
selNode.isHidden || (sn!="polyline" && sn!="path") ],
|
2015-01-10 16:54:23 +00:00
|
|
|
function(arg) {
|
|
|
|
|
|
|
|
//////////////////////////////////// copy
|
|
|
|
if(arg == 0) {
|
2015-07-03 16:53:17 +00:00
|
|
|
svg_pastedata = {
|
|
|
|
key:"svg_pastedata",
|
|
|
|
tag:sn, attr:pn,
|
|
|
|
y_min:$(sel).attr("y_min"),
|
|
|
|
y_mul:$(sel).attr("y_mul"),
|
|
|
|
datapoints:$(sel).attr(pn)
|
|
|
|
};
|
|
|
|
svg_save("svg_pastedata", svg_pastedata);
|
2015-01-10 16:54:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////// paste
|
|
|
|
if(arg == 1) {
|
|
|
|
var doc = $(svg).get(0).ownerDocument;
|
2015-07-03 16:53:17 +00:00
|
|
|
var o=doc.createElementNS(svgNS, svg_pastedata.tag);
|
|
|
|
o.setAttribute("class", "SVGplot pasted");
|
|
|
|
o.setAttribute(svg_pastedata.attr, svg_pastedata.datapoints);
|
2015-01-10 16:54:23 +00:00
|
|
|
|
|
|
|
var h = parseFloat($(sel).attr("y_h"));
|
2015-07-03 16:53:17 +00:00
|
|
|
var ny_mul = parseFloat(svg_pastedata.y_mul);
|
|
|
|
var ny_min = parseInt(svg_pastedata.y_min);
|
2015-01-10 16:54:23 +00:00
|
|
|
var y_mul = parseFloat($(sel).attr("y_mul"));
|
|
|
|
var y_min = parseInt($(sel).attr("y_min"));
|
|
|
|
var tr =
|
|
|
|
"translate(0,"+ (h/y_mul+y_min-h/ny_mul-ny_min)*y_mul +") "+
|
|
|
|
"scale(1, "+ (y_mul/ny_mul) +") ";
|
|
|
|
o.setAttribute("transform", tr);
|
2015-07-14 13:56:38 +00:00
|
|
|
svgNode.appendChild(o);
|
2015-01-10 16:54:23 +00:00
|
|
|
}
|
|
|
|
|
2015-02-07 08:07:31 +00:00
|
|
|
//show/hide
|
|
|
|
if(arg == 2) {
|
|
|
|
setVisibility(lid, selNode.isHidden?1:0);
|
|
|
|
$(label).attr("opacity", selNode.isHidden?0.4:1);
|
2015-01-10 16:54:23 +00:00
|
|
|
}
|
|
|
|
|
2015-02-07 08:07:31 +00:00
|
|
|
//hide other
|
2015-01-10 16:54:23 +00:00
|
|
|
if(arg == 3) {
|
2015-02-07 08:07:31 +00:00
|
|
|
$(svg).find("[id]").each(function(){
|
|
|
|
var id = $(this).attr("id");
|
|
|
|
if(id.indexOf("line_") != 0 )
|
|
|
|
return;
|
|
|
|
var label = $(svg).find('[line_id="'+id+'"]');
|
|
|
|
if( !label.length ) // ignore lines with label none
|
|
|
|
return;
|
|
|
|
var sel = $(svg).find("#"+id);
|
|
|
|
var selNode = $(sel).get(0);
|
|
|
|
if( (selNode.isHidden?false:true) != (id == lid) )
|
|
|
|
setVisibility(id, id == lid);
|
|
|
|
label.attr("opacity", id == lid?1:0.4);
|
|
|
|
} );
|
|
|
|
}
|
2015-01-10 16:54:23 +00:00
|
|
|
|
2015-02-07 08:07:31 +00:00
|
|
|
//show all
|
|
|
|
if(arg == 4) {
|
|
|
|
$(svg).find("[line_id]").attr("opacity",1);
|
|
|
|
$(svg).find("[id]").each(function(){
|
|
|
|
var id = $(this).attr("id");
|
|
|
|
if(id.indexOf("line_") != 0 )
|
|
|
|
return;
|
|
|
|
var sel = $(svg).find("#"+id);
|
|
|
|
var selNode = $(sel).get(0);
|
|
|
|
if( !selNode.isHidden )
|
|
|
|
return;
|
|
|
|
setVisibility(id, 1);
|
|
|
|
//$(svg).find('[line_id="'+id+'"]').attr("opacity",1);
|
|
|
|
} );
|
|
|
|
}
|
2015-01-10 16:54:23 +00:00
|
|
|
|
2015-02-07 08:07:31 +00:00
|
|
|
//////////////////////////////////// value display
|
|
|
|
if(arg == 5) {
|
|
|
|
|
|
|
|
var hadShowVal = selNode.showVal;
|
|
|
|
showValOff();
|
2015-01-10 16:54:23 +00:00
|
|
|
|
|
|
|
if(!hadShowVal) {
|
|
|
|
selNode.showVal = true;
|
|
|
|
$(svg).mousemove(mousemove);
|
|
|
|
svgNode.par = par = svg_prepareHash(selNode);
|
|
|
|
|
|
|
|
par.circle =
|
|
|
|
$(svg).get(0).ownerDocument.createElementNS(svgNS, "circle");
|
|
|
|
$(par.circle).attr("id", "svgmarker").attr("r", "8");
|
|
|
|
$(svg).append(par.circle);
|
|
|
|
|
|
|
|
par.div = $('<div id="svgmarker">');
|
|
|
|
par.divoffY = $(embed ? embed : svg).offset().top -
|
|
|
|
$("#content").offset().top-50;
|
|
|
|
$("#content").append(par.div);
|
|
|
|
|
2015-01-19 22:03:17 +00:00
|
|
|
var pl = selNode[arrName];
|
2016-02-12 15:44:13 +00:00
|
|
|
if(!pl)
|
2016-02-10 20:20:49 +00:00
|
|
|
selNode[arrName] = pl = new myPathSegList(selNode);
|
2015-02-08 16:38:50 +00:00
|
|
|
if(pl.numberOfItems > 2)
|
|
|
|
mousemove({pageX:pl.getItem(pl.numberOfItems-2).x});
|
2015-01-10 16:54:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-07 08:07:31 +00:00
|
|
|
|
|
|
|
if( arg >= 2 && arg <= 4 ) {
|
|
|
|
var hidden = $(svg).find(".hidden");
|
|
|
|
if( lines.length - hidden.length == 1 ) {
|
|
|
|
$(tl).attr("hiddentitle", $(tl).text());
|
|
|
|
if($(sel).attr(pn) != null)
|
|
|
|
$(tl).text($(label).attr("title"));
|
|
|
|
|
|
|
|
} else if( $(tl).attr("hiddentitle") ) {
|
|
|
|
$(tl).text($(tl).attr("hiddentitle"));
|
|
|
|
$(tl).removeAttr("hiddentitle")
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-10 16:54:23 +00:00
|
|
|
}, embed);
|
|
|
|
|
2015-01-25 14:17:11 +00:00
|
|
|
function pad0(v) { return (v < 10 ? '0'+v :v); }
|
|
|
|
|
2015-01-10 16:54:23 +00:00
|
|
|
function
|
|
|
|
mousemove(e)
|
|
|
|
{
|
2015-02-08 16:38:50 +00:00
|
|
|
var xRaw = e.pageX, pl = selNode[arrName], l = pl.numberOfItems, i1;
|
2015-01-10 16:54:23 +00:00
|
|
|
if(!embed)
|
|
|
|
xRaw -= $(svg).offset().left;
|
|
|
|
for(i1=0; i1<l; i1++)
|
2015-02-08 16:38:50 +00:00
|
|
|
if(pl.getItem(i1).x > xRaw)
|
2015-01-10 16:54:23 +00:00
|
|
|
break;
|
|
|
|
if(i1==l || i1==0)
|
|
|
|
return;
|
|
|
|
|
2015-02-08 16:38:50 +00:00
|
|
|
var pp=pl.getItem(i1-1), pn=pl.getItem(i1);
|
2015-01-10 16:54:23 +00:00
|
|
|
var xR = (xRaw-pp.x)/(pn.x-pp.x); // Compute interim values
|
|
|
|
var yRaw = pp.y+xR*(pn.y-pp.y);
|
|
|
|
|
2016-05-18 10:15:20 +00:00
|
|
|
var y = (((par.y_h-yRaw)/par.y_mul)+par.y_min);
|
|
|
|
|
|
|
|
if( par.log_scale ) {
|
|
|
|
y *= par.log_scale;
|
2016-05-29 08:18:23 +00:00
|
|
|
y = Math.pow(10,y) - 1;
|
2016-05-18 10:15:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
y = y.toFixed(par.decimals);
|
|
|
|
|
|
|
|
if( par.x_mul ) {
|
|
|
|
ts = (((xRaw-par.x_min)/par.x_mul)+par.x_off).toFixed(par.decimals);
|
2015-01-10 16:54:23 +00:00
|
|
|
|
2015-01-25 14:17:11 +00:00
|
|
|
} else {
|
2016-05-18 10:15:20 +00:00
|
|
|
var d = new Date((((xRaw-par.x_min)/par.t_mul)+par.x_off) * 1000), ts;
|
|
|
|
if(par.t_mul < 0.0001) { // Year
|
2016-05-18 17:24:22 +00:00
|
|
|
ts =(pad0(d.getMonth()+1))+"."+pad0(d.getDate()+"."+(d.getYear()+1900));
|
2016-05-18 10:15:20 +00:00
|
|
|
} else if(par.t_mul < 0.001) { // Month
|
2016-05-18 17:24:22 +00:00
|
|
|
ts = (pad0(d.getMonth()+1))+"."+pad0(d.getDate())+
|
|
|
|
". "+pad0(d.getHours())+":"+pad0(d.getMinutes());
|
2016-05-18 10:15:20 +00:00
|
|
|
} else {
|
|
|
|
ts = pad0(d.getHours())+":"+pad0(d.getMinutes());
|
|
|
|
}
|
2015-01-25 14:17:11 +00:00
|
|
|
}
|
2015-01-10 16:54:23 +00:00
|
|
|
|
|
|
|
$(par.circle).attr("cx", xRaw).attr("cy", yRaw);
|
|
|
|
var yd = Math.floor((yRaw+par.divoffY) / 20)*20;
|
|
|
|
$(par.div).html(ts+" "+y)
|
|
|
|
.css({ left:xRaw-20, top:yd });
|
2012-01-23 21:07:25 +00:00
|
|
|
}
|
2015-01-10 16:54:23 +00:00
|
|
|
|
|
|
|
function
|
2015-02-07 08:07:31 +00:00
|
|
|
setVisibility(id,visible)
|
|
|
|
{
|
|
|
|
var sel = $(svg).find("#"+id);
|
|
|
|
var selNode = $(sel).get(0);
|
|
|
|
var currval = visible?1:0;
|
|
|
|
var h = parseFloat(sel.attr("y_h"));
|
2016-05-18 17:24:22 +00:00
|
|
|
//sel.attr("transform", "translate(0,"+h*(1-currval)+") "
|
|
|
|
//+ "scale(1,"+currval+")");
|
2015-02-07 08:07:31 +00:00
|
|
|
|
|
|
|
if( !visible
|
|
|
|
&& selNode.showVal )
|
|
|
|
showValOff();
|
|
|
|
|
|
|
|
animateVisibility(sel,visible?0:1, visible?1:0);
|
|
|
|
|
|
|
|
if( visible ) {
|
|
|
|
delete(selNode.isHidden);
|
|
|
|
sel.attr("class", sel.attr("class").replace(/ hidden/, "" ) );
|
|
|
|
} else {
|
|
|
|
selNode.isHidden = true;
|
|
|
|
sel.attr("class", sel.attr("class") + " hidden" );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function
|
|
|
|
animateVisibility(sel, currval, maxval)
|
2015-01-10 16:54:23 +00:00
|
|
|
{
|
2015-02-07 08:07:31 +00:00
|
|
|
var h = parseFloat(sel.attr("y_h"));
|
|
|
|
sel.attr("transform", "translate(0,"+h*(1-currval)+") "+
|
2015-01-10 16:54:23 +00:00
|
|
|
"scale(1,"+currval+")");
|
|
|
|
|
|
|
|
if(currval != maxval) {
|
|
|
|
currval += (currval<maxval ? 0.02 : -0.02);
|
|
|
|
currval = Math.round(currval*100)/100;
|
2015-02-07 08:07:31 +00:00
|
|
|
setTimeout(function(){ animateVisibility(sel,currval,maxval) }, 10);
|
2015-01-10 16:54:23 +00:00
|
|
|
}
|
2012-01-21 09:47:01 +00:00
|
|
|
}
|
2015-01-10 16:54:23 +00:00
|
|
|
|
2012-01-21 09:47:01 +00:00
|
|
|
}
|
2010-05-14 12:27:18 +00:00
|
|
|
|
|
|
|
function
|
2015-01-10 16:54:23 +00:00
|
|
|
svg_init_one(embed, svg)
|
2010-05-14 12:27:18 +00:00
|
|
|
{
|
2015-01-10 16:54:23 +00:00
|
|
|
var sid = $(svg).attr("id");
|
|
|
|
if(svg_initialized[sid])
|
|
|
|
return;
|
|
|
|
svg_initialized[sid] = true;
|
|
|
|
$("text.legend", svg).click(function(e){sv_menu(e, embed)});
|
2010-05-14 12:27:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function
|
2015-01-10 16:54:23 +00:00
|
|
|
svg_init(par) // also called directly from perl, in race condition
|
2010-05-14 12:27:18 +00:00
|
|
|
{
|
2015-01-10 16:54:23 +00:00
|
|
|
$("embed").each(function(){
|
|
|
|
var e = this;
|
|
|
|
var src = $(e).attr("src");
|
2017-02-01 20:55:00 +00:00
|
|
|
var ed = FW_getSVG(e);
|
2015-01-10 16:54:23 +00:00
|
|
|
if(src.indexOf("SVG_showLog") < 0 || !ed)
|
|
|
|
return;
|
2015-08-13 18:09:42 +00:00
|
|
|
var sTag = $("svg", ed)[0]; // "not well-formed" warning in FireFox
|
2015-01-10 16:54:23 +00:00
|
|
|
if((par && $(sTag).attr("id") != par))
|
|
|
|
return;
|
|
|
|
svg_init_one(e, sTag);
|
|
|
|
});
|
|
|
|
}
|
2010-05-14 12:27:18 +00:00
|
|
|
|
2015-01-10 16:54:23 +00:00
|
|
|
$(document).ready(function(){
|
2017-01-13 17:14:34 +00:00
|
|
|
if(svgCounter++ > 0) // if svg.js is included twice, e.g. by Dashboard
|
|
|
|
return;
|
2015-01-10 16:54:23 +00:00
|
|
|
svg_init(); // <embed><svg>
|
2015-07-03 16:53:17 +00:00
|
|
|
svg_initDb(function(){
|
|
|
|
svg_load("svg_pastedata", function(val) {svg_pastedata = val} );
|
|
|
|
});
|
2015-01-10 16:54:23 +00:00
|
|
|
$("svg[id]").each(function(){ // <svg> (direct)
|
|
|
|
if($(this).attr("id").indexOf("SVGPLOT") == 0)
|
|
|
|
svg_init_one(undefined, this);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// longpollSVG code below
|
|
|
|
function
|
|
|
|
FW_svgUpdateDevs(devs)
|
|
|
|
{
|
|
|
|
// if matches, refresh the SVG by removing and readding the embed tag
|
|
|
|
var embArr = document.getElementsByTagName("embed");
|
|
|
|
for(var i = 0; i < embArr.length; i++) {
|
2017-02-01 20:55:00 +00:00
|
|
|
var svg = FW_getSVG(embArr[i]);
|
2015-01-10 16:54:23 +00:00
|
|
|
if(!svg || !svg.firstChild || !svg.firstChild.nextSibling)
|
|
|
|
continue;
|
2017-02-01 20:55:00 +00:00
|
|
|
if(svg.contentType != "image/svg+xml" &&
|
|
|
|
typeof embArr[i].getSVGDocument != "function")
|
|
|
|
continue;
|
2015-02-11 05:52:12 +00:00
|
|
|
svg = svg.firstChild.nextSibling;
|
|
|
|
var flog = svg.getAttribute("flog");
|
2015-01-11 09:43:59 +00:00
|
|
|
if(!flog)
|
|
|
|
continue;
|
2015-01-18 14:13:47 +00:00
|
|
|
flog = flog.replace(/\\x3a/g, ".");
|
2015-01-11 09:43:59 +00:00
|
|
|
log("longpollSVG filter:"+flog);
|
2015-01-10 16:54:23 +00:00
|
|
|
for(var j=0; j < devs.length; j++) {
|
2015-01-24 14:20:27 +00:00
|
|
|
var d = devs[j];
|
|
|
|
var ev = d[0]+":"+d[1];
|
2015-01-11 09:43:59 +00:00
|
|
|
if(ev.match(flog)) {
|
2015-01-18 14:13:47 +00:00
|
|
|
log("longpollSVG: reload SVG");
|
2015-02-11 05:52:12 +00:00
|
|
|
delete(svg_initialized[$(svg).attr("id")]);
|
2015-01-10 16:54:23 +00:00
|
|
|
var e = embArr[i];
|
|
|
|
var newE = document.createElement("embed");
|
|
|
|
for(var k=0; k<e.attributes.length; k++)
|
|
|
|
newE.setAttribute(e.attributes[k].name, e.attributes[k].value);
|
|
|
|
e.parentNode.insertBefore(newE, e);
|
|
|
|
e.parentNode.removeChild(e);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-05-14 12:27:18 +00:00
|
|
|
}
|
2015-01-10 16:54:23 +00:00
|
|
|
|
|
|
|
FW_widgets.SVG = { updateDevs:FW_svgUpdateDevs };
|