diff options
Diffstat (limited to 'crocoite/data')
-rw-r--r-- | crocoite/data/canvas-snapshot.js | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/crocoite/data/canvas-snapshot.js b/crocoite/data/canvas-snapshot.js new file mode 100644 index 0000000..2395411 --- /dev/null +++ b/crocoite/data/canvas-snapshot.js @@ -0,0 +1,18 @@ +/* Replace canvas with image snapshot + */ +(function(){ + var canvas = document.querySelectorAll ("canvas"); + for (var i = 0; i < canvas.length; i++) { + var c = canvas[i]; + var data = c.toDataURL (); + var parent = c.parentNode; + var img = document.createElement ('img'); + /* copy all attributes */ + for (var i = 0; i < c.attributes.length; i++) { + var attr = c.attributes.item(i); + img.setAttribute (attr.nodeName, attr.nodeValue); + } + img.src = data; + parent.replaceChild (img, c); + } +}()); |