mirror of
https://github.com/gchq/CyberChef.git
synced 2025-05-07 15:07:11 -04:00
Async operation code tidy.
This commit is contained in:
parent
11e06eeb75
commit
9f75077fe8
5 changed files with 21 additions and 48 deletions
|
@ -97,9 +97,7 @@
|
|||
<div id="input" class="split no-select">
|
||||
<div class="title no-select">
|
||||
Input
|
||||
<div class="loading-icon"
|
||||
style="display: none">
|
||||
</div>
|
||||
<div class="loading-icon" style="display: none"></div>
|
||||
<div class="btn-group io-btn-group">
|
||||
<button type="button" class="btn btn-default btn-sm" id="clr-io"><img src="images/recycle-16x16.png" /> Clear I/O</button>
|
||||
<button type="button" class="btn btn-default btn-sm" id="reset-layout"><img src="images/layout-16x16.png" /> Reset layout</button>
|
||||
|
@ -116,9 +114,7 @@
|
|||
<div id="output" class="split">
|
||||
<div class="title no-select">
|
||||
Output
|
||||
<div class="loading-icon"
|
||||
style="display: none">
|
||||
</div>
|
||||
<div class="loading-icon" style="display: none"></div>
|
||||
<div class="btn-group io-btn-group">
|
||||
<button type="button" class="btn btn-default btn-sm" id="save-to-file" title="Save to file"><img src="images/save_as-16x16.png" /> Save to file</button>
|
||||
<button type="button" class="btn btn-default btn-sm" id="switch" title="Move output to input"><img src="images/switch-16x16.png" /> Move output to input</button>
|
||||
|
|
|
@ -3135,7 +3135,7 @@ var OperationConfig = {
|
|||
]
|
||||
},
|
||||
"Wait": {
|
||||
description: "Waits for a number of milliseconds.",
|
||||
description: "Sleeps for a number of milliseconds.",
|
||||
run: FlowControl.runWait,
|
||||
inputType: "string",
|
||||
outputType: "string",
|
||||
|
|
|
@ -79,7 +79,6 @@ Chef.prototype.bake = function(inputText, recipeConfig, options, progress, step)
|
|||
chef.dish.get(Dish.HTML) :
|
||||
chef.dish.get(Dish.STRING);
|
||||
ret.type = Dish.enumLookup(chef.dish.type);
|
||||
|
||||
ret.duration = new Date().getTime() - startTime;
|
||||
ret.progress = progress;
|
||||
|
||||
|
@ -90,7 +89,6 @@ Chef.prototype.bake = function(inputText, recipeConfig, options, progress, step)
|
|||
chef.dish.get(Dish.HTML) :
|
||||
chef.dish.get(Dish.STRING);
|
||||
ret.type = Dish.enumLookup(chef.dish.type);
|
||||
|
||||
ret.duration = new Date().getTime() - startTime;
|
||||
ret.progress = err.progress;
|
||||
ret.error = err;
|
||||
|
|
|
@ -24,13 +24,11 @@ var HTMLApp = function(categories, operations, defaultFavourites, defaultOptions
|
|||
this.chef = new Chef();
|
||||
this.manager = new Manager(this);
|
||||
|
||||
this.baking = false;
|
||||
this.autoBake_ = false;
|
||||
this.progress = 0;
|
||||
this.ingId = 0;
|
||||
|
||||
this.baking = false;
|
||||
this.rebake = false;
|
||||
|
||||
window.chef = this.chef;
|
||||
};
|
||||
|
||||
|
@ -70,11 +68,12 @@ HTMLApp.prototype.handleError = function(err) {
|
|||
* @param {bakingStatus}
|
||||
*/
|
||||
HTMLApp.prototype.setBakingStatus = function(bakingStatus) {
|
||||
var inputLoadingIcon = document.querySelector("#input .title .loading-icon");
|
||||
var outputLoadingIcon = document.querySelector("#output .title .loading-icon");
|
||||
this.baking = bakingStatus;
|
||||
|
||||
var inputElement = document.querySelector("#input-text");
|
||||
var outputElement = document.querySelector("#output-text");
|
||||
var inputLoadingIcon = document.querySelector("#input .title .loading-icon"),
|
||||
outputLoadingIcon = document.querySelector("#output .title .loading-icon"),
|
||||
inputElement = document.querySelector("#input-text"),
|
||||
outputElement = document.querySelector("#output-text");
|
||||
|
||||
if (bakingStatus) {
|
||||
inputLoadingIcon.style.display = "inline-block";
|
||||
|
@ -97,27 +96,13 @@ HTMLApp.prototype.setBakingStatus = function(bakingStatus) {
|
|||
/**
|
||||
* Calls the Chef to bake the current input using the current recipe.
|
||||
*
|
||||
* @param {boolean} [step] - Set to true if we should only execute one operation instead of the
|
||||
* whole recipe.
|
||||
* @param {boolean} [step] - Set to true if we should only execute one operation instead of the whole recipe.
|
||||
*/
|
||||
HTMLApp.prototype.bake = function(step) {
|
||||
var app = this;
|
||||
|
||||
if (app.baking) {
|
||||
if (!app.rebake) {
|
||||
// We do not want to keep autobaking
|
||||
// Say that we will rebake and then try again later
|
||||
app.rebake = true;
|
||||
setTimeout(function() {
|
||||
app.bake(step);
|
||||
}, 500);
|
||||
}
|
||||
if (app.baking) return;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
app.rebake = false;
|
||||
app.baking = true;
|
||||
app.setBakingStatus(true);
|
||||
|
||||
try {
|
||||
|
@ -129,15 +114,10 @@ HTMLApp.prototype.bake = function(step) {
|
|||
step // Whether or not to take one step or execute the whole recipe
|
||||
)
|
||||
.then(function(response) {
|
||||
app.baking = false;
|
||||
app.setBakingStatus(false);
|
||||
|
||||
if (!response) {
|
||||
return;
|
||||
}
|
||||
if (response.error) {
|
||||
app.handleError(response.error);
|
||||
}
|
||||
if (!response) return;
|
||||
if (response.error) app.handleError(response.error);
|
||||
|
||||
app.options = response.options;
|
||||
|
||||
|
@ -159,10 +139,9 @@ HTMLApp.prototype.bake = function(step) {
|
|||
}
|
||||
})
|
||||
.catch(function(err) {
|
||||
console.error("Chef's promise was rejected, should never occur");
|
||||
console.error("Chef's promise was rejected, this should never occur");
|
||||
});
|
||||
} catch (err) {
|
||||
app.baking = false;
|
||||
app.setBakingStatus(false);
|
||||
app.handleError(err);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue