Reviewed Highlighter and Options waiters

This commit is contained in:
n1474335 2023-01-19 17:14:24 +00:00
parent 934efcc5a0
commit fa21768931
3 changed files with 16 additions and 27 deletions

View File

@ -72,7 +72,6 @@ class HighlighterWaiter {
} }
} }
/** /**
* Displays highlight offsets sent back from the Chef. * Displays highlight offsets sent back from the Chef.
* *
@ -89,7 +88,6 @@ class HighlighterWaiter {
this.highlight(io, pos); this.highlight(io, pos);
} }
/** /**
* Sends selection updates to the relevant EditorView. * Sends selection updates to the relevant EditorView.
* *
@ -129,9 +127,8 @@ class HighlighterWaiter {
} catch (err) { } catch (err) {
// Ignore Range Errors // Ignore Range Errors
if (!err.toString().startsWith("RangeError")) { if (!err.toString().startsWith("RangeError")) {
console.error(err); log.error(err);
} }
} }
} }
} }

View File

@ -26,33 +26,27 @@ class OptionsWaiter {
* @param {Object} options * @param {Object} options
*/ */
load(options) { load(options) {
for (const option in options) { Object.assign(this.app.options, options);
this.app.options[option] = options[option];
}
// Set options to match object // Set options to match object
const cboxes = document.querySelectorAll("#options-body input[type=checkbox]"); document.querySelectorAll("#options-body input[type=checkbox]").forEach(cbox => {
let i; cbox.checked = this.app.options[cbox.getAttribute("option")];
for (i = 0; i < cboxes.length; i++) { });
cboxes[i].checked = this.app.options[cboxes[i].getAttribute("option")];
}
const nboxes = document.querySelectorAll("#options-body input[type=number]"); document.querySelectorAll("#options-body input[type=number]").forEach(nbox => {
for (i = 0; i < nboxes.length; i++) { nbox.value = this.app.options[nbox.getAttribute("option")];
nboxes[i].value = this.app.options[nboxes[i].getAttribute("option")]; nbox.dispatchEvent(new CustomEvent("change", {bubbles: true}));
nboxes[i].dispatchEvent(new CustomEvent("change", {bubbles: true})); });
}
const selects = document.querySelectorAll("#options-body select"); document.querySelectorAll("#options-body select").forEach(select => {
for (i = 0; i < selects.length; i++) { const val = this.app.options[select.getAttribute("option")];
const val = this.app.options[selects[i].getAttribute("option")];
if (val) { if (val) {
selects[i].value = val; select.value = val;
selects[i].dispatchEvent(new CustomEvent("change", {bubbles: true})); select.dispatchEvent(new CustomEvent("change", {bubbles: true}));
} else { } else {
selects[i].selectedIndex = 0; select.selectedIndex = 0;
} }
} });
// Initialise options // Initialise options
this.setWordWrap(); this.setWordWrap();
@ -151,7 +145,6 @@ class OptionsWaiter {
*/ */
themeChange(e) { themeChange(e) {
const themeClass = e.target.value; const themeClass = e.target.value;
this.changeTheme(themeClass); this.changeTheme(themeClass);
} }

View File

@ -30,8 +30,7 @@ class SeasonalWaiter {
window.addEventListener("keydown", this.konamiCodeListener.bind(this)); window.addEventListener("keydown", this.konamiCodeListener.bind(this));
// CyberChef Challenge // CyberChef Challenge
// eslint-disable-next-line no-console log.info("43 6f 6e 67 72 61 74 75 6c 61 74 69 6f 6e 73 2c 20 79 6f 75 20 68 61 76 65 20 63 6f 6d 70 6c 65 74 65 64 20 43 79 62 65 72 43 68 65 66 20 63 68 61 6c 6c 65 6e 67 65 20 23 31 21 0a 0a 54 68 69 73 20 63 68 61 6c 6c 65 6e 67 65 20 65 78 70 6c 6f 72 65 64 20 68 65 78 61 64 65 63 69 6d 61 6c 20 65 6e 63 6f 64 69 6e 67 2e 20 54 6f 20 6c 65 61 72 6e 20 6d 6f 72 65 2c 20 76 69 73 69 74 20 77 69 6b 69 70 65 64 69 61 2e 6f 72 67 2f 77 69 6b 69 2f 48 65 78 61 64 65 63 69 6d 61 6c 2e 0a 0a 54 68 65 20 63 6f 64 65 20 66 6f 72 20 74 68 69 73 20 63 68 61 6c 6c 65 6e 67 65 20 69 73 20 39 64 34 63 62 63 65 66 2d 62 65 35 32 2d 34 37 35 31 2d 61 32 62 32 2d 38 33 33 38 65 36 34 30 39 34 31 36 20 28 6b 65 65 70 20 74 68 69 73 20 70 72 69 76 61 74 65 29 2e 0a 0a 54 68 65 20 6e 65 78 74 20 63 68 61 6c 6c 65 6e 67 65 20 63 61 6e 20 62 65 20 66 6f 75 6e 64 20 61 74 20 68 74 74 70 73 3a 2f 2f 70 61 73 74 65 62 69 6e 2e 63 6f 6d 2f 47 53 6e 54 41 6d 6b 56 2e");
console.log("43 6f 6e 67 72 61 74 75 6c 61 74 69 6f 6e 73 2c 20 79 6f 75 20 68 61 76 65 20 63 6f 6d 70 6c 65 74 65 64 20 43 79 62 65 72 43 68 65 66 20 63 68 61 6c 6c 65 6e 67 65 20 23 31 21 0a 0a 54 68 69 73 20 63 68 61 6c 6c 65 6e 67 65 20 65 78 70 6c 6f 72 65 64 20 68 65 78 61 64 65 63 69 6d 61 6c 20 65 6e 63 6f 64 69 6e 67 2e 20 54 6f 20 6c 65 61 72 6e 20 6d 6f 72 65 2c 20 76 69 73 69 74 20 77 69 6b 69 70 65 64 69 61 2e 6f 72 67 2f 77 69 6b 69 2f 48 65 78 61 64 65 63 69 6d 61 6c 2e 0a 0a 54 68 65 20 63 6f 64 65 20 66 6f 72 20 74 68 69 73 20 63 68 61 6c 6c 65 6e 67 65 20 69 73 20 39 64 34 63 62 63 65 66 2d 62 65 35 32 2d 34 37 35 31 2d 61 32 62 32 2d 38 33 33 38 65 36 34 30 39 34 31 36 20 28 6b 65 65 70 20 74 68 69 73 20 70 72 69 76 61 74 65 29 2e 0a 0a 54 68 65 20 6e 65 78 74 20 63 68 61 6c 6c 65 6e 67 65 20 63 61 6e 20 62 65 20 66 6f 75 6e 64 20 61 74 20 68 74 74 70 73 3a 2f 2f 70 61 73 74 65 62 69 6e 2e 63 6f 6d 2f 47 53 6e 54 41 6d 6b 56 2e");
} }