Code improvements (#613)

This commit is contained in:
nobody 2021-08-14 06:59:52 +02:00
parent 9460b02af7
commit 1b67c9c979
No known key found for this signature in database
GPG Key ID: 8F6DE3D614FCFD7A
1 changed files with 14 additions and 0 deletions

View File

@ -147,6 +147,10 @@ optionsOther._colorPicker = function (element) {
optionsOther._setDefaultColor = function ({target}) {
let element = optionsOther._getBadgeElement(target.id);
if (element === undefined) {
return;
}
if (target.id === element.RESTORE_TEXT_COLOR) {
let txtColor = element.HEX_TEXT_COLOR;
wrappers.setBadgeTextColor({'type': element.TYPE, 'color': txtColor});
@ -165,6 +169,10 @@ optionsOther._setDefaultColor = function ({target}) {
optionsOther._onChangedHexColor = function ({target}) {
let element = optionsOther._getBadgeElement(target.id);
if (element === undefined) {
return;
}
if (/#([a-f0-9]{3}){1,2}\b/i.test(target.value)) {
target.classList.remove('color-error');
if (target.id === element.BADGED_TEXT_COLOR) {
@ -183,12 +191,18 @@ optionsOther._onChangedHexColor = function ({target}) {
optionsOther._getBadgeElement = function (targetId) {
switch (targetId) {
case BadgeSetting.BADGED_TEXT_COLOR:
case BadgeSetting.BADGED_BACKGROUND_COLOR:
case BadgeSetting.RESTORE_TEXT_COLOR:
case BadgeSetting.RESTORE_BACKGROUND_COLOR:
return BadgeSetting;
case BadgeSettingHTMLFilter.BADGED_TEXT_COLOR:
case BadgeSettingHTMLFilter.BADGED_BACKGROUND_COLOR:
case BadgeSettingHTMLFilter.RESTORE_TEXT_COLOR:
case BadgeSettingHTMLFilter.RESTORE_BACKGROUND_COLOR:
return BadgeSettingHTMLFilter;
case BadgeSettingMissingResource.BADGED_TEXT_COLOR:
case BadgeSettingMissingResource.BADGED_BACKGROUND_COLOR:
case BadgeSettingMissingResource.RESTORE_TEXT_COLOR:
case BadgeSettingMissingResource.RESTORE_BACKGROUND_COLOR:
return BadgeSettingMissingResource;