Class: HTMLApp

HTMLApp


new HTMLApp(categories, operations, default_favourites, options)

HTML view for CyberChef responsible for building the web page and dealing with all user
interactions.

Parameters:
Name Type Description
categories Array.<CatConf>

The list of categories and operations to be populated.

operations Object.<string, OpConf>

The list of operation configuration objects.

default_favourites Array.<String>

A list of default favourite operations.

options Object

Default setting for app options.

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

Methods


setup()

This function sets up the stage and creates listeners for all events.

Source:
Fires:

handle_error(err)

An error handler for displaying the error to the user.

Parameters:
Name Type Description
err Error
Source:

bake( [step])

Calls the Chef to bake the current input using the current recipe.

Parameters:
Name Type Argument Description
step boolean <optional>

Set to true if we should only execute one operation instead of the
whole recipe.

Source:

auto_bake()

Runs Auto Bake if it is set.

Source:

silent_bake()

Runs a silent bake forcing the browser to load and cache all the relevant JavaScript code needed
to do a real bake.

The output will not be modified (hence "silent" bake). This will only actually execute the
recipe if auto-bake is enabled, otherwise it will just load the recipe, ingredients and dish.

Source:
Returns:
  • The number of miliseconds it took to run the silent bake.
Type
number

get_input()

Gets the user's input data.

Source:
Returns:
Type
string

set_input(input)

Sets the user's input data.

Parameters:
Name Type Description
input string

The string to set the input to

Source:

populate_operations_list()

Populates the operations accordion list with the categories and operations specified in the
view constructor.

Source:
Fires:

initialise_splitter()

Sets up the adjustable splitter to allow the user to resize areas of the page.

Source:

load_local_storage()

Loads the information previously saved to the HTML5 local storage object so that user options
and favourites can be restored.

Source:

load_favourites()

Loads the user's favourite operations from the HTML5 local storage object and populates the
Favourites category with them.
If the user currently has no saved favourites, the defaults from the view constructor are used.

Source:

valid_favourites(favourites)

Filters the list of favourite operations that the user had stored and removes any that are no
longer available. The user is notified if this is the case.

Parameters:
Name Type Description
favourites Array.<string>

A list of the user's favourite operations

Source:
Returns:

A list of the valid favourites

Type
Array.<string>

save_favourites(favourites)

Saves a list of favourite operations to the HTML5 local storage object.

Parameters:
Name Type Description
favourites Array.<string>

A list of the user's favourite operations

Source:

reset_favourites()

Resets favourite operations back to the default as specified in the view constructor and
refreshes the operation list.

Source:

add_favourite(name)

Adds an operation to the user's favourites.

Parameters:
Name Type Description
name string

The name of the operation

Source:

load_URI_params()

Checks for input and recipe in the URI parameters and loads them if present.

Source:

next_ing_id()

Returns the next ingredient ID and increments it for next time.

Source:
Returns:
Type
number

get_recipe_config()

Gets the current recipe configuration.

Source:
Returns:
Type
Array.<Object>

set_recipe_config(recipe_config)

Given a recipe configuration, sets the recipe to that configuration.

Parameters:
Name Type Description
recipe_config Array.<Object>

The recipe configuration

Source:

reset_layout()

Resets the splitter positions to default.

Source:

set_compile_message()

Sets the compile message.

Source:

alert(str, style, timeout [, silent])

Pops up a message to the user and writes it to the console log.

Parameters:
Name Type Argument Default Description
str string

The message to display (HTML supported)

style string

The colour of the popup
"danger" = red
"warning" = amber
"info" = blue
"success" = green

timeout number

The number of milliseconds before the popup closes automatically
0 for never (until the user closes it)

silent boolean <optional>
false

Don't show the message in the popup, only print it to the
console

Source:
Example
// Pops up a red box with the message "[current time] Error: Something has gone wrong!"
// that will need to be dismissed by the user.
this.alert("Error: Something has gone wrong!", "danger", 0);

// Pops up a blue information box with the message "[current time] Happy Christmas!"
// that will disappear after 5 seconds.
this.alert("Happy Christmas!", "info", 5000);

confirm(title, body, callback [, scope])

Pops up a box asking the user a question and sending the answer to a specified callback function.

Parameters:
Name Type Argument Default Description
title string

The title of the box

body string

The question (HTML supported)

callback function

A function accepting one boolean argument which handles the
response e.g. function(answer) {...}

scope Object <optional>
this

The object to bind to the callback function

Source:
Example
// Pops up a box asking if the user would like a cookie. Prints the answer to the console.
this.confirm("Question", "Would you like a cookie?", function(answer) {console.log(answer);});

alert_close_click()

Handler for the alert close button click event.
Closes the alert box.

Source:

state_change(e)

Handler for CyerChef statechange events.
Fires whenever the input or recipe changes in any way.

Parameters:
Name Type Description
e event
Source:
Listens to Events:

pop_state(e)

Handler for the history popstate event.
Reloads parameters from the URL.

Parameters:
Name Type Description
e event
Source:

call_api()

Function to call an external API from this view.

Source: