Fix removal of image modifiers with non-zero weights

Properly handles removal of image modifiers that had (((modifiers))) or [[[modifiers]]] updated at runtime.
This commit is contained in:
patriceac 2022-11-27 03:00:19 -08:00
parent c4bad5c454
commit e278e639a3

View File

@ -87,9 +87,9 @@ function createModifierGroup(modifierGroup, initiallyExpanded) {
modifiersEl.appendChild(modifierCard)
modifierCard.addEventListener('click', () => {
if (activeTags.map(x => x.name).includes(modifierName)) {
if (activeTags.map(x => trimModifiers(x.name)).includes(trimModifiers(modifierName))) {
// remove modifier from active array
activeTags = activeTags.filter(x => x.name != modifierName)
activeTags = activeTags.filter(x => trimModifiers(x.name) != trimModifiers(modifierName))
modifierCard.classList.remove(activeCardClass)
modifierCard.querySelector('.modifier-card-image-overlay').innerText = '+'
@ -125,6 +125,10 @@ function createModifierGroup(modifierGroup, initiallyExpanded) {
return e
}
function trimModifiers(tag) {
return tag.replace(/^\(+|\)+$/g, '').replace(/^\[+|\]+$/g, '')
}
async function loadModifiers() {
try {
let res = await fetch('/get/modifiers')