mirror of
https://github.com/Investigamer/cardconjurer.git
synced 2025-07-27 05:14:53 -05:00
alternative downloads
This commit is contained in:
@@ -465,10 +465,7 @@ include('../globalHTML/header-1.php');
|
|||||||
</div>
|
</div>
|
||||||
<div class='readable-background padding'>
|
<div class='readable-background padding'>
|
||||||
<h3 class='download padding' onclick='downloadCard();'>Download your card</h3>
|
<h3 class='download padding' onclick='downloadCard();'>Download your card</h3>
|
||||||
<h5 class='collapsible collapsed padding input-description debugging hidden' onclick='toggleCollapse(event);'>Not downloading? </h5>
|
<h5 onclick='downloadCard(true);' id='downloadAlt' href='' target='_blank' class='padding download input-description' style='text-align: left;'>Click here for an alternative download</h5>
|
||||||
<div class='input-grid margin-bottom debugging hidden'>
|
|
||||||
<h4 onclick='downloadCard(true);' id='downloadAlt' href='' target='_blank' class='padding download' style='text-align: left;'>Use this link to open your card image in a new window, then save it manually.</h4>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -491,5 +488,5 @@ include('../globalHTML/header-1.php');
|
|||||||
</h4>
|
</h4>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script defer src='/js/creator-17.js'></script>
|
<script defer src='/js/creator-18.js'></script>
|
||||||
<?php include('../globalHTML/footer.php'); ?>
|
<?php include('../globalHTML/footer.php'); ?>
|
@@ -1287,32 +1287,32 @@ function drawCard() {
|
|||||||
previewContext.drawImage(cardCanvas, 0, 0, previewCanvas.width, previewCanvas.height);
|
previewContext.drawImage(cardCanvas, 0, 0, previewCanvas.width, previewCanvas.height);
|
||||||
}
|
}
|
||||||
//DOWNLOADING
|
//DOWNLOADING
|
||||||
async function downloadCard(alt = false) {
|
function downloadCard(alt = false) {
|
||||||
if (card.infoArtist.replace(/ /g, '') == '' && !card.artSource.includes('/img/blank.png') && !card.artZoom == 0) {
|
if (card.infoArtist.replace(/ /g, '') == '' && !card.artSource.includes('/img/blank.png') && !card.artZoom == 0) {
|
||||||
notify('You must credit an artist before downloading!', 5);
|
notify('You must credit an artist before downloading!', 5);
|
||||||
} else {
|
} else {
|
||||||
//Prep file information
|
// Prep file information
|
||||||
const imageDataURL = cardCanvas.toDataURL('image/png');
|
const imageDataURL = cardCanvas.toDataURL('image/png');
|
||||||
var imageName = card.text.title.text || 'card';
|
var imageName = card.text.title.text || 'card';
|
||||||
if (card.text.nickname) {
|
if (card.text.nickname) {
|
||||||
imageName = imageName + ' (' + card.text.nickname.text + ')'
|
imageName = imageName + ' (' + card.text.nickname.text + ')'
|
||||||
}
|
}
|
||||||
imageName += '.png';
|
imageName += '.png';
|
||||||
//download image
|
// Download image
|
||||||
if (alt) {
|
if (alt) {
|
||||||
var w = window.open('about:blank');
|
const newWindow = window.open('about:blank');
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
w.document.body.appendChild(w.document.createElement('img'))
|
newWindow.document.body.appendChild(newWindow.document.createElement('img')).src = imageDataURL;
|
||||||
.src = imageDataURL;
|
newWindow.document.querySelector('img').style = 'max-height: 100vh; max-width: 100vw;';
|
||||||
w.document.querySelector('img').style = 'max-height: 90vh; max-width: 90vw;';
|
newWindow.document.body.style = 'padding: 0; margin: 0; text-align: center; background-color: #888;';
|
||||||
|
newWindow.document.title = imageName;
|
||||||
}, 0);
|
}, 0);
|
||||||
} else {
|
} else {
|
||||||
var downloadElement = document.createElement('a');
|
const downloadElement = document.createElement('a');
|
||||||
downloadElement.download = imageName;
|
downloadElement.download = imageName;
|
||||||
downloadElement.target = '_blank';
|
downloadElement.target = '_blank';
|
||||||
downloadElement.href = imageDataURL;
|
downloadElement.href = imageDataURL;
|
||||||
document.body.appendChild(downloadElement);
|
document.body.appendChild(downloadElement);
|
||||||
// if (alt) {alert('test');}
|
|
||||||
downloadElement.click();
|
downloadElement.click();
|
||||||
downloadElement.remove();
|
downloadElement.remove();
|
||||||
}
|
}
|
Reference in New Issue
Block a user