From f84f7399f6750b53330e44b3a8bf5c368a80ea93 Mon Sep 17 00:00:00 2001
From: Kyle <41976328+ImKyle4815@users.noreply.github.com>
Date: Wed, 12 May 2021 09:25:37 -0700
Subject: [PATCH] alternative downloads
---
creator/index.php | 7 ++-----
js/{creator-17.js => creator-18.js} | 18 +++++++++---------
2 files changed, 11 insertions(+), 14 deletions(-)
rename js/{creator-17.js => creator-18.js} (99%)
diff --git a/creator/index.php b/creator/index.php
index 1dad8004..b712044c 100644
--- a/creator/index.php
+++ b/creator/index.php
@@ -465,10 +465,7 @@ include('../globalHTML/header-1.php');
Download your card
-
-
-
Use this link to open your card image in a new window, then save it manually.
-
+
@@ -491,5 +488,5 @@ include('../globalHTML/header-1.php');
-
+
\ No newline at end of file
diff --git a/js/creator-17.js b/js/creator-18.js
similarity index 99%
rename from js/creator-17.js
rename to js/creator-18.js
index 802c2d1a..4b177f56 100644
--- a/js/creator-17.js
+++ b/js/creator-18.js
@@ -1287,32 +1287,32 @@ function drawCard() {
previewContext.drawImage(cardCanvas, 0, 0, previewCanvas.width, previewCanvas.height);
}
//DOWNLOADING
-async function downloadCard(alt = false) {
+function downloadCard(alt = false) {
if (card.infoArtist.replace(/ /g, '') == '' && !card.artSource.includes('/img/blank.png') && !card.artZoom == 0) {
notify('You must credit an artist before downloading!', 5);
} else {
- //Prep file information
+ // Prep file information
const imageDataURL = cardCanvas.toDataURL('image/png');
var imageName = card.text.title.text || 'card';
if (card.text.nickname) {
imageName = imageName + ' (' + card.text.nickname.text + ')'
}
imageName += '.png';
- //download image
+ // Download image
if (alt) {
- var w = window.open('about:blank');
+ const newWindow = window.open('about:blank');
setTimeout(function(){
- w.document.body.appendChild(w.document.createElement('img'))
- .src = imageDataURL;
- w.document.querySelector('img').style = 'max-height: 90vh; max-width: 90vw;';
+ newWindow.document.body.appendChild(newWindow.document.createElement('img')).src = imageDataURL;
+ newWindow.document.querySelector('img').style = 'max-height: 100vh; max-width: 100vw;';
+ newWindow.document.body.style = 'padding: 0; margin: 0; text-align: center; background-color: #888;';
+ newWindow.document.title = imageName;
}, 0);
} else {
- var downloadElement = document.createElement('a');
+ const downloadElement = document.createElement('a');
downloadElement.download = imageName;
downloadElement.target = '_blank';
downloadElement.href = imageDataURL;
document.body.appendChild(downloadElement);
- // if (alt) {alert('test');}
downloadElement.click();
downloadElement.remove();
}