Add JSON download button for card information in card creator
This commit is contained in:
parent
5356c1ecf4
commit
076fcfc1c4
1 changed files with 24 additions and 0 deletions
|
@ -226,5 +226,29 @@ downloadBtn.addEventListener("click", () => {
|
||||||
link.href = canvas.toDataURL("image/webp", 0.95);
|
link.href = canvas.toDataURL("image/webp", 0.95);
|
||||||
link.click();
|
link.click();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Create and place the JSON download button below the card download button
|
||||||
|
const jsonBtn = document.createElement("button");
|
||||||
|
jsonBtn.textContent = "Download Card Info";
|
||||||
|
jsonBtn.style.marginTop = "0.5rem";
|
||||||
|
jsonBtn.onclick = () => {
|
||||||
|
const cardData = {
|
||||||
|
name: nameInput.value,
|
||||||
|
pack: packInput.value,
|
||||||
|
power: powerInput.value,
|
||||||
|
charm: charmInput.value,
|
||||||
|
wit: witInput.value,
|
||||||
|
flavor: flavorInput.value,
|
||||||
|
artist: artistInput.value,
|
||||||
|
frame: frameSelect.value
|
||||||
|
};
|
||||||
|
const blob = new Blob([JSON.stringify(cardData, null, 2)], {type: "application/json"});
|
||||||
|
const link = document.createElement("a");
|
||||||
|
link.href = URL.createObjectURL(blob);
|
||||||
|
link.download = "kemoverse-card.json";
|
||||||
|
link.click();
|
||||||
|
};
|
||||||
|
// Place the button below the downloadBtn
|
||||||
|
downloadBtn.parentNode.insertBefore(jsonBtn, downloadBtn.nextSibling);
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
Loading…
Add table
Reference in a new issue