ソースを参照

Added download button

Abram Kash 6 年 前
コミット
029fad27b4
3 ファイル変更9 行追加2 行削除
  1. 8 1
      results.js
  2. 1 0
      results/index.html
  3. 0 1
      style.css

+ 8 - 1
results.js

@@ -605,7 +605,7 @@ function onImageLoaded() {
       ctx.fillStyle = "#ffffff";
       ctx.font = "bold 15px sans-serif";
       ctx.textAlign = "right";
-      ctx.fillText("www.politiscales.net", rPreview.width - 10, 27);
+      ctx.fillText("dbhq.github.io", rPreview.width - 10, 27);
 
       yPos += 48;
 
@@ -812,3 +812,10 @@ for (var b in images) {
   images[b].src = src;
   images[b].onload = onImageLoaded;
 }
+
+function download_image(){
+  var canvas = document.getElementById('generatedResults');
+  var link = document.getElementById("download");
+  link.href = canvas.toDataURL();
+  link.download = `PolitiScales_Results_${+ new Date()}.png`;
+}

+ 1 - 0
results/index.html

@@ -41,6 +41,7 @@
 			</div>
 			<div class="navButtons">
 				<a class="button buttonLink" onclick="shareLink();" id="buttonLink"><i class="fa fa-link" aria-hidden="true"></i> Copy Link</a>
+				<a id="download" target="_blank" class="button buttonLink" onclick="download_image();"><i class="fa fa-download" aria-hidden="true"></i> Download</a>
 			</div>
 
 			<hr/>

+ 0 - 1
style.css

@@ -240,7 +240,6 @@ h3 {
   border-radius: 3px;
   text-decoration: none;
   font-size: 18px;
-  transition: 0.5s;
 }
 .button:hover {
   background-color: white;