aboutsummaryrefslogtreecommitdiff
path: root/ext/js/input/hotkey-help-controller.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/js/input/hotkey-help-controller.js')
-rw-r--r--ext/js/input/hotkey-help-controller.js32
1 files changed, 32 insertions, 0 deletions
diff --git a/ext/js/input/hotkey-help-controller.js b/ext/js/input/hotkey-help-controller.js
index 16f3d26f..b495365d 100644
--- a/ext/js/input/hotkey-help-controller.js
+++ b/ext/js/input/hotkey-help-controller.js
@@ -181,4 +181,36 @@ export class HotkeyHelpController {
defaultAttributeValues
};
}
+
+ /**
+ * @param {HTMLElement} node
+ * @returns {?string}
+ */
+ getHotkeyLabel(node) {
+ const {hotkey} = node.dataset;
+ if (typeof hotkey !== 'string') { return null; }
+
+ const data = /** @type {unknown} */ (parseJson(hotkey));
+ if (!Array.isArray(data)) { return null; }
+
+ const values = /** @type {unknown[]} */ (data)[2];
+ if (typeof values !== 'string') { return null; }
+
+ return values;
+ }
+
+ /**
+ * @param {HTMLElement} node
+ * @param {string} label
+ */
+ setHotkeyLabel(node, label) {
+ const {hotkey} = node.dataset;
+ if (typeof hotkey !== 'string') { return; }
+
+ const data = /** @type {unknown} */ (parseJson(hotkey));
+ if (!Array.isArray(data)) { return; }
+
+ data[2] = label;
+ node.dataset.hotkey = JSON.stringify(data);
+ }
}