mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-23 00:06:17 -04:00
Variable names changed from underscore to CamelCase. Eslint rules updated. #64
This commit is contained in:
parent
f8193797fa
commit
e3c977934b
66 changed files with 3176 additions and 3172 deletions
|
@ -19,15 +19,15 @@ var ControlsWaiter = function(app, manager) {
|
|||
* Adjusts the display properties of the control buttons so that they fit within the current width
|
||||
* without wrapping or overflowing.
|
||||
*/
|
||||
ControlsWaiter.prototype.adjust_width = function() {
|
||||
var controls = document.getElementById("controls"),
|
||||
step = document.getElementById("step"),
|
||||
clr_breaks = document.getElementById("clr-breaks"),
|
||||
save_img = document.querySelector("#save img"),
|
||||
load_img = document.querySelector("#load img"),
|
||||
step_img = document.querySelector("#step img"),
|
||||
clr_recip_img = document.querySelector("#clr-recipe img"),
|
||||
clr_breaks_img = document.querySelector("#clr-breaks img");
|
||||
ControlsWaiter.prototype.adjustWidth = function() {
|
||||
var controls = document.getElementById("controls"),
|
||||
step = document.getElementById("step"),
|
||||
clrBreaks = document.getElementById("clr-breaks"),
|
||||
saveImg = document.querySelector("#save img"),
|
||||
loadImg = document.querySelector("#load img"),
|
||||
stepImg = document.querySelector("#step img"),
|
||||
clrRecipImg = document.querySelector("#clr-recipe img"),
|
||||
clrBreaksImg = document.querySelector("#clr-breaks img");
|
||||
|
||||
if (controls.clientWidth < 470) {
|
||||
step.childNodes[1].nodeValue = " Step";
|
||||
|
@ -36,23 +36,23 @@ ControlsWaiter.prototype.adjust_width = function() {
|
|||
}
|
||||
|
||||
if (controls.clientWidth < 400) {
|
||||
save_img.style.display = "none";
|
||||
load_img.style.display = "none";
|
||||
step_img.style.display = "none";
|
||||
clr_recip_img.style.display = "none";
|
||||
clr_breaks_img.style.display = "none";
|
||||
saveImg.style.display = "none";
|
||||
loadImg.style.display = "none";
|
||||
stepImg.style.display = "none";
|
||||
clrRecipImg.style.display = "none";
|
||||
clrBreaksImg.style.display = "none";
|
||||
} else {
|
||||
save_img.style.display = "inline";
|
||||
load_img.style.display = "inline";
|
||||
step_img.style.display = "inline";
|
||||
clr_recip_img.style.display = "inline";
|
||||
clr_breaks_img.style.display = "inline";
|
||||
saveImg.style.display = "inline";
|
||||
loadImg.style.display = "inline";
|
||||
stepImg.style.display = "inline";
|
||||
clrRecipImg.style.display = "inline";
|
||||
clrBreaksImg.style.display = "inline";
|
||||
}
|
||||
|
||||
if (controls.clientWidth < 330) {
|
||||
clr_breaks.childNodes[1].nodeValue = " Clear breaks";
|
||||
clrBreaks.childNodes[1].nodeValue = " Clear breaks";
|
||||
} else {
|
||||
clr_breaks.childNodes[1].nodeValue = " Clear breakpoints";
|
||||
clrBreaks.childNodes[1].nodeValue = " Clear breakpoints";
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -62,11 +62,11 @@ ControlsWaiter.prototype.adjust_width = function() {
|
|||
*
|
||||
* @param {boolean} value - The new value for Auto Bake.
|
||||
*/
|
||||
ControlsWaiter.prototype.set_auto_bake = function(value) {
|
||||
var auto_bake_checkbox = document.getElementById("auto-bake");
|
||||
ControlsWaiter.prototype.setAutoBake = function(value) {
|
||||
var autoBakeCheckbox = document.getElementById("auto-bake");
|
||||
|
||||
if (auto_bake_checkbox.checked !== value) {
|
||||
auto_bake_checkbox.click();
|
||||
if (autoBakeCheckbox.checked !== value) {
|
||||
autoBakeCheckbox.click();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -74,7 +74,7 @@ ControlsWaiter.prototype.set_auto_bake = function(value) {
|
|||
/**
|
||||
* Handler to trigger baking.
|
||||
*/
|
||||
ControlsWaiter.prototype.bake_click = function() {
|
||||
ControlsWaiter.prototype.bakeClick = function() {
|
||||
this.app.bake();
|
||||
$("#output-text").selectRange(0);
|
||||
};
|
||||
|
@ -83,7 +83,7 @@ ControlsWaiter.prototype.bake_click = function() {
|
|||
/**
|
||||
* Handler for the 'Step through' command. Executes the next step of the recipe.
|
||||
*/
|
||||
ControlsWaiter.prototype.step_click = function() {
|
||||
ControlsWaiter.prototype.stepClick = function() {
|
||||
this.app.bake(true);
|
||||
$("#output-text").selectRange(0);
|
||||
};
|
||||
|
@ -92,18 +92,18 @@ ControlsWaiter.prototype.step_click = function() {
|
|||
/**
|
||||
* Handler for changes made to the Auto Bake checkbox.
|
||||
*/
|
||||
ControlsWaiter.prototype.auto_bake_change = function() {
|
||||
var auto_bake_label = document.getElementById("auto-bake-label"),
|
||||
auto_bake_checkbox = document.getElementById("auto-bake");
|
||||
ControlsWaiter.prototype.autoBakeChange = function() {
|
||||
var autoBakeLabel = document.getElementById("auto-bake-label"),
|
||||
autoBakeCheckbox = document.getElementById("auto-bake");
|
||||
|
||||
this.app.auto_bake_ = auto_bake_checkbox.checked;
|
||||
this.app.autoBake_ = autoBakeCheckbox.checked;
|
||||
|
||||
if (auto_bake_checkbox.checked) {
|
||||
auto_bake_label.classList.remove("btn-default");
|
||||
auto_bake_label.classList.add("btn-success");
|
||||
if (autoBakeCheckbox.checked) {
|
||||
autoBakeLabel.classList.remove("btn-default");
|
||||
autoBakeLabel.classList.add("btn-success");
|
||||
} else {
|
||||
auto_bake_label.classList.remove("btn-success");
|
||||
auto_bake_label.classList.add("btn-default");
|
||||
autoBakeLabel.classList.remove("btn-success");
|
||||
autoBakeLabel.classList.add("btn-default");
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -111,8 +111,8 @@ ControlsWaiter.prototype.auto_bake_change = function() {
|
|||
/**
|
||||
* Handler for the 'Clear recipe' command. Removes all operations from the recipe.
|
||||
*/
|
||||
ControlsWaiter.prototype.clear_recipe_click = function() {
|
||||
this.manager.recipe.clear_recipe();
|
||||
ControlsWaiter.prototype.clearRecipeClick = function() {
|
||||
this.manager.recipe.clearRecipe();
|
||||
};
|
||||
|
||||
|
||||
|
@ -120,8 +120,8 @@ ControlsWaiter.prototype.clear_recipe_click = function() {
|
|||
* Handler for the 'Clear breakpoints' command. Removes all breakpoints from operations in the
|
||||
* recipe.
|
||||
*/
|
||||
ControlsWaiter.prototype.clear_breaks_click = function() {
|
||||
var bps = document.querySelectorAll("#rec_list li.operation .breakpoint");
|
||||
ControlsWaiter.prototype.clearBreaksClick = function() {
|
||||
var bps = document.querySelectorAll("#rec-list li.operation .breakpoint");
|
||||
|
||||
for (var i = 0; i < bps.length; i++) {
|
||||
bps[i].setAttribute("break", "false");
|
||||
|
@ -133,49 +133,49 @@ ControlsWaiter.prototype.clear_breaks_click = function() {
|
|||
/**
|
||||
* Populates the save disalog box with a URL incorporating the recipe and input.
|
||||
*
|
||||
* @param {Object[]} [recipe_config] - The recipe configuration object array.
|
||||
* @param {Object[]} [recipeConfig] - The recipe configuration object array.
|
||||
*/
|
||||
ControlsWaiter.prototype.initialise_save_link = function(recipe_config) {
|
||||
recipe_config = recipe_config || this.app.get_recipe_config();
|
||||
ControlsWaiter.prototype.initialiseSaveLink = function(recipeConfig) {
|
||||
recipeConfig = recipeConfig || this.app.getRecipeConfig();
|
||||
|
||||
var include_recipe = document.getElementById("save-link-recipe-checkbox").checked,
|
||||
include_input = document.getElementById("save-link-input-checkbox").checked,
|
||||
save_link_el = document.getElementById("save-link"),
|
||||
save_link = this.generate_state_url(include_recipe, include_input, recipe_config);
|
||||
var includeRecipe = document.getElementById("save-link-recipe-checkbox").checked,
|
||||
includeInput = document.getElementById("save-link-input-checkbox").checked,
|
||||
saveLinkEl = document.getElementById("save-link"),
|
||||
saveLink = this.generateStateUrl(includeRecipe, includeInput, recipeConfig);
|
||||
|
||||
save_link_el.innerHTML = Utils.truncate(save_link, 120);
|
||||
save_link_el.setAttribute("href", save_link);
|
||||
saveLinkEl.innerHTML = Utils.truncate(saveLink, 120);
|
||||
saveLinkEl.setAttribute("href", saveLink);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Generates a URL containing the current recipe and input state.
|
||||
*
|
||||
* @param {boolean} include_recipe - Whether to include the recipe in the URL.
|
||||
* @param {boolean} include_input - Whether to include the input in the URL.
|
||||
* @param {Object[]} [recipe_config] - The recipe configuration object array.
|
||||
* @param {boolean} includeRecipe - Whether to include the recipe in the URL.
|
||||
* @param {boolean} includeInput - Whether to include the input in the URL.
|
||||
* @param {Object[]} [recipeConfig] - The recipe configuration object array.
|
||||
* @returns {string}
|
||||
*/
|
||||
ControlsWaiter.prototype.generate_state_url = function(include_recipe, include_input, recipe_config) {
|
||||
recipe_config = recipe_config || this.app.get_recipe_config();
|
||||
ControlsWaiter.prototype.generateStateUrl = function(includeRecipe, includeInput, recipeConfig) {
|
||||
recipeConfig = recipeConfig || this.app.getRecipeConfig();
|
||||
|
||||
var link = window.location.protocol + "//" +
|
||||
window.location.host +
|
||||
window.location.pathname,
|
||||
recipe_str = JSON.stringify(recipe_config),
|
||||
input_str = Utils.to_base64(this.app.get_input(), "A-Za-z0-9+/"); // B64 alphabet with no padding
|
||||
recipeStr = JSON.stringify(recipeConfig),
|
||||
inputStr = Utils.toBase64(this.app.getInput(), "A-Za-z0-9+/"); // B64 alphabet with no padding
|
||||
|
||||
include_recipe = include_recipe && (recipe_config.length > 0);
|
||||
include_input = include_input && (input_str.length > 0) && (input_str.length < 8000);
|
||||
includeRecipe = includeRecipe && (recipeConfig.length > 0);
|
||||
includeInput = includeInput && (inputStr.length > 0) && (inputStr.length < 8000);
|
||||
|
||||
if (include_recipe) {
|
||||
link += "?recipe=" + encodeURIComponent(recipe_str);
|
||||
if (includeRecipe) {
|
||||
link += "?recipe=" + encodeURIComponent(recipeStr);
|
||||
}
|
||||
|
||||
if (include_recipe && include_input) {
|
||||
link += "&input=" + encodeURIComponent(input_str);
|
||||
} else if (include_input) {
|
||||
link += "?input=" + encodeURIComponent(input_str);
|
||||
if (includeRecipe && includeInput) {
|
||||
link += "&input=" + encodeURIComponent(inputStr);
|
||||
} else if (includeInput) {
|
||||
link += "?input=" + encodeURIComponent(inputStr);
|
||||
}
|
||||
|
||||
return link;
|
||||
|
@ -185,10 +185,10 @@ ControlsWaiter.prototype.generate_state_url = function(include_recipe, include_i
|
|||
/**
|
||||
* Handler for changes made to the save dialog text area. Re-initialises the save link.
|
||||
*/
|
||||
ControlsWaiter.prototype.save_text_change = function() {
|
||||
ControlsWaiter.prototype.saveTextChange = function() {
|
||||
try {
|
||||
var recipe_config = JSON.parse(document.getElementById("save-text").value);
|
||||
this.initialise_save_link(recipe_config);
|
||||
var recipeConfig = JSON.parse(document.getElementById("save-text").value);
|
||||
this.initialiseSaveLink(recipeConfig);
|
||||
} catch(err) {}
|
||||
};
|
||||
|
||||
|
@ -196,12 +196,13 @@ ControlsWaiter.prototype.save_text_change = function() {
|
|||
/**
|
||||
* Handler for the 'Save' command. Pops up the save dialog box.
|
||||
*/
|
||||
ControlsWaiter.prototype.save_click = function() {
|
||||
var recipe_config = this.app.get_recipe_config();
|
||||
var recipe_str = JSON.stringify(recipe_config).replace(/},{/g, "},\n{");
|
||||
document.getElementById("save-text").value = recipe_str;
|
||||
ControlsWaiter.prototype.saveClick = function() {
|
||||
var recipeConfig = this.app.getRecipeConfig(),
|
||||
recipeStr = JSON.stringify(recipeConfig).replace(/},{/g, "},\n{");
|
||||
|
||||
document.getElementById("save-text").value = recipeStr;
|
||||
|
||||
this.initialise_save_link(recipe_config);
|
||||
this.initialiseSaveLink(recipeConfig);
|
||||
$("#save-modal").modal();
|
||||
};
|
||||
|
||||
|
@ -209,24 +210,24 @@ ControlsWaiter.prototype.save_click = function() {
|
|||
/**
|
||||
* Handler for the save link recipe checkbox change event.
|
||||
*/
|
||||
ControlsWaiter.prototype.slr_check_change = function() {
|
||||
this.initialise_save_link();
|
||||
ControlsWaiter.prototype.slrCheckChange = function() {
|
||||
this.initialiseSaveLink();
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Handler for the save link input checkbox change event.
|
||||
*/
|
||||
ControlsWaiter.prototype.sli_check_change = function() {
|
||||
this.initialise_save_link();
|
||||
ControlsWaiter.prototype.sliCheckChange = function() {
|
||||
this.initialiseSaveLink();
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Handler for the 'Load' command. Pops up the load dialog box.
|
||||
*/
|
||||
ControlsWaiter.prototype.load_click = function() {
|
||||
this.populate_load_recipes_list();
|
||||
ControlsWaiter.prototype.loadClick = function() {
|
||||
this.populateLoadRecipesList();
|
||||
$("#load-modal").modal();
|
||||
};
|
||||
|
||||
|
@ -234,88 +235,88 @@ ControlsWaiter.prototype.load_click = function() {
|
|||
/**
|
||||
* Saves the recipe specified in the save textarea to local storage.
|
||||
*/
|
||||
ControlsWaiter.prototype.save_button_click = function() {
|
||||
var recipe_name = document.getElementById("save-name").value,
|
||||
recipe_str = document.getElementById("save-text").value;
|
||||
ControlsWaiter.prototype.saveButtonClick = function() {
|
||||
var recipeName = document.getElementById("save-name").value,
|
||||
recipeStr = document.getElementById("save-text").value;
|
||||
|
||||
if (!recipe_name) {
|
||||
if (!recipeName) {
|
||||
this.app.alert("Please enter a recipe name", "danger", 2000);
|
||||
return;
|
||||
}
|
||||
|
||||
var saved_recipes = localStorage.saved_recipes ?
|
||||
JSON.parse(localStorage.saved_recipes) : [],
|
||||
recipe_id = localStorage.recipe_id || 0;
|
||||
var savedRecipes = localStorage.savedRecipes ?
|
||||
JSON.parse(localStorage.savedRecipes) : [],
|
||||
recipeId = localStorage.recipeId || 0;
|
||||
|
||||
saved_recipes.push({
|
||||
id: ++recipe_id,
|
||||
name: recipe_name,
|
||||
recipe: recipe_str
|
||||
savedRecipes.push({
|
||||
id: ++recipeId,
|
||||
name: recipeName,
|
||||
recipe: recipeStr
|
||||
});
|
||||
|
||||
localStorage.saved_recipes = JSON.stringify(saved_recipes);
|
||||
localStorage.recipe_id = recipe_id;
|
||||
localStorage.savedRecipes = JSON.stringify(savedRecipes);
|
||||
localStorage.recipeId = recipeId;
|
||||
|
||||
this.app.alert("Recipe saved as \"" + recipe_name + "\".", "success", 2000);
|
||||
this.app.alert("Recipe saved as \"" + recipeName + "\".", "success", 2000);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Populates the list of saved recipes in the load dialog box from local storage.
|
||||
*/
|
||||
ControlsWaiter.prototype.populate_load_recipes_list = function() {
|
||||
var load_name_el = document.getElementById("load-name");
|
||||
ControlsWaiter.prototype.populateLoadRecipesList = function() {
|
||||
var loadNameEl = document.getElementById("load-name");
|
||||
|
||||
// Remove current recipes from select
|
||||
var i = load_name_el.options.length;
|
||||
var i = loadNameEl.options.length;
|
||||
while (i--) {
|
||||
load_name_el.remove(i);
|
||||
loadNameEl.remove(i);
|
||||
}
|
||||
|
||||
// Add recipes to select
|
||||
var saved_recipes = localStorage.saved_recipes ?
|
||||
JSON.parse(localStorage.saved_recipes) : [];
|
||||
var savedRecipes = localStorage.savedRecipes ?
|
||||
JSON.parse(localStorage.savedRecipes) : [];
|
||||
|
||||
for (i = 0; i < saved_recipes.length; i++) {
|
||||
for (i = 0; i < savedRecipes.length; i++) {
|
||||
var opt = document.createElement("option");
|
||||
opt.value = saved_recipes[i].id;
|
||||
opt.innerHTML = saved_recipes[i].name;
|
||||
opt.value = savedRecipes[i].id;
|
||||
opt.innerHTML = savedRecipes[i].name;
|
||||
|
||||
load_name_el.appendChild(opt);
|
||||
loadNameEl.appendChild(opt);
|
||||
}
|
||||
|
||||
// Populate textarea with first recipe
|
||||
document.getElementById("load-text").value = saved_recipes.length ? saved_recipes[0].recipe : "";
|
||||
document.getElementById("load-text").value = savedRecipes.length ? savedRecipes[0].recipe : "";
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Removes the currently selected recipe from local storage.
|
||||
*/
|
||||
ControlsWaiter.prototype.load_delete_click = function() {
|
||||
ControlsWaiter.prototype.loadDeleteClick = function() {
|
||||
var id = parseInt(document.getElementById("load-name").value, 10),
|
||||
saved_recipes = localStorage.saved_recipes ?
|
||||
JSON.parse(localStorage.saved_recipes) : [];
|
||||
savedRecipes = localStorage.savedRecipes ?
|
||||
JSON.parse(localStorage.savedRecipes) : [];
|
||||
|
||||
saved_recipes = saved_recipes.filter(function(r) {
|
||||
savedRecipes = savedRecipes.filter(function(r) {
|
||||
return r.id !== id;
|
||||
});
|
||||
|
||||
localStorage.saved_recipes = JSON.stringify(saved_recipes);
|
||||
this.populate_load_recipes_list();
|
||||
localStorage.savedRecipes = JSON.stringify(savedRecipes);
|
||||
this.populateLoadRecipesList();
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Displays the selected recipe in the load text box.
|
||||
*/
|
||||
ControlsWaiter.prototype.load_name_change = function(e) {
|
||||
ControlsWaiter.prototype.loadNameChange = function(e) {
|
||||
var el = e.target,
|
||||
saved_recipes = localStorage.saved_recipes ?
|
||||
JSON.parse(localStorage.saved_recipes) : [],
|
||||
savedRecipes = localStorage.savedRecipes ?
|
||||
JSON.parse(localStorage.savedRecipes) : [],
|
||||
id = parseInt(el.value, 10);
|
||||
|
||||
var recipe = saved_recipes.filter(function(r) {
|
||||
var recipe = savedRecipes.filter(function(r) {
|
||||
return r.id === id;
|
||||
})[0];
|
||||
|
||||
|
@ -326,12 +327,12 @@ ControlsWaiter.prototype.load_name_change = function(e) {
|
|||
/**
|
||||
* Loads the selected recipe and populates the Recipe with its operations.
|
||||
*/
|
||||
ControlsWaiter.prototype.load_button_click = function() {
|
||||
ControlsWaiter.prototype.loadButtonClick = function() {
|
||||
try {
|
||||
var recipe_config = JSON.parse(document.getElementById("load-text").value);
|
||||
this.app.set_recipe_config(recipe_config);
|
||||
var recipeConfig = JSON.parse(document.getElementById("load-text").value);
|
||||
this.app.setRecipeConfig(recipeConfig);
|
||||
|
||||
$("#rec_list [data-toggle=popover]").popover();
|
||||
$("#rec-list [data-toggle=popover]").popover();
|
||||
} catch(e) {
|
||||
this.app.alert("Invalid recipe", "danger", 2000);
|
||||
}
|
||||
|
|
|
@ -11,22 +11,22 @@
|
|||
* @constructor
|
||||
* @param {CatConf[]} categories - The list of categories and operations to be populated.
|
||||
* @param {Object.<string, OpConf>} operations - The list of operation configuration objects.
|
||||
* @param {String[]} default_favourites - A list of default favourite operations.
|
||||
* @param {String[]} defaultFavourites - A list of default favourite operations.
|
||||
* @param {Object} options - Default setting for app options.
|
||||
*/
|
||||
var HTMLApp = function(categories, operations, default_favourites, default_options) {
|
||||
var HTMLApp = function(categories, operations, defaultFavourites, defaultOptions) {
|
||||
this.categories = categories;
|
||||
this.operations = operations;
|
||||
this.dfavourites = default_favourites;
|
||||
this.doptions = default_options;
|
||||
this.options = Utils.extend({}, default_options);
|
||||
this.dfavourites = defaultFavourites;
|
||||
this.doptions = defaultOptions;
|
||||
this.options = Utils.extend({}, defaultOptions);
|
||||
|
||||
this.chef = new Chef();
|
||||
this.manager = new Manager(this);
|
||||
|
||||
this.auto_bake_ = false;
|
||||
this.autoBake_ = false;
|
||||
this.progress = 0;
|
||||
this.ing_id = 0;
|
||||
this.ingId = 0;
|
||||
|
||||
window.chef = this.chef;
|
||||
};
|
||||
|
@ -39,13 +39,13 @@ var HTMLApp = function(categories, operations, default_favourites, default_optio
|
|||
*/
|
||||
HTMLApp.prototype.setup = function() {
|
||||
document.dispatchEvent(this.manager.appstart);
|
||||
this.initialise_splitter();
|
||||
this.load_local_storage();
|
||||
this.populate_operations_list();
|
||||
this.initialiseSplitter();
|
||||
this.loadLocalStorage();
|
||||
this.populateOperationsList();
|
||||
this.manager.setup();
|
||||
this.reset_layout();
|
||||
this.set_compile_message();
|
||||
this.load_URI_params();
|
||||
this.resetLayout();
|
||||
this.setCompileMessage();
|
||||
this.loadURIParams();
|
||||
};
|
||||
|
||||
|
||||
|
@ -54,10 +54,10 @@ HTMLApp.prototype.setup = function() {
|
|||
*
|
||||
* @param {Error} err
|
||||
*/
|
||||
HTMLApp.prototype.handle_error = function(err) {
|
||||
HTMLApp.prototype.handleError = function(err) {
|
||||
console.error(err);
|
||||
var msg = err.display_str || err.toString();
|
||||
this.alert(msg, "danger", this.options.error_timeout, !this.options.show_errors);
|
||||
var msg = err.displayStr || err.toString();
|
||||
this.alert(msg, "danger", this.options.errorTimeout, !this.options.showErrors);
|
||||
};
|
||||
|
||||
|
||||
|
@ -72,32 +72,32 @@ HTMLApp.prototype.bake = function(step) {
|
|||
|
||||
try {
|
||||
response = this.chef.bake(
|
||||
this.get_input(), // The user's input
|
||||
this.get_recipe_config(), // The configuration of the recipe
|
||||
this.getInput(), // The user's input
|
||||
this.getRecipeConfig(), // The configuration of the recipe
|
||||
this.options, // Options set by the user
|
||||
this.progress, // The current position in the recipe
|
||||
step // Whether or not to take one step or execute the whole recipe
|
||||
);
|
||||
} catch (err) {
|
||||
this.handle_error(err);
|
||||
this.handleError(err);
|
||||
}
|
||||
|
||||
if (!response) return;
|
||||
|
||||
if (response.error) {
|
||||
this.handle_error(response.error);
|
||||
this.handleError(response.error);
|
||||
}
|
||||
|
||||
this.options = response.options;
|
||||
this.dish_str = response.type === "html" ? Utils.strip_html_tags(response.result, true) : response.result;
|
||||
this.dishStr = response.type === "html" ? Utils.stripHtmlTags(response.result, true) : response.result;
|
||||
this.progress = response.progress;
|
||||
this.manager.recipe.update_breakpoint_indicator(response.progress);
|
||||
this.manager.recipe.updateBreakpointIndicator(response.progress);
|
||||
this.manager.output.set(response.result, response.type, response.duration);
|
||||
|
||||
// If baking took too long, disable auto-bake
|
||||
if (response.duration > this.options.auto_bake_threshold && this.auto_bake_) {
|
||||
this.manager.controls.set_auto_bake(false);
|
||||
this.alert("Baking took longer than " + this.options.auto_bake_threshold +
|
||||
if (response.duration > this.options.autoBakeThreshold && this.autoBake_) {
|
||||
this.manager.controls.setAutoBake(false);
|
||||
this.alert("Baking took longer than " + this.options.autoBakeThreshold +
|
||||
"ms, Auto Bake has been disabled.", "warning", 5000);
|
||||
}
|
||||
};
|
||||
|
@ -106,8 +106,8 @@ HTMLApp.prototype.bake = function(step) {
|
|||
/**
|
||||
* Runs Auto Bake if it is set.
|
||||
*/
|
||||
HTMLApp.prototype.auto_bake = function() {
|
||||
if (this.auto_bake_) {
|
||||
HTMLApp.prototype.autoBake = function() {
|
||||
if (this.autoBake_) {
|
||||
this.bake();
|
||||
}
|
||||
};
|
||||
|
@ -122,15 +122,15 @@ HTMLApp.prototype.auto_bake = function() {
|
|||
*
|
||||
* @returns {number} - The number of miliseconds it took to run the silent bake.
|
||||
*/
|
||||
HTMLApp.prototype.silent_bake = function() {
|
||||
var start_time = new Date().getTime(),
|
||||
recipe_config = this.get_recipe_config();
|
||||
HTMLApp.prototype.silentBake = function() {
|
||||
var startTime = new Date().getTime(),
|
||||
recipeConfig = this.getRecipeConfig();
|
||||
|
||||
if (this.auto_bake_) {
|
||||
this.chef.silent_bake(recipe_config);
|
||||
if (this.autoBake_) {
|
||||
this.chef.silentBake(recipeConfig);
|
||||
}
|
||||
|
||||
return new Date().getTime() - start_time;
|
||||
return new Date().getTime() - startTime;
|
||||
};
|
||||
|
||||
|
||||
|
@ -139,11 +139,11 @@ HTMLApp.prototype.silent_bake = function() {
|
|||
*
|
||||
* @returns {string}
|
||||
*/
|
||||
HTMLApp.prototype.get_input = function() {
|
||||
HTMLApp.prototype.getInput = function() {
|
||||
var input = this.manager.input.get();
|
||||
|
||||
// Save to session storage in case we need to restore it later
|
||||
sessionStorage.setItem("input_length", input.length);
|
||||
sessionStorage.setItem("inputLength", input.length);
|
||||
sessionStorage.setItem("input", input);
|
||||
|
||||
return input;
|
||||
|
@ -155,8 +155,8 @@ HTMLApp.prototype.get_input = function() {
|
|||
*
|
||||
* @param {string} input - The string to set the input to
|
||||
*/
|
||||
HTMLApp.prototype.set_input = function(input) {
|
||||
sessionStorage.setItem("input_length", input.length);
|
||||
HTMLApp.prototype.setInput = function(input) {
|
||||
sessionStorage.setItem("inputLength", input.length);
|
||||
sessionStorage.setItem("input", input);
|
||||
this.manager.input.set(input);
|
||||
};
|
||||
|
@ -168,32 +168,32 @@ HTMLApp.prototype.set_input = function(input) {
|
|||
*
|
||||
* @fires Manager#oplistcreate
|
||||
*/
|
||||
HTMLApp.prototype.populate_operations_list = function() {
|
||||
HTMLApp.prototype.populateOperationsList = function() {
|
||||
// Move edit button away before we overwrite it
|
||||
document.body.appendChild(document.getElementById("edit-favourites"));
|
||||
|
||||
var html = "";
|
||||
|
||||
for (var i = 0; i < this.categories.length; i++) {
|
||||
var cat_conf = this.categories[i],
|
||||
var catConf = this.categories[i],
|
||||
selected = i === 0,
|
||||
cat = new HTMLCategory(cat_conf.name, selected);
|
||||
cat = new HTMLCategory(catConf.name, selected);
|
||||
|
||||
for (var j = 0; j < cat_conf.ops.length; j++) {
|
||||
var op_name = cat_conf.ops[j],
|
||||
op = new HTMLOperation(op_name, this.operations[op_name], this, this.manager);
|
||||
cat.add_operation(op);
|
||||
for (var j = 0; j < catConf.ops.length; j++) {
|
||||
var opName = catConf.ops[j],
|
||||
op = new HTMLOperation(opName, this.operations[opName], this, this.manager);
|
||||
cat.addOperation(op);
|
||||
}
|
||||
|
||||
html += cat.to_html();
|
||||
html += cat.toHtml();
|
||||
}
|
||||
|
||||
document.getElementById("categories").innerHTML = html;
|
||||
|
||||
var op_lists = document.querySelectorAll("#categories .op_list");
|
||||
var opLists = document.querySelectorAll("#categories .op-list");
|
||||
|
||||
for (i = 0; i < op_lists.length; i++) {
|
||||
op_lists[i].dispatchEvent(this.manager.oplistcreate);
|
||||
for (i = 0; i < opLists.length; i++) {
|
||||
opLists[i].dispatchEvent(this.manager.oplistcreate);
|
||||
}
|
||||
|
||||
// Add edit button to first category (Favourites)
|
||||
|
@ -204,23 +204,23 @@ HTMLApp.prototype.populate_operations_list = function() {
|
|||
/**
|
||||
* Sets up the adjustable splitter to allow the user to resize areas of the page.
|
||||
*/
|
||||
HTMLApp.prototype.initialise_splitter = function() {
|
||||
this.column_splitter = Split(["#operations", "#recipe", "#IO"], {
|
||||
HTMLApp.prototype.initialiseSplitter = function() {
|
||||
this.columnSplitter = Split(["#operations", "#recipe", "#IO"], {
|
||||
sizes: [20, 30, 50],
|
||||
minSize: [240, 325, 440],
|
||||
gutterSize: 4,
|
||||
onDrag: function() {
|
||||
this.manager.controls.adjust_width();
|
||||
this.manager.output.adjust_width();
|
||||
this.manager.controls.adjustWidth();
|
||||
this.manager.output.adjustWidth();
|
||||
}.bind(this)
|
||||
});
|
||||
|
||||
this.io_splitter = Split(["#input", "#output"], {
|
||||
this.ioSplitter = Split(["#input", "#output"], {
|
||||
direction: "vertical",
|
||||
gutterSize: 4,
|
||||
});
|
||||
|
||||
this.reset_layout();
|
||||
this.resetLayout();
|
||||
};
|
||||
|
||||
|
||||
|
@ -228,16 +228,16 @@ HTMLApp.prototype.initialise_splitter = function() {
|
|||
* Loads the information previously saved to the HTML5 local storage object so that user options
|
||||
* and favourites can be restored.
|
||||
*/
|
||||
HTMLApp.prototype.load_local_storage = function() {
|
||||
HTMLApp.prototype.loadLocalStorage = function() {
|
||||
// Load options
|
||||
var l_options;
|
||||
var lOptions;
|
||||
if (localStorage.options !== undefined) {
|
||||
l_options = JSON.parse(localStorage.options);
|
||||
lOptions = JSON.parse(localStorage.options);
|
||||
}
|
||||
this.manager.options.load(l_options);
|
||||
this.manager.options.load(lOptions);
|
||||
|
||||
// Load favourites
|
||||
this.load_favourites();
|
||||
this.loadFavourites();
|
||||
};
|
||||
|
||||
|
||||
|
@ -246,21 +246,21 @@ HTMLApp.prototype.load_local_storage = function() {
|
|||
* Favourites category with them.
|
||||
* If the user currently has no saved favourites, the defaults from the view constructor are used.
|
||||
*/
|
||||
HTMLApp.prototype.load_favourites = function() {
|
||||
HTMLApp.prototype.loadFavourites = function() {
|
||||
var favourites = localStorage.favourites &&
|
||||
localStorage.favourites.length > 2 ?
|
||||
JSON.parse(localStorage.favourites) :
|
||||
this.dfavourites;
|
||||
|
||||
favourites = this.valid_favourites(favourites);
|
||||
this.save_favourites(favourites);
|
||||
favourites = this.validFavourites(favourites);
|
||||
this.saveFavourites(favourites);
|
||||
|
||||
var fav_cat = this.categories.filter(function(c) {
|
||||
var favCat = this.categories.filter(function(c) {
|
||||
return c.name === "Favourites";
|
||||
})[0];
|
||||
|
||||
if (fav_cat) {
|
||||
fav_cat.ops = favourites;
|
||||
if (favCat) {
|
||||
favCat.ops = favourites;
|
||||
} else {
|
||||
this.categories.unshift({
|
||||
name: "Favourites",
|
||||
|
@ -277,17 +277,17 @@ HTMLApp.prototype.load_favourites = function() {
|
|||
* @param {string[]} favourites - A list of the user's favourite operations
|
||||
* @returns {string[]} A list of the valid favourites
|
||||
*/
|
||||
HTMLApp.prototype.valid_favourites = function(favourites) {
|
||||
var valid_favs = [];
|
||||
HTMLApp.prototype.validFavourites = function(favourites) {
|
||||
var validFavs = [];
|
||||
for (var i = 0; i < favourites.length; i++) {
|
||||
if (this.operations.hasOwnProperty(favourites[i])) {
|
||||
valid_favs.push(favourites[i]);
|
||||
validFavs.push(favourites[i]);
|
||||
} else {
|
||||
this.alert("The operation \"" + Utils.escape_html(favourites[i]) +
|
||||
this.alert("The operation \"" + Utils.escapeHtml(favourites[i]) +
|
||||
"\" is no longer available. It has been removed from your favourites.", "info");
|
||||
}
|
||||
}
|
||||
return valid_favs;
|
||||
return validFavs;
|
||||
};
|
||||
|
||||
|
||||
|
@ -296,8 +296,8 @@ HTMLApp.prototype.valid_favourites = function(favourites) {
|
|||
*
|
||||
* @param {string[]} favourites - A list of the user's favourite operations
|
||||
*/
|
||||
HTMLApp.prototype.save_favourites = function(favourites) {
|
||||
localStorage.setItem("favourites", JSON.stringify(this.valid_favourites(favourites)));
|
||||
HTMLApp.prototype.saveFavourites = function(favourites) {
|
||||
localStorage.setItem("favourites", JSON.stringify(this.validFavourites(favourites)));
|
||||
};
|
||||
|
||||
|
||||
|
@ -305,11 +305,11 @@ HTMLApp.prototype.save_favourites = function(favourites) {
|
|||
* Resets favourite operations back to the default as specified in the view constructor and
|
||||
* refreshes the operation list.
|
||||
*/
|
||||
HTMLApp.prototype.reset_favourites = function() {
|
||||
this.save_favourites(this.dfavourites);
|
||||
this.load_favourites();
|
||||
this.populate_operations_list();
|
||||
this.manager.recipe.initialise_operation_drag_n_drop();
|
||||
HTMLApp.prototype.resetFavourites = function() {
|
||||
this.saveFavourites(this.dfavourites);
|
||||
this.loadFavourites();
|
||||
this.populateOperationsList();
|
||||
this.manager.recipe.initialiseOperationDragNDrop();
|
||||
};
|
||||
|
||||
|
||||
|
@ -318,7 +318,7 @@ HTMLApp.prototype.reset_favourites = function() {
|
|||
*
|
||||
* @param {string} name - The name of the operation
|
||||
*/
|
||||
HTMLApp.prototype.add_favourite = function(name) {
|
||||
HTMLApp.prototype.addFavourite = function(name) {
|
||||
var favourites = JSON.parse(localStorage.favourites);
|
||||
|
||||
if (favourites.indexOf(name) >= 0) {
|
||||
|
@ -327,19 +327,19 @@ HTMLApp.prototype.add_favourite = function(name) {
|
|||
}
|
||||
|
||||
favourites.push(name);
|
||||
this.save_favourites(favourites);
|
||||
this.load_favourites();
|
||||
this.populate_operations_list();
|
||||
this.manager.recipe.initialise_operation_drag_n_drop();
|
||||
this.saveFavourites(favourites);
|
||||
this.loadFavourites();
|
||||
this.populateOperationsList();
|
||||
this.manager.recipe.initialiseOperationDragNDrop();
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Checks for input and recipe in the URI parameters and loads them if present.
|
||||
*/
|
||||
HTMLApp.prototype.load_URI_params = function() {
|
||||
HTMLApp.prototype.loadURIParams = function() {
|
||||
// Load query string from URI
|
||||
this.query_string = (function(a) {
|
||||
this.queryString = (function(a) {
|
||||
if (a === "") return {};
|
||||
var b = {};
|
||||
for (var i = 0; i < a.length; i++) {
|
||||
|
@ -354,46 +354,46 @@ HTMLApp.prototype.load_URI_params = function() {
|
|||
})(window.location.search.substr(1).split("&"));
|
||||
|
||||
// Turn off auto-bake while loading
|
||||
var auto_bake_val = this.auto_bake_;
|
||||
this.auto_bake_ = false;
|
||||
var autoBakeVal = this.autoBake_;
|
||||
this.autoBake_ = false;
|
||||
|
||||
// Read in recipe from query string
|
||||
if (this.query_string.recipe) {
|
||||
if (this.queryString.recipe) {
|
||||
try {
|
||||
var recipe_config = JSON.parse(this.query_string.recipe);
|
||||
this.set_recipe_config(recipe_config);
|
||||
var recipeConfig = JSON.parse(this.queryString.recipe);
|
||||
this.setRecipeConfig(recipeConfig);
|
||||
} catch(err) {}
|
||||
} else if (this.query_string.op) {
|
||||
} else if (this.queryString.op) {
|
||||
// If there's no recipe, look for single operations
|
||||
this.manager.recipe.clear_recipe();
|
||||
this.manager.recipe.clearRecipe();
|
||||
try {
|
||||
this.manager.recipe.add_operation(this.query_string.op);
|
||||
this.manager.recipe.addOperation(this.queryString.op);
|
||||
} catch(err) {
|
||||
// If no exact match, search for nearest match and add that
|
||||
var matched_ops = this.manager.ops.filter_operations(this.query_string.op, false);
|
||||
if (matched_ops.length) {
|
||||
this.manager.recipe.add_operation(matched_ops[0].name);
|
||||
var matchedOps = this.manager.ops.filterOperations(this.queryString.op, false);
|
||||
if (matchedOps.length) {
|
||||
this.manager.recipe.addOperation(matchedOps[0].name);
|
||||
}
|
||||
|
||||
// Populate search with the string
|
||||
var search = document.getElementById("search");
|
||||
|
||||
search.value = this.query_string.op;
|
||||
search.value = this.queryString.op;
|
||||
search.dispatchEvent(new Event("search"));
|
||||
}
|
||||
}
|
||||
|
||||
// Read in input data from query string
|
||||
if (this.query_string.input) {
|
||||
if (this.queryString.input) {
|
||||
try {
|
||||
var input_data = Utils.from_base64(this.query_string.input);
|
||||
this.set_input(input_data);
|
||||
var inputData = Utils.fromBase64(this.queryString.input);
|
||||
this.setInput(inputData);
|
||||
} catch(err) {}
|
||||
}
|
||||
|
||||
// Restore auto-bake state
|
||||
this.auto_bake_ = auto_bake_val;
|
||||
this.auto_bake();
|
||||
this.autoBake_ = autoBakeVal;
|
||||
this.autoBake();
|
||||
};
|
||||
|
||||
|
||||
|
@ -402,8 +402,8 @@ HTMLApp.prototype.load_URI_params = function() {
|
|||
*
|
||||
* @returns {number}
|
||||
*/
|
||||
HTMLApp.prototype.next_ing_id = function() {
|
||||
return this.ing_id++;
|
||||
HTMLApp.prototype.nextIngId = function() {
|
||||
return this.ingId++;
|
||||
};
|
||||
|
||||
|
||||
|
@ -412,48 +412,48 @@ HTMLApp.prototype.next_ing_id = function() {
|
|||
*
|
||||
* @returns {Object[]}
|
||||
*/
|
||||
HTMLApp.prototype.get_recipe_config = function() {
|
||||
var recipe_config = this.manager.recipe.get_config();
|
||||
sessionStorage.setItem("recipe_config", JSON.stringify(recipe_config));
|
||||
return recipe_config;
|
||||
HTMLApp.prototype.getRecipeConfig = function() {
|
||||
var recipeConfig = this.manager.recipe.getConfig();
|
||||
sessionStorage.setItem("recipeConfig", JSON.stringify(recipeConfig));
|
||||
return recipeConfig;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Given a recipe configuration, sets the recipe to that configuration.
|
||||
*
|
||||
* @param {Object[]} recipe_config - The recipe configuration
|
||||
* @param {Object[]} recipeConfig - The recipe configuration
|
||||
*/
|
||||
HTMLApp.prototype.set_recipe_config = function(recipe_config) {
|
||||
sessionStorage.setItem("recipe_config", JSON.stringify(recipe_config));
|
||||
document.getElementById("rec_list").innerHTML = null;
|
||||
HTMLApp.prototype.setRecipeConfig = function(recipeConfig) {
|
||||
sessionStorage.setItem("recipeConfig", JSON.stringify(recipeConfig));
|
||||
document.getElementById("rec-list").innerHTML = null;
|
||||
|
||||
for (var i = 0; i < recipe_config.length; i++) {
|
||||
var item = this.manager.recipe.add_operation(recipe_config[i].op);
|
||||
for (var i = 0; i < recipeConfig.length; i++) {
|
||||
var item = this.manager.recipe.addOperation(recipeConfig[i].op);
|
||||
|
||||
// Populate arguments
|
||||
var args = item.querySelectorAll(".arg");
|
||||
for (var j = 0; j < args.length; j++) {
|
||||
if (args[j].getAttribute("type") === "checkbox") {
|
||||
// checkbox
|
||||
args[j].checked = recipe_config[i].args[j];
|
||||
args[j].checked = recipeConfig[i].args[j];
|
||||
} else if (args[j].classList.contains("toggle-string")) {
|
||||
// toggle_string
|
||||
args[j].value = recipe_config[i].args[j].string;
|
||||
// toggleString
|
||||
args[j].value = recipeConfig[i].args[j].string;
|
||||
args[j].previousSibling.children[0].innerHTML =
|
||||
Utils.escape_html(recipe_config[i].args[j].option) +
|
||||
Utils.escapeHtml(recipeConfig[i].args[j].option) +
|
||||
" <span class='caret'></span>";
|
||||
} else {
|
||||
// all others
|
||||
args[j].value = recipe_config[i].args[j];
|
||||
args[j].value = recipeConfig[i].args[j];
|
||||
}
|
||||
}
|
||||
|
||||
// Set disabled and breakpoint
|
||||
if (recipe_config[i].disabled) {
|
||||
if (recipeConfig[i].disabled) {
|
||||
item.querySelector(".disable-icon").click();
|
||||
}
|
||||
if (recipe_config[i].breakpoint) {
|
||||
if (recipeConfig[i].breakpoint) {
|
||||
item.querySelector(".breakpoint").click();
|
||||
}
|
||||
|
||||
|
@ -465,31 +465,31 @@ HTMLApp.prototype.set_recipe_config = function(recipe_config) {
|
|||
/**
|
||||
* Resets the splitter positions to default.
|
||||
*/
|
||||
HTMLApp.prototype.reset_layout = function() {
|
||||
this.column_splitter.setSizes([20, 30, 50]);
|
||||
this.io_splitter.setSizes([50, 50]);
|
||||
HTMLApp.prototype.resetLayout = function() {
|
||||
this.columnSplitter.setSizes([20, 30, 50]);
|
||||
this.ioSplitter.setSizes([50, 50]);
|
||||
|
||||
this.manager.controls.adjust_width();
|
||||
this.manager.output.adjust_width();
|
||||
this.manager.controls.adjustWidth();
|
||||
this.manager.output.adjustWidth();
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Sets the compile message.
|
||||
*/
|
||||
HTMLApp.prototype.set_compile_message = function() {
|
||||
HTMLApp.prototype.setCompileMessage = function() {
|
||||
// Display time since last build and compile message
|
||||
var now = new Date(),
|
||||
time_since_compile = Utils.fuzzy_time(now.getTime() - window.compile_time),
|
||||
compile_info = "<span style=\"font-weight: normal\">Last build: " +
|
||||
time_since_compile.substr(0, 1).toUpperCase() + time_since_compile.substr(1) + " ago";
|
||||
timeSinceCompile = Utils.fuzzyTime(now.getTime() - window.compileTime),
|
||||
compileInfo = "<span style=\"font-weight: normal\">Last build: " +
|
||||
timeSinceCompile.substr(0, 1).toUpperCase() + timeSinceCompile.substr(1) + " ago";
|
||||
|
||||
if (window.compile_message !== "") {
|
||||
compile_info += " - " + window.compile_message;
|
||||
if (window.compileMessage !== "") {
|
||||
compileInfo += " - " + window.compileMessage;
|
||||
}
|
||||
|
||||
compile_info += "</span>";
|
||||
document.getElementById("notice").innerHTML = compile_info;
|
||||
compileInfo += "</span>";
|
||||
document.getElementById("notice").innerHTML = compileInfo;
|
||||
};
|
||||
|
||||
|
||||
|
@ -525,32 +525,32 @@ HTMLApp.prototype.alert = function(str, style, timeout, silent) {
|
|||
style = style || "danger";
|
||||
timeout = timeout || 0;
|
||||
|
||||
var alert_el = document.getElementById("alert"),
|
||||
alert_content = document.getElementById("alert-content");
|
||||
var alertEl = document.getElementById("alert"),
|
||||
alertContent = document.getElementById("alert-content");
|
||||
|
||||
alert_el.classList.remove("alert-danger");
|
||||
alert_el.classList.remove("alert-warning");
|
||||
alert_el.classList.remove("alert-info");
|
||||
alert_el.classList.remove("alert-success");
|
||||
alert_el.classList.add("alert-" + style);
|
||||
alertEl.classList.remove("alert-danger");
|
||||
alertEl.classList.remove("alert-warning");
|
||||
alertEl.classList.remove("alert-info");
|
||||
alertEl.classList.remove("alert-success");
|
||||
alertEl.classList.add("alert-" + style);
|
||||
|
||||
// If the box hasn't been closed, append to it rather than replacing
|
||||
if (alert_el.style.display === "block") {
|
||||
alert_content.innerHTML +=
|
||||
if (alertEl.style.display === "block") {
|
||||
alertContent.innerHTML +=
|
||||
"<br><br>[" + time.toLocaleTimeString() + "] " + str;
|
||||
} else {
|
||||
alert_content.innerHTML =
|
||||
alertContent.innerHTML =
|
||||
"[" + time.toLocaleTimeString() + "] " + str;
|
||||
}
|
||||
|
||||
// Stop the animation if it is in progress
|
||||
$("#alert").stop();
|
||||
alert_el.style.display = "block";
|
||||
alert_el.style.opacity = 1;
|
||||
alertEl.style.display = "block";
|
||||
alertEl.style.opacity = 1;
|
||||
|
||||
if (timeout > 0) {
|
||||
clearTimeout(this.alert_timeout);
|
||||
this.alert_timeout = setTimeout(function(){
|
||||
clearTimeout(this.alertTimeout);
|
||||
this.alertTimeout = setTimeout(function(){
|
||||
$("#alert").slideUp(100);
|
||||
}, timeout);
|
||||
}
|
||||
|
@ -576,20 +576,20 @@ HTMLApp.prototype.confirm = function(title, body, callback, scope) {
|
|||
document.getElementById("confirm-body").innerHTML = body;
|
||||
document.getElementById("confirm-modal").style.display = "block";
|
||||
|
||||
this.confirm_closed = false;
|
||||
this.confirmClosed = false;
|
||||
$("#confirm-modal").modal()
|
||||
.one("show.bs.modal", function(e) {
|
||||
this.confirm_closed = false;
|
||||
this.confirmClosed = false;
|
||||
}.bind(this))
|
||||
.one("click", "#confirm-yes", function() {
|
||||
this.confirm_closed = true;
|
||||
this.confirmClosed = true;
|
||||
callback.bind(scope)(true);
|
||||
$("#confirm-modal").modal("hide");
|
||||
}.bind(this))
|
||||
.one("hide.bs.modal", function(e) {
|
||||
if (!this.confirm_closed)
|
||||
if (!this.confirmClosed)
|
||||
callback.bind(scope)(false);
|
||||
this.confirm_closed = true;
|
||||
this.confirmClosed = true;
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
|
@ -598,7 +598,7 @@ HTMLApp.prototype.confirm = function(title, body, callback, scope) {
|
|||
* Handler for the alert close button click event.
|
||||
* Closes the alert box.
|
||||
*/
|
||||
HTMLApp.prototype.alert_close_click = function() {
|
||||
HTMLApp.prototype.alertCloseClick = function() {
|
||||
document.getElementById("alert").style.display = "none";
|
||||
};
|
||||
|
||||
|
@ -610,13 +610,13 @@ HTMLApp.prototype.alert_close_click = function() {
|
|||
* @listens Manager#statechange
|
||||
* @param {event} e
|
||||
*/
|
||||
HTMLApp.prototype.state_change = function(e) {
|
||||
this.auto_bake();
|
||||
HTMLApp.prototype.stateChange = function(e) {
|
||||
this.autoBake();
|
||||
|
||||
// Update the current history state (not creating a new one)
|
||||
if (this.options.update_url) {
|
||||
this.last_state_url = this.manager.controls.generate_state_url(true, true);
|
||||
window.history.replaceState({}, "CyberChef", this.last_state_url);
|
||||
if (this.options.updateUrl) {
|
||||
this.lastStateUrl = this.manager.controls.generateStateUrl(true, true);
|
||||
window.history.replaceState({}, "CyberChef", this.lastStateUrl);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -627,9 +627,9 @@ HTMLApp.prototype.state_change = function(e) {
|
|||
*
|
||||
* @param {event} e
|
||||
*/
|
||||
HTMLApp.prototype.pop_state = function(e) {
|
||||
if (window.location.href.split("#")[0] !== this.last_state_url) {
|
||||
this.load_URI_params();
|
||||
HTMLApp.prototype.popState = function(e) {
|
||||
if (window.location.href.split("#")[0] !== this.lastStateUrl) {
|
||||
this.loadURIParams();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -637,11 +637,11 @@ HTMLApp.prototype.pop_state = function(e) {
|
|||
/**
|
||||
* Function to call an external API from this view.
|
||||
*/
|
||||
HTMLApp.prototype.call_api = function(url, type, data, data_type, content_type) {
|
||||
HTMLApp.prototype.callApi = function(url, type, data, dataType, contentType) {
|
||||
type = type || "POST";
|
||||
data = data || {};
|
||||
data_type = data_type || undefined;
|
||||
content_type = content_type || "application/json";
|
||||
dataType = dataType || undefined;
|
||||
contentType = contentType || "application/json";
|
||||
|
||||
var response = null,
|
||||
success = false;
|
||||
|
@ -651,8 +651,8 @@ HTMLApp.prototype.call_api = function(url, type, data, data_type, content_type)
|
|||
async: false,
|
||||
type: type,
|
||||
data: data,
|
||||
dataType: data_type,
|
||||
contentType: content_type,
|
||||
dataType: dataType,
|
||||
contentType: contentType,
|
||||
success: function(data) {
|
||||
success = true;
|
||||
response = data;
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
var HTMLCategory = function(name, selected) {
|
||||
this.name = name;
|
||||
this.selected = selected;
|
||||
this.op_list = [];
|
||||
this.opList = [];
|
||||
};
|
||||
|
||||
|
||||
|
@ -21,8 +21,8 @@ var HTMLCategory = function(name, selected) {
|
|||
*
|
||||
* @param {HTMLOperation} operation - The operation to add.
|
||||
*/
|
||||
HTMLCategory.prototype.add_operation = function(operation) {
|
||||
this.op_list.push(operation);
|
||||
HTMLCategory.prototype.addOperation = function(operation) {
|
||||
this.opList.push(operation);
|
||||
};
|
||||
|
||||
|
||||
|
@ -31,18 +31,18 @@ HTMLCategory.prototype.add_operation = function(operation) {
|
|||
*
|
||||
* @returns {string}
|
||||
*/
|
||||
HTMLCategory.prototype.to_html = function() {
|
||||
var cat_name = "cat" + this.name.replace(/[\s/-:_]/g, "");
|
||||
HTMLCategory.prototype.toHtml = function() {
|
||||
var catName = "cat" + this.name.replace(/[\s/-:_]/g, "");
|
||||
var html = "<div class='panel category'>\
|
||||
<a class='category-title' data-toggle='collapse'\
|
||||
data-parent='#categories' href='#" + cat_name + "'>\
|
||||
data-parent='#categories' href='#" + catName + "'>\
|
||||
" + this.name + "\
|
||||
</a>\
|
||||
<div id='" + cat_name + "' class='panel-collapse collapse\
|
||||
" + (this.selected ? " in" : "") + "'><ul class='op_list'>";
|
||||
<div id='" + catName + "' class='panel-collapse collapse\
|
||||
" + (this.selected ? " in" : "") + "'><ul class='op-list'>";
|
||||
|
||||
for (var i = 0; i < this.op_list.length; i++) {
|
||||
html += this.op_list[i].to_stub_html();
|
||||
for (var i = 0; i < this.opList.length; i++) {
|
||||
html += this.opList[i].toStubHtml();
|
||||
}
|
||||
|
||||
html += "</ul></div></div>";
|
||||
|
|
|
@ -18,11 +18,11 @@ var HTMLIngredient = function(config, app, manager) {
|
|||
this.type = config.type;
|
||||
this.value = config.value;
|
||||
this.disabled = config.disabled || false;
|
||||
this.disable_args = config.disable_args || false;
|
||||
this.disableArgs = config.disableArgs || false;
|
||||
this.placeholder = config.placeholder || false;
|
||||
this.target = config.target;
|
||||
this.toggle_values = config.toggle_values;
|
||||
this.id = "ing-" + this.app.next_ing_id();
|
||||
this.toggleValues = config.toggleValues;
|
||||
this.id = "ing-" + this.app.nextIngId();
|
||||
};
|
||||
|
||||
|
||||
|
@ -31,12 +31,12 @@ var HTMLIngredient = function(config, app, manager) {
|
|||
*
|
||||
* @returns {string}
|
||||
*/
|
||||
HTMLIngredient.prototype.to_html = function() {
|
||||
HTMLIngredient.prototype.toHtml = function() {
|
||||
var inline = (this.type === "boolean" ||
|
||||
this.type === "number" ||
|
||||
this.type === "option" ||
|
||||
this.type === "short_string" ||
|
||||
this.type === "binary_short_string"),
|
||||
this.type === "shortString" ||
|
||||
this.type === "binaryShortString"),
|
||||
html = inline ? "" : "<div class='clearfix'> </div>",
|
||||
i, m;
|
||||
|
||||
|
@ -46,50 +46,50 @@ HTMLIngredient.prototype.to_html = function() {
|
|||
|
||||
switch (this.type) {
|
||||
case "string":
|
||||
case "binary_string":
|
||||
case "byte_array":
|
||||
html += "<input type='text' id='" + this.id + "' class='arg arg-input' arg_name='" +
|
||||
case "binaryString":
|
||||
case "byteArray":
|
||||
html += "<input type='text' id='" + this.id + "' class='arg arg-input' arg-name='" +
|
||||
this.name + "' value='" + this.value + "'" +
|
||||
(this.disabled ? " disabled='disabled'" : "") +
|
||||
(this.placeholder ? " placeholder='" + this.placeholder + "'" : "") + ">";
|
||||
break;
|
||||
case "short_string":
|
||||
case "binary_short_string":
|
||||
case "shortString":
|
||||
case "binaryShortString":
|
||||
html += "<input type='text' id='" + this.id +
|
||||
"'class='arg arg-input short-string' arg_name='" + this.name + "'value='" +
|
||||
"'class='arg arg-input short-string' arg-name='" + this.name + "'value='" +
|
||||
this.value + "'" + (this.disabled ? " disabled='disabled'" : "") +
|
||||
(this.placeholder ? " placeholder='" + this.placeholder + "'" : "") + ">";
|
||||
break;
|
||||
case "toggle_string":
|
||||
case "toggleString":
|
||||
html += "<div class='input-group'><div class='input-group-btn'>\
|
||||
<button type='button' class='btn btn-default dropdown-toggle' data-toggle='dropdown'\
|
||||
aria-haspopup='true' aria-expanded='false'" +
|
||||
(this.disabled ? " disabled='disabled'" : "") + ">" + this.toggle_values[0] +
|
||||
(this.disabled ? " disabled='disabled'" : "") + ">" + this.toggleValues[0] +
|
||||
" <span class='caret'></span></button><ul class='dropdown-menu'>";
|
||||
for (i = 0; i < this.toggle_values.length; i++) {
|
||||
html += "<li><a href='#'>" + this.toggle_values[i] + "</a></li>";
|
||||
for (i = 0; i < this.toggleValues.length; i++) {
|
||||
html += "<li><a href='#'>" + this.toggleValues[i] + "</a></li>";
|
||||
}
|
||||
html += "</ul></div><input type='text' class='arg arg-input toggle-string'" +
|
||||
(this.disabled ? " disabled='disabled'" : "") +
|
||||
(this.placeholder ? " placeholder='" + this.placeholder + "'" : "") + "></div>";
|
||||
break;
|
||||
case "number":
|
||||
html += "<input type='number' id='" + this.id + "'class='arg arg-input' arg_name='" +
|
||||
html += "<input type='number' id='" + this.id + "'class='arg arg-input' arg-name='" +
|
||||
this.name + "'value='" + this.value + "'" +
|
||||
(this.disabled ? " disabled='disabled'" : "") +
|
||||
(this.placeholder ? " placeholder='" + this.placeholder + "'" : "") + ">";
|
||||
break;
|
||||
case "boolean":
|
||||
html += "<input type='checkbox' id='" + this.id + "'class='arg' arg_name='" +
|
||||
html += "<input type='checkbox' id='" + this.id + "'class='arg' arg-name='" +
|
||||
this.name + "'" + (this.value ? " checked='checked' " : "") +
|
||||
(this.disabled ? " disabled='disabled'" : "") + ">";
|
||||
|
||||
if (this.disable_args) {
|
||||
this.manager.add_dynamic_listener("#" + this.id, "click", this.toggle_disable_args, this);
|
||||
if (this.disableArgs) {
|
||||
this.manager.addDynamicListener("#" + this.id, "click", this.toggleDisableArgs, this);
|
||||
}
|
||||
break;
|
||||
case "option":
|
||||
html += "<select class='arg' id='" + this.id + "'arg_name='" + this.name + "'" +
|
||||
html += "<select class='arg' id='" + this.id + "'arg-name='" + this.name + "'" +
|
||||
(this.disabled ? " disabled='disabled'" : "") + ">";
|
||||
for (i = 0; i < this.value.length; i++) {
|
||||
if ((m = this.value[i].match(/\[([a-z0-9 -()^]+)\]/i))) {
|
||||
|
@ -102,8 +102,8 @@ HTMLIngredient.prototype.to_html = function() {
|
|||
}
|
||||
html += "</select>";
|
||||
break;
|
||||
case "populate_option":
|
||||
html += "<select class='arg' id='" + this.id + "'arg_name='" + this.name + "'" +
|
||||
case "populateOption":
|
||||
html += "<select class='arg' id='" + this.id + "'arg-name='" + this.name + "'" +
|
||||
(this.disabled ? " disabled='disabled'" : "") + ">";
|
||||
for (i = 0; i < this.value.length; i++) {
|
||||
if ((m = this.value[i].name.match(/\[([a-z0-9 -()^]+)\]/i))) {
|
||||
|
@ -117,9 +117,9 @@ HTMLIngredient.prototype.to_html = function() {
|
|||
}
|
||||
html += "</select>";
|
||||
|
||||
this.manager.add_dynamic_listener("#" + this.id, "change", this.populate_option_change, this);
|
||||
this.manager.addDynamicListener("#" + this.id, "change", this.populateOptionChange, this);
|
||||
break;
|
||||
case "editable_option":
|
||||
case "editableOption":
|
||||
html += "<div class='editable-option'>";
|
||||
html += "<select class='editable-option-select' id='sel-" + this.id + "'" +
|
||||
(this.disabled ? " disabled='disabled'" : "") + ">";
|
||||
|
@ -128,16 +128,16 @@ HTMLIngredient.prototype.to_html = function() {
|
|||
}
|
||||
html += "</select>";
|
||||
html += "<input class='arg arg-input editable-option-input' id='" + this.id +
|
||||
"'arg_name='" + this.name + "'" + " value='" + this.value[0].value + "'" +
|
||||
"'arg-name='" + this.name + "'" + " value='" + this.value[0].value + "'" +
|
||||
(this.disabled ? " disabled='disabled'" : "") +
|
||||
(this.placeholder ? " placeholder='" + this.placeholder + "'" : "") + ">";
|
||||
html += "</div>";
|
||||
|
||||
|
||||
this.manager.add_dynamic_listener("#sel-" + this.id, "change", this.editable_option_change, this);
|
||||
this.manager.addDynamicListener("#sel-" + this.id, "change", this.editableOptionChange, this);
|
||||
break;
|
||||
case "text":
|
||||
html += "<textarea id='" + this.id + "' class='arg' arg_name='" +
|
||||
html += "<textarea id='" + this.id + "' class='arg' arg-name='" +
|
||||
this.name + "'" + (this.disabled ? " disabled='disabled'" : "") +
|
||||
(this.placeholder ? " placeholder='" + this.placeholder + "'" : "") + ">" +
|
||||
this.value + "</textarea>";
|
||||
|
@ -153,18 +153,18 @@ HTMLIngredient.prototype.to_html = function() {
|
|||
|
||||
/**
|
||||
* Handler for argument disable toggle.
|
||||
* Toggles disabled state for all arguments in the disable_args list for this ingredient.
|
||||
* Toggles disabled state for all arguments in the disableArgs list for this ingredient.
|
||||
*
|
||||
* @param {event} e
|
||||
*/
|
||||
HTMLIngredient.prototype.toggle_disable_args = function(e) {
|
||||
HTMLIngredient.prototype.toggleDisableArgs = function(e) {
|
||||
var el = e.target,
|
||||
op = el.parentNode.parentNode,
|
||||
args = op.querySelectorAll(".arg-group"),
|
||||
els;
|
||||
|
||||
for (var i = 0; i < this.disable_args.length; i++) {
|
||||
els = args[this.disable_args[i]].querySelectorAll("input, select, button");
|
||||
for (var i = 0; i < this.disableArgs.length; i++) {
|
||||
els = args[this.disableArgs[i]].querySelectorAll("input, select, button");
|
||||
|
||||
for (var j = 0; j < els.length; j++) {
|
||||
if (els[j].getAttribute("disabled")) {
|
||||
|
@ -175,7 +175,7 @@ HTMLIngredient.prototype.toggle_disable_args = function(e) {
|
|||
}
|
||||
}
|
||||
|
||||
this.manager.recipe.ing_change();
|
||||
this.manager.recipe.ingChange();
|
||||
};
|
||||
|
||||
|
||||
|
@ -185,14 +185,14 @@ HTMLIngredient.prototype.toggle_disable_args = function(e) {
|
|||
*
|
||||
* @param {event} e
|
||||
*/
|
||||
HTMLIngredient.prototype.populate_option_change = function(e) {
|
||||
HTMLIngredient.prototype.populateOptionChange = function(e) {
|
||||
var el = e.target,
|
||||
op = el.parentNode.parentNode,
|
||||
target = op.querySelectorAll(".arg-group")[this.target].querySelector("input, select, textarea");
|
||||
|
||||
target.value = el.childNodes[el.selectedIndex].getAttribute("populate-value");
|
||||
|
||||
this.manager.recipe.ing_change();
|
||||
this.manager.recipe.ingChange();
|
||||
};
|
||||
|
||||
|
||||
|
@ -202,11 +202,11 @@ HTMLIngredient.prototype.populate_option_change = function(e) {
|
|||
*
|
||||
* @param {event} e
|
||||
*/
|
||||
HTMLIngredient.prototype.editable_option_change = function(e) {
|
||||
HTMLIngredient.prototype.editableOptionChange = function(e) {
|
||||
var select = e.target,
|
||||
input = select.nextSibling;
|
||||
|
||||
input.value = select.childNodes[select.selectedIndex].value;
|
||||
|
||||
this.manager.recipe.ing_change();
|
||||
this.manager.recipe.ingChange();
|
||||
};
|
||||
|
|
|
@ -17,13 +17,13 @@ var HTMLOperation = function(name, config, app, manager) {
|
|||
|
||||
this.name = name;
|
||||
this.description = config.description;
|
||||
this.manual_bake = config.manual_bake || false;
|
||||
this.manualBake = config.manualBake || false;
|
||||
this.config = config;
|
||||
this.ing_list = [];
|
||||
this.ingList = [];
|
||||
|
||||
for (var i = 0; i < config.args.length; i++) {
|
||||
var ing = new HTMLIngredient(config.args[i], this.app, this.manager);
|
||||
this.ing_list.push(ing);
|
||||
this.ingList.push(ing);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -43,7 +43,7 @@ HTMLOperation.REMOVE_ICON = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABwkl
|
|||
*
|
||||
* @returns {string}
|
||||
*/
|
||||
HTMLOperation.prototype.to_stub_html = function(remove_icon) {
|
||||
HTMLOperation.prototype.toStubHtml = function(removeIcon) {
|
||||
var html = "<li class='operation'";
|
||||
|
||||
if (this.description) {
|
||||
|
@ -53,7 +53,7 @@ HTMLOperation.prototype.to_stub_html = function(remove_icon) {
|
|||
|
||||
html += ">" + this.name;
|
||||
|
||||
if (remove_icon) {
|
||||
if (removeIcon) {
|
||||
html += "<img src='data:image/png;base64," + HTMLOperation.REMOVE_ICON +
|
||||
"' class='op-icon remove-icon'>";
|
||||
}
|
||||
|
@ -73,11 +73,11 @@ HTMLOperation.prototype.to_stub_html = function(remove_icon) {
|
|||
*
|
||||
* @returns {string}
|
||||
*/
|
||||
HTMLOperation.prototype.to_full_html = function() {
|
||||
HTMLOperation.prototype.toFullHtml = function() {
|
||||
var html = "<div class='arg-title'>" + this.name + "</div>";
|
||||
|
||||
for (var i = 0; i < this.ing_list.length; i++) {
|
||||
html += this.ing_list[i].to_html();
|
||||
for (var i = 0; i < this.ingList.length; i++) {
|
||||
html += this.ingList[i].toHtml();
|
||||
}
|
||||
|
||||
html += "<div class='recip-icons'>\
|
||||
|
@ -95,20 +95,20 @@ HTMLOperation.prototype.to_full_html = function() {
|
|||
/**
|
||||
* Highlights the searched string in the name and description of the operation.
|
||||
*
|
||||
* @param {string} search_str
|
||||
* @param {number} name_pos - The position of the search string in the operation name
|
||||
* @param {number} desc_pos - The position of the search string in the operation description
|
||||
* @param {string} searchStr
|
||||
* @param {number} namePos - The position of the search string in the operation name
|
||||
* @param {number} descPos - The position of the search string in the operation description
|
||||
*/
|
||||
HTMLOperation.prototype.highlight_search_string = function(search_str, name_pos, desc_pos) {
|
||||
if (name_pos >= 0) {
|
||||
this.name = this.name.slice(0, name_pos) + "<b><u>" +
|
||||
this.name.slice(name_pos, name_pos + search_str.length) + "</u></b>" +
|
||||
this.name.slice(name_pos + search_str.length);
|
||||
HTMLOperation.prototype.highlightSearchString = function(searchStr, namePos, descPos) {
|
||||
if (namePos >= 0) {
|
||||
this.name = this.name.slice(0, namePos) + "<b><u>" +
|
||||
this.name.slice(namePos, namePos + searchStr.length) + "</u></b>" +
|
||||
this.name.slice(namePos + searchStr.length);
|
||||
}
|
||||
|
||||
if (this.description && desc_pos >= 0) {
|
||||
this.description = this.description.slice(0, desc_pos) + "<b><u>" +
|
||||
this.description.slice(desc_pos, desc_pos + search_str.length) + "</u></b>" +
|
||||
this.description.slice(desc_pos + search_str.length);
|
||||
if (this.description && descPos >= 0) {
|
||||
this.description = this.description.slice(0, descPos) + "<b><u>" +
|
||||
this.description.slice(descPos, descPos + searchStr.length) + "</u></b>" +
|
||||
this.description.slice(descPos + searchStr.length);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
var HighlighterWaiter = function(app) {
|
||||
this.app = app;
|
||||
|
||||
this.mouse_button_down = false;
|
||||
this.mouse_target = null;
|
||||
this.mouseButtonDown = false;
|
||||
this.mouseTarget = null;
|
||||
};
|
||||
|
||||
|
||||
|
@ -37,7 +37,7 @@ HighlighterWaiter.OUTPUT = 1;
|
|||
* @private
|
||||
* @returns {boolean}
|
||||
*/
|
||||
HighlighterWaiter.prototype._is_selection_backwards = function() {
|
||||
HighlighterWaiter.prototype._isSelectionBackwards = function() {
|
||||
var backwards = false,
|
||||
sel = window.getSelection();
|
||||
|
||||
|
@ -60,7 +60,7 @@ HighlighterWaiter.prototype._is_selection_backwards = function() {
|
|||
* @param {number} offset - The offset since the last HTML element.
|
||||
* @returns {number}
|
||||
*/
|
||||
HighlighterWaiter.prototype._get_output_html_offset = function(node, offset) {
|
||||
HighlighterWaiter.prototype._getOutputHtmlOffset = function(node, offset) {
|
||||
var sel = window.getSelection(),
|
||||
range = document.createRange();
|
||||
|
||||
|
@ -81,7 +81,7 @@ HighlighterWaiter.prototype._get_output_html_offset = function(node, offset) {
|
|||
* @returns {number} pos.start
|
||||
* @returns {number} pos.end
|
||||
*/
|
||||
HighlighterWaiter.prototype._get_output_html_selection_offsets = function() {
|
||||
HighlighterWaiter.prototype._getOutputHtmlSelectionOffsets = function() {
|
||||
var sel = window.getSelection(),
|
||||
range,
|
||||
start = 0,
|
||||
|
@ -90,9 +90,9 @@ HighlighterWaiter.prototype._get_output_html_selection_offsets = function() {
|
|||
|
||||
if (sel.rangeCount) {
|
||||
range = sel.getRangeAt(sel.rangeCount - 1);
|
||||
backwards = this._is_selection_backwards();
|
||||
start = this._get_output_html_offset(range.startContainer, range.startOffset);
|
||||
end = this._get_output_html_offset(range.endContainer, range.endOffset);
|
||||
backwards = this._isSelectionBackwards();
|
||||
start = this._getOutputHtmlOffset(range.startContainer, range.startOffset);
|
||||
end = this._getOutputHtmlOffset(range.endContainer, range.endOffset);
|
||||
sel.removeAllRanges();
|
||||
sel.addRange(range);
|
||||
|
||||
|
@ -117,7 +117,7 @@ HighlighterWaiter.prototype._get_output_html_selection_offsets = function() {
|
|||
*
|
||||
* @param {event} e
|
||||
*/
|
||||
HighlighterWaiter.prototype.input_scroll = function(e) {
|
||||
HighlighterWaiter.prototype.inputScroll = function(e) {
|
||||
var el = e.target;
|
||||
document.getElementById("input-highlighter").scrollTop = el.scrollTop;
|
||||
document.getElementById("input-highlighter").scrollLeft = el.scrollLeft;
|
||||
|
@ -130,7 +130,7 @@ HighlighterWaiter.prototype.input_scroll = function(e) {
|
|||
*
|
||||
* @param {event} e
|
||||
*/
|
||||
HighlighterWaiter.prototype.output_scroll = function(e) {
|
||||
HighlighterWaiter.prototype.outputScroll = function(e) {
|
||||
var el = e.target;
|
||||
document.getElementById("output-highlighter").scrollTop = el.scrollTop;
|
||||
document.getElementById("output-highlighter").scrollLeft = el.scrollLeft;
|
||||
|
@ -143,18 +143,18 @@ HighlighterWaiter.prototype.output_scroll = function(e) {
|
|||
*
|
||||
* @param {event} e
|
||||
*/
|
||||
HighlighterWaiter.prototype.input_mousedown = function(e) {
|
||||
this.mouse_button_down = true;
|
||||
this.mouse_target = HighlighterWaiter.INPUT;
|
||||
this.remove_highlights();
|
||||
HighlighterWaiter.prototype.inputMousedown = function(e) {
|
||||
this.mouseButtonDown = true;
|
||||
this.mouseTarget = HighlighterWaiter.INPUT;
|
||||
this.removeHighlights();
|
||||
|
||||
var el = e.target,
|
||||
start = el.selectionStart,
|
||||
end = el.selectionEnd;
|
||||
|
||||
if (start !== 0 || end !== 0) {
|
||||
document.getElementById("input-selection-info").innerHTML = this.selection_info(start, end);
|
||||
this.highlight_output([{start: start, end: end}]);
|
||||
document.getElementById("input-selection-info").innerHTML = this.selectionInfo(start, end);
|
||||
this.highlightOutput([{start: start, end: end}]);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -165,18 +165,18 @@ HighlighterWaiter.prototype.input_mousedown = function(e) {
|
|||
*
|
||||
* @param {event} e
|
||||
*/
|
||||
HighlighterWaiter.prototype.output_mousedown = function(e) {
|
||||
this.mouse_button_down = true;
|
||||
this.mouse_target = HighlighterWaiter.OUTPUT;
|
||||
this.remove_highlights();
|
||||
HighlighterWaiter.prototype.outputMousedown = function(e) {
|
||||
this.mouseButtonDown = true;
|
||||
this.mouseTarget = HighlighterWaiter.OUTPUT;
|
||||
this.removeHighlights();
|
||||
|
||||
var el = e.target,
|
||||
start = el.selectionStart,
|
||||
end = el.selectionEnd;
|
||||
|
||||
if (start !== 0 || end !== 0) {
|
||||
document.getElementById("output-selection-info").innerHTML = this.selection_info(start, end);
|
||||
this.highlight_input([{start: start, end: end}]);
|
||||
document.getElementById("output-selection-info").innerHTML = this.selectionInfo(start, end);
|
||||
this.highlightInput([{start: start, end: end}]);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -187,13 +187,13 @@ HighlighterWaiter.prototype.output_mousedown = function(e) {
|
|||
*
|
||||
* @param {event} e
|
||||
*/
|
||||
HighlighterWaiter.prototype.output_html_mousedown = function(e) {
|
||||
this.mouse_button_down = true;
|
||||
this.mouse_target = HighlighterWaiter.OUTPUT;
|
||||
HighlighterWaiter.prototype.outputHtmlMousedown = function(e) {
|
||||
this.mouseButtonDown = true;
|
||||
this.mouseTarget = HighlighterWaiter.OUTPUT;
|
||||
|
||||
var sel = this._get_output_html_selection_offsets();
|
||||
var sel = this._getOutputHtmlSelectionOffsets();
|
||||
if (sel.start !== 0 || sel.end !== 0) {
|
||||
document.getElementById("output-selection-info").innerHTML = this.selection_info(sel.start, sel.end);
|
||||
document.getElementById("output-selection-info").innerHTML = this.selectionInfo(sel.start, sel.end);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -203,8 +203,8 @@ HighlighterWaiter.prototype.output_html_mousedown = function(e) {
|
|||
*
|
||||
* @param {event} e
|
||||
*/
|
||||
HighlighterWaiter.prototype.input_mouseup = function(e) {
|
||||
this.mouse_button_down = false;
|
||||
HighlighterWaiter.prototype.inputMouseup = function(e) {
|
||||
this.mouseButtonDown = false;
|
||||
};
|
||||
|
||||
|
||||
|
@ -213,8 +213,8 @@ HighlighterWaiter.prototype.input_mouseup = function(e) {
|
|||
*
|
||||
* @param {event} e
|
||||
*/
|
||||
HighlighterWaiter.prototype.output_mouseup = function(e) {
|
||||
this.mouse_button_down = false;
|
||||
HighlighterWaiter.prototype.outputMouseup = function(e) {
|
||||
this.mouseButtonDown = false;
|
||||
};
|
||||
|
||||
|
||||
|
@ -223,8 +223,8 @@ HighlighterWaiter.prototype.output_mouseup = function(e) {
|
|||
*
|
||||
* @param {event} e
|
||||
*/
|
||||
HighlighterWaiter.prototype.output_html_mouseup = function(e) {
|
||||
this.mouse_button_down = false;
|
||||
HighlighterWaiter.prototype.outputHtmlMouseup = function(e) {
|
||||
this.mouseButtonDown = false;
|
||||
};
|
||||
|
||||
|
||||
|
@ -234,11 +234,11 @@ HighlighterWaiter.prototype.output_html_mouseup = function(e) {
|
|||
*
|
||||
* @param {event} e
|
||||
*/
|
||||
HighlighterWaiter.prototype.input_mousemove = function(e) {
|
||||
HighlighterWaiter.prototype.inputMousemove = function(e) {
|
||||
// Check that the left mouse button is pressed
|
||||
if (!this.mouse_button_down ||
|
||||
if (!this.mouseButtonDown ||
|
||||
e.which !== 1 ||
|
||||
this.mouse_target !== HighlighterWaiter.INPUT)
|
||||
this.mouseTarget !== HighlighterWaiter.INPUT)
|
||||
return;
|
||||
|
||||
var el = e.target,
|
||||
|
@ -246,8 +246,8 @@ HighlighterWaiter.prototype.input_mousemove = function(e) {
|
|||
end = el.selectionEnd;
|
||||
|
||||
if (start !== 0 || end !== 0) {
|
||||
document.getElementById("input-selection-info").innerHTML = this.selection_info(start, end);
|
||||
this.highlight_output([{start: start, end: end}]);
|
||||
document.getElementById("input-selection-info").innerHTML = this.selectionInfo(start, end);
|
||||
this.highlightOutput([{start: start, end: end}]);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -258,11 +258,11 @@ HighlighterWaiter.prototype.input_mousemove = function(e) {
|
|||
*
|
||||
* @param {event} e
|
||||
*/
|
||||
HighlighterWaiter.prototype.output_mousemove = function(e) {
|
||||
HighlighterWaiter.prototype.outputMousemove = function(e) {
|
||||
// Check that the left mouse button is pressed
|
||||
if (!this.mouse_button_down ||
|
||||
if (!this.mouseButtonDown ||
|
||||
e.which !== 1 ||
|
||||
this.mouse_target !== HighlighterWaiter.OUTPUT)
|
||||
this.mouseTarget !== HighlighterWaiter.OUTPUT)
|
||||
return;
|
||||
|
||||
var el = e.target,
|
||||
|
@ -270,8 +270,8 @@ HighlighterWaiter.prototype.output_mousemove = function(e) {
|
|||
end = el.selectionEnd;
|
||||
|
||||
if (start !== 0 || end !== 0) {
|
||||
document.getElementById("output-selection-info").innerHTML = this.selection_info(start, end);
|
||||
this.highlight_input([{start: start, end: end}]);
|
||||
document.getElementById("output-selection-info").innerHTML = this.selectionInfo(start, end);
|
||||
this.highlightInput([{start: start, end: end}]);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -282,16 +282,16 @@ HighlighterWaiter.prototype.output_mousemove = function(e) {
|
|||
*
|
||||
* @param {event} e
|
||||
*/
|
||||
HighlighterWaiter.prototype.output_html_mousemove = function(e) {
|
||||
HighlighterWaiter.prototype.outputHtmlMousemove = function(e) {
|
||||
// Check that the left mouse button is pressed
|
||||
if (!this.mouse_button_down ||
|
||||
if (!this.mouseButtonDown ||
|
||||
e.which !== 1 ||
|
||||
this.mouse_target !== HighlighterWaiter.OUTPUT)
|
||||
this.mouseTarget !== HighlighterWaiter.OUTPUT)
|
||||
return;
|
||||
|
||||
var sel = this._get_output_html_selection_offsets();
|
||||
var sel = this._getOutputHtmlSelectionOffsets();
|
||||
if (sel.start !== 0 || sel.end !== 0) {
|
||||
document.getElementById("output-selection-info").innerHTML = this.selection_info(sel.start, sel.end);
|
||||
document.getElementById("output-selection-info").innerHTML = this.selectionInfo(sel.start, sel.end);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -304,21 +304,21 @@ HighlighterWaiter.prototype.output_html_mousemove = function(e) {
|
|||
* @param {number} end - The end offset.
|
||||
* @returns {string}
|
||||
*/
|
||||
HighlighterWaiter.prototype.selection_info = function(start, end) {
|
||||
HighlighterWaiter.prototype.selectionInfo = function(start, end) {
|
||||
var width = end.toString().length;
|
||||
width = width < 2 ? 2 : width;
|
||||
var start_str = Utils.pad(start.toString(), width, " ").replace(/ /g, " "),
|
||||
end_str = Utils.pad(end.toString(), width, " ").replace(/ /g, " "),
|
||||
len_str = Utils.pad((end-start).toString(), width, " ").replace(/ /g, " ");
|
||||
var startStr = Utils.pad(start.toString(), width, " ").replace(/ /g, " "),
|
||||
endStr = Utils.pad(end.toString(), width, " ").replace(/ /g, " "),
|
||||
lenStr = Utils.pad((end-start).toString(), width, " ").replace(/ /g, " ");
|
||||
|
||||
return "start: " + start_str + "<br>end: " + end_str + "<br>length: " + len_str;
|
||||
return "start: " + startStr + "<br>end: " + endStr + "<br>length: " + lenStr;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Removes highlighting and selection information.
|
||||
*/
|
||||
HighlighterWaiter.prototype.remove_highlights = function() {
|
||||
HighlighterWaiter.prototype.removeHighlights = function() {
|
||||
document.getElementById("input-highlighter").innerHTML = "";
|
||||
document.getElementById("output-highlighter").innerHTML = "";
|
||||
document.getElementById("input-selection-info").innerHTML = "";
|
||||
|
@ -335,25 +335,25 @@ HighlighterWaiter.prototype.remove_highlights = function() {
|
|||
* @returns {function} highlights[].b
|
||||
* @returns {Object[]} highlights[].args
|
||||
*/
|
||||
HighlighterWaiter.prototype.generate_highlight_list = function() {
|
||||
var recipe_config = this.app.get_recipe_config(),
|
||||
HighlighterWaiter.prototype.generateHighlightList = function() {
|
||||
var recipeConfig = this.app.getRecipeConfig(),
|
||||
highlights = [];
|
||||
|
||||
for (var i = 0; i < recipe_config.length; i++) {
|
||||
if (recipe_config[i].disabled) continue;
|
||||
for (var i = 0; i < recipeConfig.length; i++) {
|
||||
if (recipeConfig[i].disabled) continue;
|
||||
|
||||
// If any breakpoints are set, do not attempt to highlight
|
||||
if (recipe_config[i].breakpoint) return false;
|
||||
if (recipeConfig[i].breakpoint) return false;
|
||||
|
||||
var op = this.app.operations[recipe_config[i].op];
|
||||
var op = this.app.operations[recipeConfig[i].op];
|
||||
|
||||
// If any of the operations do not support highlighting, fail immediately.
|
||||
if (op.highlight === false || op.highlight === undefined) return false;
|
||||
|
||||
highlights.push({
|
||||
f: op.highlight,
|
||||
b: op.highlight_reverse,
|
||||
args: recipe_config[i].args
|
||||
b: op.highlightReverse,
|
||||
args: recipeConfig[i].args
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -372,10 +372,10 @@ HighlighterWaiter.prototype.generate_highlight_list = function() {
|
|||
* @param {number} pos.start - The start offset.
|
||||
* @param {number} pos.end - The end offset.
|
||||
*/
|
||||
HighlighterWaiter.prototype.highlight_output = function(pos) {
|
||||
var highlights = this.generate_highlight_list();
|
||||
HighlighterWaiter.prototype.highlightOutput = function(pos) {
|
||||
var highlights = this.generateHighlightList();
|
||||
|
||||
if (!highlights || !this.app.auto_bake_) {
|
||||
if (!highlights || !this.app.autoBake_) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -388,7 +388,7 @@ HighlighterWaiter.prototype.highlight_output = function(pos) {
|
|||
}
|
||||
}
|
||||
|
||||
document.getElementById("output-selection-info").innerHTML = this.selection_info(pos[0].start, pos[0].end);
|
||||
document.getElementById("output-selection-info").innerHTML = this.selectionInfo(pos[0].start, pos[0].end);
|
||||
this.highlight(
|
||||
document.getElementById("output-text"),
|
||||
document.getElementById("output-highlighter"),
|
||||
|
@ -407,10 +407,10 @@ HighlighterWaiter.prototype.highlight_output = function(pos) {
|
|||
* @param {number} pos.start - The start offset.
|
||||
* @param {number} pos.end - The end offset.
|
||||
*/
|
||||
HighlighterWaiter.prototype.highlight_input = function(pos) {
|
||||
var highlights = this.generate_highlight_list();
|
||||
HighlighterWaiter.prototype.highlightInput = function(pos) {
|
||||
var highlights = this.generateHighlightList();
|
||||
|
||||
if (!highlights || !this.app.auto_bake_) {
|
||||
if (!highlights || !this.app.autoBake_) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -423,7 +423,7 @@ HighlighterWaiter.prototype.highlight_input = function(pos) {
|
|||
}
|
||||
}
|
||||
|
||||
document.getElementById("input-selection-info").innerHTML = this.selection_info(pos[0].start, pos[0].end);
|
||||
document.getElementById("input-selection-info").innerHTML = this.selectionInfo(pos[0].start, pos[0].end);
|
||||
this.highlight(
|
||||
document.getElementById("input-text"),
|
||||
document.getElementById("input-highlighter"),
|
||||
|
@ -442,17 +442,17 @@ HighlighterWaiter.prototype.highlight_input = function(pos) {
|
|||
* @param {number} pos.end - The end offset.
|
||||
*/
|
||||
HighlighterWaiter.prototype.highlight = function(textarea, highlighter, pos) {
|
||||
if (!this.app.options.show_highlighter) return false;
|
||||
if (!this.app.options.attempt_highlight) return false;
|
||||
if (!this.app.options.showHighlighter) return false;
|
||||
if (!this.app.options.attemptHighlight) return false;
|
||||
|
||||
// Check if there is a carriage return in the output dish as this will not
|
||||
// be displayed by the HTML textarea and will mess up highlighting offsets.
|
||||
if (!this.app.dish_str || this.app.dish_str.indexOf("\r") >= 0) return false;
|
||||
if (!this.app.dishStr || this.app.dishStr.indexOf("\r") >= 0) return false;
|
||||
|
||||
var start_placeholder = "[start_highlight]",
|
||||
start_placeholder_regex = /\[start_highlight\]/g,
|
||||
end_placeholder = "[end_highlight]",
|
||||
end_placeholder_regex = /\[end_highlight\]/g,
|
||||
var startPlaceholder = "[startHighlight]",
|
||||
startPlaceholderRegex = /\[startHighlight\]/g,
|
||||
endPlaceholder = "[endHighlight]",
|
||||
endPlaceholderRegex = /\[endHighlight\]/g,
|
||||
text = textarea.value;
|
||||
|
||||
// Put placeholders in position
|
||||
|
@ -461,33 +461,33 @@ HighlighterWaiter.prototype.highlight = function(textarea, highlighter, pos) {
|
|||
if (pos.length === 1) {
|
||||
if (pos[0].end < pos[0].start) return;
|
||||
text = text.slice(0, pos[0].start) +
|
||||
start_placeholder + text.slice(pos[0].start, pos[0].end) + end_placeholder +
|
||||
startPlaceholder + text.slice(pos[0].start, pos[0].end) + endPlaceholder +
|
||||
text.slice(pos[0].end, text.length);
|
||||
} else {
|
||||
// O(n^2) - Can anyone improve this without overwriting placeholders?
|
||||
var result = "",
|
||||
end_placed = true;
|
||||
endPlaced = true;
|
||||
|
||||
for (var i = 0; i < text.length; i++) {
|
||||
for (var j = 1; j < pos.length; j++) {
|
||||
if (pos[j].end < pos[j].start) continue;
|
||||
if (pos[j].start === i) {
|
||||
result += start_placeholder;
|
||||
end_placed = false;
|
||||
result += startPlaceholder;
|
||||
endPlaced = false;
|
||||
}
|
||||
if (pos[j].end === i) {
|
||||
result += end_placeholder;
|
||||
end_placed = true;
|
||||
result += endPlaceholder;
|
||||
endPlaced = true;
|
||||
}
|
||||
}
|
||||
result += text[i];
|
||||
}
|
||||
if (!end_placed) result += end_placeholder;
|
||||
if (!endPlaced) result += endPlaceholder;
|
||||
text = result;
|
||||
}
|
||||
|
||||
var css_class = "hl1";
|
||||
//if (colour) css_class += "-"+colour;
|
||||
var cssClass = "hl1";
|
||||
//if (colour) cssClass += "-"+colour;
|
||||
|
||||
// Remove HTML tags
|
||||
text = text.replace(/&/g, "&")
|
||||
|
@ -495,8 +495,8 @@ HighlighterWaiter.prototype.highlight = function(textarea, highlighter, pos) {
|
|||
.replace(/>/g, ">")
|
||||
.replace(/\n/g, " ")
|
||||
// Convert placeholders to tags
|
||||
.replace(start_placeholder_regex, "<span class=\""+css_class+"\">")
|
||||
.replace(end_placeholder_regex, "</span>") + " ";
|
||||
.replace(startPlaceholderRegex, "<span class=\""+cssClass+"\">")
|
||||
.replace(endPlaceholderRegex, "</span>") + " ";
|
||||
|
||||
// Adjust width to allow for scrollbars
|
||||
highlighter.style.width = textarea.clientWidth + "px";
|
||||
|
|
|
@ -14,7 +14,7 @@ var InputWaiter = function(app, manager) {
|
|||
this.manager = manager;
|
||||
|
||||
// Define keys that don't change the input so we don't have to autobake when they are pressed
|
||||
this.bad_keys = [
|
||||
this.badKeys = [
|
||||
16, //Shift
|
||||
17, //Ctrl
|
||||
18, //Alt
|
||||
|
@ -62,14 +62,14 @@ InputWaiter.prototype.set = function(input) {
|
|||
* @param {number} length - The length of the current input string
|
||||
* @param {number} lines - The number of the lines in the current input string
|
||||
*/
|
||||
InputWaiter.prototype.set_input_info = function(length, lines) {
|
||||
InputWaiter.prototype.setInputInfo = function(length, lines) {
|
||||
var width = length.toString().length;
|
||||
width = width < 2 ? 2 : width;
|
||||
|
||||
var length_str = Utils.pad(length.toString(), width, " ").replace(/ /g, " ");
|
||||
var lines_str = Utils.pad(lines.toString(), width, " ").replace(/ /g, " ");
|
||||
var lengthStr = Utils.pad(length.toString(), width, " ").replace(/ /g, " ");
|
||||
var linesStr = Utils.pad(lines.toString(), width, " ").replace(/ /g, " ");
|
||||
|
||||
document.getElementById("input-info").innerHTML = "length: " + length_str + "<br>lines: " + lines_str;
|
||||
document.getElementById("input-info").innerHTML = "length: " + lengthStr + "<br>lines: " + linesStr;
|
||||
};
|
||||
|
||||
|
||||
|
@ -81,21 +81,21 @@ InputWaiter.prototype.set_input_info = function(length, lines) {
|
|||
*
|
||||
* @fires Manager#statechange
|
||||
*/
|
||||
InputWaiter.prototype.input_change = function(e) {
|
||||
InputWaiter.prototype.inputChange = function(e) {
|
||||
// Remove highlighting from input and output panes as the offsets might be different now
|
||||
this.manager.highlighter.remove_highlights();
|
||||
this.manager.highlighter.removeHighlights();
|
||||
|
||||
// Reset recipe progress as any previous processing will be redundant now
|
||||
this.app.progress = 0;
|
||||
|
||||
// Update the input metadata info
|
||||
var input_text = this.get(),
|
||||
lines = input_text.count("\n") + 1;
|
||||
var inputText = this.get(),
|
||||
lines = inputText.count("\n") + 1;
|
||||
|
||||
this.set_input_info(input_text.length, lines);
|
||||
this.setInputInfo(inputText.length, lines);
|
||||
|
||||
|
||||
if (this.bad_keys.indexOf(e.keyCode) < 0) {
|
||||
if (this.badKeys.indexOf(e.keyCode) < 0) {
|
||||
// Fire the statechange event as the input has been modified
|
||||
window.dispatchEvent(this.manager.statechange);
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ InputWaiter.prototype.input_change = function(e) {
|
|||
*
|
||||
* @param {event} e
|
||||
*/
|
||||
InputWaiter.prototype.input_dragover = function(e) {
|
||||
InputWaiter.prototype.inputDragover = function(e) {
|
||||
// This will be set if we're dragging an operation
|
||||
if (e.dataTransfer.effectAllowed === "move")
|
||||
return false;
|
||||
|
@ -125,7 +125,7 @@ InputWaiter.prototype.input_dragover = function(e) {
|
|||
*
|
||||
* @param {event} e
|
||||
*/
|
||||
InputWaiter.prototype.input_dragleave = function(e) {
|
||||
InputWaiter.prototype.inputDragleave = function(e) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
e.target.classList.remove("dropping-file");
|
||||
|
@ -138,7 +138,7 @@ InputWaiter.prototype.input_dragleave = function(e) {
|
|||
*
|
||||
* @param {event} e
|
||||
*/
|
||||
InputWaiter.prototype.input_drop = function(e) {
|
||||
InputWaiter.prototype.inputDrop = function(e) {
|
||||
// This will be set if we're dragging an operation
|
||||
if (e.dataTransfer.effectAllowed === "move")
|
||||
return false;
|
||||
|
@ -150,29 +150,29 @@ InputWaiter.prototype.input_drop = function(e) {
|
|||
file = e.dataTransfer.files[0],
|
||||
text = e.dataTransfer.getData("Text"),
|
||||
reader = new FileReader(),
|
||||
input_charcode = "",
|
||||
inputCharcode = "",
|
||||
offset = 0,
|
||||
CHUNK_SIZE = 20480; // 20KB
|
||||
|
||||
var set_input = function() {
|
||||
if (input_charcode.length > 100000 && this.app.auto_bake_) {
|
||||
this.manager.controls.set_auto_bake(false);
|
||||
var setInput = function() {
|
||||
if (inputCharcode.length > 100000 && this.app.autoBake_) {
|
||||
this.manager.controls.setAutoBake(false);
|
||||
this.app.alert("Turned off Auto Bake as the input is large", "warning", 5000);
|
||||
}
|
||||
|
||||
this.set(input_charcode);
|
||||
var recipe_config = this.app.get_recipe_config();
|
||||
if (!recipe_config[0] || recipe_config[0].op !== "From Hex") {
|
||||
recipe_config.unshift({op:"From Hex", args:["Space"]});
|
||||
this.app.set_recipe_config(recipe_config);
|
||||
this.set(inputCharcode);
|
||||
var recipeConfig = this.app.getRecipeConfig();
|
||||
if (!recipeConfig[0] || recipeConfig[0].op !== "From Hex") {
|
||||
recipeConfig.unshift({op:"From Hex", args:["Space"]});
|
||||
this.app.setRecipeConfig(recipeConfig);
|
||||
}
|
||||
|
||||
el.classList.remove("loading_file");
|
||||
el.classList.remove("loadingFile");
|
||||
}.bind(this);
|
||||
|
||||
var seek = function() {
|
||||
if (offset >= file.size) {
|
||||
set_input();
|
||||
setInput();
|
||||
return;
|
||||
}
|
||||
el.value = "Processing... " + Math.round(offset / file.size * 100) + "%";
|
||||
|
@ -182,7 +182,7 @@ InputWaiter.prototype.input_drop = function(e) {
|
|||
|
||||
reader.onload = function(e) {
|
||||
var data = new Uint8Array(reader.result);
|
||||
input_charcode += Utils.to_hex_fast(data);
|
||||
inputCharcode += Utils.toHexFast(data);
|
||||
offset += CHUNK_SIZE;
|
||||
seek();
|
||||
};
|
||||
|
@ -191,7 +191,7 @@ InputWaiter.prototype.input_drop = function(e) {
|
|||
el.classList.remove("dropping-file");
|
||||
|
||||
if (file) {
|
||||
el.classList.add("loading_file");
|
||||
el.classList.add("loadingFile");
|
||||
seek();
|
||||
} else if (text) {
|
||||
this.set(text);
|
||||
|
@ -205,8 +205,8 @@ InputWaiter.prototype.input_drop = function(e) {
|
|||
*
|
||||
* @fires Manager#statechange
|
||||
*/
|
||||
InputWaiter.prototype.clear_io_click = function() {
|
||||
this.manager.highlighter.remove_highlights();
|
||||
InputWaiter.prototype.clearIoClick = function() {
|
||||
this.manager.highlighter.removeHighlights();
|
||||
document.getElementById("input-text").value = "";
|
||||
document.getElementById("output-text").value = "";
|
||||
document.getElementById("input-info").innerHTML = "";
|
||||
|
|
|
@ -45,9 +45,9 @@ var Manager = function(app) {
|
|||
this.seasonal = new SeasonalWaiter(this.app, this);
|
||||
|
||||
// Object to store dynamic handlers to fire on elements that may not exist yet
|
||||
this.dynamic_handlers = {};
|
||||
this.dynamicHandlers = {};
|
||||
|
||||
this.initialise_event_listeners();
|
||||
this.initialiseEventListeners();
|
||||
};
|
||||
|
||||
|
||||
|
@ -55,8 +55,8 @@ var Manager = function(app) {
|
|||
* Sets up the various components and listeners.
|
||||
*/
|
||||
Manager.prototype.setup = function() {
|
||||
this.recipe.initialise_operation_drag_n_drop();
|
||||
this.controls.auto_bake_change();
|
||||
this.recipe.initialiseOperationDragNDrop();
|
||||
this.controls.autoBakeChange();
|
||||
this.seasonal.load();
|
||||
};
|
||||
|
||||
|
@ -64,87 +64,87 @@ Manager.prototype.setup = function() {
|
|||
/**
|
||||
* Main function to handle the creation of the event listeners.
|
||||
*/
|
||||
Manager.prototype.initialise_event_listeners = function() {
|
||||
Manager.prototype.initialiseEventListeners = function() {
|
||||
// Global
|
||||
window.addEventListener("resize", this.window.window_resize.bind(this.window));
|
||||
window.addEventListener("blur", this.window.window_blur.bind(this.window));
|
||||
window.addEventListener("focus", this.window.window_focus.bind(this.window));
|
||||
window.addEventListener("statechange", this.app.state_change.bind(this.app));
|
||||
window.addEventListener("popstate", this.app.pop_state.bind(this.app));
|
||||
window.addEventListener("resize", this.window.windowResize.bind(this.window));
|
||||
window.addEventListener("blur", this.window.windowBlur.bind(this.window));
|
||||
window.addEventListener("focus", this.window.windowFocus.bind(this.window));
|
||||
window.addEventListener("statechange", this.app.stateChange.bind(this.app));
|
||||
window.addEventListener("popstate", this.app.popState.bind(this.app));
|
||||
|
||||
// Controls
|
||||
document.getElementById("bake").addEventListener("click", this.controls.bake_click.bind(this.controls));
|
||||
document.getElementById("auto-bake").addEventListener("change", this.controls.auto_bake_change.bind(this.controls));
|
||||
document.getElementById("step").addEventListener("click", this.controls.step_click.bind(this.controls));
|
||||
document.getElementById("clr-recipe").addEventListener("click", this.controls.clear_recipe_click.bind(this.controls));
|
||||
document.getElementById("clr-breaks").addEventListener("click", this.controls.clear_breaks_click.bind(this.controls));
|
||||
document.getElementById("save").addEventListener("click", this.controls.save_click.bind(this.controls));
|
||||
document.getElementById("save-button").addEventListener("click", this.controls.save_button_click.bind(this.controls));
|
||||
document.getElementById("save-link-recipe-checkbox").addEventListener("change", this.controls.slr_check_change.bind(this.controls));
|
||||
document.getElementById("save-link-input-checkbox").addEventListener("change", this.controls.sli_check_change.bind(this.controls));
|
||||
document.getElementById("load").addEventListener("click", this.controls.load_click.bind(this.controls));
|
||||
document.getElementById("load-delete-button").addEventListener("click", this.controls.load_delete_click.bind(this.controls));
|
||||
document.getElementById("load-name").addEventListener("change", this.controls.load_name_change.bind(this.controls));
|
||||
document.getElementById("load-button").addEventListener("click", this.controls.load_button_click.bind(this.controls));
|
||||
this.add_multi_event_listener("#save-text", "keyup paste", this.controls.save_text_change, this.controls);
|
||||
document.getElementById("bake").addEventListener("click", this.controls.bakeClick.bind(this.controls));
|
||||
document.getElementById("auto-bake").addEventListener("change", this.controls.autoBakeChange.bind(this.controls));
|
||||
document.getElementById("step").addEventListener("click", this.controls.stepClick.bind(this.controls));
|
||||
document.getElementById("clr-recipe").addEventListener("click", this.controls.clearRecipeClick.bind(this.controls));
|
||||
document.getElementById("clr-breaks").addEventListener("click", this.controls.clearBreaksClick.bind(this.controls));
|
||||
document.getElementById("save").addEventListener("click", this.controls.saveClick.bind(this.controls));
|
||||
document.getElementById("save-button").addEventListener("click", this.controls.saveButtonClick.bind(this.controls));
|
||||
document.getElementById("save-link-recipe-checkbox").addEventListener("change", this.controls.slrCheckChange.bind(this.controls));
|
||||
document.getElementById("save-link-input-checkbox").addEventListener("change", this.controls.sliCheckChange.bind(this.controls));
|
||||
document.getElementById("load").addEventListener("click", this.controls.loadClick.bind(this.controls));
|
||||
document.getElementById("load-delete-button").addEventListener("click", this.controls.loadDeleteClick.bind(this.controls));
|
||||
document.getElementById("load-name").addEventListener("change", this.controls.loadNameChange.bind(this.controls));
|
||||
document.getElementById("load-button").addEventListener("click", this.controls.loadButtonClick.bind(this.controls));
|
||||
this.addMultiEventListener("#save-text", "keyup paste", this.controls.saveTextChange, this.controls);
|
||||
|
||||
// Operations
|
||||
this.add_multi_event_listener("#search", "keyup paste search", this.ops.search_operations, this.ops);
|
||||
this.add_dynamic_listener(".op_list li.operation", "dblclick", this.ops.operation_dblclick, this.ops);
|
||||
document.getElementById("edit-favourites").addEventListener("click", this.ops.edit_favourites_click.bind(this.ops));
|
||||
document.getElementById("save-favourites").addEventListener("click", this.ops.save_favourites_click.bind(this.ops));
|
||||
document.getElementById("reset-favourites").addEventListener("click", this.ops.reset_favourites_click.bind(this.ops));
|
||||
this.add_dynamic_listener(".op_list .op-icon", "mouseover", this.ops.op_icon_mouseover, this.ops);
|
||||
this.add_dynamic_listener(".op_list .op-icon", "mouseleave", this.ops.op_icon_mouseleave, this.ops);
|
||||
this.add_dynamic_listener(".op_list", "oplistcreate", this.ops.op_list_create, this.ops);
|
||||
this.add_dynamic_listener("li.operation", "operationadd", this.recipe.op_add.bind(this.recipe));
|
||||
this.addMultiEventListener("#search", "keyup paste search", this.ops.searchOperations, this.ops);
|
||||
this.addDynamicListener(".op-list li.operation", "dblclick", this.ops.operationDblclick, this.ops);
|
||||
document.getElementById("edit-favourites").addEventListener("click", this.ops.editFavouritesClick.bind(this.ops));
|
||||
document.getElementById("save-favourites").addEventListener("click", this.ops.saveFavouritesClick.bind(this.ops));
|
||||
document.getElementById("reset-favourites").addEventListener("click", this.ops.resetFavouritesClick.bind(this.ops));
|
||||
this.addDynamicListener(".op-list .op-icon", "mouseover", this.ops.opIconMouseover, this.ops);
|
||||
this.addDynamicListener(".op-list .op-icon", "mouseleave", this.ops.opIconMouseleave, this.ops);
|
||||
this.addDynamicListener(".op-list", "oplistcreate", this.ops.opListCreate, this.ops);
|
||||
this.addDynamicListener("li.operation", "operationadd", this.recipe.opAdd.bind(this.recipe));
|
||||
|
||||
// Recipe
|
||||
this.add_dynamic_listener(".arg", "keyup", this.recipe.ing_change, this.recipe);
|
||||
this.add_dynamic_listener(".arg", "change", this.recipe.ing_change, this.recipe);
|
||||
this.add_dynamic_listener(".disable-icon", "click", this.recipe.disable_click, this.recipe);
|
||||
this.add_dynamic_listener(".breakpoint", "click", this.recipe.breakpoint_click, this.recipe);
|
||||
this.add_dynamic_listener("#rec_list li.operation", "dblclick", this.recipe.operation_dblclick, this.recipe);
|
||||
this.add_dynamic_listener("#rec_list li.operation > div", "dblclick", this.recipe.operation_child_dblclick, this.recipe);
|
||||
this.add_dynamic_listener("#rec_list .input-group .dropdown-menu a", "click", this.recipe.dropdown_toggle_click, this.recipe);
|
||||
this.add_dynamic_listener("#rec_list", "operationremove", this.recipe.op_remove.bind(this.recipe));
|
||||
this.addDynamicListener(".arg", "keyup", this.recipe.ingChange, this.recipe);
|
||||
this.addDynamicListener(".arg", "change", this.recipe.ingChange, this.recipe);
|
||||
this.addDynamicListener(".disable-icon", "click", this.recipe.disableClick, this.recipe);
|
||||
this.addDynamicListener(".breakpoint", "click", this.recipe.breakpointClick, this.recipe);
|
||||
this.addDynamicListener("#rec-list li.operation", "dblclick", this.recipe.operationDblclick, this.recipe);
|
||||
this.addDynamicListener("#rec-list li.operation > div", "dblclick", this.recipe.operationChildDblclick, this.recipe);
|
||||
this.addDynamicListener("#rec-list .input-group .dropdown-menu a", "click", this.recipe.dropdownToggleClick, this.recipe);
|
||||
this.addDynamicListener("#rec-list", "operationremove", this.recipe.opRemove.bind(this.recipe));
|
||||
|
||||
// Input
|
||||
this.add_multi_event_listener("#input-text", "keyup paste", this.input.input_change, this.input);
|
||||
document.getElementById("reset-layout").addEventListener("click", this.app.reset_layout.bind(this.app));
|
||||
document.getElementById("clr-io").addEventListener("click", this.input.clear_io_click.bind(this.input));
|
||||
document.getElementById("input-text").addEventListener("dragover", this.input.input_dragover.bind(this.input));
|
||||
document.getElementById("input-text").addEventListener("dragleave", this.input.input_dragleave.bind(this.input));
|
||||
document.getElementById("input-text").addEventListener("drop", this.input.input_drop.bind(this.input));
|
||||
document.getElementById("input-text").addEventListener("scroll", this.highlighter.input_scroll.bind(this.highlighter));
|
||||
document.getElementById("input-text").addEventListener("mouseup", this.highlighter.input_mouseup.bind(this.highlighter));
|
||||
document.getElementById("input-text").addEventListener("mousemove", this.highlighter.input_mousemove.bind(this.highlighter));
|
||||
this.add_multi_event_listener("#input-text", "mousedown dblclick select", this.highlighter.input_mousedown, this.highlighter);
|
||||
this.addMultiEventListener("#input-text", "keyup paste", this.input.inputChange, this.input);
|
||||
document.getElementById("reset-layout").addEventListener("click", this.app.resetLayout.bind(this.app));
|
||||
document.getElementById("clr-io").addEventListener("click", this.input.clearIoClick.bind(this.input));
|
||||
document.getElementById("input-text").addEventListener("dragover", this.input.inputDragover.bind(this.input));
|
||||
document.getElementById("input-text").addEventListener("dragleave", this.input.inputDragleave.bind(this.input));
|
||||
document.getElementById("input-text").addEventListener("drop", this.input.inputDrop.bind(this.input));
|
||||
document.getElementById("input-text").addEventListener("scroll", this.highlighter.inputScroll.bind(this.highlighter));
|
||||
document.getElementById("input-text").addEventListener("mouseup", this.highlighter.inputMouseup.bind(this.highlighter));
|
||||
document.getElementById("input-text").addEventListener("mousemove", this.highlighter.inputMousemove.bind(this.highlighter));
|
||||
this.addMultiEventListener("#input-text", "mousedown dblclick select", this.highlighter.inputMousedown, this.highlighter);
|
||||
|
||||
// Output
|
||||
document.getElementById("save-to-file").addEventListener("click", this.output.save_click.bind(this.output));
|
||||
document.getElementById("switch").addEventListener("click", this.output.switch_click.bind(this.output));
|
||||
document.getElementById("undo-switch").addEventListener("click", this.output.undo_switch_click.bind(this.output));
|
||||
document.getElementById("maximise-output").addEventListener("click", this.output.maximise_output_click.bind(this.output));
|
||||
document.getElementById("output-text").addEventListener("scroll", this.highlighter.output_scroll.bind(this.highlighter));
|
||||
document.getElementById("output-text").addEventListener("mouseup", this.highlighter.output_mouseup.bind(this.highlighter));
|
||||
document.getElementById("output-text").addEventListener("mousemove", this.highlighter.output_mousemove.bind(this.highlighter));
|
||||
document.getElementById("output-html").addEventListener("mouseup", this.highlighter.output_html_mouseup.bind(this.highlighter));
|
||||
document.getElementById("output-html").addEventListener("mousemove", this.highlighter.output_html_mousemove.bind(this.highlighter));
|
||||
this.add_multi_event_listener("#output-text", "mousedown dblclick select", this.highlighter.output_mousedown, this.highlighter);
|
||||
this.add_multi_event_listener("#output-html", "mousedown dblclick select", this.highlighter.output_html_mousedown, this.highlighter);
|
||||
document.getElementById("save-to-file").addEventListener("click", this.output.saveClick.bind(this.output));
|
||||
document.getElementById("switch").addEventListener("click", this.output.switchClick.bind(this.output));
|
||||
document.getElementById("undo-switch").addEventListener("click", this.output.undoSwitchClick.bind(this.output));
|
||||
document.getElementById("maximise-output").addEventListener("click", this.output.maximiseOutputClick.bind(this.output));
|
||||
document.getElementById("output-text").addEventListener("scroll", this.highlighter.outputScroll.bind(this.highlighter));
|
||||
document.getElementById("output-text").addEventListener("mouseup", this.highlighter.outputMouseup.bind(this.highlighter));
|
||||
document.getElementById("output-text").addEventListener("mousemove", this.highlighter.outputMousemove.bind(this.highlighter));
|
||||
document.getElementById("output-html").addEventListener("mouseup", this.highlighter.outputHtmlMouseup.bind(this.highlighter));
|
||||
document.getElementById("output-html").addEventListener("mousemove", this.highlighter.outputHtmlMousemove.bind(this.highlighter));
|
||||
this.addMultiEventListener("#output-text", "mousedown dblclick select", this.highlighter.outputMousedown, this.highlighter);
|
||||
this.addMultiEventListener("#output-html", "mousedown dblclick select", this.highlighter.outputHtmlMousedown, this.highlighter);
|
||||
|
||||
// Options
|
||||
document.getElementById("options").addEventListener("click", this.options.options_click.bind(this.options));
|
||||
document.getElementById("reset-options").addEventListener("click", this.options.reset_options_click.bind(this.options));
|
||||
$(document).on("switchChange.bootstrapSwitch", ".option-item input:checkbox", this.options.switch_change.bind(this.options));
|
||||
$(document).on("switchChange.bootstrapSwitch", ".option-item input:checkbox", this.options.set_word_wrap.bind(this.options));
|
||||
this.add_dynamic_listener(".option-item input[type=number]", "keyup", this.options.number_change, this.options);
|
||||
this.add_dynamic_listener(".option-item input[type=number]", "change", this.options.number_change, this.options);
|
||||
this.add_dynamic_listener(".option-item select", "change", this.options.select_change, this.options);
|
||||
document.getElementById("options").addEventListener("click", this.options.optionsClick.bind(this.options));
|
||||
document.getElementById("reset-options").addEventListener("click", this.options.resetOptionsClick.bind(this.options));
|
||||
$(document).on("switchChange.bootstrapSwitch", ".option-item input:checkbox", this.options.switchChange.bind(this.options));
|
||||
$(document).on("switchChange.bootstrapSwitch", ".option-item input:checkbox", this.options.setWordWrap.bind(this.options));
|
||||
this.addDynamicListener(".option-item input[type=number]", "keyup", this.options.numberChange, this.options);
|
||||
this.addDynamicListener(".option-item input[type=number]", "change", this.options.numberChange, this.options);
|
||||
this.addDynamicListener(".option-item select", "change", this.options.selectChange, this.options);
|
||||
|
||||
// Misc
|
||||
document.getElementById("alert-close").addEventListener("click", this.app.alert_close_click.bind(this.app));
|
||||
document.getElementById("alert-close").addEventListener("click", this.app.alertCloseClick.bind(this.app));
|
||||
};
|
||||
|
||||
|
||||
|
@ -152,19 +152,19 @@ Manager.prototype.initialise_event_listeners = function() {
|
|||
* Adds an event listener to each element in the specified group.
|
||||
*
|
||||
* @param {string} selector - A selector string for the element group to add the event to, see
|
||||
* this.get_all()
|
||||
* @param {string} event_type - The event to listen for
|
||||
* this.getAll()
|
||||
* @param {string} eventType - The event to listen for
|
||||
* @param {function} callback - The function to execute when the event is triggered
|
||||
* @param {Object} [scope=this] - The object to bind to the callback function
|
||||
*
|
||||
* @example
|
||||
* // Calls the clickable function whenever any element with the .clickable class is clicked
|
||||
* this.add_listeners(".clickable", "click", this.clickable, this);
|
||||
* this.addListeners(".clickable", "click", this.clickable, this);
|
||||
*/
|
||||
Manager.prototype.add_listeners = function(selector, event_type, callback, scope) {
|
||||
Manager.prototype.addListeners = function(selector, eventType, callback, scope) {
|
||||
scope = scope || this;
|
||||
[].forEach.call(document.querySelectorAll(selector), function(el) {
|
||||
el.addEventListener(event_type, callback.bind(scope));
|
||||
el.addEventListener(eventType, callback.bind(scope));
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -173,17 +173,17 @@ Manager.prototype.add_listeners = function(selector, event_type, callback, scope
|
|||
* Adds multiple event listeners to the specified element.
|
||||
*
|
||||
* @param {string} selector - A selector string for the element to add the events to
|
||||
* @param {string} event_types - A space-separated string of all the event types to listen for
|
||||
* @param {string} eventTypes - A space-separated string of all the event types to listen for
|
||||
* @param {function} callback - The function to execute when the events are triggered
|
||||
* @param {Object} [scope=this] - The object to bind to the callback function
|
||||
*
|
||||
* @example
|
||||
* // Calls the search function whenever the the keyup, paste or search events are triggered on the
|
||||
* // search element
|
||||
* this.add_multi_event_listener("search", "keyup paste search", this.search, this);
|
||||
* this.addMultiEventListener("search", "keyup paste search", this.search, this);
|
||||
*/
|
||||
Manager.prototype.add_multi_event_listener = function(selector, event_types, callback, scope) {
|
||||
var evs = event_types.split(" ");
|
||||
Manager.prototype.addMultiEventListener = function(selector, eventTypes, callback, scope) {
|
||||
var evs = eventTypes.split(" ");
|
||||
for (var i = 0; i < evs.length; i++) {
|
||||
document.querySelector(selector).addEventListener(evs[i], callback.bind(scope));
|
||||
}
|
||||
|
@ -194,19 +194,19 @@ Manager.prototype.add_multi_event_listener = function(selector, event_types, cal
|
|||
* Adds multiple event listeners to each element in the specified group.
|
||||
*
|
||||
* @param {string} selector - A selector string for the element group to add the events to
|
||||
* @param {string} event_types - A space-separated string of all the event types to listen for
|
||||
* @param {string} eventTypes - A space-separated string of all the event types to listen for
|
||||
* @param {function} callback - The function to execute when the events are triggered
|
||||
* @param {Object} [scope=this] - The object to bind to the callback function
|
||||
*
|
||||
* @example
|
||||
* // Calls the save function whenever the the keyup or paste events are triggered on any element
|
||||
* // with the .saveable class
|
||||
* this.add_multi_event_listener(".saveable", "keyup paste", this.save, this);
|
||||
* this.addMultiEventListener(".saveable", "keyup paste", this.save, this);
|
||||
*/
|
||||
Manager.prototype.add_multi_event_listeners = function(selector, event_types, callback, scope) {
|
||||
var evs = event_types.split(" ");
|
||||
Manager.prototype.addMultiEventListeners = function(selector, eventTypes, callback, scope) {
|
||||
var evs = eventTypes.split(" ");
|
||||
for (var i = 0; i < evs.length; i++) {
|
||||
this.add_listeners(selector, evs[i], callback, scope);
|
||||
this.addListeners(selector, evs[i], callback, scope);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -216,28 +216,28 @@ Manager.prototype.add_multi_event_listeners = function(selector, event_types, ca
|
|||
* may not exist in the DOM yet.
|
||||
*
|
||||
* @param {string} selector - A selector string for the element(s) to add the event to
|
||||
* @param {string} event_type - The event(s) to listen for
|
||||
* @param {string} eventType - The event(s) to listen for
|
||||
* @param {function} callback - The function to execute when the event(s) is/are triggered
|
||||
* @param {Object} [scope=this] - The object to bind to the callback function
|
||||
*
|
||||
* @example
|
||||
* // Pops up an alert whenever any button is clicked, even if it is added to the DOM after this
|
||||
* // listener is created
|
||||
* this.add_dynamic_listener("button", "click", alert, this);
|
||||
* this.addDynamicListener("button", "click", alert, this);
|
||||
*/
|
||||
Manager.prototype.add_dynamic_listener = function(selector, event_type, callback, scope) {
|
||||
var event_config = {
|
||||
Manager.prototype.addDynamicListener = function(selector, eventType, callback, scope) {
|
||||
var eventConfig = {
|
||||
selector: selector,
|
||||
callback: callback.bind(scope || this)
|
||||
};
|
||||
|
||||
if (this.dynamic_handlers.hasOwnProperty(event_type)) {
|
||||
if (this.dynamicHandlers.hasOwnProperty(eventType)) {
|
||||
// Listener already exists, add new handler to the appropriate list
|
||||
this.dynamic_handlers[event_type].push(event_config);
|
||||
this.dynamicHandlers[eventType].push(eventConfig);
|
||||
} else {
|
||||
this.dynamic_handlers[event_type] = [event_config];
|
||||
this.dynamicHandlers[eventType] = [eventConfig];
|
||||
// Set up listener for this new type
|
||||
document.addEventListener(event_type, this.dynamic_listener_handler.bind(this));
|
||||
document.addEventListener(eventType, this.dynamicListenerHandler.bind(this));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -248,8 +248,8 @@ Manager.prototype.add_dynamic_listener = function(selector, event_type, callback
|
|||
*
|
||||
* @param {Event} e - The event to be handled
|
||||
*/
|
||||
Manager.prototype.dynamic_listener_handler = function(e) {
|
||||
var handlers = this.dynamic_handlers[e.type],
|
||||
Manager.prototype.dynamicListenerHandler = function(e) {
|
||||
var handlers = this.dynamicHandlers[e.type],
|
||||
matches = e.target.matches ||
|
||||
e.target.webkitMatchesSelector ||
|
||||
e.target.mozMatchesSelector ||
|
||||
|
|
|
@ -16,7 +16,7 @@ var OperationsWaiter = function(app, manager) {
|
|||
this.manager = manager;
|
||||
|
||||
this.options = {};
|
||||
this.remove_intent = false;
|
||||
this.removeIntent = false;
|
||||
};
|
||||
|
||||
|
||||
|
@ -26,17 +26,17 @@ var OperationsWaiter = function(app, manager) {
|
|||
*
|
||||
* @param {event} e
|
||||
*/
|
||||
OperationsWaiter.prototype.search_operations = function(e) {
|
||||
OperationsWaiter.prototype.searchOperations = function(e) {
|
||||
var ops, selected;
|
||||
|
||||
if (e.type === "search") { // Search
|
||||
e.preventDefault();
|
||||
ops = document.querySelectorAll("#search-results li");
|
||||
if (ops.length) {
|
||||
selected = this.get_selected_op(ops);
|
||||
selected = this.getSelectedOp(ops);
|
||||
if (selected > -1) {
|
||||
this.manager.recipe.add_operation(ops[selected].innerHTML);
|
||||
this.app.auto_bake();
|
||||
this.manager.recipe.addOperation(ops[selected].innerHTML);
|
||||
this.app.autoBake();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ OperationsWaiter.prototype.search_operations = function(e) {
|
|||
e.preventDefault();
|
||||
ops = document.querySelectorAll("#search-results li");
|
||||
if (ops.length) {
|
||||
selected = this.get_selected_op(ops);
|
||||
selected = this.getSelectedOp(ops);
|
||||
if (selected > -1) {
|
||||
ops[selected].classList.remove("selected-op");
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ OperationsWaiter.prototype.search_operations = function(e) {
|
|||
e.preventDefault();
|
||||
ops = document.querySelectorAll("#search-results li");
|
||||
if (ops.length) {
|
||||
selected = this.get_selected_op(ops);
|
||||
selected = this.getSelectedOp(ops);
|
||||
if (selected > -1) {
|
||||
ops[selected].classList.remove("selected-op");
|
||||
}
|
||||
|
@ -66,26 +66,26 @@ OperationsWaiter.prototype.search_operations = function(e) {
|
|||
ops[selected-1].classList.add("selected-op");
|
||||
}
|
||||
} else {
|
||||
var search_results_el = document.getElementById("search-results"),
|
||||
var searchResultsEl = document.getElementById("search-results"),
|
||||
el = e.target,
|
||||
str = el.value;
|
||||
|
||||
while (search_results_el.firstChild) {
|
||||
$(search_results_el.firstChild).popover("destroy");
|
||||
search_results_el.removeChild(search_results_el.firstChild);
|
||||
while (searchResultsEl.firstChild) {
|
||||
$(searchResultsEl.firstChild).popover("destroy");
|
||||
searchResultsEl.removeChild(searchResultsEl.firstChild);
|
||||
}
|
||||
|
||||
$("#categories .in").collapse("hide");
|
||||
if (str) {
|
||||
var matched_ops = this.filter_operations(str, true),
|
||||
matched_ops_html = "";
|
||||
var matchedOps = this.filterOperations(str, true),
|
||||
matchedOpsHtml = "";
|
||||
|
||||
for (var i = 0; i < matched_ops.length; i++) {
|
||||
matched_ops_html += matched_ops[i].to_stub_html();
|
||||
for (var i = 0; i < matchedOps.length; i++) {
|
||||
matchedOpsHtml += matchedOps[i].toStubHtml();
|
||||
}
|
||||
|
||||
search_results_el.innerHTML = matched_ops_html;
|
||||
search_results_el.dispatchEvent(this.manager.oplistcreate);
|
||||
searchResultsEl.innerHTML = matchedOpsHtml;
|
||||
searchResultsEl.dispatchEvent(this.manager.oplistcreate);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -94,37 +94,37 @@ OperationsWaiter.prototype.search_operations = function(e) {
|
|||
/**
|
||||
* Filters operations based on the search string and returns the matching ones.
|
||||
*
|
||||
* @param {string} search_str
|
||||
* @param {string} searchStr
|
||||
* @param {boolean} highlight - Whether or not to highlight the matching string in the operation
|
||||
* name and description
|
||||
* @returns {string[]}
|
||||
*/
|
||||
OperationsWaiter.prototype.filter_operations = function(search_str, highlight) {
|
||||
var matched_ops = [],
|
||||
matched_descs = [];
|
||||
OperationsWaiter.prototype.filterOperations = function(searchStr, highlight) {
|
||||
var matchedOps = [],
|
||||
matchedDescs = [];
|
||||
|
||||
search_str = search_str.toLowerCase();
|
||||
searchStr = searchStr.toLowerCase();
|
||||
|
||||
for (var op_name in this.app.operations) {
|
||||
var op = this.app.operations[op_name],
|
||||
name_pos = op_name.toLowerCase().indexOf(search_str),
|
||||
desc_pos = op.description.toLowerCase().indexOf(search_str);
|
||||
for (var opName in this.app.operations) {
|
||||
var op = this.app.operations[opName],
|
||||
namePos = opName.toLowerCase().indexOf(searchStr),
|
||||
descPos = op.description.toLowerCase().indexOf(searchStr);
|
||||
|
||||
if (name_pos >= 0 || desc_pos >= 0) {
|
||||
var operation = new HTMLOperation(op_name, this.app.operations[op_name], this.app, this.manager);
|
||||
if (namePos >= 0 || descPos >= 0) {
|
||||
var operation = new HTMLOperation(opName, this.app.operations[opName], this.app, this.manager);
|
||||
if (highlight) {
|
||||
operation.highlight_search_string(search_str, name_pos, desc_pos);
|
||||
operation.highlightSearchString(searchStr, namePos, descPos);
|
||||
}
|
||||
|
||||
if (name_pos < 0) {
|
||||
matched_ops.push(operation);
|
||||
if (namePos < 0) {
|
||||
matchedOps.push(operation);
|
||||
} else {
|
||||
matched_descs.push(operation);
|
||||
matchedDescs.push(operation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return matched_descs.concat(matched_ops);
|
||||
return matchedDescs.concat(matchedOps);
|
||||
};
|
||||
|
||||
|
||||
|
@ -135,7 +135,7 @@ OperationsWaiter.prototype.filter_operations = function(search_str, highlight) {
|
|||
* @param {element[]} ops
|
||||
* @returns {number}
|
||||
*/
|
||||
OperationsWaiter.prototype.get_selected_op = function(ops) {
|
||||
OperationsWaiter.prototype.getSelectedOp = function(ops) {
|
||||
for (var i = 0; i < ops.length; i++) {
|
||||
if (ops[i].classList.contains("selected-op")) {
|
||||
return i;
|
||||
|
@ -151,8 +151,8 @@ OperationsWaiter.prototype.get_selected_op = function(ops) {
|
|||
* @listens Manager#oplistcreate
|
||||
* @param {event} e
|
||||
*/
|
||||
OperationsWaiter.prototype.op_list_create = function(e) {
|
||||
this.manager.recipe.create_sortable_seed_list(e.target);
|
||||
OperationsWaiter.prototype.opListCreate = function(e) {
|
||||
this.manager.recipe.createSortableSeedList(e.target);
|
||||
$("[data-toggle=popover]").popover();
|
||||
};
|
||||
|
||||
|
@ -163,11 +163,11 @@ OperationsWaiter.prototype.op_list_create = function(e) {
|
|||
*
|
||||
* @param {event} e
|
||||
*/
|
||||
OperationsWaiter.prototype.operation_dblclick = function(e) {
|
||||
OperationsWaiter.prototype.operationDblclick = function(e) {
|
||||
var li = e.target;
|
||||
|
||||
this.manager.recipe.add_operation(li.textContent);
|
||||
this.app.auto_bake();
|
||||
this.manager.recipe.addOperation(li.textContent);
|
||||
this.app.autoBake();
|
||||
};
|
||||
|
||||
|
||||
|
@ -177,46 +177,46 @@ OperationsWaiter.prototype.operation_dblclick = function(e) {
|
|||
*
|
||||
* @param {event} e
|
||||
*/
|
||||
OperationsWaiter.prototype.edit_favourites_click = function(e) {
|
||||
OperationsWaiter.prototype.editFavouritesClick = function(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
// Add favourites to modal
|
||||
var fav_cat = this.app.categories.filter(function(c) {
|
||||
var favCat = this.app.categories.filter(function(c) {
|
||||
return c.name === "Favourites";
|
||||
})[0];
|
||||
|
||||
var html = "";
|
||||
for (var i = 0; i < fav_cat.ops.length; i++) {
|
||||
var op_name = fav_cat.ops[i];
|
||||
var operation = new HTMLOperation(op_name, this.app.operations[op_name], this.app, this.manager);
|
||||
html += operation.to_stub_html(true);
|
||||
for (var i = 0; i < favCat.ops.length; i++) {
|
||||
var opName = favCat.ops[i];
|
||||
var operation = new HTMLOperation(opName, this.app.operations[opName], this.app, this.manager);
|
||||
html += operation.toStubHtml(true);
|
||||
}
|
||||
|
||||
var edit_favourites_list = document.getElementById("edit-favourites-list");
|
||||
edit_favourites_list.innerHTML = html;
|
||||
this.remove_intent = false;
|
||||
var editFavouritesList = document.getElementById("edit-favourites-list");
|
||||
editFavouritesList.innerHTML = html;
|
||||
this.removeIntent = false;
|
||||
|
||||
var editable_list = Sortable.create(edit_favourites_list, {
|
||||
var editableList = Sortable.create(editFavouritesList, {
|
||||
filter: ".remove-icon",
|
||||
onFilter: function (evt) {
|
||||
var el = editable_list.closest(evt.item);
|
||||
var el = editableList.closest(evt.item);
|
||||
if (el) {
|
||||
$(el).popover("destroy");
|
||||
el.parentNode.removeChild(el);
|
||||
}
|
||||
},
|
||||
onEnd: function(evt) {
|
||||
if (this.remove_intent) evt.item.remove();
|
||||
if (this.removeIntent) evt.item.remove();
|
||||
}.bind(this),
|
||||
});
|
||||
|
||||
Sortable.utils.on(edit_favourites_list, "dragleave", function() {
|
||||
this.remove_intent = true;
|
||||
Sortable.utils.on(editFavouritesList, "dragleave", function() {
|
||||
this.removeIntent = true;
|
||||
}.bind(this));
|
||||
|
||||
Sortable.utils.on(edit_favourites_list, "dragover", function() {
|
||||
this.remove_intent = false;
|
||||
Sortable.utils.on(editFavouritesList, "dragover", function() {
|
||||
this.removeIntent = false;
|
||||
}.bind(this));
|
||||
|
||||
$("#edit-favourites-list [data-toggle=popover]").popover();
|
||||
|
@ -228,18 +228,18 @@ OperationsWaiter.prototype.edit_favourites_click = function(e) {
|
|||
* Handler for save favourites click events.
|
||||
* Saves the selected favourites and reloads them.
|
||||
*/
|
||||
OperationsWaiter.prototype.save_favourites_click = function() {
|
||||
var favourites_list = [],
|
||||
OperationsWaiter.prototype.saveFavouritesClick = function() {
|
||||
var favouritesList = [],
|
||||
favs = document.querySelectorAll("#edit-favourites-list li");
|
||||
|
||||
for (var i = 0; i < favs.length; i++) {
|
||||
favourites_list.push(favs[i].textContent);
|
||||
favouritesList.push(favs[i].textContent);
|
||||
}
|
||||
|
||||
this.app.save_favourites(favourites_list);
|
||||
this.app.load_favourites();
|
||||
this.app.populate_operations_list();
|
||||
this.manager.recipe.initialise_operation_drag_n_drop();
|
||||
this.app.saveFavourites(favouritesList);
|
||||
this.app.loadFavourites();
|
||||
this.app.populateOperationsList();
|
||||
this.manager.recipe.initialiseOperationDragNDrop();
|
||||
};
|
||||
|
||||
|
||||
|
@ -247,37 +247,37 @@ OperationsWaiter.prototype.save_favourites_click = function() {
|
|||
* Handler for reset favourites click events.
|
||||
* Resets favourites to their defaults.
|
||||
*/
|
||||
OperationsWaiter.prototype.reset_favourites_click = function() {
|
||||
this.app.reset_favourites();
|
||||
OperationsWaiter.prototype.resetFavouritesClick = function() {
|
||||
this.app.resetFavourites();
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Handler for op_icon mouseover events.
|
||||
* Handler for opIcon mouseover events.
|
||||
* Hides any popovers already showing on the operation so that there aren't two at once.
|
||||
*
|
||||
* @param {event} e
|
||||
*/
|
||||
OperationsWaiter.prototype.op_icon_mouseover = function(e) {
|
||||
var op_el = e.target.parentNode;
|
||||
OperationsWaiter.prototype.opIconMouseover = function(e) {
|
||||
var opEl = e.target.parentNode;
|
||||
if (e.target.getAttribute("data-toggle") === "popover") {
|
||||
$(op_el).popover("hide");
|
||||
$(opEl).popover("hide");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Handler for op_icon mouseleave events.
|
||||
* Handler for opIcon mouseleave events.
|
||||
* If this icon created a popover and we're moving back to the operation element, display the
|
||||
* operation popover again.
|
||||
*
|
||||
* @param {event} e
|
||||
*/
|
||||
OperationsWaiter.prototype.op_icon_mouseleave = function(e) {
|
||||
var op_el = e.target.parentNode,
|
||||
to_el = e.toElement || e.relatedElement;
|
||||
OperationsWaiter.prototype.opIconMouseleave = function(e) {
|
||||
var opEl = e.target.parentNode,
|
||||
toEl = e.toElement || e.relatedElement;
|
||||
|
||||
if (e.target.getAttribute("data-toggle") === "popover" && to_el === op_el) {
|
||||
$(op_el).popover("show");
|
||||
if (e.target.getAttribute("data-toggle") === "popover" && toEl === opEl) {
|
||||
$(opEl).popover("show");
|
||||
}
|
||||
};
|
||||
|
|
|
@ -52,7 +52,7 @@ OptionsWaiter.prototype.load = function(options) {
|
|||
* Handler for options click events.
|
||||
* Dispays the options pane.
|
||||
*/
|
||||
OptionsWaiter.prototype.options_click = function() {
|
||||
OptionsWaiter.prototype.optionsClick = function() {
|
||||
$("#options-modal").modal();
|
||||
};
|
||||
|
||||
|
@ -61,7 +61,7 @@ OptionsWaiter.prototype.options_click = function() {
|
|||
* Handler for reset options click events.
|
||||
* Resets options back to their default values.
|
||||
*/
|
||||
OptionsWaiter.prototype.reset_options_click = function() {
|
||||
OptionsWaiter.prototype.resetOptionsClick = function() {
|
||||
this.load(this.app.doptions);
|
||||
};
|
||||
|
||||
|
@ -73,7 +73,7 @@ OptionsWaiter.prototype.reset_options_click = function() {
|
|||
* @param {event} e
|
||||
* @param {boolean} state
|
||||
*/
|
||||
OptionsWaiter.prototype.switch_change = function(e, state) {
|
||||
OptionsWaiter.prototype.switchChange = function(e, state) {
|
||||
var el = e.target,
|
||||
option = el.getAttribute("option");
|
||||
|
||||
|
@ -88,7 +88,7 @@ OptionsWaiter.prototype.switch_change = function(e, state) {
|
|||
*
|
||||
* @param {event} e
|
||||
*/
|
||||
OptionsWaiter.prototype.number_change = function(e) {
|
||||
OptionsWaiter.prototype.numberChange = function(e) {
|
||||
var el = e.target,
|
||||
option = el.getAttribute("option");
|
||||
|
||||
|
@ -103,7 +103,7 @@ OptionsWaiter.prototype.number_change = function(e) {
|
|||
*
|
||||
* @param {event} e
|
||||
*/
|
||||
OptionsWaiter.prototype.select_change = function(e) {
|
||||
OptionsWaiter.prototype.selectChange = function(e) {
|
||||
var el = e.target,
|
||||
option = el.getAttribute("option");
|
||||
|
||||
|
@ -113,16 +113,16 @@ OptionsWaiter.prototype.select_change = function(e) {
|
|||
|
||||
|
||||
/**
|
||||
* Sets or unsets word wrap on the input and output depending on the word_wrap option value.
|
||||
* Sets or unsets word wrap on the input and output depending on the wordWrap option value.
|
||||
*/
|
||||
OptionsWaiter.prototype.set_word_wrap = function() {
|
||||
OptionsWaiter.prototype.setWordWrap = function() {
|
||||
document.getElementById("input-text").classList.remove("word-wrap");
|
||||
document.getElementById("output-text").classList.remove("word-wrap");
|
||||
document.getElementById("output-html").classList.remove("word-wrap");
|
||||
document.getElementById("input-highlighter").classList.remove("word-wrap");
|
||||
document.getElementById("output-highlighter").classList.remove("word-wrap");
|
||||
|
||||
if (!this.app.options.word_wrap) {
|
||||
if (!this.app.options.wordWrap) {
|
||||
document.getElementById("input-text").classList.add("word-wrap");
|
||||
document.getElementById("output-text").classList.add("word-wrap");
|
||||
document.getElementById("output-html").classList.add("word-wrap");
|
||||
|
|
|
@ -28,47 +28,47 @@ OutputWaiter.prototype.get = function() {
|
|||
/**
|
||||
* Sets the output in the output textarea.
|
||||
*
|
||||
* @param {string} data_str - The output string/HTML
|
||||
* @param {string} dataStr - The output string/HTML
|
||||
* @param {string} type - The data type of the output
|
||||
* @param {number} duration - The length of time (ms) it took to generate the output
|
||||
*/
|
||||
OutputWaiter.prototype.set = function(data_str, type, duration) {
|
||||
var output_text = document.getElementById("output-text"),
|
||||
output_html = document.getElementById("output-html"),
|
||||
output_highlighter = document.getElementById("output-highlighter"),
|
||||
input_highlighter = document.getElementById("input-highlighter");
|
||||
OutputWaiter.prototype.set = function(dataStr, type, duration) {
|
||||
var outputText = document.getElementById("output-text"),
|
||||
outputHtml = document.getElementById("output-html"),
|
||||
outputHighlighter = document.getElementById("output-highlighter"),
|
||||
inputHighlighter = document.getElementById("input-highlighter");
|
||||
|
||||
if (type === "html") {
|
||||
output_text.style.display = "none";
|
||||
output_html.style.display = "block";
|
||||
output_highlighter.display = "none";
|
||||
input_highlighter.display = "none";
|
||||
outputText.style.display = "none";
|
||||
outputHtml.style.display = "block";
|
||||
outputHighlighter.display = "none";
|
||||
inputHighlighter.display = "none";
|
||||
|
||||
output_text.value = "";
|
||||
output_html.innerHTML = data_str;
|
||||
outputText.value = "";
|
||||
outputHtml.innerHTML = dataStr;
|
||||
|
||||
// Execute script sections
|
||||
var script_elements = output_html.querySelectorAll("script");
|
||||
for (var i = 0; i < script_elements.length; i++) {
|
||||
var scriptElements = outputHtml.querySelectorAll("script");
|
||||
for (var i = 0; i < scriptElements.length; i++) {
|
||||
try {
|
||||
eval(script_elements[i].innerHTML); // eslint-disable-line no-eval
|
||||
eval(scriptElements[i].innerHTML); // eslint-disable-line no-eval
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
output_text.style.display = "block";
|
||||
output_html.style.display = "none";
|
||||
output_highlighter.display = "block";
|
||||
input_highlighter.display = "block";
|
||||
outputText.style.display = "block";
|
||||
outputHtml.style.display = "none";
|
||||
outputHighlighter.display = "block";
|
||||
inputHighlighter.display = "block";
|
||||
|
||||
output_text.value = Utils.printable(data_str, true);
|
||||
output_html.innerHTML = "";
|
||||
outputText.value = Utils.printable(dataStr, true);
|
||||
outputHtml.innerHTML = "";
|
||||
}
|
||||
|
||||
this.manager.highlighter.remove_highlights();
|
||||
var lines = data_str.count("\n") + 1;
|
||||
this.set_output_info(data_str.length, lines, duration);
|
||||
this.manager.highlighter.removeHighlights();
|
||||
var lines = dataStr.count("\n") + 1;
|
||||
this.setOutputInfo(dataStr.length, lines, duration);
|
||||
};
|
||||
|
||||
|
||||
|
@ -79,17 +79,17 @@ OutputWaiter.prototype.set = function(data_str, type, duration) {
|
|||
* @param {number} lines - The number of the lines in the current output string
|
||||
* @param {number} duration - The length of time (ms) it took to generate the output
|
||||
*/
|
||||
OutputWaiter.prototype.set_output_info = function(length, lines, duration) {
|
||||
OutputWaiter.prototype.setOutputInfo = function(length, lines, duration) {
|
||||
var width = length.toString().length;
|
||||
width = width < 4 ? 4 : width;
|
||||
|
||||
var length_str = Utils.pad(length.toString(), width, " ").replace(/ /g, " ");
|
||||
var lines_str = Utils.pad(lines.toString(), width, " ").replace(/ /g, " ");
|
||||
var time_str = Utils.pad(duration.toString() + "ms", width, " ").replace(/ /g, " ");
|
||||
var lengthStr = Utils.pad(length.toString(), width, " ").replace(/ /g, " ");
|
||||
var linesStr = Utils.pad(lines.toString(), width, " ").replace(/ /g, " ");
|
||||
var timeStr = Utils.pad(duration.toString() + "ms", width, " ").replace(/ /g, " ");
|
||||
|
||||
document.getElementById("output-info").innerHTML = "time: " + time_str +
|
||||
"<br>length: " + length_str +
|
||||
"<br>lines: " + lines_str;
|
||||
document.getElementById("output-info").innerHTML = "time: " + timeStr +
|
||||
"<br>length: " + lengthStr +
|
||||
"<br>lines: " + linesStr;
|
||||
document.getElementById("input-selection-info").innerHTML = "";
|
||||
document.getElementById("output-selection-info").innerHTML = "";
|
||||
};
|
||||
|
@ -99,24 +99,24 @@ OutputWaiter.prototype.set_output_info = function(length, lines, duration) {
|
|||
* Adjusts the display properties of the output buttons so that they fit within the current width
|
||||
* without wrapping or overflowing.
|
||||
*/
|
||||
OutputWaiter.prototype.adjust_width = function() {
|
||||
var output = document.getElementById("output"),
|
||||
save_to_file = document.getElementById("save-to-file"),
|
||||
switch_io = document.getElementById("switch"),
|
||||
undo_switch = document.getElementById("undo-switch"),
|
||||
maximise_output = document.getElementById("maximise-output");
|
||||
OutputWaiter.prototype.adjustWidth = function() {
|
||||
var output = document.getElementById("output"),
|
||||
saveToFile = document.getElementById("save-to-file"),
|
||||
switchIO = document.getElementById("switch"),
|
||||
undoSwitch = document.getElementById("undo-switch"),
|
||||
maximiseOutput = document.getElementById("maximise-output");
|
||||
|
||||
if (output.clientWidth < 680) {
|
||||
save_to_file.childNodes[1].nodeValue = "";
|
||||
switch_io.childNodes[1].nodeValue = "";
|
||||
undo_switch.childNodes[1].nodeValue = "";
|
||||
maximise_output.childNodes[1].nodeValue = "";
|
||||
saveToFile.childNodes[1].nodeValue = "";
|
||||
switchIO.childNodes[1].nodeValue = "";
|
||||
undoSwitch.childNodes[1].nodeValue = "";
|
||||
maximiseOutput.childNodes[1].nodeValue = "";
|
||||
} else {
|
||||
save_to_file.childNodes[1].nodeValue = " Save to file";
|
||||
switch_io.childNodes[1].nodeValue = " Move output to input";
|
||||
undo_switch.childNodes[1].nodeValue = " Undo";
|
||||
maximise_output.childNodes[1].nodeValue =
|
||||
maximise_output.getAttribute("title") === "Maximise" ? " Max" : " Restore";
|
||||
saveToFile.childNodes[1].nodeValue = " Save to file";
|
||||
switchIO.childNodes[1].nodeValue = " Move output to input";
|
||||
undoSwitch.childNodes[1].nodeValue = " Undo";
|
||||
maximiseOutput.childNodes[1].nodeValue =
|
||||
maximiseOutput.getAttribute("title") === "Maximise" ? " Max" : " Restore";
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -125,8 +125,8 @@ OutputWaiter.prototype.adjust_width = function() {
|
|||
* Handler for save click events.
|
||||
* Saves the current output to a file, downloaded as a URL octet stream.
|
||||
*/
|
||||
OutputWaiter.prototype.save_click = function() {
|
||||
var data = Utils.to_base64(this.app.dish_str),
|
||||
OutputWaiter.prototype.saveClick = function() {
|
||||
var data = Utils.toBase64(this.app.dishStr),
|
||||
filename = window.prompt("Please enter a filename:", "download.dat");
|
||||
|
||||
if (filename) {
|
||||
|
@ -148,10 +148,10 @@ OutputWaiter.prototype.save_click = function() {
|
|||
* Handler for switch click events.
|
||||
* Moves the current output into the input textarea.
|
||||
*/
|
||||
OutputWaiter.prototype.switch_click = function() {
|
||||
this.switch_orig_data = this.manager.input.get();
|
||||
OutputWaiter.prototype.switchClick = function() {
|
||||
this.switchOrigData = this.manager.input.get();
|
||||
document.getElementById("undo-switch").disabled = false;
|
||||
this.app.set_input(this.app.dish_str);
|
||||
this.app.setInput(this.app.dishStr);
|
||||
};
|
||||
|
||||
|
||||
|
@ -159,8 +159,8 @@ OutputWaiter.prototype.switch_click = function() {
|
|||
* Handler for undo switch click events.
|
||||
* Removes the output from the input and replaces the input that was removed.
|
||||
*/
|
||||
OutputWaiter.prototype.undo_switch_click = function() {
|
||||
this.app.set_input(this.switch_orig_data);
|
||||
OutputWaiter.prototype.undoSwitchClick = function() {
|
||||
this.app.setInput(this.switchOrigData);
|
||||
document.getElementById("undo-switch").disabled = true;
|
||||
};
|
||||
|
||||
|
@ -169,20 +169,20 @@ OutputWaiter.prototype.undo_switch_click = function() {
|
|||
* Handler for maximise output click events.
|
||||
* Resizes the output frame to be as large as possible, or restores it to its original size.
|
||||
*/
|
||||
OutputWaiter.prototype.maximise_output_click = function(e) {
|
||||
OutputWaiter.prototype.maximiseOutputClick = function(e) {
|
||||
var el = e.target.id === "maximise-output" ? e.target : e.target.parentNode;
|
||||
|
||||
if (el.getAttribute("title") === "Maximise") {
|
||||
this.app.column_splitter.collapse(0);
|
||||
this.app.column_splitter.collapse(1);
|
||||
this.app.io_splitter.collapse(0);
|
||||
this.app.columnSplitter.collapse(0);
|
||||
this.app.columnSplitter.collapse(1);
|
||||
this.app.ioSplitter.collapse(0);
|
||||
|
||||
el.setAttribute("title", "Restore");
|
||||
el.innerHTML = "<img src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAlUlEQVQ4y93RwQpBQRQG4C9ba1fxBteGPIj38BTejFJKLFnwCJIiCsW1mcV0k9yx82/OzGK+OXMGOpiiLTFjFNiilQI0sQ7IJiAjLKsgGVYB2YdaVO0kwy46/BVQi9ZDNPyQWen2ub/KufS8y7shfkq9tF9U7SC+/YluKvAI9YZeFeCECXJcA3JHP2WgMXJM/ZUcBwxeM+YuSWTgMtUAAAAASUVORK5CYII='> Restore";
|
||||
this.adjust_width();
|
||||
this.adjustWidth();
|
||||
} else {
|
||||
el.setAttribute("title", "Maximise");
|
||||
el.innerHTML = "<img src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAi0lEQVQ4y83TMQrCQBCF4S+5g4rJEdJ7KE+RQ1lrIQQCllroEULuoM0Ww3a7aXwwLAzMPzDvLcz4hnooUItT1rsoVNy+4lgLWNL7RlcCmDBij2eCfNCrUITc0dRCrhj8m5otw0O6SV8LuAV3uhrAAa8sJ2Np7KPFawhgscVLjH9bCDhjt8WNKft88w/HjCvuVqu53QAAAABJRU5ErkJggg=='> Max";
|
||||
this.app.reset_layout();
|
||||
this.app.resetLayout();
|
||||
}
|
||||
};
|
||||
|
|
|
@ -14,79 +14,79 @@
|
|||
var RecipeWaiter = function(app, manager) {
|
||||
this.app = app;
|
||||
this.manager = manager;
|
||||
this.remove_intent = false;
|
||||
this.removeIntent = false;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Sets up the drag and drop capability for operations in the operations and recipe areas.
|
||||
*/
|
||||
RecipeWaiter.prototype.initialise_operation_drag_n_drop = function() {
|
||||
var rec_list = document.getElementById("rec_list");
|
||||
RecipeWaiter.prototype.initialiseOperationDragNDrop = function() {
|
||||
var recList = document.getElementById("rec-list");
|
||||
|
||||
|
||||
// Recipe list
|
||||
Sortable.create(rec_list, {
|
||||
Sortable.create(recList, {
|
||||
group: "recipe",
|
||||
sort: true,
|
||||
animation: 0,
|
||||
delay: 0,
|
||||
filter: ".arg-input,.arg", // Relies on commenting out a line in Sortable.js which calls evt.preventDefault()
|
||||
setData: function(dataTransfer, drag_el) {
|
||||
dataTransfer.setData("Text", drag_el.querySelector(".arg-title").textContent);
|
||||
setData: function(dataTransfer, dragEl) {
|
||||
dataTransfer.setData("Text", dragEl.querySelector(".arg-title").textContent);
|
||||
},
|
||||
onEnd: function(evt) {
|
||||
if (this.remove_intent) {
|
||||
if (this.removeIntent) {
|
||||
evt.item.remove();
|
||||
evt.target.dispatchEvent(this.manager.operationremove);
|
||||
}
|
||||
}.bind(this)
|
||||
});
|
||||
|
||||
Sortable.utils.on(rec_list, "dragover", function() {
|
||||
this.remove_intent = false;
|
||||
Sortable.utils.on(recList, "dragover", function() {
|
||||
this.removeIntent = false;
|
||||
}.bind(this));
|
||||
|
||||
Sortable.utils.on(rec_list, "dragleave", function() {
|
||||
this.remove_intent = true;
|
||||
Sortable.utils.on(recList, "dragleave", function() {
|
||||
this.removeIntent = true;
|
||||
this.app.progress = 0;
|
||||
}.bind(this));
|
||||
|
||||
Sortable.utils.on(rec_list, "touchend", function(e) {
|
||||
Sortable.utils.on(recList, "touchend", function(e) {
|
||||
var loc = e.changedTouches[0],
|
||||
target = document.elementFromPoint(loc.clientX, loc.clientY);
|
||||
|
||||
this.remove_intent = !rec_list.contains(target);
|
||||
this.removeIntent = !recList.contains(target);
|
||||
}.bind(this));
|
||||
|
||||
// Favourites category
|
||||
document.querySelector("#categories a").addEventListener("dragover", this.fav_dragover.bind(this));
|
||||
document.querySelector("#categories a").addEventListener("dragleave", this.fav_dragleave.bind(this));
|
||||
document.querySelector("#categories a").addEventListener("drop", this.fav_drop.bind(this));
|
||||
document.querySelector("#categories a").addEventListener("dragover", this.favDragover.bind(this));
|
||||
document.querySelector("#categories a").addEventListener("dragleave", this.favDragleave.bind(this));
|
||||
document.querySelector("#categories a").addEventListener("drop", this.favDrop.bind(this));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Creates a drag-n-droppable seed list of operations.
|
||||
*
|
||||
* @param {element} list_el - The list the initialise
|
||||
* @param {element} listEl - The list the initialise
|
||||
*/
|
||||
RecipeWaiter.prototype.create_sortable_seed_list = function(list_el) {
|
||||
Sortable.create(list_el, {
|
||||
RecipeWaiter.prototype.createSortableSeedList = function(listEl) {
|
||||
Sortable.create(listEl, {
|
||||
group: {
|
||||
name: "recipe",
|
||||
pull: "clone",
|
||||
put: false
|
||||
},
|
||||
sort: false,
|
||||
setData: function(dataTransfer, drag_el) {
|
||||
dataTransfer.setData("Text", drag_el.textContent);
|
||||
setData: function(dataTransfer, dragEl) {
|
||||
dataTransfer.setData("Text", dragEl.textContent);
|
||||
},
|
||||
onStart: function(evt) {
|
||||
$(evt.item).popover("destroy");
|
||||
evt.item.setAttribute("data-toggle", "popover-disabled");
|
||||
},
|
||||
onEnd: this.op_sort_end.bind(this)
|
||||
onEnd: this.opSortEnd.bind(this)
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -99,9 +99,9 @@ RecipeWaiter.prototype.create_sortable_seed_list = function(list_el) {
|
|||
* @fires Manager#operationadd
|
||||
* @param {event} evt
|
||||
*/
|
||||
RecipeWaiter.prototype.op_sort_end = function(evt) {
|
||||
if (this.remove_intent) {
|
||||
if (evt.item.parentNode.id === "rec_list") {
|
||||
RecipeWaiter.prototype.opSortEnd = function(evt) {
|
||||
if (this.removeIntent) {
|
||||
if (evt.item.parentNode.id === "rec-list") {
|
||||
evt.item.remove();
|
||||
}
|
||||
return;
|
||||
|
@ -112,11 +112,11 @@ RecipeWaiter.prototype.op_sort_end = function(evt) {
|
|||
$(evt.clone).popover();
|
||||
$(evt.clone).children("[data-toggle=popover]").popover();
|
||||
|
||||
if (evt.item.parentNode.id !== "rec_list") {
|
||||
if (evt.item.parentNode.id !== "rec-list") {
|
||||
return;
|
||||
}
|
||||
|
||||
this.build_recipe_operation(evt.item);
|
||||
this.buildRecipeOperation(evt.item);
|
||||
evt.item.dispatchEvent(this.manager.operationadd);
|
||||
};
|
||||
|
||||
|
@ -128,7 +128,7 @@ RecipeWaiter.prototype.op_sort_end = function(evt) {
|
|||
*
|
||||
* @param {event} e
|
||||
*/
|
||||
RecipeWaiter.prototype.fav_dragover = function(e) {
|
||||
RecipeWaiter.prototype.favDragover = function(e) {
|
||||
if (e.dataTransfer.effectAllowed !== "move")
|
||||
return false;
|
||||
|
||||
|
@ -153,7 +153,7 @@ RecipeWaiter.prototype.fav_dragover = function(e) {
|
|||
*
|
||||
* @param {event} e
|
||||
*/
|
||||
RecipeWaiter.prototype.fav_dragleave = function(e) {
|
||||
RecipeWaiter.prototype.favDragleave = function(e) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
document.querySelector("#categories a").classList.remove("favourites-hover");
|
||||
|
@ -166,13 +166,13 @@ RecipeWaiter.prototype.fav_dragleave = function(e) {
|
|||
*
|
||||
* @param {event} e
|
||||
*/
|
||||
RecipeWaiter.prototype.fav_drop = function(e) {
|
||||
RecipeWaiter.prototype.favDrop = function(e) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
e.target.classList.remove("favourites-hover");
|
||||
|
||||
var op_name = e.dataTransfer.getData("Text");
|
||||
this.app.add_favourite(op_name);
|
||||
var opName = e.dataTransfer.getData("Text");
|
||||
this.app.addFavourite(opName);
|
||||
};
|
||||
|
||||
|
||||
|
@ -181,7 +181,7 @@ RecipeWaiter.prototype.fav_drop = function(e) {
|
|||
*
|
||||
* @fires Manager#statechange
|
||||
*/
|
||||
RecipeWaiter.prototype.ing_change = function() {
|
||||
RecipeWaiter.prototype.ingChange = function() {
|
||||
window.dispatchEvent(this.manager.statechange);
|
||||
};
|
||||
|
||||
|
@ -193,7 +193,7 @@ RecipeWaiter.prototype.ing_change = function() {
|
|||
* @fires Manager#statechange
|
||||
* @param {event} e
|
||||
*/
|
||||
RecipeWaiter.prototype.disable_click = function(e) {
|
||||
RecipeWaiter.prototype.disableClick = function(e) {
|
||||
var icon = e.target;
|
||||
|
||||
if (icon.getAttribute("disabled") === "false") {
|
||||
|
@ -218,7 +218,7 @@ RecipeWaiter.prototype.disable_click = function(e) {
|
|||
* @fires Manager#statechange
|
||||
* @param {event} e
|
||||
*/
|
||||
RecipeWaiter.prototype.breakpoint_click = function(e) {
|
||||
RecipeWaiter.prototype.breakpointClick = function(e) {
|
||||
var bp = e.target;
|
||||
|
||||
if (bp.getAttribute("break") === "false") {
|
||||
|
@ -240,7 +240,7 @@ RecipeWaiter.prototype.breakpoint_click = function(e) {
|
|||
* @fires Manager#statechange
|
||||
* @param {event} e
|
||||
*/
|
||||
RecipeWaiter.prototype.operation_dblclick = function(e) {
|
||||
RecipeWaiter.prototype.operationDblclick = function(e) {
|
||||
e.target.remove();
|
||||
window.dispatchEvent(this.manager.statechange);
|
||||
};
|
||||
|
@ -253,7 +253,7 @@ RecipeWaiter.prototype.operation_dblclick = function(e) {
|
|||
* @fires Manager#statechange
|
||||
* @param {event} e
|
||||
*/
|
||||
RecipeWaiter.prototype.operation_child_dblclick = function(e) {
|
||||
RecipeWaiter.prototype.operationChildDblclick = function(e) {
|
||||
e.target.parentNode.remove();
|
||||
window.dispatchEvent(this.manager.statechange);
|
||||
};
|
||||
|
@ -262,31 +262,31 @@ RecipeWaiter.prototype.operation_child_dblclick = function(e) {
|
|||
/**
|
||||
* Generates a configuration object to represent the current recipe.
|
||||
*
|
||||
* @returns {recipe_config}
|
||||
* @returns {recipeConfig}
|
||||
*/
|
||||
RecipeWaiter.prototype.get_config = function() {
|
||||
var config = [], ingredients, ing_list, disabled, bp, item,
|
||||
operations = document.querySelectorAll("#rec_list li.operation");
|
||||
RecipeWaiter.prototype.getConfig = function() {
|
||||
var config = [], ingredients, ingList, disabled, bp, item,
|
||||
operations = document.querySelectorAll("#rec-list li.operation");
|
||||
|
||||
for (var i = 0; i < operations.length; i++) {
|
||||
ingredients = [];
|
||||
disabled = operations[i].querySelector(".disable-icon");
|
||||
bp = operations[i].querySelector(".breakpoint");
|
||||
ing_list = operations[i].querySelectorAll(".arg");
|
||||
ingList = operations[i].querySelectorAll(".arg");
|
||||
|
||||
for (var j = 0; j < ing_list.length; j++) {
|
||||
if (ing_list[j].getAttribute("type") === "checkbox") {
|
||||
for (var j = 0; j < ingList.length; j++) {
|
||||
if (ingList[j].getAttribute("type") === "checkbox") {
|
||||
// checkbox
|
||||
ingredients[j] = ing_list[j].checked;
|
||||
} else if (ing_list[j].classList.contains("toggle-string")) {
|
||||
// toggle_string
|
||||
ingredients[j] = ingList[j].checked;
|
||||
} else if (ingList[j].classList.contains("toggle-string")) {
|
||||
// toggleString
|
||||
ingredients[j] = {
|
||||
option: ing_list[j].previousSibling.children[0].textContent.slice(0, -1),
|
||||
string: ing_list[j].value
|
||||
option: ingList[j].previousSibling.children[0].textContent.slice(0, -1),
|
||||
string: ingList[j].value
|
||||
};
|
||||
} else {
|
||||
// all others
|
||||
ingredients[j] = ing_list[j].value;
|
||||
ingredients[j] = ingList[j].value;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -315,8 +315,8 @@ RecipeWaiter.prototype.get_config = function() {
|
|||
*
|
||||
* @param {number} position
|
||||
*/
|
||||
RecipeWaiter.prototype.update_breakpoint_indicator = function(position) {
|
||||
var operations = document.querySelectorAll("#rec_list li.operation");
|
||||
RecipeWaiter.prototype.updateBreakpointIndicator = function(position) {
|
||||
var operations = document.querySelectorAll("#rec-list li.operation");
|
||||
for (var i = 0; i < operations.length; i++) {
|
||||
if (i === position) {
|
||||
operations[i].classList.add("break");
|
||||
|
@ -333,19 +333,19 @@ RecipeWaiter.prototype.update_breakpoint_indicator = function(position) {
|
|||
*
|
||||
* @param {element} el - The operation stub element from the operations pane
|
||||
*/
|
||||
RecipeWaiter.prototype.build_recipe_operation = function(el) {
|
||||
var op_name = el.textContent;
|
||||
var op = new HTMLOperation(op_name, this.app.operations[op_name], this.app, this.manager);
|
||||
el.innerHTML = op.to_full_html();
|
||||
RecipeWaiter.prototype.buildRecipeOperation = function(el) {
|
||||
var opName = el.textContent;
|
||||
var op = new HTMLOperation(opName, this.app.operations[opName], this.app, this.manager);
|
||||
el.innerHTML = op.toFullHtml();
|
||||
|
||||
if (this.app.operations[op_name].flow_control) {
|
||||
if (this.app.operations[opName].flowControl) {
|
||||
el.classList.add("flow-control-op");
|
||||
}
|
||||
|
||||
// Disable auto-bake if this is a manual op - this should be moved to the 'operationadd'
|
||||
// handler after event restructuring
|
||||
if (op.manual_bake && this.app.auto_bake_) {
|
||||
this.manager.controls.set_auto_bake(false);
|
||||
if (op.manualBake && this.app.autoBake_) {
|
||||
this.manager.controls.setAutoBake(false);
|
||||
this.app.alert("Auto-Bake is disabled by default when using this operation.", "info", 5000);
|
||||
}
|
||||
};
|
||||
|
@ -357,13 +357,13 @@ RecipeWaiter.prototype.build_recipe_operation = function(el) {
|
|||
* @param {string} name - The name of the operation to add
|
||||
* @returns {element}
|
||||
*/
|
||||
RecipeWaiter.prototype.add_operation = function(name) {
|
||||
RecipeWaiter.prototype.addOperation = function(name) {
|
||||
var item = document.createElement("li");
|
||||
|
||||
item.classList.add("operation");
|
||||
item.innerHTML = name;
|
||||
this.build_recipe_operation(item);
|
||||
document.getElementById("rec_list").appendChild(item);
|
||||
this.buildRecipeOperation(item);
|
||||
document.getElementById("rec-list").appendChild(item);
|
||||
|
||||
item.dispatchEvent(this.manager.operationadd);
|
||||
return item;
|
||||
|
@ -375,27 +375,27 @@ RecipeWaiter.prototype.add_operation = function(name) {
|
|||
*
|
||||
* @fires Manager#operationremove
|
||||
*/
|
||||
RecipeWaiter.prototype.clear_recipe = function() {
|
||||
var rec_list = document.getElementById("rec_list");
|
||||
while (rec_list.firstChild) {
|
||||
rec_list.removeChild(rec_list.firstChild);
|
||||
RecipeWaiter.prototype.clearRecipe = function() {
|
||||
var recList = document.getElementById("rec-list");
|
||||
while (recList.firstChild) {
|
||||
recList.removeChild(recList.firstChild);
|
||||
}
|
||||
rec_list.dispatchEvent(this.manager.operationremove);
|
||||
recList.dispatchEvent(this.manager.operationremove);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Handler for operation dropdown events from toggle_string arguments.
|
||||
* Handler for operation dropdown events from toggleString arguments.
|
||||
* Sets the selected option as the name of the button.
|
||||
*
|
||||
* @param {event} e
|
||||
*/
|
||||
RecipeWaiter.prototype.dropdown_toggle_click = function(e) {
|
||||
RecipeWaiter.prototype.dropdownToggleClick = function(e) {
|
||||
var el = e.target,
|
||||
button = el.parentNode.parentNode.previousSibling;
|
||||
|
||||
button.innerHTML = el.textContent + " <span class='caret'></span>";
|
||||
this.ing_change();
|
||||
this.ingChange();
|
||||
};
|
||||
|
||||
|
||||
|
@ -406,7 +406,7 @@ RecipeWaiter.prototype.dropdown_toggle_click = function(e) {
|
|||
* @fires Manager#statechange
|
||||
* @param {event} e
|
||||
*/
|
||||
RecipeWaiter.prototype.op_add = function(e) {
|
||||
RecipeWaiter.prototype.opAdd = function(e) {
|
||||
window.dispatchEvent(this.manager.statechange);
|
||||
};
|
||||
|
||||
|
@ -418,6 +418,6 @@ RecipeWaiter.prototype.op_add = function(e) {
|
|||
* @fires Manager#statechange
|
||||
* @param {event} e
|
||||
*/
|
||||
RecipeWaiter.prototype.op_remove = function(e) {
|
||||
RecipeWaiter.prototype.opRemove = function(e) {
|
||||
window.dispatchEvent(this.manager.statechange);
|
||||
};
|
||||
|
|
|
@ -24,22 +24,22 @@ SeasonalWaiter.prototype.load = function() {
|
|||
// Snowfall
|
||||
if (now.getMonth() === 11 && now.getDate() > 12) { // Dec 13 -> Dec 31
|
||||
this.app.options.snow = false;
|
||||
this.create_snow_option();
|
||||
$(document).on("switchChange.bootstrapSwitch", ".option-item input:checkbox[option='snow']", this.let_it_snow.bind(this));
|
||||
window.addEventListener("resize", this.let_it_snow.bind(this));
|
||||
this.manager.add_listeners(".btn", "click", this.shake_off_snow, this);
|
||||
if (now.getDate() === 25) this.let_it_snow();
|
||||
this.createSnowOption();
|
||||
$(document).on("switchChange.bootstrapSwitch", ".option-item input:checkbox[option='snow']", this.letItSnow.bind(this));
|
||||
window.addEventListener("resize", this.letItSnow.bind(this));
|
||||
this.manager.addListeners(".btn", "click", this.shakeOffSnow, this);
|
||||
if (now.getDate() === 25) this.letItSnow();
|
||||
}
|
||||
|
||||
// SpiderChef
|
||||
// if (now.getMonth() === 3 && now.getDate() === 1) { // Apr 1
|
||||
// this.insert_spider_icons();
|
||||
// this.insert_spider_text();
|
||||
// this.insertSpiderIcons();
|
||||
// this.insertSpiderText();
|
||||
// }
|
||||
|
||||
// Konami code
|
||||
this.kkeys = [];
|
||||
window.addEventListener("keydown", this.konami_code_listener.bind(this));
|
||||
window.addEventListener("keydown", this.konamiCodeListener.bind(this));
|
||||
};
|
||||
|
||||
|
||||
|
@ -47,7 +47,7 @@ SeasonalWaiter.prototype.load = function() {
|
|||
* Replaces chef icons with spider icons.
|
||||
* #spiderchef
|
||||
*/
|
||||
SeasonalWaiter.prototype.insert_spider_icons = function() {
|
||||
SeasonalWaiter.prototype.insertSpiderIcons = function() {
|
||||
var spider16 = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAB3UlEQVQ4y2NgGJaAmYGBgVnf0oKJgYGBobWtXamqqoYTn2I4CI+LTzM2NTulpKbu+vPHz2dV5RWlluZmi3j5+KqFJSSEzpw8uQPdAEYYIzo5Kfjrl28rWFlZzjAzMYuEBQao3Lh+g+HGvbsMzExMDN++fWf4/PXLBzY2tqYNK1f2+4eHM2xcuRLigsT09Igf3384MTExbf767etBI319jU8fPsi+//jx/72HDxh5uLkZ7ty7y/Dz1687Avz8n2UUFR3Z2NjOySoqfmdhYGBg+PbtuwI7O8e5H79+8X379t357PnzYo+ePP7y6cuXc9++f69nYGRsvf/w4XdtLS2R799/bBUWFHr57sP7Jbs3b/ZkzswvUP3165fZ7z9//r988WIVAyPDr8tXr576+u3bpb9//7YwMjKeV1dV41NWVGoVEhDgPH761DJREeHaz1+/lqlpafUx6+jrRfz4+fPy+w8fTu/fsf3uw7t3L39+//4cv7DwGQYGhpdPbt9m4BcRFlNWVJC4fuvWASszs4C379792Ldt2xZBUdEdDP5hYSqQGIjDGa965uYKCalpZQwMDAxhMTG9DAwMDLaurhIkJY7A8IgGBgYGBgd3Dz2yUpeFo6O4rasrA9T24ZRxAAMTwMpgEJwLAAAAAElFTkSuQmCC",
|
||||
spider32 = "iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAACYVBMVEUAAAAcJSU2Pz85QkM9RUWEhIWMjI2MkJEcJSU2Pz85QkM9RUWWlpc9RUVXXl4cJSU2Pz85QkM8REU9RUVRWFh6ens9RUVCSkpNVFRdY2McJSU5QkM7REQ9RUVGTk5KUlJQVldcY2Rla2uTk5WampscJSVUWltZX2BrcHF1e3scJSUjLCw9RUVASEhFTU1HTk9bYWJeZGRma2xudHV1eHiZmZocJSUyOjpJUFFQVldSWlpTWVpXXl5YXl5rb3B9fX6RkZIcJSUmLy8tNTU9RUVFTU1IT1BOVldRV1hTWlp0enocJSUfKChJUFBWXV1hZ2hnbGwcJSVETExLUlJLU1NNVVVPVlZYXl9cY2RiaGlobW5rcXFyd3h0eHgcJSUpMTFDS0tQV1dRV1hSWFlWXF1bYWJma2tobW5uc3SsrK0cJSVJUFBMVFROVlZVW1xZX2BdYmNhZ2hjaGhla2tqcHBscHE4Pz9KUlJRWVlSWVlXXF1aYGFbYWFfZWZlampqbW4cJSUgKSkiKysuNjY0PD01PT07QkNES0tHTk5JUFBMUlNMU1NOU1ROVVVPVVZRVlZRV1dSWVlWXFxXXV5aX2BbYWFbYWJcYmJcYmNcY2RdYmNgZmZhZmdkaWpkampkamtlamtla2tma2tma2xnbG1obW5pbG1pb3Bqb3Brb3BtcXJudHVvcHFvcXJvc3NwcXNwdXVxc3RzeXl1eXp2eXl3ent6e3x+gYKAhISBg4SKi4yLi4yWlpeampudnZ6fn6CkpaanqKiur6+vr7C4uLm6urq6u7u8vLy9vb3Av8DR0dL2b74UAAAAgHRSTlMAEBAQEBAQECAgICAgMDBAQEBAQEBAUFBQUGBgYGBgYGBgYGBgcHBwcHCAgICAgICAgICAgICPj4+Pj4+Pj4+Pj5+fn5+fn5+fn5+vr6+vr6+/v7+/v7+/v7+/v7+/z8/Pz8/Pz8/Pz8/P39/f39/f39/f39/f7+/v7+/v7+/v78x6RlYAAAGBSURBVDjLY2AYWUCSgUGAk4GBTdlUhQebvP7yjIgCPQbWzBMnjx5wwJSX37Rwfm1isqj9/iPHTuxYlyeMJi+yunfptBkZOw/uWj9h3vatcycu8eRGlldb3Vsts3ph/cFTh7fN3bCoe2Vf8+TZoQhTvBa6REozVC7cuPvQnmULJm1e2z+308eyJieEBSLPXbKQIUqQIczk+N6eNaumtnZMaWhaHM89m8XVCqJA02Y5w0xmga6yfVsamtrN4xoXNzS0JTHkK3CXy4EVFMumcxUy2LbENTVkZfEzMDAudtJyTmNwS2XQreAFyvOlK9louDNVaXurmjkGgnTMkWDgXswtNouFISEX6Awv+RihQi5OcYY4DtVARpCCFCMGhiJ1hjwFBpagEAaWEpFoC0WQOCOjFMRRwXYMDB4BDLJ+QLYsg7GBGjtasLnEMjCIrWBgyAZ7058FI9x1SoFEnTCDsCyIhynPILYYSFgbYpUDA5bpQBluXzxpI1yYAbd2sCMYRhwAAHB9ZPztbuMUAAAAAElFTkSuQmCC",
|
||||
spider64 = "iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAJZUlEQVR42u1ZaXMU1xXlJ+gHpFITOy5sAcnIYCi2aIL2bTSSZrSP1NpHK41kISQBHgFaQIJBCMwi4TFUGYcPzggwEMcxHVGxQaag5QR/np/QP+Hmnsdr0hpmtEACwulb9aq7p7d3zz333Pt61q2zzTbbbLPNNttss80222yzzTbbVmu7MzKcJRWVkXjntqam6jyURPeGQqeTpqbOqp+evxC5dGlam5m5rE3PzGi8Hzx/4aLzbXDe09HdYxwZHaPc4mLFXVoW9pRXGNv3pDngeHlNLfE2Ljjj4xPOUGjSYKfpq6/+TLdv36bbX39Nt27epGvXvqSLl6bp3LlPtdOnz7jWrPNZ7kLCKCovp5bOTmP/4EHq6vmYMtzuSKbbbQCAHE8Rxd47MjrmuHjxkjF3/z4tLCzQkyc6PX78mB49ekQPHjygub/P0d27f6FrX/6JpqbO0YkT48E1R/sCr9cYHZ+gqrp64mPq+riXcoqKKC0vP9q6VyV/fQOiH+LrsPVY7z82PBKZnb1Bd+7cpfn5eQbgCT1hAADC/MN5uj83R99881eanZ2lL5gN/nrxjihAXwvOJ7l9vuiBQ4dF9LEtLC0V+2rv/ijTX6luaCS3rxT57wADAMTBQ4c9PIIDg4PBwYOHaHhklM5MnSWkwLff/o0+v3qVHv34Iz344QEDc4d8VVXUEAhQXXMzVdQqzKweKq6oABARzOGNOZ+Wl6fD6T25ubQrPT0E5xF93o82tbdjkkZ+iZfAAgbD6fZ6o339A8S0p7HjJ2h4eIQOHf6EujlV9nX3UOj0JDXzfXje+KlTdOPGDeF0T1+fGHg+2JSen08tHZ0CiPySEoPn8vq1IaOgIAzneQK0UzjcQd6qaqrlCVfV1+tpubnRnv5+2p2ZqYMF/oZGPTh0xLhy5Sr9wLn9j++/p5nLn9FxBoLZQJ1dKrkys6iYNeTExEnx3PqWFuF4W9deKq2upkEGCyzyMBC709MFC7r391Fjayv9MSdHZyCU1xJ5FjrNdN6VnU1KS4CjU4Yoh/m8CsezCguFJgAMV05ueP+BfhF5OL+gL9A/f/qJ7t3TaPLMFB09eoy6mTkMGg2PjTELOsS20OcTACgMKqJugqA0NtE7ycn0202b6A+ZmYIVAAKApGZlgRHB/0lqQPAqFEVE9hntM0R0ZblTzeswWdCeU8HAtYW+Uu0AUx+0f/jwoXD+56c/073v7tHU2XMiFbrUfVTNAtfL10FIAQL2QftsBrOEnavld5kg7E7PoF+99x79ev162rJrV9RMi6a2dvKUlQsR5uAgII7/ivMsbEE4g2hggjzC7LQL1OftovoO0WJKUn0gYEAn2hmMXo4QHIXQIfLfsfOXPwuLvB86cpQqamooyEzg1BLMwv04RkoE+B3B4BBBMHEcCwIP0N+ByJdUVhpgBJ7j4WvdANDjeTUglOaWEChfJF7uJzPX2HEPaj1vg7EAbHO5QnAeIPgqKvUB7gtAdbBgcvKMqOnc/NAIVwCcq21qElFnCgvaI9cBBFKhlSPbPzBIbbzduGULpWzfLkDAdZs++sgEwSlZqoIJMg2CzFSNGzODwdBfOi26+w4YTCm9LhDQwQDzdzguFf4FALjciTws8/u1yyx2N2/dovPnL9DRY8PkZ204xtuhoSM0wI7V8DEiirQCCHD+99u2CUdx3Lmvmz7kfemoGDgPEDr4HNKAf1MlAC4wgMGLWFJXQUrklZSEX6rLE2rOyDIQGlhgBUAyYFEZkm2vAGVi4qQ+x83M0389pevXr6OToy07d4qcR+krr/KzqpeJ/IfjGO+npDx3FCKHVPjd1q2LAMBI3ryZ9vL7U56BEzLfD80ACFba876OlGCQV9dAcT0Pyw7PgWij6zPP5Xt9EYgg+n3LosdVzdfz5CI8KY1LH31+5Yro9KanZwjHmPzmHTsoOeVDemfDBuE8dGVnWpqx3unUrE4CDLCAG64XAHB88IFgQV5xMY7DFmc16A6CZvnNBYYVcW+yKj0A/VHTsQ8dwMPNc6X+Gg0VIGbVpzYGWundjRujmGQWi9Eol7+TJ0/R2Nhx2sNlM9YJRPDdDRsM5DGPJB4KHOIhngHhAwixAGAAuDZ2lsuiYnFWBQOYrdEYNochilyiV6YHoH+rRNJkAG+fUw31PzU7Z1EFKPD69CIuQ1Bm6URoh8tFmVym3nc6rZOPyi0cD8HxeHPg3x2InNrbS79JTsYzNXmPuBclsO3ZvKwAOJEGsmI5rT0M+gSf3y9K5LIA1LUEIlL1k0AhCYBH5r9TCqBqib4D+c/1PyInGOThkvuaHCYALhlpbQWBMGR/4IpzTqlpbKQyf0045vdoe0zATHagSYMeWFMkbscnHRYPZjoFJaIiUkz9EJy15j/X3qCsAIqMcFjSWrNE1Iygg0fEmrtLzEUTdT/OhBFht9fHDVCbEUt3LJxi08B8Xj6vTDESriq9lVWqBECgHujqiqAUmufb1X3cfRXoluhjZWiwkOnSUcUS6ZD8LUmmhks6b5j1ezkAkAKZBe5QvPPcNBnoCawMwT66Qxk0R2xwwRAui2iSDGuaPDcubzo3EJq8wcx/9Vmk3QryH42QBQCFF0UagIiJtjX6DskIXTLEucJSHIIIMuO0BOcjn3A3ybU/lu5RCUBc5qA0Ih0Q2EWiCPRk7VfMNhjLW1zETic1tLYZDMKyuSsdfh5l6bwho5+0il4kyA0VohlNcF5FP8DlWo/VB16HYB2hJ0pzgIe2mcXxP2IOumPRY17U0tll8KIkZNb+sppafOxYkQPSaYfchyYoL9GMqWYpTLRIq1QUcT4O3aPQgqVqPwIOIMwDhzX6mQUFIQAgo+9MzcrWrML3mj6+YIKiFCZyhL87RqVQKrEskF+P1BUvfLCAkfRwoPUtq6l5o5+lZb5SolJo6oT8avTCl+c9OTmat6pKW8mLkvBpGzlvsiGuQr4ZEEwA1EQgoR/gNtxIxKBluz+OtMJiF31jHxqXBiAqAUj4WRxpADFM0DCFlv1khvX7Wol4vF4AIldVVxdZqlrIfiCYQPHDy6bAGv7nKYRVY6JewExZVAP+ey5Rv+Ba97aaUHMW5NauLmMZFkegBb/EP14d6NoS9QLWFSzWBmuZza8CQmSpXsAqmGtVy14VALWuuYWWy+W3OteXa4jwceQX6+BKG6J1/8+2VCNkm2222WabbbbZZpttttlmm22rt38DCdA0vq3bcAkAAAAASUVORK5CYII=";
|
||||
|
@ -67,12 +67,12 @@ SeasonalWaiter.prototype.insert_spider_icons = function() {
|
|||
* Replaces all instances of the word "cyber" with "spider".
|
||||
* #spiderchef
|
||||
*/
|
||||
SeasonalWaiter.prototype.insert_spider_text = function() {
|
||||
SeasonalWaiter.prototype.insertSpiderText = function() {
|
||||
// Title
|
||||
document.title = document.title.replace(/Cyber/g, "Spider");
|
||||
|
||||
// Body
|
||||
SeasonalWaiter.tree_walk(document.body, function(node) {
|
||||
SeasonalWaiter.treeWalk(document.body, function(node) {
|
||||
// process only text nodes
|
||||
if (node.nodeType === 3) {
|
||||
node.nodeValue = node.nodeValue.replace(/Cyber/g, "Spider");
|
||||
|
@ -80,7 +80,7 @@ SeasonalWaiter.prototype.insert_spider_text = function() {
|
|||
}, true);
|
||||
|
||||
// Bake button
|
||||
SeasonalWaiter.tree_walk(document.getElementById("bake-group"), function(node) {
|
||||
SeasonalWaiter.treeWalk(document.getElementById("bake-group"), function(node) {
|
||||
// process only text nodes
|
||||
if (node.nodeType === 3) {
|
||||
node.nodeValue = node.nodeValue.replace(/Bake/g, "Spin");
|
||||
|
@ -96,15 +96,15 @@ SeasonalWaiter.prototype.insert_spider_text = function() {
|
|||
* Adds an option to make it snow.
|
||||
* #letitsnow
|
||||
*/
|
||||
SeasonalWaiter.prototype.create_snow_option = function() {
|
||||
var options_body = document.getElementById("options-body"),
|
||||
option_item = document.createElement("div");
|
||||
SeasonalWaiter.prototype.createSnowOption = function() {
|
||||
var optionsBody = document.getElementById("options-body"),
|
||||
optionItem = document.createElement("div");
|
||||
|
||||
option_item.className = "option-item";
|
||||
option_item.innerHTML =
|
||||
optionItem.className = "option-item";
|
||||
optionItem.innerHTML =
|
||||
"<input type='checkbox' option='snow' checked />\
|
||||
Let it snow";
|
||||
options_body.appendChild(option_item);
|
||||
optionsBody.appendChild(optionItem);
|
||||
|
||||
this.manager.options.load();
|
||||
};
|
||||
|
@ -114,14 +114,14 @@ SeasonalWaiter.prototype.create_snow_option = function() {
|
|||
* Initialises a snowstorm.
|
||||
* #letitsnow
|
||||
*/
|
||||
SeasonalWaiter.prototype.let_it_snow = function() {
|
||||
SeasonalWaiter.prototype.letItSnow = function() {
|
||||
$(document).snowfall("clear");
|
||||
if (!this.app.options.snow) return;
|
||||
|
||||
var options = {},
|
||||
firefox_version = navigator.userAgent.match(/Firefox\/(\d\d?)/);
|
||||
firefoxVersion = navigator.userAgent.match(/Firefox\/(\d\d?)/);
|
||||
|
||||
if (firefox_version && parseInt(firefox_version[1], 10) < 30) {
|
||||
if (firefoxVersion && parseInt(firefoxVersion[1], 10) < 30) {
|
||||
// Firefox < 30
|
||||
options = {
|
||||
flakeCount: 10,
|
||||
|
@ -163,12 +163,12 @@ SeasonalWaiter.prototype.let_it_snow = function() {
|
|||
* When a button is clicked, shake the snow off that button.
|
||||
* #letitsnow
|
||||
*/
|
||||
SeasonalWaiter.prototype.shake_off_snow = function(e) {
|
||||
SeasonalWaiter.prototype.shakeOffSnow = function(e) {
|
||||
var el = e.target,
|
||||
rect = el.getBoundingClientRect(),
|
||||
canvases = document.querySelectorAll("canvas.snowfall-canvas"),
|
||||
canvas = null,
|
||||
remove_func = function() {
|
||||
removeFunc = function() {
|
||||
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
||||
$(this).fadeIn();
|
||||
};
|
||||
|
@ -178,7 +178,7 @@ SeasonalWaiter.prototype.shake_off_snow = function(e) {
|
|||
if (canvas.style.left === rect.left + "px" && canvas.style.top === (rect.top - 20) + "px") {
|
||||
var ctx = canvas.getContext("2d");
|
||||
|
||||
$(canvas).fadeOut("slow", remove_func);
|
||||
$(canvas).fadeOut("slow", removeFunc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -190,7 +190,7 @@ SeasonalWaiter.prototype.shake_off_snow = function(e) {
|
|||
* sequence.
|
||||
* #konamicode
|
||||
*/
|
||||
SeasonalWaiter.prototype.konami_code_listener = function(e) {
|
||||
SeasonalWaiter.prototype.konamiCodeListener = function(e) {
|
||||
this.kkeys.push(e.keyCode);
|
||||
var konami = [38, 38, 40, 40, 37, 39, 37, 39, 66, 65];
|
||||
for (var i = 0; i < this.kkeys.length; i++) {
|
||||
|
@ -212,20 +212,20 @@ SeasonalWaiter.prototype.konami_code_listener = function(e) {
|
|||
* @static
|
||||
* @param {element} parent - The DOM node to start from
|
||||
* @param {Function} fn - The callback function to operate on each node
|
||||
* @param {booleam} all_nodes - Whether to operate on every node or not
|
||||
* @param {booleam} allNodes - Whether to operate on every node or not
|
||||
*/
|
||||
SeasonalWaiter.tree_walk = (function() {
|
||||
SeasonalWaiter.treeWalk = (function() {
|
||||
// Create closure for constants
|
||||
var skipTags = {
|
||||
"SCRIPT": true, "IFRAME": true, "OBJECT": true,
|
||||
"EMBED": true, "STYLE": true, "LINK": true, "META": true
|
||||
};
|
||||
|
||||
return function(parent, fn, all_nodes) {
|
||||
return function(parent, fn, allNodes) {
|
||||
var node = parent.firstChild;
|
||||
|
||||
while (node && node !== parent) {
|
||||
if (all_nodes || node.nodeType === 1) {
|
||||
if (allNodes || node.nodeType === 1) {
|
||||
if (fn(node) === false) {
|
||||
return(false);
|
||||
}
|
||||
|
|
|
@ -18,9 +18,9 @@ var WindowWaiter = function(app) {
|
|||
* Resets the layout of CyberChef's panes after 200ms (so that continuous resizing doesn't cause
|
||||
* continuous resetting).
|
||||
*/
|
||||
WindowWaiter.prototype.window_resize = function() {
|
||||
clearTimeout(this.reset_layout_timeout);
|
||||
this.reset_layout_timeout = setTimeout(this.app.reset_layout.bind(this.app), 200);
|
||||
WindowWaiter.prototype.windowResize = function() {
|
||||
clearTimeout(this.resetLayoutTimeout);
|
||||
this.resetLayoutTimeout = setTimeout(this.app.resetLayout.bind(this.app), 200);
|
||||
};
|
||||
|
||||
|
||||
|
@ -29,8 +29,8 @@ WindowWaiter.prototype.window_resize = function() {
|
|||
* Saves the current time so that we can calculate how long the window was unfocussed for when
|
||||
* focus is returned.
|
||||
*/
|
||||
WindowWaiter.prototype.window_blur = function() {
|
||||
this.window_blur_time = new Date().getTime();
|
||||
WindowWaiter.prototype.windowBlur = function() {
|
||||
this.windowBlurTime = new Date().getTime();
|
||||
};
|
||||
|
||||
|
||||
|
@ -44,9 +44,9 @@ WindowWaiter.prototype.window_blur = function() {
|
|||
* This will stop baking taking a long time when the CyberChef browser tab has been unfocused for
|
||||
* a long time and the browser has swapped out all its memory.
|
||||
*/
|
||||
WindowWaiter.prototype.window_focus = function() {
|
||||
var unfocused_time = new Date().getTime() - this.window_blur_time;
|
||||
if (unfocused_time > 60000) {
|
||||
this.app.silent_bake();
|
||||
WindowWaiter.prototype.windowFocus = function() {
|
||||
var unfocusedTime = new Date().getTime() - this.windowBlurTime;
|
||||
if (unfocusedTime > 60000) {
|
||||
this.app.silentBake();
|
||||
}
|
||||
};
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
* Main function used to build the CyberChef web app.
|
||||
*/
|
||||
var main = function() {
|
||||
var default_favourites = [
|
||||
var defaultFavourites = [
|
||||
"To Base64",
|
||||
"From Base64",
|
||||
"To Hex",
|
||||
|
@ -23,27 +23,27 @@ var main = function() {
|
|||
"Fork"
|
||||
];
|
||||
|
||||
var default_options = {
|
||||
update_url : true,
|
||||
show_highlighter : true,
|
||||
treat_as_utf8 : true,
|
||||
word_wrap : true,
|
||||
show_errors : true,
|
||||
error_timeout : 4000,
|
||||
auto_bake_threshold : 200,
|
||||
attempt_highlight : true,
|
||||
snow : false,
|
||||
var defaultOptions = {
|
||||
updateUrl : true,
|
||||
showHighlighter : true,
|
||||
treatAsUtf8 : true,
|
||||
wordWrap : true,
|
||||
showErrors : true,
|
||||
errorTimeout : 4000,
|
||||
autoBakeThreshold : 200,
|
||||
attemptHighlight : true,
|
||||
snow : false,
|
||||
};
|
||||
|
||||
document.removeEventListener("DOMContentLoaded", main, false);
|
||||
window.app = new HTMLApp(Categories, OperationConfig, default_favourites, default_options);
|
||||
window.app = new HTMLApp(Categories, OperationConfig, defaultFavourites, defaultOptions);
|
||||
window.app.setup();
|
||||
};
|
||||
|
||||
// Fix issues with browsers that don't support console.log()
|
||||
window.console = console || {log: function() {}, error: function() {}};
|
||||
|
||||
window.compile_time = moment.tz("<%= grunt.template.today() %>", "ddd MMM D YYYY HH:mm:ss", "UTC").valueOf();
|
||||
window.compile_message = "<%= compile_msg %>";
|
||||
window.compileTime = moment.tz("<%= grunt.template.today() %>", "ddd MMM D YYYY HH:mm:ss", "UTC").valueOf();
|
||||
window.compileMessage = "<%= compileMsg %>";
|
||||
|
||||
document.addEventListener("DOMContentLoaded", main, false);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue