Skip to content

Commit e3c88f3

Browse files
committed
improve readability
1 parent e0b7088 commit e3c88f3

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

html/dubeditor.js

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ function runCommand(/** @type {string} */ command, /** @type {any} */ argument)
3737
* @property {string} [value]
3838
*/
3939

40+
/**
41+
* @typedef {Object} AccessType
42+
* @property {boolean} [platform] true if this setting is set with a platform/arch/compiler suffix.
43+
* @property {boolean} [subscope] true if this setting is inside a config or build config.
44+
* @property {string} [desc] Human readable description (suffix)
45+
*/
46+
4047
/**
4148
* @param {string} label
4249
* @param {InputOptions | undefined} options
@@ -540,12 +547,12 @@ function hideResetButton(setting) {
540547

541548
/**
542549
* @param {HTMLElement} setting
543-
* @param {[boolean, boolean, string] | undefined} usedAccess
550+
* @param {AccessType | undefined} usedAccess
544551
*/
545552
function makeSetInLabel(setting, usedAccess) {
546553
let label = getLabelElement(setting);
547554
let modifiedHint = label?.querySelector(".modified-hint a");
548-
if (usedAccess && usedAccess[2] && label) {
555+
if (usedAccess && usedAccess.desc && label) {
549556
if (!modifiedHint) {
550557
let hint = document.createElement("span");
551558
hint.className = "modified-hint";
@@ -573,9 +580,9 @@ function makeSetInLabel(setting, usedAccess) {
573580
return false;
574581
});
575582
}
576-
modifiedHint.textContent = usedAccess[2];
577-
modifiedHint.setAttribute("data-prefix", usedAccess[1] ? "true" : "false");
578-
modifiedHint.setAttribute("data-suffix", usedAccess[0] ? "true" : "false");
583+
modifiedHint.textContent = usedAccess.desc;
584+
modifiedHint.setAttribute("data-prefix", usedAccess.subscope ? "true" : "false");
585+
modifiedHint.setAttribute("data-suffix", usedAccess.platform ? "true" : "false");
579586
} else {
580587
modifiedHint?.parentElement?.parentElement?.removeChild(modifiedHint.parentElement);
581588
}
@@ -640,7 +647,7 @@ function ready() {
640647

641648
let suffixDisabled = !hasSuffixMembers;
642649
let overridesDisabled = !hasOverride;
643-
650+
644651
if (overridesDisabled)
645652
overridesSelector.classList.add("effectless");
646653
else
@@ -729,16 +736,23 @@ function loadJsonIntoUI() {
729736
let type = setting.getAttribute("json-type");
730737
let strValue = setting.getAttribute("json-value");
731738
let configPath = undefined;
739+
/**
740+
* @type {AccessType | undefined}
741+
*/
732742
let usedAccess = undefined;
733743
/**
734-
* @type {[boolean, boolean, string][]}
744+
* @type {AccessType[]}
735745
*/
736746
const accessTries = [
737747
[true, true, ""], // in current config/override with platform suffix
738748
[false, true, "all platforms"], // in current config/override without platform suffix
739749
[true, false, "Base"], // in global scope with platform suffix
740750
[false, false, "Base with all platforms"], // in global scope without platform suffix
741-
];
751+
].map(v => ({
752+
platform: /** @type {boolean} */ (v[0]),
753+
subscope: /** @type {boolean} */ (v[1]),
754+
desc: /** @type {string} */ (v[2])
755+
});
742756
accessTries.forEach(access => {
743757
if (configPath) return;
744758
let resolved = makePath(setting, path, access[0], access[1]);

0 commit comments

Comments
 (0)