From 012e4abc779d6f98059df7faa181809a8b7feacd Mon Sep 17 00:00:00 2001 From: Josh Birnholz Date: Thu, 16 Feb 2023 15:39:26 -0500 Subject: [PATCH] Update {cardname} and ~ shortcuts to use nickname if it exists --- js/creator-23.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/js/creator-23.js b/js/creator-23.js index 442c2b7c..7aef5422 100644 --- a/js/creator-23.js +++ b/js/creator-23.js @@ -173,6 +173,16 @@ function getCardName() { } return imageName.replace(/\{[^}]+\}/g, ''); } +function getInlineCardName() { + if (card.text == undefined || card.text.title == undefined) { + return 'unnamed'; + } + var imageName = card.text.title.text || 'unnamed'; + if (card.text.nickname) { + imageName = card.text.nickname.text; + } + return imageName.replace(/\{[^}]+\}/g, ''); +} //UI function toggleCreatorTabs(event, target) { Array.from(document.querySelector('#creator-menu-sections').children).forEach(element => element.classList.add('hidden')); @@ -2287,7 +2297,7 @@ function writeText(textObject, targetContext) { if (rawText == 'none') { rawText = ''; } } if (rawText.toLowerCase().includes('{cardname}') || rawText.toLowerCase().includes('~')) { - rawText = rawText.replace(/{cardname}|~/ig, getCardName()); + rawText = rawText.replace(/{cardname}|~/ig, getInlineCardName()); } if (document.querySelector('#info-artist').value == '') { rawText = rawText.replace('\uFFEE{elemidinfo-artist}', '');