Refactor generateCardId function to accept variable arguments for enhanced ID generation
This commit is contained in:
parent
eff962608f
commit
18b1eef26e
1 changed files with 3 additions and 3 deletions
|
@ -72,9 +72,9 @@ const artistInput = document.getElementById("artistInput");
|
|||
const downloadBtn = document.getElementById("downloadBtn");
|
||||
|
||||
// Generate a unique ID for the card based on pack and card name
|
||||
async function generateCardId(packName, cardName) {
|
||||
async function generateCardId(...args) {
|
||||
const encoder = new TextEncoder();
|
||||
const data = encoder.encode(packName + ':' + cardName);
|
||||
const data = encoder.encode(args.join(':'));
|
||||
const hashBuffer = await crypto.subtle.digest('SHA-1', data);
|
||||
|
||||
// Convert hash to hex
|
||||
|
@ -130,7 +130,7 @@ function drawCard() {
|
|||
}
|
||||
|
||||
async function drawCardId() {
|
||||
const id = await generateCardId(packInput.value, nameInput.value);
|
||||
const id = await generateCardId(packInput.value, nameInput.value, powerInput.value, charmInput.value, witInput.value, artistInput.value);
|
||||
ctx.font = "15px sans-serif";
|
||||
ctx.fillText("KC-" + id, canvas.width/2, canvas.height - 30);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue