From 28a849c44c4ca1d94da755f347803b30e8901e18 Mon Sep 17 00:00:00 2001 From: Skriv <skrivelese@gmail.com> Date: Sat, 25 May 2019 16:01:38 +0200 Subject: [PATCH] yoda and template lits --- src/js/textbox2.js | 10 +++++----- src/js/utilJS.js | 16 ++++------------ 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/src/js/textbox2.js b/src/js/textbox2.js index cebb01edecd..7fcb9902103 100644 --- a/src/js/textbox2.js +++ b/src/js/textbox2.js @@ -4,9 +4,9 @@ Macro.add("textbox2", { const e = []; return this.args.length < 1 && e.push("variable name"), this.args.length < 2 && e.push("default value"), this.error(`no ${e.join(" or ")} specified`); } - if ("string" !== typeof this.args[0]) { return this.error("variable name argument is not a string"); } + if (typeof this.args[0] !== "string") { return this.error("variable name argument is not a string"); } const t = this.args[0].trim(); - if ("$" !== t[0] && "_" !== t[0]) { return this.error(`variable name "${this.args[0]}" is missing its sigil ($ or _)`); } + if (t[0] !== "$" && t[0] !== "_") { return this.error(`variable name "${this.args[0]}" is missing its sigil ($ or _)`); } Config.debug && this.debugView.modes({ block: true }); @@ -19,12 +19,12 @@ Macro.add("textbox2", { let setargs = null; if (this.args.length > 3) { passage = this.args[2]; - autofocus = "autofocus" === this.args[3]; + autofocus = this.args[3] === "autofocus"; if (!autofocus) { setargs = this.args[3]; } } else if (this.args.length > 2) { - if ("autofocus" === this.args[2]) { + if (this.args[2] === "autofocus") { autofocus = true; } else { passage = this.args[2]; @@ -78,7 +78,7 @@ Macro.add("textbox2", { } }) .on("keypress", function(e) { - 13 === e.which && (e.preventDefault(), State.setVar(t, valueToNumberIfSame(this.value)), gotoPassage()); + e.which === 13 && (e.preventDefault(), State.setVar(t, valueToNumberIfSame(this.value)), gotoPassage()); }).appendTo(this.output), State.setVar(t, a), inputElement.value = a, autofocus && (inputElement.setAttribute("autofocus", "autofocus"), postdisplay[`#autofocus:${inputElement.id}`] = function(e) { delete postdisplay[e], setTimeout(function() { return inputElement.focus(); diff --git a/src/js/utilJS.js b/src/js/utilJS.js index 658f0f6f634..7371986280f 100644 --- a/src/js/utilJS.js +++ b/src/js/utilJS.js @@ -1844,7 +1844,7 @@ App.UI.tabbar = function() { * @returns {string} */ function makeTab(name, content) { - return `<div id="${name}" class="tabcontent"><div class="content">` + content + '</div></div>'; + return `<div id="${name}" class="tabcontent"><div class="content">${content}</div></div>`; } function handlePreSelectedTab() { @@ -1941,7 +1941,7 @@ App.UI.replace = function(selector, newContent) { App.UI.htag = function(text, attributes, tag = 'div') { const payload = text.replace(/(^\n+|\n+$)/, ""); - if ("object" === typeof attributes) { + if (typeof attributes === "object") { attributes = $.map(attributes, (val, key) => `${key}="${val}"`).join(" "); } else { attributes = `id="${attributes.trim()}"`; @@ -2210,19 +2210,11 @@ window.upgradeMultiplierTrade = function() { }; window.jsNdef = function(input) { - if (typeof input === "undefined") { - return true; - } else { - return false; - } + return typeof input === "undefined"; }; window.jsDef = function(input) { - if (typeof input !== "undefined") { - return true; - } else { - return false; - } + return typeof input !== "undefined"; }; /** -- GitLab