mirror of
https://github.com/Investigamer/cardconjurer.git
synced 2025-07-27 05:14:53 -05:00
automatically clean card names of text codes
This commit is contained in:
@@ -156,6 +156,13 @@ function scaleHeight(input) {
|
|||||||
function getElementIndex(element) {
|
function getElementIndex(element) {
|
||||||
return Array.prototype.indexOf.call(element.parentElement.children, element);
|
return Array.prototype.indexOf.call(element.parentElement.children, element);
|
||||||
}
|
}
|
||||||
|
function getCardName() {
|
||||||
|
var imageName = card.text.title.text || 'unnamed';
|
||||||
|
if (card.text.nickname) {
|
||||||
|
imageName += ' (' + card.text.nickname.text + ')';
|
||||||
|
}
|
||||||
|
return imageName.replace(/\{[^}]+\}/g, '') + '.png';
|
||||||
|
}
|
||||||
//UI
|
//UI
|
||||||
function toggleCreatorTabs(event, target) {
|
function toggleCreatorTabs(event, target) {
|
||||||
Array.from(document.querySelector('#creator-menu-sections').children).forEach(element => element.classList.add('hidden'));
|
Array.from(document.querySelector('#creator-menu-sections').children).forEach(element => element.classList.add('hidden'));
|
||||||
@@ -1542,11 +1549,7 @@ function downloadCard(alt = false) {
|
|||||||
} 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 = getCardName();
|
||||||
if (card.text.nickname) {
|
|
||||||
imageName = imageName + ' (' + card.text.nickname.text + ')'
|
|
||||||
}
|
|
||||||
imageName += '.png';
|
|
||||||
// Download image
|
// Download image
|
||||||
if (alt) {
|
if (alt) {
|
||||||
const newWindow = window.open('about:blank');
|
const newWindow = window.open('about:blank');
|
||||||
@@ -1670,7 +1673,7 @@ function saveCard(saveFromFile) {
|
|||||||
if (saveFromFile) {
|
if (saveFromFile) {
|
||||||
cardKey = saveFromFile.key;
|
cardKey = saveFromFile.key;
|
||||||
} else {
|
} else {
|
||||||
cardKey = card.text.title.text || 'unnamed';
|
cardKey = getCardName();
|
||||||
}
|
}
|
||||||
if (!saveFromFile) {
|
if (!saveFromFile) {
|
||||||
cardKey = prompt('Enter the name you would like to save your card under:', cardKey);
|
cardKey = prompt('Enter the name you would like to save your card under:', cardKey);
|
||||||
|
Reference in New Issue
Block a user