@gregoriusrippenstein/node-red-contrib-introspection 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/nodes/15-screenshot.html +37 -23
- package/package.json +1 -1
package/nodes/15-screenshot.html
CHANGED
|
@@ -54,14 +54,16 @@
|
|
|
54
54
|
|
|
55
55
|
this.editor.setValue( "Please wait, screenshot being prepared ..." );
|
|
56
56
|
|
|
57
|
-
var hwAttrs = (
|
|
58
|
-
'width="' + $($('svg')[0]).attr('width') + '" height="' +
|
|
59
|
-
$($('svg')[0]).attr('height') + '"'
|
|
60
|
-
);
|
|
61
|
-
|
|
62
57
|
//
|
|
63
58
|
// begin the SVG conversion code.
|
|
64
59
|
//
|
|
60
|
+
var origSvg = $($('svg')[0]);
|
|
61
|
+
|
|
62
|
+
var hwAttrs = (
|
|
63
|
+
'width="' + origSvg.attr('width') + '" height="' +
|
|
64
|
+
origSvg.attr('height') + '"'
|
|
65
|
+
);
|
|
66
|
+
|
|
65
67
|
var svgHeader = (
|
|
66
68
|
'<?xml version="1.0" standalone="no"?>\r\n' +
|
|
67
69
|
'<svg ' + hwAttrs + ' pointer-events="all" style="cursor: crosshair; '+
|
|
@@ -69,7 +71,7 @@
|
|
|
69
71
|
'xmlns:xlink="http://www.w3.org/1999/xlink">\r\n'
|
|
70
72
|
);
|
|
71
73
|
|
|
72
|
-
var svgBody =
|
|
74
|
+
var svgBody = origSvg.html();
|
|
73
75
|
|
|
74
76
|
var parser = new DOMParser();
|
|
75
77
|
var doc = parser.parseFromString(svgHeader + svgBody + '\r\n</svg>',
|
|
@@ -101,23 +103,28 @@
|
|
|
101
103
|
// Set everything that might have been set via CSS directly on the
|
|
102
104
|
// element. All styling values must be defined as attributes on the
|
|
103
105
|
// SVG element.
|
|
104
|
-
var convertCssToAttr = function( collection ) {
|
|
106
|
+
var convertCssToAttr = function( collection, origElems ) {
|
|
105
107
|
for ( var idx = 0; idx < collection.length; idx++ ) {
|
|
106
108
|
var elem = collection.item(idx);
|
|
107
|
-
|
|
109
|
+
var origElem = origElems[idx];
|
|
110
|
+
|
|
111
|
+
[
|
|
112
|
+
"fill", "stroke"
|
|
113
|
+
].forEach( function(attrname) {
|
|
108
114
|
elem.setAttribute(attrname,
|
|
109
|
-
rgb2hex($(
|
|
110
|
-
$(
|
|
115
|
+
rgb2hex($(origElem).attr(attrname) ||
|
|
116
|
+
$(origElem).css(attrname) ));
|
|
111
117
|
});
|
|
112
118
|
|
|
113
119
|
[
|
|
114
120
|
"stroke-width","fill-opacity","stroke-opacity","opacity"
|
|
115
121
|
].forEach(function(attrname) {
|
|
116
122
|
elem.setAttribute(attrname,
|
|
117
|
-
$(
|
|
123
|
+
$(origElem).attr(attrname) ||
|
|
124
|
+
$(origElem).css(attrname));
|
|
118
125
|
});
|
|
119
126
|
|
|
120
|
-
if ( $(
|
|
127
|
+
if ( $(origElem).hasClass('hide') ) {
|
|
121
128
|
if ( elem.tagName == "g" ) {
|
|
122
129
|
// according to the SVG standard, visibility cannot be applied
|
|
123
130
|
// (or better said: has no effect) on 'g' (group) elements.
|
|
@@ -132,28 +139,35 @@
|
|
|
132
139
|
}
|
|
133
140
|
|
|
134
141
|
// include font details on the text elements.
|
|
135
|
-
var convertFontsToAttr = function( collection ) {
|
|
142
|
+
var convertFontsToAttr = function( collection, origElems ) {
|
|
136
143
|
for ( var idx = 0; idx < collection.length; idx++ ) {
|
|
137
144
|
var elem = collection.item(idx);
|
|
145
|
+
var origElem = origElems[idx];
|
|
146
|
+
|
|
138
147
|
["font-family", "font-size", "font-size-adjust", "font-stretch",
|
|
139
148
|
"font-style", "font-variant", "font-weight"
|
|
140
149
|
].forEach( function(attrname) {
|
|
141
150
|
elem.setAttribute(attrname,
|
|
142
|
-
$(
|
|
151
|
+
$(origElem).attr(attrname) ||
|
|
152
|
+
$(origElem).css(attrname) );
|
|
143
153
|
})
|
|
144
154
|
}
|
|
145
155
|
}
|
|
146
156
|
|
|
147
157
|
// probably missed some elements ...
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
158
|
+
var tagnames = [ "g", "rect", "line", "path", "circle", "image" ];
|
|
159
|
+
tagnames.forEach( function(tagname) {
|
|
160
|
+
convertCssToAttr(doc.getElementsByTagName(tagname),
|
|
161
|
+
origSvg.find(tagname));
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
[ "text" ].forEach( function(tagname) {
|
|
165
|
+
convertCssToAttr(doc.getElementsByTagName(tagname),
|
|
166
|
+
origSvg.find(tagname));
|
|
167
|
+
|
|
168
|
+
convertFontsToAttr(doc.getElementsByTagName(tagname),
|
|
169
|
+
origSvg.find(tagname));
|
|
170
|
+
});
|
|
157
171
|
|
|
158
172
|
// inline image data. Image types supported: Jpeg, Png and Svg.
|
|
159
173
|
var imageColl = doc.getElementsByTagName("image");
|