mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-23 00:06:17 -04:00
Added more tests, fixed length count bug and IO clearance bug
This commit is contained in:
parent
8c0e23e196
commit
819e4a574c
6 changed files with 277 additions and 22 deletions
|
@ -149,13 +149,20 @@ class StatusBarPanel {
|
|||
|
||||
/**
|
||||
* Counts the stats of a document
|
||||
* @param {Text} doc
|
||||
* @param {EditorState} state
|
||||
*/
|
||||
updateStats(doc) {
|
||||
updateStats(state) {
|
||||
const length = this.dom.querySelector(".stats-length-value"),
|
||||
lines = this.dom.querySelector(".stats-lines-value");
|
||||
length.textContent = doc.length;
|
||||
lines.textContent = doc.lines;
|
||||
|
||||
let docLength = state.doc.length;
|
||||
// CodeMirror always counts line breaks as one character.
|
||||
// We want to show an accurate reading of how many bytes there are.
|
||||
if (state.lineBreak.length !== 1) {
|
||||
docLength += (state.lineBreak.length * state.doc.lines) - state.doc.lines - 1;
|
||||
}
|
||||
length.textContent = docLength;
|
||||
lines.textContent = state.doc.lines;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -434,7 +441,7 @@ function makePanel(opts) {
|
|||
sbPanel.updateEOL(view.state);
|
||||
sbPanel.updateCharEnc();
|
||||
sbPanel.updateTiming();
|
||||
sbPanel.updateStats(view.state.doc);
|
||||
sbPanel.updateStats(view.state);
|
||||
sbPanel.updateSelection(view.state, false);
|
||||
sbPanel.monitorHTMLOutput();
|
||||
|
||||
|
@ -450,7 +457,7 @@ function makePanel(opts) {
|
|||
sbPanel.updateSizing(update.view);
|
||||
}
|
||||
if (update.docChanged) {
|
||||
sbPanel.updateStats(update.state.doc);
|
||||
sbPanel.updateStats(update.state);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1222,12 +1222,6 @@ class InputWaiter {
|
|||
this.setupInputWorker();
|
||||
this.manager.worker.setupChefWorker();
|
||||
this.addInput(true);
|
||||
|
||||
// Fire the statechange event as the input has been modified,
|
||||
// leaving enough time for workers to be initialised
|
||||
setTimeout(function() {
|
||||
window.dispatchEvent(this.manager.statechange);
|
||||
}.bind(this), 100);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -231,9 +231,13 @@ class OutputWaiter {
|
|||
*/
|
||||
async setOutput(data, force=false) {
|
||||
// Don't do anything if the output hasn't changed
|
||||
if (!force && data === this.currentOutputCache) return;
|
||||
this.currentOutputCache = data;
|
||||
if (!force && data === this.currentOutputCache) {
|
||||
this.manager.controls.hideStaleIndicator();
|
||||
this.toggleLoader(false);
|
||||
return;
|
||||
}
|
||||
|
||||
this.currentOutputCache = data;
|
||||
this.toggleLoader(true);
|
||||
|
||||
// If data is an ArrayBuffer, convert to a string in the correct character encoding
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue