diff --git a/package-lock.json b/package-lock.json index 9d5b2edb..f8595b49 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7719,9 +7719,15 @@ "resolved": "https://registry.npmjs.org/nomnom/-/nomnom-1.5.2.tgz", "integrity": "sha1-9DRUSKhTz71cDSYyDyR3qwUm/i8=", "requires": { + "colors": "0.5.x", "underscore": "1.1.x" }, "dependencies": { + "colors": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/colors/-/colors-0.5.1.tgz", + "integrity": "sha1-fQAj6usVTo7p/Oddy5I9DtFmd3Q=" + }, "underscore": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.1.7.tgz", diff --git a/package.json b/package.json index 3390e0bb..5cec2afe 100644 --- a/package.json +++ b/package.json @@ -60,8 +60,8 @@ "postcss-css-variables": "^0.8.1", "postcss-import": "^11.1.0", "postcss-loader": "^2.1.4", - "sass-loader": "^7.0.2", "prompt": "^1.0.0", + "sass-loader": "^7.0.2", "sitemap": "^1.13.0", "style-loader": "^0.21.0", "url-loader": "^1.0.1", @@ -79,7 +79,6 @@ "bignumber.js": "^7.0.1", "bootstrap-colorpicker": "^2.5.2", "bootstrap-material-design": "^4.1.1", - "bootstrap-switch": "^3.3.4", "bson": "^2.0.6", "chi-squared": "^1.1.0", "crypto-api": "^0.8.0", diff --git a/src/web/ControlsWaiter.mjs b/src/web/ControlsWaiter.mjs index 0f213c03..dbad5423 100755 --- a/src/web/ControlsWaiter.mjs +++ b/src/web/ControlsWaiter.mjs @@ -270,7 +270,10 @@ class ControlsWaiter { } // Populate textarea with first recipe - document.getElementById("load-text").value = savedRecipes.length ? savedRecipes[0].recipe : ""; + const loadText = document.getElementById("load-text"); + const evt = new Event("change"); + loadText.value = savedRecipes.length ? savedRecipes[0].recipe : ""; + loadText.dispatchEvent(evt); } diff --git a/src/web/Manager.mjs b/src/web/Manager.mjs index 9d203635..39c8c4b5 100755 --- a/src/web/Manager.mjs +++ b/src/web/Manager.mjs @@ -172,9 +172,9 @@ class Manager { // 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)); - $(document).on("switchChange.bootstrapSwitch", ".option-item input:checkbox#useMetaKey", this.bindings.updateKeybList.bind(this.bindings)); + this.addDynamicListener(".option-item input[type=checkbox]", "change", this.options.switchChange, this.options); + this.addDynamicListener(".option-item input[type=checkbox]", "change", this.options.setWordWrap, this.options); + this.addDynamicListener(".option-item input[type=checkbox]#useMetaKey", "change", this.bindings.updateKeybList, this.bindings); 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); diff --git a/src/web/OperationsWaiter.mjs b/src/web/OperationsWaiter.mjs index 83d39d2b..e0286d42 100755 --- a/src/web/OperationsWaiter.mjs +++ b/src/web/OperationsWaiter.mjs @@ -268,7 +268,7 @@ class OperationsWaiter { */ saveFavouritesClick() { const favs = document.querySelectorAll("#edit-favourites-list li"); - const favouritesList = Array.from(favs, e => e.textContent); + const favouritesList = Array.from(favs, e => e.childNodes[0].textContent); this.app.saveFavourites(favouritesList); this.app.loadFavourites(); diff --git a/src/web/OptionsWaiter.mjs b/src/web/OptionsWaiter.mjs index a3832dc4..3f08b91b 100755 --- a/src/web/OptionsWaiter.mjs +++ b/src/web/OptionsWaiter.mjs @@ -20,11 +20,6 @@ const OptionsWaiter = function(app, manager) { * @param {Object} options */ OptionsWaiter.prototype.load = function(options) { - $(".option-item input:checkbox").bootstrapSwitch({ - size: "small", - animate: false, - }); - for (const option in options) { this.app.options[option] = options[option]; } @@ -33,7 +28,7 @@ OptionsWaiter.prototype.load = function(options) { const cboxes = document.querySelectorAll("#options-body input[type=checkbox]"); let i; for (i = 0; i < cboxes.length; i++) { - $(cboxes[i]).bootstrapSwitch("state", this.app.options[cboxes[i].getAttribute("option")]); + cboxes[i].checked = this.app.options[cboxes[i].getAttribute("option")]; } const nboxes = document.querySelectorAll("#options-body input[type=number]"); @@ -81,11 +76,11 @@ OptionsWaiter.prototype.resetOptionsClick = function() { * Modifies the option state and saves it to local storage. * * @param {event} e - * @param {boolean} state */ -OptionsWaiter.prototype.switchChange = function(e, state) { +OptionsWaiter.prototype.switchChange = function(e) { const el = e.target; const option = el.getAttribute("option"); + const state = el.checked; log.debug(`Setting ${option} to ${state}`); this.app.options[option] = state; diff --git a/src/web/html/index.html b/src/web/html/index.html index 555d5439..d717fc99 100755 --- a/src/web/html/index.html +++ b/src/web/html/index.html @@ -203,7 +203,7 @@