mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-20 06:55:08 -04:00
Highlighting now works with the web worker
This commit is contained in:
parent
8c960f0661
commit
13f07abb8a
10 changed files with 200 additions and 95 deletions
|
@ -53,6 +53,13 @@ self.addEventListener("message", function(e) {
|
|||
// imported into an inline worker.
|
||||
self.docURL = e.data.data;
|
||||
break;
|
||||
case "highlight":
|
||||
calculateHighlights(
|
||||
e.data.data.recipeConfig,
|
||||
e.data.data.direction,
|
||||
e.data.data.pos
|
||||
);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -121,6 +128,25 @@ function loadRequiredModules(recipeConfig) {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Calculates highlight offsets if possible.
|
||||
*
|
||||
* @param {Object[]} recipeConfig
|
||||
* @param {string} direction
|
||||
* @param {Object} pos - The position object for the highlight.
|
||||
* @param {number} pos.start - The start offset.
|
||||
* @param {number} pos.end - The end offset.
|
||||
*/
|
||||
function calculateHighlights(recipeConfig, direction, pos) {
|
||||
pos = self.chef.calculateHighlights(recipeConfig, direction, pos);
|
||||
|
||||
self.postMessage({
|
||||
action: "highlightsCalculated",
|
||||
data: pos
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Send status update to the app.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue