|
|
@ -241,50 +241,3 @@ |
|
|
|
} |
|
|
|
}); |
|
|
|
})(); |
|
|
|
|
|
|
|
function generateScreenshot() { |
|
|
|
var css = ''; |
|
|
|
var svgs = document.getElementsByTagName('svg'); |
|
|
|
for (var i = 0; i < document.styleSheets.length; i++) { |
|
|
|
if (document.styleSheets[i].href && !document.styleSheets[i].href.match(/web\-fonts/)) { |
|
|
|
var rules = document.styleSheets[i].rules || document.styleSheets[i].cssRules; |
|
|
|
for (var j = 0; j < rules.length; j++) { |
|
|
|
cssText = rules[j].cssText; |
|
|
|
if (rules[j].selectorText) { |
|
|
|
if (rules[j].selectorText.match(/(^|\s)svg[^\w]/) || cssText.match(/\s(fill|stroke(\-width)?):/)) { |
|
|
|
css += cssText; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
for (var i = 0; i < svgs.length; i++) { |
|
|
|
var svg = svgs[i]; |
|
|
|
// svg.innerHTML = '<style type="text/css"><![CDATA[' + css + ']]></style>' + svg.innerHTML;
|
|
|
|
svg.innerHTML = '<style type="text/css"><![CDATA[' + css + ']]></style>' + svg.innerHTML; |
|
|
|
svg.setAttribute('height', svg.clientHeight); |
|
|
|
svg.setAttribute('width', svg.clientWidth); |
|
|
|
var canvas = document.createElement('canvas'); |
|
|
|
canvg(canvas, svg.outerHTML); |
|
|
|
console.log(svg.outerHTML); |
|
|
|
svg.style.backgroundImage = 'url(' + encodeURI(canvas.toDataURL('image/png')) + ')'; |
|
|
|
} |
|
|
|
|
|
|
|
html2canvas(document.body, { |
|
|
|
logging: true, |
|
|
|
profile: true, |
|
|
|
useCORS: true}).then(function(canvas) { |
|
|
|
var data = canvas.toDataURL('image/jpeg', 0.9); |
|
|
|
var src = encodeURI(data); |
|
|
|
|
|
|
|
window.open(src, '_blank'); |
|
|
|
|
|
|
|
// reset the svg height and width
|
|
|
|
for (var i = 0; i < svgs.length; i++) { |
|
|
|
var svg = svgs[i]; |
|
|
|
svg.removeAttribute('height'); |
|
|
|
svg.removeAttribute('width'); |
|
|
|
svg.removeAttribute('style'); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|