From 03199c5a4f9bf7dd798645a280735ff0f9f6a17a Mon Sep 17 00:00:00 2001 From: patriceac <48073125+patriceac@users.noreply.github.com> Date: Sat, 1 Apr 2023 03:17:15 -0700 Subject: [PATCH] cleanup code --- ui/media/js/image-modifiers.js | 3 +- ui/plugins/ui/Modifiers-wheel.plugin.js | 38 +++++++++---------------- 2 files changed, 14 insertions(+), 27 deletions(-) diff --git a/ui/media/js/image-modifiers.js b/ui/media/js/image-modifiers.js index 32d4eeb4..5a56d940 100644 --- a/ui/media/js/image-modifiers.js +++ b/ui/media/js/image-modifiers.js @@ -129,8 +129,7 @@ function createModifierGroup(modifierGroup, initiallyExpanded, removeBy) { } function trimModifiers(tag) { - // Remove trailing '-' and/or '+' - return tag.replace(/[-+]+$/, ''); + return tag.replace(/^\(+|\)+$/g, '').replace(/^\[+|\]+$/g, '') } async function loadModifiers() { diff --git a/ui/plugins/ui/Modifiers-wheel.plugin.js b/ui/plugins/ui/Modifiers-wheel.plugin.js index 0967a725..322cca8f 100644 --- a/ui/plugins/ui/Modifiers-wheel.plugin.js +++ b/ui/plugins/ui/Modifiers-wheel.plugin.js @@ -1,8 +1,4 @@ -(function () { - "use strict" - - const MAX_WEIGHT = 5 - +(function () { "use strict" if (typeof editorModifierTagsList !== 'object') { console.error('editorModifierTagsList missing...') return @@ -38,42 +34,34 @@ break } } - if (s.charAt(0) !== '(' && s.charAt(s.length - 1) !== ')' && s.trim().includes(' ')) { - s = '(' + s + ')' - t = '(' + t + ')' - } if (delta < 0) { // wheel scrolling up - if (s.substring(s.length - 1) == '-') { - s = s.substring(0, s.length - 1) - t = t.substring(0, t.length - 1) + if (s.substring(0, 1) == '[' && s.substring(s.length-1) == ']') { + s = s.substring(1, s.length - 1) + t = t.substring(1, t.length - 1) } else { - if (s.substring(s.length - MAX_WEIGHT) !== '+'.repeat(MAX_WEIGHT)) { - s = s + '+' - t = t + '+' + if (s.substring(0, 10) !== '('.repeat(10) && s.substring(s.length-10) !== ')'.repeat(10)) { + s = '(' + s + ')' + t = '(' + t + ')' } } } else{ // wheel scrolling down - if (s.substring(s.length - 1) == '+') { - s = s.substring(0, s.length - 1) - t = t.substring(0, t.length - 1) + if (s.substring(0, 1) == '(' && s.substring(s.length-1) == ')') { + s = s.substring(1, s.length - 1) + t = t.substring(1, t.length - 1) } else { - if (s.substring(s.length - MAX_WEIGHT) !== '-'.repeat(MAX_WEIGHT)) { - s = s + '-' - t = t + '-' + if (s.substring(0, 10) !== '['.repeat(10) && s.substring(s.length-10) !== ']'.repeat(10)) { + s = '[' + s + ']' + t = '[' + t + ']' } } } - if (s.charAt(0) === '(' && s.charAt(s.length - 1) === ')') { - s = s.substring(1, s.length - 1) - t = t.substring(1, t.length - 1) - } i.parentElement.getElementsByClassName('modifier-card-label')[0].getElementsByTagName("p")[0].innerText = s // update activeTags for (let it = 0; it < overlays.length; it++) {