Updated eslint whitespace rules

This commit is contained in:
n1474335 2017-02-09 15:09:33 +00:00
parent ebf2258715
commit e803d208e8
51 changed files with 801 additions and 793 deletions

View file

@ -30,13 +30,13 @@ ControlsWaiter.prototype.adjustWidth = function() {
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";
} else {
step.childNodes[1].nodeValue = " Step through";
}
if (controls.clientWidth < 400) {
saveImg.style.display = "none";
loadImg.style.display = "none";
@ -50,7 +50,7 @@ ControlsWaiter.prototype.adjustWidth = function() {
clrRecipImg.style.display = "inline";
clrBreaksImg.style.display = "inline";
}
if (controls.clientWidth < 330) {
clrBreaks.childNodes[1].nodeValue = " Clear breaks";
} else {
@ -66,7 +66,7 @@ ControlsWaiter.prototype.adjustWidth = function() {
*/
ControlsWaiter.prototype.setAutoBake = function(value) {
var autoBakeCheckbox = document.getElementById("auto-bake");
if (autoBakeCheckbox.checked !== value) {
autoBakeCheckbox.click();
}
@ -97,9 +97,9 @@ ControlsWaiter.prototype.stepClick = function() {
ControlsWaiter.prototype.autoBakeChange = function() {
var autoBakeLabel = document.getElementById("auto-bake-label"),
autoBakeCheckbox = document.getElementById("auto-bake");
this.app.autoBake_ = autoBakeCheckbox.checked;
if (autoBakeCheckbox.checked) {
autoBakeLabel.classList.remove("btn-default");
autoBakeLabel.classList.add("btn-success");
@ -124,7 +124,7 @@ ControlsWaiter.prototype.clearRecipeClick = function() {
*/
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");
bps[i].classList.remove("breakpoint-selected");
@ -139,12 +139,12 @@ ControlsWaiter.prototype.clearBreaksClick = function() {
*/
ControlsWaiter.prototype.initialiseSaveLink = function(recipeConfig) {
recipeConfig = recipeConfig || this.app.getRecipeConfig();
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);
saveLinkEl.innerHTML = Utils.truncate(saveLink, 120);
saveLinkEl.setAttribute("href", saveLink);
};
@ -161,26 +161,26 @@ ControlsWaiter.prototype.initialiseSaveLink = function(recipeConfig) {
*/
ControlsWaiter.prototype.generateStateUrl = function(includeRecipe, includeInput, recipeConfig, baseURL) {
recipeConfig = recipeConfig || this.app.getRecipeConfig();
var link = baseURL || window.location.protocol + "//" +
window.location.host +
window.location.pathname,
recipeStr = JSON.stringify(recipeConfig),
inputStr = Utils.toBase64(this.app.getInput(), "A-Za-z0-9+/"); // B64 alphabet with no padding
includeRecipe = includeRecipe && (recipeConfig.length > 0);
includeInput = includeInput && (inputStr.length > 0) && (inputStr.length < 8000);
if (includeRecipe) {
link += "?recipe=" + encodeURIComponent(recipeStr);
}
if (includeRecipe && includeInput) {
link += "&input=" + encodeURIComponent(inputStr);
} else if (includeInput) {
link += "?input=" + encodeURIComponent(inputStr);
}
return link;
};
@ -192,7 +192,7 @@ ControlsWaiter.prototype.saveTextChange = function() {
try {
var recipeConfig = JSON.parse(document.getElementById("save-text").value);
this.initialiseSaveLink(recipeConfig);
} catch(err) {}
} catch (err) {}
};
@ -202,9 +202,9 @@ ControlsWaiter.prototype.saveTextChange = function() {
ControlsWaiter.prototype.saveClick = function() {
var recipeConfig = this.app.getRecipeConfig(),
recipeStr = JSON.stringify(recipeConfig).replace(/},{/g, "},\n{");
document.getElementById("save-text").value = recipeStr;
this.initialiseSaveLink(recipeConfig);
$("#save-modal").modal();
};
@ -241,25 +241,25 @@ ControlsWaiter.prototype.loadClick = function() {
ControlsWaiter.prototype.saveButtonClick = function() {
var recipeName = document.getElementById("save-name").value,
recipeStr = document.getElementById("save-text").value;
if (!recipeName) {
this.app.alert("Please enter a recipe name", "danger", 2000);
return;
}
var savedRecipes = localStorage.savedRecipes ?
JSON.parse(localStorage.savedRecipes) : [],
recipeId = localStorage.recipeId || 0;
savedRecipes.push({
id: ++recipeId,
name: recipeName,
recipe: recipeStr
});
localStorage.savedRecipes = JSON.stringify(savedRecipes);
localStorage.recipeId = recipeId;
this.app.alert("Recipe saved as \"" + recipeName + "\".", "success", 2000);
};
@ -269,7 +269,7 @@ ControlsWaiter.prototype.saveButtonClick = function() {
*/
ControlsWaiter.prototype.populateLoadRecipesList = function() {
var loadNameEl = document.getElementById("load-name");
// Remove current recipes from select
var i = loadNameEl.options.length;
while (i--) {
@ -279,15 +279,15 @@ ControlsWaiter.prototype.populateLoadRecipesList = function() {
// Add recipes to select
var savedRecipes = localStorage.savedRecipes ?
JSON.parse(localStorage.savedRecipes) : [];
for (i = 0; i < savedRecipes.length; i++) {
var opt = document.createElement("option");
opt.value = savedRecipes[i].id;
opt.innerHTML = savedRecipes[i].name;
loadNameEl.appendChild(opt);
}
// Populate textarea with first recipe
document.getElementById("load-text").value = savedRecipes.length ? savedRecipes[0].recipe : "";
};
@ -300,11 +300,11 @@ ControlsWaiter.prototype.loadDeleteClick = function() {
var id = parseInt(document.getElementById("load-name").value, 10),
savedRecipes = localStorage.savedRecipes ?
JSON.parse(localStorage.savedRecipes) : [];
savedRecipes = savedRecipes.filter(function(r) {
return r.id !== id;
});
localStorage.savedRecipes = JSON.stringify(savedRecipes);
this.populateLoadRecipesList();
};
@ -318,11 +318,11 @@ ControlsWaiter.prototype.loadNameChange = function(e) {
savedRecipes = localStorage.savedRecipes ?
JSON.parse(localStorage.savedRecipes) : [],
id = parseInt(el.value, 10);
var recipe = savedRecipes.filter(function(r) {
return r.id === id;
})[0];
document.getElementById("load-text").value = recipe.recipe;
};
@ -336,7 +336,7 @@ ControlsWaiter.prototype.loadButtonClick = function() {
this.app.setRecipeConfig(recipeConfig);
$("#rec-list [data-toggle=popover]").popover();
} catch(e) {
} catch (e) {
this.app.alert("Invalid recipe", "danger", 2000);
}
};

View file

@ -362,13 +362,13 @@ HTMLApp.prototype.loadURIParams = function() {
try {
var recipeConfig = JSON.parse(this.queryString.recipe);
this.setRecipeConfig(recipeConfig);
} catch(err) {}
} catch (err) {}
} else if (this.queryString.op) {
// If there's no recipe, look for single operations
this.manager.recipe.clearRecipe();
try {
this.manager.recipe.addOperation(this.queryString.op);
} catch(err) {
} catch (err) {
// If no exact match, search for nearest match and add that
var matchedOps = this.manager.ops.filterOperations(this.queryString.op, false);
if (matchedOps.length) {
@ -388,7 +388,7 @@ HTMLApp.prototype.loadURIParams = function() {
try {
var inputData = Utils.fromBase64(this.queryString.input);
this.setInput(inputData);
} catch(err) {}
} catch (err) {}
}
// Restore auto-bake state

View file

@ -40,11 +40,11 @@ HTMLCategory.prototype.toHtml = function() {
</a>\
<div id='" + catName + "' class='panel-collapse collapse\
" + (this.selected ? " in" : "") + "'><ul class='op-list'>";
for (var i = 0; i < this.opList.length; i++) {
html += this.opList[i].toStubHtml();
}
html += "</ul></div></div>";
return html;
};

View file

@ -13,7 +13,7 @@
var HTMLIngredient = function(config, app, manager) {
this.app = app;
this.manager = manager;
this.name = config.name;
this.type = config.type;
this.value = config.value;
@ -39,11 +39,11 @@ HTMLIngredient.prototype.toHtml = function() {
this.type === "binaryShortString"),
html = inline ? "" : "<div class='clearfix'>&nbsp;</div>",
i, m;
html += "<div class='arg-group" + (inline ? " inline-args" : "") +
(this.type === "text" ? " arg-group-text" : "") + "'><label class='arg-label' for='" +
this.id + "'>" + this.name + "</label>";
switch (this.type) {
case "string":
case "binaryString":
@ -83,7 +83,7 @@ HTMLIngredient.prototype.toHtml = function() {
html += "<input type='checkbox' id='" + this.id + "'class='arg' arg-name='" +
this.name + "'" + (this.value ? " checked='checked' " : "") +
(this.disabled ? " disabled='disabled'" : "") + ">";
if (this.disableArgs) {
this.manager.addDynamicListener("#" + this.id, "click", this.toggleDisableArgs, this);
}
@ -116,7 +116,7 @@ HTMLIngredient.prototype.toHtml = function() {
}
}
html += "</select>";
this.manager.addDynamicListener("#" + this.id, "change", this.populateOptionChange, this);
break;
case "editableOption":
@ -132,8 +132,8 @@ HTMLIngredient.prototype.toHtml = function() {
(this.disabled ? " disabled='disabled'" : "") +
(this.placeholder ? " placeholder='" + this.placeholder + "'" : "") + ">";
html += "</div>";
this.manager.addDynamicListener("#sel-" + this.id, "change", this.editableOptionChange, this);
break;
case "text":
@ -146,7 +146,7 @@ HTMLIngredient.prototype.toHtml = function() {
break;
}
html += "</div>";
return html;
};
@ -162,10 +162,10 @@ HTMLIngredient.prototype.toggleDisableArgs = function(e) {
op = el.parentNode.parentNode,
args = op.querySelectorAll(".arg-group"),
els;
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")) {
els[j].removeAttribute("disabled");
@ -174,7 +174,7 @@ HTMLIngredient.prototype.toggleDisableArgs = function(e) {
}
}
}
this.manager.recipe.ingChange();
};
@ -191,7 +191,7 @@ HTMLIngredient.prototype.populateOptionChange = function(e) {
target = op.querySelectorAll(".arg-group")[this.target].querySelector("input, select, textarea");
target.value = el.childNodes[el.selectedIndex].getAttribute("populate-value");
this.manager.recipe.ingChange();
};
@ -207,6 +207,6 @@ HTMLIngredient.prototype.editableOptionChange = function(e) {
input = select.nextSibling;
input.value = select.childNodes[select.selectedIndex].value;
this.manager.recipe.ingChange();
};

View file

@ -14,13 +14,13 @@
var HTMLOperation = function(name, config, app, manager) {
this.app = app;
this.manager = manager;
this.name = name;
this.description = config.description;
this.manualBake = config.manualBake || false;
this.config = config;
this.ingList = [];
for (var i = 0; i < config.args.length; i++) {
var ing = new HTMLIngredient(config.args[i], this.app, this.manager);
this.ingList.push(ing);
@ -45,25 +45,25 @@ HTMLOperation.REMOVE_ICON = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABwkl
*/
HTMLOperation.prototype.toStubHtml = function(removeIcon) {
var html = "<li class='operation'";
if (this.description) {
html += " data-container='body' data-toggle='popover' data-placement='auto right'\
data-content=\"" + this.description + "\" data-html='true' data-trigger='hover'";
}
html += ">" + this.name;
if (removeIcon) {
html += "<img src='data:image/png;base64," + HTMLOperation.REMOVE_ICON +
"' class='op-icon remove-icon'>";
}
if (this.description) {
html += "<img src='data:image/png;base64," + HTMLOperation.INFO_ICON + "' class='op-icon'>";
}
html += "</li>";
return html;
};
@ -79,15 +79,15 @@ HTMLOperation.prototype.toFullHtml = function() {
for (var i = 0; i < this.ingList.length; i++) {
html += this.ingList[i].toHtml();
}
html += "<div class='recip-icons'>\
<div class='breakpoint' title='Set breakpoint' break='false'></div>\
<div class='disable-icon recip-icon' title='Disable operation'\
disabled='false'></div>";
html += "</div>\
<div class='clearfix'>&nbsp;</div>";
return html;
};
@ -105,7 +105,7 @@ HTMLOperation.prototype.highlightSearchString = function(searchStr, namePos, des
this.name.slice(namePos, namePos + searchStr.length) + "</u></b>" +
this.name.slice(namePos + searchStr.length);
}
if (this.description && descPos >= 0) {
this.description = this.description.slice(0, descPos) + "<b><u>" +
this.description.slice(descPos, descPos + searchStr.length) + "</u></b>" +

View file

@ -12,7 +12,7 @@
var InputWaiter = function(app, manager) {
this.app = app;
this.manager = manager;
// Define keys that don't change the input so we don't have to autobake when they are pressed
this.badKeys = [
16, //Shift
@ -65,10 +65,10 @@ InputWaiter.prototype.set = function(input) {
InputWaiter.prototype.setInputInfo = function(length, lines) {
var width = length.toString().length;
width = width < 2 ? 2 : width;
var lengthStr = Utils.pad(length.toString(), width, " ").replace(/ /g, "&nbsp;");
var linesStr = Utils.pad(lines.toString(), width, " ").replace(/ /g, "&nbsp;");
document.getElementById("input-info").innerHTML = "length: " + lengthStr + "<br>lines: " + linesStr;
};
@ -84,17 +84,17 @@ InputWaiter.prototype.setInputInfo = function(length, lines) {
InputWaiter.prototype.inputChange = function(e) {
// Remove highlighting from input and output panes as the offsets might be different now
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 inputText = this.get(),
lines = inputText.count("\n") + 1;
this.setInputInfo(inputText.length, lines);
if (this.badKeys.indexOf(e.keyCode) < 0) {
// Fire the statechange event as the input has been modified
window.dispatchEvent(this.manager.statechange);
@ -112,7 +112,7 @@ InputWaiter.prototype.inputDragover = function(e) {
// This will be set if we're dragging an operation
if (e.dataTransfer.effectAllowed === "move")
return false;
e.stopPropagation();
e.preventDefault();
e.target.classList.add("dropping-file");
@ -142,10 +142,10 @@ InputWaiter.prototype.inputDrop = function(e) {
// This will be set if we're dragging an operation
if (e.dataTransfer.effectAllowed === "move")
return false;
e.stopPropagation();
e.preventDefault();
var el = e.target,
file = e.dataTransfer.files[0],
text = e.dataTransfer.getData("Text"),
@ -153,23 +153,23 @@ InputWaiter.prototype.inputDrop = function(e) {
inputCharcode = "",
offset = 0,
CHUNK_SIZE = 20480; // 20KB
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(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("loadingFile");
}.bind(this);
var seek = function() {
if (offset >= file.size) {
setInput();
@ -179,17 +179,17 @@ InputWaiter.prototype.inputDrop = function(e) {
var slice = file.slice(offset, offset + CHUNK_SIZE);
reader.readAsArrayBuffer(slice);
};
reader.onload = function(e) {
var data = new Uint8Array(reader.result);
inputCharcode += Utils.toHexFast(data);
offset += CHUNK_SIZE;
seek();
};
el.classList.remove("dropping-file");
if (file) {
el.classList.add("loadingFile");
seek();

View file

@ -10,7 +10,7 @@
*/
var Manager = function(app) {
this.app = app;
// Define custom events
/**
* @event Manager#appstart
@ -32,7 +32,7 @@ var Manager = function(app) {
* @event Manager#statechange
*/
this.statechange = new CustomEvent("statechange", {bubbles: true});
// Define Waiter objects to handle various areas
this.window = new WindowWaiter(this.app);
this.controls = new ControlsWaiter(this.app, this);
@ -43,10 +43,10 @@ var Manager = function(app) {
this.options = new OptionsWaiter(this.app);
this.highlighter = new HighlighterWaiter(this.app);
this.seasonal = new SeasonalWaiter(this.app, this);
// Object to store dynamic handlers to fire on elements that may not exist yet
this.dynamicHandlers = {};
this.initialiseEventListeners();
};
@ -71,7 +71,7 @@ Manager.prototype.initialiseEventListeners = function() {
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.bakeClick.bind(this.controls));
document.getElementById("auto-bake").addEventListener("change", this.controls.autoBakeChange.bind(this.controls));
@ -88,7 +88,7 @@ Manager.prototype.initialiseEventListeners = function() {
document.getElementById("load-button").addEventListener("click", this.controls.loadButtonClick.bind(this.controls));
document.getElementById("support").addEventListener("click", this.controls.supportButtonClick.bind(this.controls));
this.addMultiEventListener("#save-text", "keyup paste", this.controls.saveTextChange, this.controls);
// Operations
this.addMultiEventListener("#search", "keyup paste search", this.ops.searchOperations, this.ops);
this.addDynamicListener(".op-list li.operation", "dblclick", this.ops.operationDblclick, this.ops);
@ -99,7 +99,7 @@ Manager.prototype.initialiseEventListeners = function() {
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.addDynamicListener(".arg", "keyup", this.recipe.ingChange, this.recipe);
this.addDynamicListener(".arg", "change", this.recipe.ingChange, this.recipe);
@ -109,7 +109,7 @@ Manager.prototype.initialiseEventListeners = function() {
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.addMultiEventListener("#input-text", "keyup paste", this.input.inputChange, this.input);
document.getElementById("reset-layout").addEventListener("click", this.app.resetLayout.bind(this.app));
@ -121,7 +121,7 @@ Manager.prototype.initialiseEventListeners = function() {
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.saveClick.bind(this.output));
document.getElementById("switch").addEventListener("click", this.output.switchClick.bind(this.output));
@ -134,7 +134,7 @@ Manager.prototype.initialiseEventListeners = function() {
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.optionsClick.bind(this.options));
document.getElementById("reset-options").addEventListener("click", this.options.resetOptionsClick.bind(this.options));
@ -143,7 +143,7 @@ Manager.prototype.initialiseEventListeners = function() {
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.alertCloseClick.bind(this.app));
};
@ -231,7 +231,7 @@ Manager.prototype.addDynamicListener = function(selector, eventType, callback, s
selector: selector,
callback: callback.bind(scope || this)
};
if (this.dynamicHandlers.hasOwnProperty(eventType)) {
// Listener already exists, add new handler to the appropriate list
this.dynamicHandlers[eventType].push(eventConfig);
@ -256,7 +256,7 @@ Manager.prototype.dynamicListenerHandler = function(e) {
e.target.mozMatchesSelector ||
e.target.msMatchesSelector ||
e.target.oMatchesSelector;
for (var i = 0; i < handlers.length; i++) {
if (matches && e.target[matches.name](handlers[i].selector)) {
handlers[i].callback(e);

View file

@ -14,7 +14,7 @@
var OperationsWaiter = function(app, manager) {
this.app = app;
this.manager = manager;
this.options = {};
this.removeIntent = false;
};
@ -28,7 +28,7 @@ var OperationsWaiter = function(app, manager) {
*/
OperationsWaiter.prototype.searchOperations = function(e) {
var ops, selected;
if (e.type === "search") { // Search
e.preventDefault();
ops = document.querySelectorAll("#search-results li");
@ -40,7 +40,7 @@ OperationsWaiter.prototype.searchOperations = function(e) {
}
}
}
if (e.keyCode === 13) { // Return
e.preventDefault();
} else if (e.keyCode === 40) { // Down
@ -69,21 +69,21 @@ OperationsWaiter.prototype.searchOperations = function(e) {
var searchResultsEl = document.getElementById("search-results"),
el = e.target,
str = el.value;
while (searchResultsEl.firstChild) {
$(searchResultsEl.firstChild).popover("destroy");
searchResultsEl.removeChild(searchResultsEl.firstChild);
}
$("#categories .in").collapse("hide");
if (str) {
var matchedOps = this.filterOperations(str, true),
matchedOpsHtml = "";
for (var i = 0; i < matchedOps.length; i++) {
matchedOpsHtml += matchedOps[i].toStubHtml();
}
searchResultsEl.innerHTML = matchedOpsHtml;
searchResultsEl.dispatchEvent(this.manager.oplistcreate);
}
@ -102,20 +102,20 @@ OperationsWaiter.prototype.searchOperations = function(e) {
OperationsWaiter.prototype.filterOperations = function(searchStr, highlight) {
var matchedOps = [],
matchedDescs = [];
searchStr = searchStr.toLowerCase();
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 (namePos >= 0 || descPos >= 0) {
var operation = new HTMLOperation(opName, this.app.operations[opName], this.app, this.manager);
if (highlight) {
operation.highlightSearchString(searchStr, namePos, descPos);
}
if (namePos < 0) {
matchedOps.push(operation);
} else {
@ -123,7 +123,7 @@ OperationsWaiter.prototype.filterOperations = function(searchStr, highlight) {
}
}
}
return matchedDescs.concat(matchedOps);
};
@ -165,7 +165,7 @@ OperationsWaiter.prototype.opListCreate = function(e) {
*/
OperationsWaiter.prototype.operationDblclick = function(e) {
var li = e.target;
this.manager.recipe.addOperation(li.textContent);
this.app.autoBake();
};
@ -180,23 +180,23 @@ OperationsWaiter.prototype.operationDblclick = function(e) {
OperationsWaiter.prototype.editFavouritesClick = function(e) {
e.preventDefault();
e.stopPropagation();
// Add favourites to modal
var favCat = this.app.categories.filter(function(c) {
return c.name === "Favourites";
})[0];
var html = "";
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 editFavouritesList = document.getElementById("edit-favourites-list");
editFavouritesList.innerHTML = html;
this.removeIntent = false;
var editableList = Sortable.create(editFavouritesList, {
filter: ".remove-icon",
onFilter: function (evt) {
@ -210,15 +210,15 @@ OperationsWaiter.prototype.editFavouritesClick = function(e) {
if (this.removeIntent) evt.item.remove();
}.bind(this),
});
Sortable.utils.on(editFavouritesList, "dragleave", function() {
this.removeIntent = true;
}.bind(this));
Sortable.utils.on(editFavouritesList, "dragover", function() {
this.removeIntent = false;
}.bind(this));
$("#edit-favourites-list [data-toggle=popover]").popover();
$("#favourites-modal").modal();
};
@ -231,7 +231,7 @@ OperationsWaiter.prototype.editFavouritesClick = function(e) {
OperationsWaiter.prototype.saveFavouritesClick = function() {
var favouritesList = [],
favs = document.querySelectorAll("#edit-favourites-list li");
for (var i = 0; i < favs.length; i++) {
favouritesList.push(favs[i].textContent);
}
@ -276,7 +276,7 @@ OperationsWaiter.prototype.opIconMouseover = function(e) {
OperationsWaiter.prototype.opIconMouseleave = function(e) {
var opEl = e.target.parentNode,
toEl = e.toElement || e.relatedElement;
if (e.target.getAttribute("data-toggle") === "popover" && toEl === opEl) {
$(opEl).popover("show");
}

View file

@ -23,11 +23,11 @@ OptionsWaiter.prototype.load = function(options) {
size: "small",
animate: false,
});
for (var option in options) {
this.app.options[option] = options[option];
}
// Set options to match object
var cboxes = document.querySelectorAll("#options-body input[type=checkbox]");
for (var i = 0; i < cboxes.length; i++) {
@ -39,7 +39,7 @@ OptionsWaiter.prototype.load = function(options) {
nboxes[i].value = this.app.options[nboxes[i].getAttribute("option")];
nboxes[i].dispatchEvent(new CustomEvent("change", {bubbles: true}));
}
var selects = document.querySelectorAll("#options-body select");
for (i = 0; i < selects.length; i++) {
selects[i].value = this.app.options[selects[i].getAttribute("option")];
@ -76,7 +76,7 @@ OptionsWaiter.prototype.resetOptionsClick = function() {
OptionsWaiter.prototype.switchChange = function(e, state) {
var el = e.target,
option = el.getAttribute("option");
this.app.options[option] = state;
localStorage.setItem("options", JSON.stringify(this.app.options));
};
@ -91,7 +91,7 @@ OptionsWaiter.prototype.switchChange = function(e, state) {
OptionsWaiter.prototype.numberChange = function(e) {
var el = e.target,
option = el.getAttribute("option");
this.app.options[option] = parseInt(el.value, 10);
localStorage.setItem("options", JSON.stringify(this.app.options));
};
@ -106,7 +106,7 @@ OptionsWaiter.prototype.numberChange = function(e) {
OptionsWaiter.prototype.selectChange = function(e) {
var el = e.target,
option = el.getAttribute("option");
this.app.options[option] = el.value;
localStorage.setItem("options", JSON.stringify(this.app.options));
};
@ -121,7 +121,7 @@ OptionsWaiter.prototype.setWordWrap = function() {
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.wordWrap) {
document.getElementById("input-text").classList.add("word-wrap");
document.getElementById("output-text").classList.add("word-wrap");

View file

@ -43,10 +43,10 @@ OutputWaiter.prototype.set = function(dataStr, type, duration) {
outputHtml.style.display = "block";
outputHighlighter.display = "none";
inputHighlighter.display = "none";
outputText.value = "";
outputHtml.innerHTML = dataStr;
// Execute script sections
var scriptElements = outputHtml.querySelectorAll("script");
for (var i = 0; i < scriptElements.length; i++) {
@ -61,11 +61,11 @@ OutputWaiter.prototype.set = function(dataStr, type, duration) {
outputHtml.style.display = "none";
outputHighlighter.display = "block";
inputHighlighter.display = "block";
outputText.value = Utils.printable(dataStr, true);
outputHtml.innerHTML = "";
}
this.manager.highlighter.removeHighlights();
var lines = dataStr.count("\n") + 1;
this.setOutputInfo(dataStr.length, lines, duration);
@ -82,11 +82,11 @@ OutputWaiter.prototype.set = function(dataStr, type, duration) {
OutputWaiter.prototype.setOutputInfo = function(length, lines, duration) {
var width = length.toString().length;
width = width < 4 ? 4 : width;
var lengthStr = Utils.pad(length.toString(), width, " ").replace(/ /g, "&nbsp;");
var linesStr = Utils.pad(lines.toString(), width, " ").replace(/ /g, "&nbsp;");
var timeStr = Utils.pad(duration.toString() + "ms", width, " ").replace(/ /g, "&nbsp;");
document.getElementById("output-info").innerHTML = "time: " + timeStr +
"<br>length: " + lengthStr +
"<br>lines: " + linesStr;
@ -105,7 +105,7 @@ OutputWaiter.prototype.adjustWidth = function() {
switchIO = document.getElementById("switch"),
undoSwitch = document.getElementById("undo-switch"),
maximiseOutput = document.getElementById("maximise-output");
if (output.clientWidth < 680) {
saveToFile.childNodes[1].nodeValue = "";
switchIO.childNodes[1].nodeValue = "";
@ -128,16 +128,16 @@ OutputWaiter.prototype.adjustWidth = function() {
OutputWaiter.prototype.saveClick = function() {
var data = Utils.toBase64(this.app.dishStr),
filename = window.prompt("Please enter a filename:", "download.dat");
if (filename) {
var el = document.createElement("a");
el.setAttribute("href", "data:application/octet-stream;base64;charset=utf-8," + data);
el.setAttribute("download", filename);
// Firefox requires that the element be added to the DOM before it can be clicked
el.style.display = "none";
document.body.appendChild(el);
el.click();
el.remove();
}

View file

@ -23,8 +23,8 @@ var RecipeWaiter = function(app, manager) {
*/
RecipeWaiter.prototype.initialiseOperationDragNDrop = function() {
var recList = document.getElementById("rec-list");
// Recipe list
Sortable.create(recList, {
group: "recipe",
@ -42,11 +42,11 @@ RecipeWaiter.prototype.initialiseOperationDragNDrop = function() {
}
}.bind(this)
});
Sortable.utils.on(recList, "dragover", function() {
this.removeIntent = false;
}.bind(this));
Sortable.utils.on(recList, "dragleave", function() {
this.removeIntent = true;
this.app.progress = 0;
@ -58,7 +58,7 @@ RecipeWaiter.prototype.initialiseOperationDragNDrop = function() {
this.removeIntent = !recList.contains(target);
}.bind(this));
// Favourites category
document.querySelector("#categories a").addEventListener("dragover", this.favDragover.bind(this));
document.querySelector("#categories a").addEventListener("dragleave", this.favDragleave.bind(this));
@ -106,16 +106,16 @@ RecipeWaiter.prototype.opSortEnd = function(evt) {
}
return;
}
// Reinitialise the popover on the original element in the ops list because for some reason it
// gets destroyed and recreated.
$(evt.clone).popover();
$(evt.clone).children("[data-toggle=popover]").popover();
if (evt.item.parentNode.id !== "rec-list") {
return;
}
this.buildRecipeOperation(evt.item);
evt.item.dispatchEvent(this.manager.operationadd);
};
@ -131,7 +131,7 @@ RecipeWaiter.prototype.opSortEnd = function(evt) {
RecipeWaiter.prototype.favDragover = function(e) {
if (e.dataTransfer.effectAllowed !== "move")
return false;
e.stopPropagation();
e.preventDefault();
if (e.target.className && e.target.className.indexOf("category-title") > -1) {
@ -170,7 +170,7 @@ RecipeWaiter.prototype.favDrop = function(e) {
e.stopPropagation();
e.preventDefault();
e.target.classList.remove("favourites-hover");
var opName = e.dataTransfer.getData("Text");
this.app.addFavourite(opName);
};
@ -195,7 +195,7 @@ RecipeWaiter.prototype.ingChange = function() {
*/
RecipeWaiter.prototype.disableClick = function(e) {
var icon = e.target;
if (icon.getAttribute("disabled") === "false") {
icon.setAttribute("disabled", "true");
icon.classList.add("disable-icon-selected");
@ -205,7 +205,7 @@ RecipeWaiter.prototype.disableClick = function(e) {
icon.classList.remove("disable-icon-selected");
icon.parentNode.parentNode.classList.remove("disabled");
}
this.app.progress = 0;
window.dispatchEvent(this.manager.statechange);
};
@ -228,7 +228,7 @@ RecipeWaiter.prototype.breakpointClick = function(e) {
bp.setAttribute("break", "false");
bp.classList.remove("breakpoint-selected");
}
window.dispatchEvent(this.manager.statechange);
};
@ -267,13 +267,13 @@ RecipeWaiter.prototype.operationChildDblclick = function(e) {
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");
ingList = operations[i].querySelectorAll(".arg");
for (var j = 0; j < ingList.length; j++) {
if (ingList[j].getAttribute("type") === "checkbox") {
// checkbox
@ -289,23 +289,23 @@ RecipeWaiter.prototype.getConfig = function() {
ingredients[j] = ingList[j].value;
}
}
item = {
op: operations[i].querySelector(".arg-title").textContent,
args: ingredients
};
if (disabled && disabled.getAttribute("disabled") === "true") {
item.disabled = true;
}
if (bp && bp.getAttribute("break") === "true") {
item.breakpoint = true;
}
config.push(item);
}
return config;
};
@ -337,11 +337,11 @@ 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[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.manualBake && this.app.autoBake_) {
@ -359,12 +359,12 @@ RecipeWaiter.prototype.buildRecipeOperation = function(el) {
*/
RecipeWaiter.prototype.addOperation = function(name) {
var item = document.createElement("li");
item.classList.add("operation");
item.innerHTML = name;
this.buildRecipeOperation(item);
document.getElementById("rec-list").appendChild(item);
item.dispatchEvent(this.manager.operationadd);
return item;
};
@ -393,7 +393,7 @@ RecipeWaiter.prototype.clearRecipe = function() {
RecipeWaiter.prototype.dropdownToggleClick = function(e) {
var el = e.target,
button = el.parentNode.parentNode.previousSibling;
button.innerHTML = el.textContent + " <span class='caret'></span>";
this.ingChange();
};

View file

@ -227,7 +227,7 @@ SeasonalWaiter.treeWalk = (function() {
while (node && node !== parent) {
if (allNodes || node.nodeType === 1) {
if (fn(node) === false) {
return(false);
return false;
}
}
// If it's an element &&

View file

@ -22,7 +22,7 @@ var main = function() {
"Entropy",
"Fork"
];
var defaultOptions = {
updateUrl : true,
showHighlighter : true,