Sha256: 8e632d9795ebcc7da48aff7289e67b3fd927cb037c6b37c1ab1b0587b786622a

Contents?: true

Size: 1.2 KB

Versions: 124

Compression:

Stored size: 1.2 KB

Contents

/* */ 
"format cjs";
/*
 * canvas2png.js
 *
 * Copyright (c) 2010-2013 Shinya Muramatsu
 * Released under the MIT License
 * http://flashcanvas.net/
 */

(function(doc) {

var scripts = doc.getElementsByTagName("script");
var script  = scripts[scripts.length - 1];
var url     = script.getAttribute("src").replace(/[^\/]+$/, "save.php");

window.canvas2png = function(canvas, filename) {
    var tagName = canvas.tagName.toLowerCase();
    if (tagName !== "canvas") {
        return;
    }

    if (typeof FlashCanvas !== "undefined") {
        FlashCanvas.saveImage(canvas, filename);
    } else {
        var action = url;
        if (filename) {
            action += "?filename=" + filename;
        }

        var form  = doc.createElement("form");
        var input = doc.createElement("input");

        form.setAttribute("action", action);
        form.setAttribute("method", "post");

        input.setAttribute("type",  "hidden");
        input.setAttribute("name",  "dataurl");
        input.setAttribute("value", canvas.toDataURL());

        doc.body.appendChild(form);
        form.appendChild(input);
        form.submit();
        form.removeChild(input);
        doc.body.removeChild(form);
    }
}

})(document);

Version data entries

124 entries across 31 versions & 1 rubygems

Version Path
sequenceserver-3.1.3 public/vendor/npm/webshim@1.15.8/js-webshim/dev/shims/FlashCanvas/canvas2png.js
sequenceserver-3.1.3 public/vendor/npm/webshim@1.15.8/js-webshim/dev/shims/FlashCanvasPro/canvas2png.js
sequenceserver-3.1.3 public/vendor/npm/webshim@1.15.8/src/shims/FlashCanvas/canvas2png.js
sequenceserver-3.1.3 public/vendor/npm/webshim@1.15.8/src/shims/FlashCanvasPro/canvas2png.js
sequenceserver-3.1.2 public/vendor/npm/webshim@1.15.8/src/shims/FlashCanvasPro/canvas2png.js
sequenceserver-3.1.2 public/vendor/npm/webshim@1.15.8/js-webshim/dev/shims/FlashCanvas/canvas2png.js
sequenceserver-3.1.2 public/vendor/npm/webshim@1.15.8/js-webshim/dev/shims/FlashCanvasPro/canvas2png.js
sequenceserver-3.1.2 public/vendor/npm/webshim@1.15.8/src/shims/FlashCanvas/canvas2png.js
sequenceserver-3.1.1 public/vendor/npm/webshim@1.15.8/js-webshim/dev/shims/FlashCanvasPro/canvas2png.js
sequenceserver-3.1.1 public/vendor/npm/webshim@1.15.8/src/shims/FlashCanvas/canvas2png.js
sequenceserver-3.1.1 public/vendor/npm/webshim@1.15.8/src/shims/FlashCanvasPro/canvas2png.js
sequenceserver-3.1.1 public/vendor/npm/webshim@1.15.8/js-webshim/dev/shims/FlashCanvas/canvas2png.js
sequenceserver-3.1.0 public/vendor/npm/webshim@1.15.8/src/shims/FlashCanvas/canvas2png.js
sequenceserver-3.1.0 public/vendor/npm/webshim@1.15.8/src/shims/FlashCanvasPro/canvas2png.js
sequenceserver-3.1.0 public/vendor/npm/webshim@1.15.8/js-webshim/dev/shims/FlashCanvas/canvas2png.js
sequenceserver-3.1.0 public/vendor/npm/webshim@1.15.8/js-webshim/dev/shims/FlashCanvasPro/canvas2png.js
sequenceserver-3.0.1 public/vendor/npm/webshim@1.15.8/src/shims/FlashCanvas/canvas2png.js
sequenceserver-3.0.1 public/vendor/npm/webshim@1.15.8/js-webshim/dev/shims/FlashCanvas/canvas2png.js
sequenceserver-3.0.1 public/vendor/npm/webshim@1.15.8/js-webshim/dev/shims/FlashCanvasPro/canvas2png.js
sequenceserver-3.0.1 public/vendor/npm/webshim@1.15.8/src/shims/FlashCanvasPro/canvas2png.js