1
0
mirror of synced 2024-11-28 08:30:48 +01:00

Changing the output encoding no longer triggers a full bake

This commit is contained in:
n1474335 2022-09-09 16:35:21 +01:00
parent 406da9fa2c
commit 3893c22275
2 changed files with 14 additions and 5 deletions

View File

@ -81,6 +81,9 @@ class StatusBarPanel {
* @param {Event} e * @param {Event} e
*/ */
eolSelectClick(e) { eolSelectClick(e) {
// preventDefault is required to stop the URL being modified and popState being triggered
e.preventDefault();
const eolLookup = { const eolLookup = {
"LF": "\u000a", "LF": "\u000a",
"VT": "\u000b", "VT": "\u000b",
@ -106,6 +109,9 @@ class StatusBarPanel {
* @param {Event} e * @param {Event} e
*/ */
chrEncSelectClick(e) { chrEncSelectClick(e) {
// preventDefault is required to stop the URL being modified and popState being triggered
e.preventDefault(); // TODO - this breaks the menus when you click the button itself
const chrEncVal = parseInt(e.target.getAttribute("data-val"), 10); const chrEncVal = parseInt(e.target.getAttribute("data-val"), 10);
if (isNaN(chrEncVal)) return; if (isNaN(chrEncVal)) return;
@ -366,9 +372,9 @@ function hideOnClickOutside(element, instantiatingEvent) {
} }
}; };
if (!Object.keys(elementsWithListeners).includes(element)) { if (!Object.prototype.hasOwnProperty.call(elementsWithListeners, element)) {
document.addEventListener("click", outsideClickListener);
elementsWithListeners[element] = outsideClickListener; elementsWithListeners[element] = outsideClickListener;
document.addEventListener("click", elementsWithListeners[element], false);
} }
} }
@ -378,7 +384,7 @@ function hideOnClickOutside(element, instantiatingEvent) {
*/ */
function hideElement(element) { function hideElement(element) {
element.classList.remove("show"); element.classList.remove("show");
document.removeEventListener("click", elementsWithListeners[element]); document.removeEventListener("click", elementsWithListeners[element], false);
delete elementsWithListeners[element]; delete elementsWithListeners[element];
} }

View File

@ -146,6 +146,8 @@ class OutputWaiter {
*/ */
chrEncChange(chrEncVal) { chrEncChange(chrEncVal) {
this.outputChrEnc = chrEncVal; this.outputChrEnc = chrEncVal;
// Reset the output, forcing it to re-decode the data with the new character encoding
this.setOutput(this.currentOutputCache, true);
} }
/** /**
@ -173,10 +175,11 @@ class OutputWaiter {
/** /**
* Sets the value of the current output * Sets the value of the current output
* @param {string|ArrayBuffer} data * @param {string|ArrayBuffer} data
* @param {boolean} [force=false]
*/ */
setOutput(data) { setOutput(data, force=false) {
// Don't do anything if the output hasn't changed // Don't do anything if the output hasn't changed
if (data === this.currentOutputCache) return; if (!force && data === this.currentOutputCache) return;
this.currentOutputCache = data; this.currentOutputCache = data;
// If data is an ArrayBuffer, convert to a string in the correct character encoding // If data is an ArrayBuffer, convert to a string in the correct character encoding