diff --git a/src/index.html b/src/index.html index 1f53f007..6460a1e4 100644 --- a/src/index.html +++ b/src/index.html @@ -615,6 +615,10 @@ +
+ + +
diff --git a/src/js/control.js b/src/js/control.js index a5f96e01..2cb1376a 100644 --- a/src/js/control.js +++ b/src/js/control.js @@ -1294,6 +1294,14 @@ var control = (function() { dependents(); search.render.engine(); } + }, { + element: helper.e(".control-header-search-engine-bing"), + path: "header.search.engine.selected", + type: "radio", + func: function() { + dependents(); + search.render.engine(); + } }, { element: helper.e(".control-header-search-engine-custom"), path: "header.search.engine.selected", @@ -2610,6 +2618,7 @@ var control = (function() { helper.e(".control-header-search-engine-duckduckgo").disabled = false; helper.e(".control-header-search-engine-youtube").disabled = false; helper.e(".control-header-search-engine-giphy").disabled = false; + helper.e(".control-header-search-engine-bing").disabled = false; helper.e(".control-header-search-engine-custom").disabled = false; helper.e(".control-header-search-text-alignment-label").removeAttribute("disabled"); helper.e(".control-header-search-text-alignment-left").disabled = false; @@ -2630,6 +2639,7 @@ var control = (function() { helper.e(".control-header-search-engine-duckduckgo").disabled = true; helper.e(".control-header-search-engine-youtube").disabled = true; helper.e(".control-header-search-engine-giphy").disabled = true; + helper.e(".control-header-search-engine-bing").disabled = true; helper.e(".control-header-search-engine-custom").disabled = true; helper.e(".control-header-search-text-alignment-label").setAttribute("disabled", ""); helper.e(".control-header-search-text-alignment-left").disabled = true; diff --git a/src/js/state.js b/src/js/state.js index 4f557c26..728c8937 100644 --- a/src/js/state.js +++ b/src/js/state.js @@ -84,6 +84,10 @@ var state = (function() { url: "https://giphy.com/search/", name: "Giphy" }, + bing: { + url: "https://www.bing.com/search?q=", + name: "Bing" + }, custom: { url: "", name: "" diff --git a/src/js/update.js b/src/js/update.js index 89df8906..890e1a0c 100644 --- a/src/js/update.js +++ b/src/js/update.js @@ -572,8 +572,20 @@ var update = (function() { return data; }; - var _update_3270 = function(data) { - data.version = "3.27.0"; + // This associative array contains all the updates. Add + // a new entry if you need to modify data. + // + // Example, this assumes the previous version is less than + // 3.28.0, so 3.27.0 would be upgraded in this case. + // versionUpdates["3.28.0"] = function(data) { + // return data; + // }; + // + // Always add the version in increasing order so the + // most recent version is last. + var versionUpdates = {}; + + versionUpdates["3.27.0"] = function(data) { data.state.header.area.alignment = data.state.header.area.alignment.horizontal; data.state.header.item.alignment = data.state.header.item.alignment.horizontal; data.state.header.search.text.alignment = data.state.header.search.text.align; @@ -584,10 +596,14 @@ var update = (function() { return data; }; - // var _update_300 = function(data) { - // data.version = 3.00; - // return data; - // }; + // Add Bing as a option for the search engines. + versionUpdates["3.28.0"] = function(data) { + data.state.header.search.engine.bing = { + url: "https://www.bing.com/search?q=", + name: "Bing" + }; + return data; + }; function run(data) { if (!("version" in data)) { @@ -595,35 +611,35 @@ var update = (function() { data = _update_100(data); }; if (typeof data.version == "number") { - if (data.version < 2.00) { + if (data.version < 2.0) { console.log("\t= running update 2.0.0"); data = _update_200(data); }; - if (data.version < 2.10) { + if (data.version < 2.1) { console.log("\t= running update 2.1.0"); data = _update_210(data); }; - if (data.version < 2.30) { + if (data.version < 2.3) { console.log("\t= running update 2.3.0"); data = _update_230(data); }; - if (data.version < 2.40) { + if (data.version < 2.4) { console.log("\t= running update 2.4.0"); data = _update_240(data); }; - if (data.version < 2.50) { + if (data.version < 2.5) { console.log("\t= running update 2.5.0"); data = _update_250(data); }; - if (data.version < 2.70) { + if (data.version < 2.7) { console.log("\t= running update 2.7.0"); data = _update_270(data); }; - if (data.version < 2.80) { + if (data.version < 2.8) { console.log("\t= running update 2.8.0"); data = _update_280(data); }; - if (data.version < 2.90) { + if (data.version < 2.9) { console.log("\t= running update 2.9.0"); data = _update_290(data); }; @@ -730,17 +746,24 @@ var update = (function() { console.log("\t= running update 3.21.0"); data = _update_3210(data); }; - if (version.compare(data.version, "3.27.0") == -1) { - console.log("\t= running update 3.27.0"); - data = _update_3270(data); + // Shift to a associate array for the configuration update as + // there less code to maintain. + for (var key in versionUpdates) { + if (version.compare(data.version, key) == -1) { + console.log("\t= running update", key); + data = versionUpdates[key](data); + data.version = key; + }; }; }; + // if no update is needed // version bump if (version.compare(data.version, version.get()) == -1) { console.log("\t= nothing to update, version bump to", version.get()); data.version = version.get(); }; + return data; }; diff --git a/src/js/version.js b/src/js/version.js index 5aff57c0..271a693c 100644 --- a/src/js/version.js +++ b/src/js/version.js @@ -1,6 +1,6 @@ var version = (function() { - var current = "3.27.0"; + var current = "3.28.0"; var compare = function(a, b) { var pa = a.split("."); diff --git a/src/manifest.json b/src/manifest.json index 08616a8b..b7c8a1b6 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -2,7 +2,7 @@ "name": "nightTab", "short_name": "nightTab", "description": "A neutral new tab page accented with a chosen colour. Customise the layout, style, background and bookmarks in nightTab.", - "version": "3.27.0", + "version": "3.28.0", "manifest_version": 2, "chrome_url_overrides": { "newtab": "index.html"