From 2e498dab9b79f906f7246a4f82f15e65d5e055ee Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Wed, 8 Sep 2021 20:08:36 -0400 Subject: [PATCH] Replace tags globaly in card text --- strange_eons_to_arkhamdb.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/strange_eons_to_arkhamdb.js b/strange_eons_to_arkhamdb.js index eeaea3d..616cc23 100644 --- a/strange_eons_to_arkhamdb.js +++ b/strange_eons_to_arkhamdb.js @@ -81,13 +81,17 @@ function leftPad(str, len, fill) { return fill.repeat(Math.max(len - str.length, 0)) + str; } +function replaceAll(str, search, replace) { + return str.split(search).join(replace); +} + function build_card(component) { function substitute_tags(str) { str = str.trim(); - str = str.replace("", String(component.getName())); + str = replaceAll(str, "", String(component.getName())); - for (tag in tag_replacements) { - str = str.replace(tag, tag_replacements[tag]); + for (var tag in tag_replacements) { + str = replaceAll(str, tag, tag_replacements[tag]); } return str; }