mirror of
https://github.com/gchq/CyberChef
synced 2025-12-10 05:13:23 +00:00
Highlighting now works with the web worker
This commit is contained in:
@@ -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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user