mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-23 00:06:17 -04:00
Replaced jsHint with eslint. Fixes #4.
This commit is contained in:
parent
e2e68dd876
commit
af4644c9eb
48 changed files with 1741 additions and 1685 deletions
|
@ -65,7 +65,7 @@ ControlsWaiter.prototype.adjust_width = function() {
|
|||
ControlsWaiter.prototype.set_auto_bake = function(value) {
|
||||
var auto_bake_checkbox = document.getElementById("auto-bake");
|
||||
|
||||
if (auto_bake_checkbox.checked != value) {
|
||||
if (auto_bake_checkbox.checked !== value) {
|
||||
auto_bake_checkbox.click();
|
||||
}
|
||||
};
|
||||
|
@ -138,9 +138,7 @@ ControlsWaiter.prototype.clear_breaks_click = function() {
|
|||
ControlsWaiter.prototype.initialise_save_link = function(recipe_config) {
|
||||
recipe_config = recipe_config || this.app.get_recipe_config();
|
||||
|
||||
var recipe_str = JSON.stringify(recipe_config),
|
||||
input_str = Utils.to_base64(this.app.get_input()),
|
||||
include_recipe = document.getElementById("save-link-recipe-checkbox").checked,
|
||||
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);
|
||||
|
@ -200,7 +198,7 @@ ControlsWaiter.prototype.save_text_change = function() {
|
|||
*/
|
||||
ControlsWaiter.prototype.save_click = function() {
|
||||
var recipe_config = this.app.get_recipe_config();
|
||||
var recipe_str = JSON.stringify(recipe_config).replace(/},{/g, '},\n{');
|
||||
var recipe_str = JSON.stringify(recipe_config).replace(/},{/g, "},\n{");
|
||||
document.getElementById("save-text").value = recipe_str;
|
||||
|
||||
this.initialise_save_link(recipe_config);
|
||||
|
@ -300,7 +298,7 @@ ControlsWaiter.prototype.load_delete_click = function() {
|
|||
JSON.parse(localStorage.saved_recipes) : [];
|
||||
|
||||
saved_recipes = saved_recipes.filter(function(r) {
|
||||
return r.id != id;
|
||||
return r.id !== id;
|
||||
});
|
||||
|
||||
localStorage.saved_recipes = JSON.stringify(saved_recipes);
|
||||
|
@ -318,7 +316,7 @@ ControlsWaiter.prototype.load_name_change = function(e) {
|
|||
id = parseInt(el.value, 10);
|
||||
|
||||
var recipe = saved_recipes.filter(function(r) {
|
||||
return r.id == id;
|
||||
return r.id === id;
|
||||
})[0];
|
||||
|
||||
document.getElementById("load-text").value = recipe.recipe;
|
||||
|
|
|
@ -20,14 +20,14 @@ var HTMLApp = function(categories, operations, default_favourites, default_optio
|
|||
this.dfavourites = default_favourites;
|
||||
this.doptions = default_options;
|
||||
this.options = Utils.extend({}, default_options);
|
||||
|
||||
|
||||
this.chef = new Chef();
|
||||
this.manager = new Manager(this);
|
||||
|
||||
|
||||
this.auto_bake_ = false;
|
||||
this.progress = 0;
|
||||
this.ing_id = 0;
|
||||
|
||||
|
||||
window.chef = this.chef;
|
||||
};
|
||||
|
||||
|
@ -69,7 +69,7 @@ HTMLApp.prototype.handle_error = function(err) {
|
|||
*/
|
||||
HTMLApp.prototype.bake = function(step) {
|
||||
var response;
|
||||
|
||||
|
||||
try {
|
||||
response = this.chef.bake(
|
||||
this.get_input(), // The user's input
|
||||
|
@ -80,24 +80,25 @@ HTMLApp.prototype.bake = function(step) {
|
|||
);
|
||||
} catch (err) {
|
||||
this.handle_error(err);
|
||||
} finally {
|
||||
if (!response) return;
|
||||
|
||||
if (response.error) {
|
||||
this.handle_error(response.error);
|
||||
}
|
||||
this.options = response.options;
|
||||
this.dish_str = response.type == "html" ? Utils.strip_html_tags(response.result, true) : response.result;
|
||||
this.progress = response.progress;
|
||||
this.manager.recipe.update_breakpoint_indicator(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 +
|
||||
"ms, Auto Bake has been disabled.", "warning", 5000);
|
||||
}
|
||||
}
|
||||
|
||||
if (!response) return;
|
||||
|
||||
if (response.error) {
|
||||
this.handle_error(response.error);
|
||||
}
|
||||
|
||||
this.options = response.options;
|
||||
this.dish_str = response.type === "html" ? Utils.strip_html_tags(response.result, true) : response.result;
|
||||
this.progress = response.progress;
|
||||
this.manager.recipe.update_breakpoint_indicator(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 +
|
||||
"ms, Auto Bake has been disabled.", "warning", 5000);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -124,11 +125,11 @@ HTMLApp.prototype.auto_bake = function() {
|
|||
HTMLApp.prototype.silent_bake = function() {
|
||||
var start_time = new Date().getTime(),
|
||||
recipe_config = this.get_recipe_config();
|
||||
|
||||
|
||||
if (this.auto_bake_) {
|
||||
this.chef.silent_bake(recipe_config);
|
||||
}
|
||||
|
||||
|
||||
return new Date().getTime() - start_time;
|
||||
};
|
||||
|
||||
|
@ -140,11 +141,11 @@ HTMLApp.prototype.silent_bake = function() {
|
|||
*/
|
||||
HTMLApp.prototype.get_input = 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("input", input);
|
||||
|
||||
|
||||
return input;
|
||||
};
|
||||
|
||||
|
@ -170,31 +171,31 @@ HTMLApp.prototype.set_input = function(input) {
|
|||
HTMLApp.prototype.populate_operations_list = 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],
|
||||
selected = i === 0,
|
||||
cat = new HTMLCategory(cat_conf.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);
|
||||
}
|
||||
|
||||
|
||||
html += cat.to_html();
|
||||
}
|
||||
|
||||
|
||||
document.getElementById("categories").innerHTML = html;
|
||||
|
||||
|
||||
var op_lists = document.querySelectorAll("#categories .op_list");
|
||||
|
||||
|
||||
for (i = 0; i < op_lists.length; i++) {
|
||||
op_lists[i].dispatchEvent(this.manager.oplistcreate);
|
||||
}
|
||||
|
||||
|
||||
// Add edit button to first category (Favourites)
|
||||
document.querySelector("#categories a").appendChild(document.getElementById("edit-favourites"));
|
||||
};
|
||||
|
@ -210,12 +211,12 @@ HTMLApp.prototype.initialise_splitter = function() {
|
|||
gutterSize: 4,
|
||||
onDrag: this.manager.controls.adjust_width.bind(this.manager.controls)
|
||||
});
|
||||
|
||||
|
||||
Split(["#input", "#output"], {
|
||||
direction: "vertical",
|
||||
gutterSize: 4,
|
||||
});
|
||||
|
||||
|
||||
this.reset_layout();
|
||||
};
|
||||
|
||||
|
@ -231,7 +232,7 @@ HTMLApp.prototype.load_local_storage = function() {
|
|||
l_options = JSON.parse(localStorage.options);
|
||||
}
|
||||
this.manager.options.load(l_options);
|
||||
|
||||
|
||||
// Load favourites
|
||||
this.load_favourites();
|
||||
};
|
||||
|
@ -247,14 +248,14 @@ HTMLApp.prototype.load_favourites = function() {
|
|||
localStorage.favourites.length > 2 ?
|
||||
JSON.parse(localStorage.favourites) :
|
||||
this.dfavourites;
|
||||
|
||||
|
||||
favourites = this.valid_favourites(favourites);
|
||||
this.save_favourites(favourites);
|
||||
|
||||
|
||||
var fav_cat = this.categories.filter(function(c) {
|
||||
return c.name == "Favourites";
|
||||
return c.name === "Favourites";
|
||||
})[0];
|
||||
|
||||
|
||||
if (fav_cat) {
|
||||
fav_cat.ops = favourites;
|
||||
} else {
|
||||
|
@ -269,7 +270,7 @@ HTMLApp.prototype.load_favourites = function() {
|
|||
/**
|
||||
* Filters the list of favourite operations that the user had stored and removes any that are no
|
||||
* longer available. The user is notified if this is the case.
|
||||
|
||||
|
||||
* @param {string[]} favourites - A list of the user's favourite operations
|
||||
* @returns {string[]} A list of the valid favourites
|
||||
*/
|
||||
|
@ -321,7 +322,7 @@ HTMLApp.prototype.add_favourite = function(name) {
|
|||
this.alert("'" + name + "' is already in your favourites", "info", 2000);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
favourites.push(name);
|
||||
this.save_favourites(favourites);
|
||||
this.load_favourites();
|
||||
|
@ -339,20 +340,20 @@ HTMLApp.prototype.load_URI_params = function() {
|
|||
if (a === "") return {};
|
||||
var b = {};
|
||||
for (var i = 0; i < a.length; i++) {
|
||||
var p = a[i].split('=');
|
||||
if (p.length != 2) {
|
||||
var p = a[i].split("=");
|
||||
if (p.length !== 2) {
|
||||
b[a[i]] = true;
|
||||
} else {
|
||||
b[p[0]] = decodeURIComponent(p[1].replace(/\+/g, " "));
|
||||
}
|
||||
}
|
||||
return b;
|
||||
})(window.location.search.substr(1).split('&'));
|
||||
|
||||
})(window.location.search.substr(1).split("&"));
|
||||
|
||||
// Turn off auto-bake while loading
|
||||
var auto_bake_val = this.auto_bake_;
|
||||
this.auto_bake_ = false;
|
||||
|
||||
|
||||
// Read in recipe from query string
|
||||
if (this.query_string.recipe) {
|
||||
try {
|
||||
|
@ -370,15 +371,15 @@ HTMLApp.prototype.load_URI_params = function() {
|
|||
if (matched_ops.length) {
|
||||
this.manager.recipe.add_operation(matched_ops[0].name);
|
||||
}
|
||||
|
||||
|
||||
// Populate search with the string
|
||||
var search = document.getElementById("search");
|
||||
|
||||
|
||||
search.value = this.query_string.op;
|
||||
search.dispatchEvent(new Event("search"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Read in input data from query string
|
||||
if (this.query_string.input) {
|
||||
try {
|
||||
|
@ -386,7 +387,7 @@ HTMLApp.prototype.load_URI_params = function() {
|
|||
this.set_input(input_data);
|
||||
} catch(err) {}
|
||||
}
|
||||
|
||||
|
||||
// Restore auto-bake state
|
||||
this.auto_bake_ = auto_bake_val;
|
||||
this.auto_bake();
|
||||
|
@ -423,14 +424,14 @@ HTMLApp.prototype.get_recipe_config = function() {
|
|||
HTMLApp.prototype.set_recipe_config = function(recipe_config) {
|
||||
sessionStorage.setItem("recipe_config", JSON.stringify(recipe_config));
|
||||
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);
|
||||
|
||||
|
||||
// Populate arguments
|
||||
var args = item.querySelectorAll(".arg");
|
||||
for (var j = 0; j < args.length; j++) {
|
||||
if (args[j].getAttribute("type") == "checkbox") {
|
||||
if (args[j].getAttribute("type") === "checkbox") {
|
||||
// checkbox
|
||||
args[j].checked = recipe_config[i].args[j];
|
||||
} else if (args[j].classList.contains("toggle-string")) {
|
||||
|
@ -444,7 +445,7 @@ HTMLApp.prototype.set_recipe_config = function(recipe_config) {
|
|||
args[j].value = recipe_config[i].args[j];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Set disabled and breakpoint
|
||||
if (recipe_config[i].disabled) {
|
||||
item.querySelector(".disable-icon").click();
|
||||
|
@ -452,7 +453,7 @@ HTMLApp.prototype.set_recipe_config = function(recipe_config) {
|
|||
if (recipe_config[i].breakpoint) {
|
||||
item.querySelector(".breakpoint").click();
|
||||
}
|
||||
|
||||
|
||||
this.progress = 0;
|
||||
}
|
||||
};
|
||||
|
@ -467,7 +468,7 @@ HTMLApp.prototype.reset_layout = function() {
|
|||
document.getElementById("IO").style.width = "calc(50% - 2px)";
|
||||
document.getElementById("input").style.height = "calc(50% - 2px)";
|
||||
document.getElementById("output").style.height = "calc(50% - 2px)";
|
||||
|
||||
|
||||
this.manager.controls.adjust_width();
|
||||
};
|
||||
|
||||
|
@ -480,12 +481,12 @@ HTMLApp.prototype.set_compile_message = function() {
|
|||
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";
|
||||
|
||||
time_since_compile.substr(0, 1).toUpperCase() + time_since_compile.substr(1) + " ago";
|
||||
|
||||
if (window.compile_message !== "") {
|
||||
compile_info += " - " + window.compile_message;
|
||||
}
|
||||
|
||||
|
||||
compile_info += "</span>";
|
||||
document.getElementById("notice").innerHTML = compile_info;
|
||||
};
|
||||
|
@ -516,36 +517,36 @@ HTMLApp.prototype.set_compile_message = function() {
|
|||
*/
|
||||
HTMLApp.prototype.alert = function(str, style, timeout, silent) {
|
||||
var time = new Date();
|
||||
|
||||
|
||||
console.log("[" + time.toLocaleString() + "] " + str);
|
||||
if (silent) return;
|
||||
|
||||
|
||||
style = style || "danger";
|
||||
timeout = timeout || 0;
|
||||
|
||||
|
||||
var alert_el = document.getElementById("alert"),
|
||||
alert_content = 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);
|
||||
|
||||
|
||||
// If the box hasn't been closed, append to it rather than replacing
|
||||
if (alert_el.style.display == "block") {
|
||||
alert_content.innerHTML +=
|
||||
if (alert_el.style.display === "block") {
|
||||
alert_content.innerHTML +=
|
||||
"<br><br>[" + time.toLocaleTimeString() + "] " + str;
|
||||
} else {
|
||||
alert_content.innerHTML =
|
||||
"[" + time.toLocaleTimeString() + "] " + str;
|
||||
}
|
||||
|
||||
|
||||
// Stop the animation if it is in progress
|
||||
$("#alert").stop();
|
||||
alert_el.style.display = "block";
|
||||
alert_el.style.opacity = 1;
|
||||
|
||||
|
||||
if (timeout > 0) {
|
||||
clearTimeout(this.alert_timeout);
|
||||
this.alert_timeout = setTimeout(function(){
|
||||
|
@ -573,7 +574,7 @@ HTMLApp.prototype.confirm = function(title, body, callback, scope) {
|
|||
document.getElementById("confirm-title").innerHTML = title;
|
||||
document.getElementById("confirm-body").innerHTML = body;
|
||||
document.getElementById("confirm-modal").style.display = "block";
|
||||
|
||||
|
||||
this.confirm_closed = false;
|
||||
$("#confirm-modal").modal()
|
||||
.one("show.bs.modal", function(e) {
|
||||
|
@ -610,7 +611,7 @@ HTMLApp.prototype.alert_close_click = function() {
|
|||
*/
|
||||
HTMLApp.prototype.state_change = function(e) {
|
||||
this.auto_bake();
|
||||
|
||||
|
||||
// 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);
|
||||
|
@ -640,10 +641,10 @@ HTMLApp.prototype.call_api = function(url, type, data, data_type, content_type)
|
|||
data = data || {};
|
||||
data_type = data_type || undefined;
|
||||
content_type = content_type || "application/json";
|
||||
|
||||
|
||||
var response = null,
|
||||
success = false;
|
||||
|
||||
|
||||
$.ajax({
|
||||
url: url,
|
||||
async: false,
|
||||
|
@ -660,7 +661,7 @@ HTMLApp.prototype.call_api = function(url, type, data, data_type, content_type)
|
|||
response = data;
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
return {
|
||||
success: success,
|
||||
response: response
|
||||
|
|
|
@ -32,16 +32,16 @@ var HTMLIngredient = function(config, app, manager) {
|
|||
* @returns {string}
|
||||
*/
|
||||
HTMLIngredient.prototype.to_html = function() {
|
||||
var inline = (this.type == "boolean" ||
|
||||
this.type == "number" ||
|
||||
this.type == "option" ||
|
||||
this.type == "short_string" ||
|
||||
this.type == "binary_short_string"),
|
||||
var inline = (this.type === "boolean" ||
|
||||
this.type === "number" ||
|
||||
this.type === "option" ||
|
||||
this.type === "short_string" ||
|
||||
this.type === "binary_short_string"),
|
||||
html = inline ? "" : "<div class='clearfix'> </div>",
|
||||
i, m;
|
||||
|
||||
html += "<div class='arg-group" + (inline ? " inline-args" : "") +
|
||||
(this.type == "text" ? " arg-group-text" : "") + "'><label class='arg-label' for='" +
|
||||
(this.type === "text" ? " arg-group-text" : "") + "'><label class='arg-label' for='" +
|
||||
this.id + "'>" + this.name + "</label>";
|
||||
|
||||
switch (this.type) {
|
||||
|
@ -92,9 +92,9 @@ HTMLIngredient.prototype.to_html = function() {
|
|||
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))) {
|
||||
if ((m = this.value[i].match(/\[([a-z0-9 -()^]+)\]/i))) {
|
||||
html += "<optgroup label='" + m[1] + "'>";
|
||||
} else if (!!(m = this.value[i].match(/\[\/([a-z0-9 -()^]+)\]/i))) {
|
||||
} else if ((m = this.value[i].match(/\[\/([a-z0-9 -()^]+)\]/i))) {
|
||||
html += "</optgroup>";
|
||||
} else {
|
||||
html += "<option>" + this.value[i] + "</option>";
|
||||
|
@ -106,9 +106,9 @@ HTMLIngredient.prototype.to_html = function() {
|
|||
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))) {
|
||||
if ((m = this.value[i].name.match(/\[([a-z0-9 -()^]+)\]/i))) {
|
||||
html += "<optgroup label='" + m[1] + "'>";
|
||||
} else if (!!(m = this.value[i].name.match(/\[\/([a-z0-9 -()^]+)\]/i))) {
|
||||
} else if ((m = this.value[i].name.match(/\[\/([a-z0-9 -()^]+)\]/i))) {
|
||||
html += "</optgroup>";
|
||||
} else {
|
||||
html += "<option populate-value='" + this.value[i].value + "'>" +
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
*/
|
||||
var HighlighterWaiter = function(app) {
|
||||
this.app = app;
|
||||
|
||||
|
||||
this.mouse_button_down = false;
|
||||
this.mouse_target = null;
|
||||
};
|
||||
|
@ -40,7 +40,7 @@ HighlighterWaiter.OUTPUT = 1;
|
|||
HighlighterWaiter.prototype._is_selection_backwards = function() {
|
||||
var backwards = false,
|
||||
sel = window.getSelection();
|
||||
|
||||
|
||||
if (!sel.isCollapsed) {
|
||||
var range = document.createRange();
|
||||
range.setStart(sel.anchorNode, sel.anchorOffset);
|
||||
|
@ -63,12 +63,12 @@ HighlighterWaiter.prototype._is_selection_backwards = function() {
|
|||
HighlighterWaiter.prototype._get_output_html_offset = function(node, offset) {
|
||||
var sel = window.getSelection(),
|
||||
range = document.createRange();
|
||||
|
||||
|
||||
range.selectNodeContents(document.getElementById("output-html"));
|
||||
range.setEnd(node, offset);
|
||||
sel.removeAllRanges();
|
||||
sel.addRange(range);
|
||||
|
||||
|
||||
return sel.toString().length;
|
||||
};
|
||||
|
||||
|
@ -87,7 +87,7 @@ HighlighterWaiter.prototype._get_output_html_selection_offsets = function() {
|
|||
start = 0,
|
||||
end = 0,
|
||||
backwards = false;
|
||||
|
||||
|
||||
if (sel.rangeCount) {
|
||||
range = sel.getRangeAt(sel.rangeCount - 1);
|
||||
backwards = this._is_selection_backwards();
|
||||
|
@ -95,7 +95,7 @@ HighlighterWaiter.prototype._get_output_html_selection_offsets = function() {
|
|||
end = this._get_output_html_offset(range.endContainer, range.endOffset);
|
||||
sel.removeAllRanges();
|
||||
sel.addRange(range);
|
||||
|
||||
|
||||
if (backwards) {
|
||||
// If selecting backwards, reverse the start and end offsets for the selection to
|
||||
// prevent deselecting as the drag continues.
|
||||
|
@ -103,7 +103,7 @@ HighlighterWaiter.prototype._get_output_html_selection_offsets = function() {
|
|||
sel.extend(sel.anchorNode, range.startOffset);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return {
|
||||
start: start,
|
||||
end: end
|
||||
|
@ -147,11 +147,11 @@ HighlighterWaiter.prototype.input_mousedown = function(e) {
|
|||
this.mouse_button_down = true;
|
||||
this.mouse_target = HighlighterWaiter.INPUT;
|
||||
this.remove_highlights();
|
||||
|
||||
|
||||
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}]);
|
||||
|
@ -169,11 +169,11 @@ HighlighterWaiter.prototype.output_mousedown = function(e) {
|
|||
this.mouse_button_down = true;
|
||||
this.mouse_target = HighlighterWaiter.OUTPUT;
|
||||
this.remove_highlights();
|
||||
|
||||
|
||||
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}]);
|
||||
|
@ -190,7 +190,7 @@ HighlighterWaiter.prototype.output_mousedown = function(e) {
|
|||
HighlighterWaiter.prototype.output_html_mousedown = function(e) {
|
||||
this.mouse_button_down = true;
|
||||
this.mouse_target = HighlighterWaiter.OUTPUT;
|
||||
|
||||
|
||||
var sel = this._get_output_html_selection_offsets();
|
||||
if (sel.start !== 0 || sel.end !== 0) {
|
||||
document.getElementById("output-selection-info").innerHTML = this.selection_info(sel.start, sel.end);
|
||||
|
@ -237,10 +237,10 @@ HighlighterWaiter.prototype.output_html_mouseup = function(e) {
|
|||
HighlighterWaiter.prototype.input_mousemove = function(e) {
|
||||
// Check that the left mouse button is pressed
|
||||
if (!this.mouse_button_down ||
|
||||
e.which != 1 ||
|
||||
this.mouse_target != HighlighterWaiter.INPUT)
|
||||
e.which !== 1 ||
|
||||
this.mouse_target !== HighlighterWaiter.INPUT)
|
||||
return;
|
||||
|
||||
|
||||
var el = e.target,
|
||||
start = el.selectionStart,
|
||||
end = el.selectionEnd;
|
||||
|
@ -261,14 +261,14 @@ HighlighterWaiter.prototype.input_mousemove = function(e) {
|
|||
HighlighterWaiter.prototype.output_mousemove = function(e) {
|
||||
// Check that the left mouse button is pressed
|
||||
if (!this.mouse_button_down ||
|
||||
e.which != 1 ||
|
||||
this.mouse_target != HighlighterWaiter.OUTPUT)
|
||||
e.which !== 1 ||
|
||||
this.mouse_target !== HighlighterWaiter.OUTPUT)
|
||||
return;
|
||||
|
||||
|
||||
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}]);
|
||||
|
@ -285,10 +285,10 @@ HighlighterWaiter.prototype.output_mousemove = function(e) {
|
|||
HighlighterWaiter.prototype.output_html_mousemove = function(e) {
|
||||
// Check that the left mouse button is pressed
|
||||
if (!this.mouse_button_down ||
|
||||
e.which != 1 ||
|
||||
this.mouse_target != HighlighterWaiter.OUTPUT)
|
||||
e.which !== 1 ||
|
||||
this.mouse_target !== HighlighterWaiter.OUTPUT)
|
||||
return;
|
||||
|
||||
|
||||
var sel = this._get_output_html_selection_offsets();
|
||||
if (sel.start !== 0 || sel.end !== 0) {
|
||||
document.getElementById("output-selection-info").innerHTML = this.selection_info(sel.start, sel.end);
|
||||
|
@ -310,7 +310,7 @@ HighlighterWaiter.prototype.selection_info = function(start, end) {
|
|||
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, " ");
|
||||
|
||||
|
||||
return "start: " + start_str + "<br>end: " + end_str + "<br>length: " + len_str;
|
||||
};
|
||||
|
||||
|
@ -327,7 +327,7 @@ HighlighterWaiter.prototype.remove_highlights = function() {
|
|||
|
||||
|
||||
/**
|
||||
* Generates a list of all the highlight functions assigned to operations in the recipe, if the
|
||||
* Generates a list of all the highlight functions assigned to operations in the recipe, if the
|
||||
* entire recipe supports highlighting.
|
||||
*
|
||||
* @returns {Object[]} highlights
|
||||
|
@ -338,25 +338,25 @@ HighlighterWaiter.prototype.remove_highlights = function() {
|
|||
HighlighterWaiter.prototype.generate_highlight_list = function() {
|
||||
var recipe_config = this.app.get_recipe_config(),
|
||||
highlights = [];
|
||||
|
||||
|
||||
for (var i = 0; i < recipe_config.length; i++) {
|
||||
if (recipe_config[i].disabled) continue;
|
||||
|
||||
|
||||
// If any breakpoints are set, do not attempt to highlight
|
||||
if (recipe_config[i].breakpoint) return false;
|
||||
|
||||
|
||||
var op = this.app.operations[recipe_config[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
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
return highlights;
|
||||
};
|
||||
|
||||
|
@ -382,12 +382,12 @@ HighlighterWaiter.prototype.highlight_output = function(pos) {
|
|||
for (var i = 0; i < highlights.length; i++) {
|
||||
// Remove multiple highlights before processing again
|
||||
pos = [pos[0]];
|
||||
|
||||
|
||||
if (typeof highlights[i].f == "function") {
|
||||
pos = highlights[i].f(pos, highlights[i].args);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
document.getElementById("output-selection-info").innerHTML = this.selection_info(pos[0].start, pos[0].end);
|
||||
this.highlight(
|
||||
document.getElementById("output-text"),
|
||||
|
@ -409,7 +409,7 @@ HighlighterWaiter.prototype.highlight_output = function(pos) {
|
|||
*/
|
||||
HighlighterWaiter.prototype.highlight_input = function(pos) {
|
||||
var highlights = this.generate_highlight_list();
|
||||
|
||||
|
||||
if (!highlights || !this.app.auto_bake_) {
|
||||
return false;
|
||||
}
|
||||
|
@ -417,12 +417,12 @@ HighlighterWaiter.prototype.highlight_input = function(pos) {
|
|||
for (var i = 0; i < highlights.length; i++) {
|
||||
// Remove multiple highlights before processing again
|
||||
pos = [pos[0]];
|
||||
|
||||
|
||||
if (typeof highlights[i].b == "function") {
|
||||
pos = highlights[i].b(pos, highlights[i].args);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
document.getElementById("input-selection-info").innerHTML = this.selection_info(pos[0].start, pos[0].end);
|
||||
this.highlight(
|
||||
document.getElementById("input-text"),
|
||||
|
@ -444,21 +444,21 @@ HighlighterWaiter.prototype.highlight_input = function(pos) {
|
|||
HighlighterWaiter.prototype.highlight = function(textarea, highlighter, pos) {
|
||||
if (!this.app.options.show_highlighter) return false;
|
||||
if (!this.app.options.attempt_highlight) 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;
|
||||
|
||||
|
||||
var start_placeholder = "[start_highlight]",
|
||||
start_placeholder_regex = /\[start_highlight\]/g,
|
||||
end_placeholder = "[end_highlight]",
|
||||
end_placeholder_regex = /\[end_highlight\]/g,
|
||||
text = textarea.value;
|
||||
|
||||
|
||||
// Put placeholders in position
|
||||
// If there's only one value, select that
|
||||
// If there are multiple, ignore the first one and select all others
|
||||
if (pos.length == 1) {
|
||||
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 +
|
||||
|
@ -467,15 +467,15 @@ HighlighterWaiter.prototype.highlight = function(textarea, highlighter, pos) {
|
|||
// O(n^2) - Can anyone improve this without overwriting placeholders?
|
||||
var result = "",
|
||||
end_placed = 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) {
|
||||
if (pos[j].start === i) {
|
||||
result += start_placeholder;
|
||||
end_placed = false;
|
||||
}
|
||||
if (pos[j].end == i) {
|
||||
if (pos[j].end === i) {
|
||||
result += end_placeholder;
|
||||
end_placed = true;
|
||||
}
|
||||
|
@ -485,10 +485,10 @@ HighlighterWaiter.prototype.highlight = function(textarea, highlighter, pos) {
|
|||
if (!end_placed) result += end_placeholder;
|
||||
text = result;
|
||||
}
|
||||
|
||||
|
||||
var css_class = "hl1";
|
||||
//if (colour) css_class += "-"+colour;
|
||||
|
||||
|
||||
// Remove HTML tags
|
||||
text = text.replace(/&/g, "&")
|
||||
.replace(/</g, "<")
|
||||
|
@ -497,7 +497,7 @@ HighlighterWaiter.prototype.highlight = function(textarea, highlighter, pos) {
|
|||
// Convert placeholders to tags
|
||||
.replace(start_placeholder_regex, "<span class=\""+css_class+"\">")
|
||||
.replace(end_placeholder_regex, "</span>") + " ";
|
||||
|
||||
|
||||
// Adjust width to allow for scrollbars
|
||||
highlighter.style.width = textarea.clientWidth + "px";
|
||||
highlighter.innerHTML = text;
|
||||
|
|
|
@ -21,12 +21,12 @@ var InputWaiter = function(app, manager) {
|
|||
19, //Pause
|
||||
20, //Caps
|
||||
27, //Esc
|
||||
33,34,35,36, //PgUp, PgDn, End, Home
|
||||
37,38,39,40, //Directional
|
||||
33, 34, 35, 36, //PgUp, PgDn, End, Home
|
||||
37, 38, 39, 40, //Directional
|
||||
44, //PrntScrn
|
||||
91,92, //Win
|
||||
91, 92, //Win
|
||||
93, //Context
|
||||
112,113,114,115,116,117,118,119,120,121,122,123, //F1-12
|
||||
112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, //F1-12
|
||||
144, //Num
|
||||
145, //Scroll
|
||||
];
|
||||
|
@ -162,8 +162,8 @@ InputWaiter.prototype.input_drop = function(e) {
|
|||
|
||||
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"]});
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -178,14 +178,14 @@ InputWaiter.prototype.input_drop = function(e) {
|
|||
el.value = "Processing... " + Math.round(offset / file.size * 100) + "%";
|
||||
var slice = file.slice(offset, offset + CHUNK_SIZE);
|
||||
reader.readAsArrayBuffer(slice);
|
||||
}.bind(this);
|
||||
};
|
||||
|
||||
reader.onload = function(e) {
|
||||
var data = new Uint8Array(reader.result);
|
||||
input_charcode += Utils.to_hex_fast(data);
|
||||
offset += CHUNK_SIZE;
|
||||
seek();
|
||||
}.bind(this);
|
||||
};
|
||||
|
||||
|
||||
el.classList.remove("dropping-file");
|
||||
|
|
|
@ -29,7 +29,7 @@ var OperationsWaiter = function(app, manager) {
|
|||
OperationsWaiter.prototype.search_operations = function(e) {
|
||||
var ops, selected;
|
||||
|
||||
if (e.type == "search") { // Search
|
||||
if (e.type === "search") { // Search
|
||||
e.preventDefault();
|
||||
ops = document.querySelectorAll("#search-results li");
|
||||
if (ops.length) {
|
||||
|
@ -41,9 +41,9 @@ OperationsWaiter.prototype.search_operations = function(e) {
|
|||
}
|
||||
}
|
||||
|
||||
if (e.keyCode == 13) { // Return
|
||||
if (e.keyCode === 13) { // Return
|
||||
e.preventDefault();
|
||||
} else if (e.keyCode == 40) { // Down
|
||||
} else if (e.keyCode === 40) { // Down
|
||||
e.preventDefault();
|
||||
ops = document.querySelectorAll("#search-results li");
|
||||
if (ops.length) {
|
||||
|
@ -51,10 +51,10 @@ OperationsWaiter.prototype.search_operations = function(e) {
|
|||
if (selected > -1) {
|
||||
ops[selected].classList.remove("selected-op");
|
||||
}
|
||||
if (selected == ops.length-1) selected = -1;
|
||||
if (selected === ops.length-1) selected = -1;
|
||||
ops[selected+1].classList.add("selected-op");
|
||||
}
|
||||
} else if (e.keyCode == 38) { // Up
|
||||
} else if (e.keyCode === 38) { // Up
|
||||
e.preventDefault();
|
||||
ops = document.querySelectorAll("#search-results li");
|
||||
if (ops.length) {
|
||||
|
@ -183,7 +183,7 @@ OperationsWaiter.prototype.edit_favourites_click = function(e) {
|
|||
|
||||
// Add favourites to modal
|
||||
var fav_cat = this.app.categories.filter(function(c) {
|
||||
return c.name == "Favourites";
|
||||
return c.name === "Favourites";
|
||||
})[0];
|
||||
|
||||
var html = "";
|
||||
|
@ -198,7 +198,7 @@ OperationsWaiter.prototype.edit_favourites_click = function(e) {
|
|||
this.remove_intent = false;
|
||||
|
||||
var editable_list = Sortable.create(edit_favourites_list, {
|
||||
filter: '.remove-icon',
|
||||
filter: ".remove-icon",
|
||||
onFilter: function (evt) {
|
||||
var el = editable_list.closest(evt.item);
|
||||
if (el) {
|
||||
|
@ -212,11 +212,11 @@ OperationsWaiter.prototype.edit_favourites_click = function(e) {
|
|||
});
|
||||
|
||||
Sortable.utils.on(edit_favourites_list, "dragleave", function() {
|
||||
this.remove_intent = true;
|
||||
this.remove_intent = true;
|
||||
}.bind(this));
|
||||
|
||||
Sortable.utils.on(edit_favourites_list, "dragover", function() {
|
||||
this.remove_intent = false;
|
||||
this.remove_intent = false;
|
||||
}.bind(this));
|
||||
|
||||
$("#edit-favourites-list [data-toggle=popover]").popover();
|
||||
|
@ -260,7 +260,7 @@ OperationsWaiter.prototype.reset_favourites_click = function() {
|
|||
*/
|
||||
OperationsWaiter.prototype.op_icon_mouseover = function(e) {
|
||||
var op_el = e.target.parentNode;
|
||||
if (e.target.getAttribute("data-toggle") == "popover") {
|
||||
if (e.target.getAttribute("data-toggle") === "popover") {
|
||||
$(op_el).popover("hide");
|
||||
}
|
||||
};
|
||||
|
@ -277,7 +277,7 @@ OperationsWaiter.prototype.op_icon_mouseleave = function(e) {
|
|||
var op_el = e.target.parentNode,
|
||||
to_el = e.toElement || e.relatedElement;
|
||||
|
||||
if (e.target.getAttribute("data-toggle") == "popover" && to_el === op_el) {
|
||||
if (e.target.getAttribute("data-toggle") === "popover" && to_el === op_el) {
|
||||
$(op_el).popover("show");
|
||||
}
|
||||
};
|
||||
|
|
|
@ -38,7 +38,7 @@ OutputWaiter.prototype.set = function(data_str, type, duration) {
|
|||
output_highlighter = document.getElementById("output-highlighter"),
|
||||
input_highlighter = document.getElementById("input-highlighter");
|
||||
|
||||
if (type == "html") {
|
||||
if (type === "html") {
|
||||
output_text.style.display = "none";
|
||||
output_html.style.display = "block";
|
||||
output_highlighter.display = "none";
|
||||
|
@ -51,7 +51,7 @@ OutputWaiter.prototype.set = function(data_str, type, duration) {
|
|||
var script_elements = output_html.querySelectorAll("script");
|
||||
for (var i = 0; i < script_elements.length; i++) {
|
||||
try {
|
||||
eval(script_elements[i].innerHTML); // jshint ignore:line
|
||||
eval(script_elements[i].innerHTML); // eslint-disable-line no-eval
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
|
|
|
@ -22,8 +22,7 @@ var RecipeWaiter = function(app, manager) {
|
|||
* 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"),
|
||||
op_lists = document.querySelectorAll(".category .op_list");
|
||||
var rec_list = document.getElementById("rec_list");
|
||||
|
||||
|
||||
// Recipe list
|
||||
|
@ -102,7 +101,7 @@ RecipeWaiter.prototype.create_sortable_seed_list = function(list_el) {
|
|||
*/
|
||||
RecipeWaiter.prototype.op_sort_end = function(evt) {
|
||||
if (this.remove_intent) {
|
||||
if (evt.item.parentNode.id == "rec_list") {
|
||||
if (evt.item.parentNode.id === "rec_list") {
|
||||
evt.item.remove();
|
||||
}
|
||||
return;
|
||||
|
@ -197,7 +196,7 @@ RecipeWaiter.prototype.ing_change = function() {
|
|||
RecipeWaiter.prototype.disable_click = function(e) {
|
||||
var icon = e.target;
|
||||
|
||||
if (icon.getAttribute("disabled") == "false") {
|
||||
if (icon.getAttribute("disabled") === "false") {
|
||||
icon.setAttribute("disabled", "true");
|
||||
icon.classList.add("disable-icon-selected");
|
||||
icon.parentNode.parentNode.classList.add("disabled");
|
||||
|
@ -222,7 +221,7 @@ RecipeWaiter.prototype.disable_click = function(e) {
|
|||
RecipeWaiter.prototype.breakpoint_click = function(e) {
|
||||
var bp = e.target;
|
||||
|
||||
if (bp.getAttribute("break") == "false") {
|
||||
if (bp.getAttribute("break") === "false") {
|
||||
bp.setAttribute("break", "true");
|
||||
bp.classList.add("breakpoint-selected");
|
||||
} else {
|
||||
|
@ -276,7 +275,7 @@ RecipeWaiter.prototype.get_config = function() {
|
|||
ing_list = operations[i].querySelectorAll(".arg");
|
||||
|
||||
for (var j = 0; j < ing_list.length; j++) {
|
||||
if (ing_list[j].getAttribute("type") == "checkbox") {
|
||||
if (ing_list[j].getAttribute("type") === "checkbox") {
|
||||
// checkbox
|
||||
ingredients[j] = ing_list[j].checked;
|
||||
} else if (ing_list[j].classList.contains("toggle-string")) {
|
||||
|
@ -296,11 +295,11 @@ RecipeWaiter.prototype.get_config = function() {
|
|||
args: ingredients
|
||||
};
|
||||
|
||||
if (disabled && disabled.getAttribute("disabled") == "true") {
|
||||
if (disabled && disabled.getAttribute("disabled") === "true") {
|
||||
item.disabled = true;
|
||||
}
|
||||
|
||||
if (bp && bp.getAttribute("break") == "true") {
|
||||
if (bp && bp.getAttribute("break") === "true") {
|
||||
item.breakpoint = true;
|
||||
}
|
||||
|
||||
|
@ -319,7 +318,7 @@ RecipeWaiter.prototype.get_config = function() {
|
|||
RecipeWaiter.prototype.update_breakpoint_indicator = function(position) {
|
||||
var operations = document.querySelectorAll("#rec_list li.operation");
|
||||
for (var i = 0; i < operations.length; i++) {
|
||||
if (i == position) {
|
||||
if (i === position) {
|
||||
operations[i].classList.add("break");
|
||||
} else {
|
||||
operations[i].classList.remove("break");
|
||||
|
@ -360,10 +359,11 @@ RecipeWaiter.prototype.build_recipe_operation = function(el) {
|
|||
*/
|
||||
RecipeWaiter.prototype.add_operation = 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);
|
||||
|
||||
item.classList.add("operation");
|
||||
item.innerHTML = name;
|
||||
this.build_recipe_operation(item);
|
||||
document.getElementById("rec_list").appendChild(item);
|
||||
|
||||
item.dispatchEvent(this.manager.operationadd);
|
||||
return item;
|
||||
|
@ -420,4 +420,4 @@ RecipeWaiter.prototype.op_add = function(e) {
|
|||
*/
|
||||
RecipeWaiter.prototype.op_remove = function(e) {
|
||||
window.dispatchEvent(this.manager.statechange);
|
||||
};
|
||||
};
|
||||
|
|
|
@ -20,23 +20,23 @@ var SeasonalWaiter = function(app, manager) {
|
|||
*/
|
||||
SeasonalWaiter.prototype.load = function() {
|
||||
var now = new Date();
|
||||
|
||||
|
||||
// Snowfall
|
||||
if (now.getMonth() == 11 && now.getDate() > 12) { // Dec 13 -> Dec 31
|
||||
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();
|
||||
if (now.getDate() === 25) this.let_it_snow();
|
||||
}
|
||||
|
||||
|
||||
// SpiderChef
|
||||
// if (now.getMonth() == 3 && now.getDate() == 1) { // Apr 1
|
||||
// if (now.getMonth() === 3 && now.getDate() === 1) { // Apr 1
|
||||
// this.insert_spider_icons();
|
||||
// this.insert_spider_text();
|
||||
// }
|
||||
|
||||
|
||||
// Konami code
|
||||
this.kkeys = [];
|
||||
window.addEventListener("keydown", this.konami_code_listener.bind(this));
|
||||
|
@ -51,13 +51,13 @@ SeasonalWaiter.prototype.insert_spider_icons = function() {
|
|||
var spider16 = "iVBORw0KGgoAAAANSUhEUgAAAB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7Wol4vF4AIldVVxdZqlrIfiCYQPHDy6bAGv7nKYRVY6JewExZVAP+ey5Rv+Ba97aaUHMW5NauLmMZFkegBb/EP14d6NoS9QLWFSzWBmuZza8CQmSpXsAqmGtVy14VALWuuYWWy+W3OteXa4jwceQX6+BKG6J1/8+2VCNkm2222WabbbbZZpttttlmm22rt38DCdA0vq3bcAkAAAAASUVORK5CYII=";
|
||||
|
||||
|
||||
// Favicon
|
||||
document.querySelector("link[rel=icon]").setAttribute("href", "data:image/png;base64," + spider16);
|
||||
|
||||
|
||||
// Bake button
|
||||
document.querySelector("#bake img").setAttribute("src", "data:image/png;base64," + spider32);
|
||||
|
||||
|
||||
// About box
|
||||
document.querySelector(".about-img-left").setAttribute("src", "data:image/png;base64," + spider64);
|
||||
};
|
||||
|
@ -70,23 +70,23 @@ SeasonalWaiter.prototype.insert_spider_icons = function() {
|
|||
SeasonalWaiter.prototype.insert_spider_text = function() {
|
||||
// Title
|
||||
document.title = document.title.replace(/Cyber/g, "Spider");
|
||||
|
||||
|
||||
// Body
|
||||
SeasonalWaiter.tree_walk(document.body, function(node) {
|
||||
// process only text nodes
|
||||
if (node.nodeType == 3) {
|
||||
if (node.nodeType === 3) {
|
||||
node.nodeValue = node.nodeValue.replace(/Cyber/g, "Spider");
|
||||
}
|
||||
}, true);
|
||||
|
||||
|
||||
// Bake button
|
||||
SeasonalWaiter.tree_walk(document.getElementById("bake-group"), function(node) {
|
||||
// process only text nodes
|
||||
if (node.nodeType == 3) {
|
||||
if (node.nodeType === 3) {
|
||||
node.nodeValue = node.nodeValue.replace(/Bake/g, "Spin");
|
||||
}
|
||||
}, true);
|
||||
|
||||
|
||||
// Recipe title
|
||||
document.querySelector("#recipe .title").innerHTML = "Web";
|
||||
};
|
||||
|
@ -99,13 +99,13 @@ SeasonalWaiter.prototype.insert_spider_text = function() {
|
|||
SeasonalWaiter.prototype.create_snow_option = function() {
|
||||
var options_body = document.getElementById("options-body"),
|
||||
option_item = document.createElement("div");
|
||||
|
||||
|
||||
option_item.className = "option-item";
|
||||
option_item.innerHTML =
|
||||
option_item.innerHTML =
|
||||
"<input type='checkbox' option='snow' checked />\
|
||||
Let it snow";
|
||||
options_body.appendChild(option_item);
|
||||
|
||||
|
||||
this.manager.options.load();
|
||||
};
|
||||
|
||||
|
@ -117,44 +117,44 @@ SeasonalWaiter.prototype.create_snow_option = function() {
|
|||
SeasonalWaiter.prototype.let_it_snow = function() {
|
||||
$(document).snowfall("clear");
|
||||
if (!this.app.options.snow) return;
|
||||
|
||||
|
||||
var options = {},
|
||||
firefox_version = navigator.userAgent.match(/Firefox\/(\d\d?)/);
|
||||
|
||||
|
||||
if (firefox_version && parseInt(firefox_version[1], 10) < 30) {
|
||||
// Firefox < 30
|
||||
options = {
|
||||
flakeCount : 10,
|
||||
flakeColor : '#fff',
|
||||
flakePosition: 'absolute',
|
||||
minSize : 1,
|
||||
maxSize : 2,
|
||||
minSpeed : 1,
|
||||
maxSpeed : 5,
|
||||
round : false,
|
||||
shadow : false,
|
||||
collection : false,
|
||||
collectionHeight : 20,
|
||||
deviceorientation : true
|
||||
flakeCount: 10,
|
||||
flakeColor: "#fff",
|
||||
flakePosition: "absolute",
|
||||
minSize: 1,
|
||||
maxSize: 2,
|
||||
minSpeed: 1,
|
||||
maxSpeed: 5,
|
||||
round: false,
|
||||
shadow: false,
|
||||
collection: false,
|
||||
collectionHeight: 20,
|
||||
deviceorientation: true
|
||||
};
|
||||
} else {
|
||||
// All other browsers
|
||||
options = {
|
||||
flakeCount : 35, //35
|
||||
flakeColor : '#fff',
|
||||
flakePosition: 'absolute',
|
||||
minSize : 5,
|
||||
maxSize : 8,
|
||||
minSpeed : 1,
|
||||
maxSpeed : 5,
|
||||
round : true,
|
||||
shadow : true,
|
||||
collection : ".btn",
|
||||
collectionHeight : 20,
|
||||
deviceorientation : true
|
||||
flakeCount: 35,
|
||||
flakeColor: "#fff",
|
||||
flakePosition: "absolute",
|
||||
minSize: 5,
|
||||
maxSize: 8,
|
||||
minSpeed: 1,
|
||||
maxSpeed: 5,
|
||||
round: true,
|
||||
shadow: true,
|
||||
collection: ".btn",
|
||||
collectionHeight: 20,
|
||||
deviceorientation: true
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
$(document).snowfall(options);
|
||||
};
|
||||
|
||||
|
@ -172,12 +172,12 @@ SeasonalWaiter.prototype.shake_off_snow = function(e) {
|
|||
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
||||
$(this).fadeIn();
|
||||
};
|
||||
|
||||
|
||||
for (var i = 0; i < canvases.length; i++) {
|
||||
canvas = canvases[i];
|
||||
if (canvas.style.left == rect.left + "px" && canvas.style.top == (rect.top - 20) + "px") {
|
||||
if (canvas.style.left === rect.left + "px" && canvas.style.top === (rect.top - 20) + "px") {
|
||||
var ctx = canvas.getContext("2d");
|
||||
|
||||
|
||||
$(canvas).fadeOut("slow", remove_func);
|
||||
break;
|
||||
}
|
||||
|
@ -192,13 +192,13 @@ SeasonalWaiter.prototype.shake_off_snow = function(e) {
|
|||
*/
|
||||
SeasonalWaiter.prototype.konami_code_listener = function(e) {
|
||||
this.kkeys.push(e.keyCode);
|
||||
var konami = [38,38,40,40,37,39,37,39,66,65];
|
||||
var konami = [38, 38, 40, 40, 37, 39, 37, 39, 66, 65];
|
||||
for (var i = 0; i < this.kkeys.length; i++) {
|
||||
if (this.kkeys[i] != konami[i]) {
|
||||
if (this.kkeys[i] !== konami[i]) {
|
||||
this.kkeys = [];
|
||||
break;
|
||||
}
|
||||
if (i == konami.length - 1) {
|
||||
if (i === konami.length - 1) {
|
||||
$("body").children().toggleClass("konami");
|
||||
this.kkeys = [];
|
||||
}
|
||||
|
@ -217,14 +217,14 @@ SeasonalWaiter.prototype.konami_code_listener = function(e) {
|
|||
SeasonalWaiter.tree_walk = (function() {
|
||||
// Create closure for constants
|
||||
var skipTags = {
|
||||
"SCRIPT": true, "IFRAME": true, "OBJECT": true,
|
||||
"SCRIPT": true, "IFRAME": true, "OBJECT": true,
|
||||
"EMBED": true, "STYLE": true, "LINK": true, "META": true
|
||||
};
|
||||
|
||||
|
||||
return function(parent, fn, all_nodes) {
|
||||
var node = parent.firstChild;
|
||||
|
||||
while (node && node != parent) {
|
||||
|
||||
while (node && node !== parent) {
|
||||
if (all_nodes || node.nodeType === 1) {
|
||||
if (fn(node) === false) {
|
||||
return(false);
|
||||
|
@ -243,7 +243,7 @@ SeasonalWaiter.tree_walk = (function() {
|
|||
} else {
|
||||
// No child and no nextsibling
|
||||
// Find parent that has a nextSibling
|
||||
while ((node = node.parentNode) != parent) {
|
||||
while ((node = node.parentNode) !== parent) {
|
||||
if (node.nextSibling) {
|
||||
node = node.nextSibling;
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue