Class: HighlighterWaiter

HighlighterWaiter


new HighlighterWaiter(app)

Waiter to handle events related to highlighting in CyberChef.

Parameters:
Name Type Description
app HTMLApp

The main view object for CyberChef.

Author:
  • <p>n1474335 [n1474335@gmail.com]</p>
License:
  • Apache-2.0
Source:

Members


<static, readonly> INPUT

HighlighterWaiter data type enum for the input.

Source:

<static, readonly> OUTPUT

HighlighterWaiter data type enum for the output.

Source:

Methods


<private> _is_selection_backwards()

Determines if the current text selection is running backwards or forwards.
StackOverflow answer id: 12652116

Source:
Returns:
Type
boolean

<private> _get_output_html_offset(node, offset)

Calculates the text offset of a position in an HTML element, ignoring HTML tags.

Parameters:
Name Type Description
node element

The parent HTML node.

offset number

The offset since the last HTML element.

Source:
Returns:
Type
number

<private> _get_output_html_selection_offsets()

Gets the current selection offsets in the output HTML, ignoring HTML tags.

Source:
Returns:
  • pos

    Type
    Object
  • pos.start

    Type
    number
  • pos.end

    Type
    number

input_scroll(e)

Handler for input scroll events.
Scrolls the highlighter pane to match the input textarea position.

Parameters:
Name Type Description
e event
Source:

output_scroll(e)

Handler for output scroll events.
Scrolls the highlighter pane to match the output textarea position.

Parameters:
Name Type Description
e event
Source:

input_mousedown(e)

Handler for input mousedown events.
Calculates the current selection info, and highlights the corresponding data in the output.

Parameters:
Name Type Description
e event
Source:

output_mousedown(e)

Handler for output mousedown events.
Calculates the current selection info, and highlights the corresponding data in the input.

Parameters:
Name Type Description
e event
Source:

output_html_mousedown(e)

Handler for output HTML mousedown events.
Calculates the current selection info.

Parameters:
Name Type Description
e event
Source:

input_mouseup(e)

Handler for input mouseup events.

Parameters:
Name Type Description
e event
Source:

output_mouseup(e)

Handler for output mouseup events.

Parameters:
Name Type Description
e event
Source:

output_html_mouseup(e)

Handler for output HTML mouseup events.

Parameters:
Name Type Description
e event
Source:

input_mousemove(e)

Handler for input mousemove events.
Calculates the current selection info, and highlights the corresponding data in the output.

Parameters:
Name Type Description
e event
Source:

output_mousemove(e)

Handler for output mousemove events.
Calculates the current selection info, and highlights the corresponding data in the input.

Parameters:
Name Type Description
e event
Source:

output_html_mousemove(e)

Handler for output HTML mousemove events.
Calculates the current selection info.

Parameters:
Name Type Description
e event
Source:

selection_info(start, end)

Given start and end offsets, writes the HTML for the selection info element with the correct
padding.

Parameters:
Name Type Description
start number

The start offset.

end number

The end offset.

Source:
Returns:
Type
string

remove_highlights()

Removes highlighting and selection information.

Source:

generate_highlight_list()

Generates a list of all the highlight functions assigned to operations in the recipe, if the
entire recipe supports highlighting.

Source:
Returns:
  • highlights

    Type
    Array.<Object>
  • highlights[].f

    Type
    function
  • highlights[].b

    Type
    function
  • highlights[].args

    Type
    Array.<Object>

highlight_output(pos)

Highlights the given offsets in the output.
We will only highlight if:

- input hasn't changed since last bake
- last bake was a full bake
- all operations in the recipe support highlighting
Parameters:
Name Type Description
pos Object

The position object for the highlight.

Properties
Name Type Description
start number

The start offset.

end number

The end offset.

Source:

highlight_input(pos)

Highlights the given offsets in the input.
We will only highlight if:

- input hasn't changed since last bake
- last bake was a full bake
- all operations in the recipe support highlighting
Parameters:
Name Type Description
pos Object

The position object for the highlight.

Properties
Name Type Description
start number

The start offset.

end number

The end offset.

Source:

highlight(textarea, highlighter, pos)

Adds the relevant HTML to the specified highlight element such that highlighting appears
underneath the correct offset.

Parameters:
Name Type Description
textarea element

The input or output textarea.

highlighter element

The input or output highlighter element.

pos Object

The position object for the highlight.

Properties
Name Type Description
start number

The start offset.

end number

The end offset.

Source: