mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-25 01:06:16 -04:00
Add getDishTitle function
This commit is contained in:
parent
f497dc3170
commit
6ee76e3bf0
5 changed files with 102 additions and 3 deletions
|
@ -442,7 +442,6 @@ class OutputWaiter {
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves the dish as an ArrayBuffer, returning the cached version if possible.
|
||||
*
|
||||
|
@ -457,6 +456,21 @@ class OutputWaiter {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the title of the Dish as a string
|
||||
*
|
||||
* @param {Dish} dish
|
||||
* @param {number} maxLength
|
||||
* @returns {string}
|
||||
*/
|
||||
async getDishTitle(dish, maxLength) {
|
||||
return await new Promise(resolve => {
|
||||
this.manager.worker.getDishTitle(dish, maxLength, r=> {
|
||||
resolve(r.value);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Save bombe object then remove it from the DOM so that it does not cause performance issues.
|
||||
*/
|
||||
|
@ -970,10 +984,9 @@ class OutputWaiter {
|
|||
let tabStr = "";
|
||||
|
||||
if (dish !== null) {
|
||||
tabStr = await this.getDishStr(this.getOutputDish(inputNum));
|
||||
tabStr = await this.getDishTitle(this.getOutputDish(inputNum), 100);
|
||||
tabStr = tabStr.replace(/[\n\r]/g, "");
|
||||
}
|
||||
tabStr = tabStr.slice(0, 200);
|
||||
this.manager.tabs.updateOutputTabHeader(inputNum, tabStr);
|
||||
if (this.manager.worker.recipeConfig !== undefined) {
|
||||
this.manager.tabs.updateOutputTabProgress(inputNum, this.outputs[inputNum].progress, this.manager.worker.recipeConfig.length);
|
||||
|
|
|
@ -631,6 +631,31 @@ class WorkerWaiter {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Asks the ChefWorker to get the title of the dish
|
||||
*
|
||||
* @param {Dish} dish
|
||||
* @param {number} maxLength
|
||||
* @param {Function} callback
|
||||
* @returns {string}
|
||||
*/
|
||||
getDishTitle(dish, maxLength, callback) {
|
||||
const id = this.callbackID++;
|
||||
|
||||
this.callbacks[id] = callback;
|
||||
|
||||
if (this.dishWorker === null) this.setupDishWorker();
|
||||
|
||||
this.dishWorker.postMessage({
|
||||
action: "getDishTitle",
|
||||
data: {
|
||||
dish: dish,
|
||||
maxLength: maxLength,
|
||||
id: id
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the console log level in the workers.
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue