Update and rename index.html to Green-Party-petition.html
authorPatrick McGuire <insidenothing@gmail.com>
Mon, 27 Apr 2020 15:43:56 +0000 (11:43 -0400)
committerGitHub <noreply@github.com>
Mon, 27 Apr 2020 15:43:56 +0000 (11:43 -0400)
Green-Party-petition.html [moved from index.html with 88% similarity]

similarity index 88%
rename from index.html
rename to Green-Party-petition.html
index a6f5880..9c5a697 100644 (file)
         document.getElementById("canvasimg_bk").style.display = "none";
     }
     function saveCanvas(canvas,ctx) {
-        alert('Starting Download');
-        //var dataURL = canvas.toDataURL();
-        //document.getElementById("canvasimg").src = dataURL;
-        //var dt = canvas.toDataURL('image/png');
-        //var dt = canvas.toDataURL();
-        /* Change MIME type to trick the browser to downlaod the file instead of displaying it */
-        //dt = dt.replace(/^data:image\/[^;]*/, 'data:application/octet-stream');
-        /* In addition to <a>'s "download" attribute, you can define HTTP-style headers */
-        //dt = dt.replace(/^data:application\/octet-stream/, 'data:application/octet-stream;headers=Content-Disposition%3A%20attachment%3B%20filename=Canvas.png');
-        //this.href = dt;
-        var image = canvas.toDataURL("image/png").replace("image/png", "image/octet-stream");  // here is the most important part because if you dont replace you will get a DOM 18 exception.
-        window.location.href=image; // it will save locally
+        //var image = canvas.toDataURL("image/png").replace("image/png", "image/octet-stream");  
+        // here is the most important part because if you dont replace you will get a DOM 18 exception.
+        //window.location.href=image; // it will save locally
+         var link = document.getElementById('link');
+         link.setAttribute('download', 'Green-Party-petition.png');
+         link.setAttribute('href', canvas.toDataURL("image/png").replace("image/png", "image/octet-stream"));
+         link.click();
+        
     }
     
 
         <input type="submit" value="SAVE to SHARE" id="sharebutton" onclick="saveCanvas(canvas,ctx);">
         <input type="submit" value="BACK" id="clearbutton" onclick="clearCanvas(canvas,ctx);">
         <input type="submit" value="CLEAR" id="clearbutton" onclick="clearCanvas(canvas,ctx);">
+        <a id="link"></a>
     </div>
     <div id="sketchpadapp">
         <div class="rightside">