Skip to content

Commit bb8d15a

Browse files
sytonezombieFox
authored andcommitted
[feature] [refactor] add Bing to the list of search engines
1 parent 0a31c44 commit bb8d15a

File tree

6 files changed

+60
-19
lines changed

6 files changed

+60
-19
lines changed

‎src/index.html‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,10 @@ <h1 class="menu-item-header-text">Search</h1>
615615
<inputid="control-header-search-engine-giphy" class="control-header-search-engine-giphy" type="radio" name="control-header-search-engine" value="giphy" tabindex="1">
616616
<labelfor="control-header-search-engine-giphy">Giphy</label>
617617
</div>
618+
<divclass="input-wrap">
619+
<inputid="control-header-search-engine-bing" class="control-header-search-engine-bing" type="radio" name="control-header-search-engine" value="bing" tabindex="1">
620+
<labelfor="control-header-search-engine-bing">Bing</label>
621+
</div>
618622
<divclass="input-wrap">
619623
<inputid="control-header-search-engine-custom" class="control-header-search-engine-custom" type="radio" name="control-header-search-engine" value="custom" tabindex="1">
620624
<labelfor="control-header-search-engine-custom">Custom</label>

‎src/js/control.js‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,6 +1294,14 @@ var control = (function(){
12941294
dependents();
12951295
search.render.engine();
12961296
}
1297+
},{
1298+
element: helper.e(".control-header-search-engine-bing"),
1299+
path: "header.search.engine.selected",
1300+
type: "radio",
1301+
func: function(){
1302+
dependents();
1303+
search.render.engine();
1304+
}
12971305
},{
12981306
element: helper.e(".control-header-search-engine-custom"),
12991307
path: "header.search.engine.selected",
@@ -2610,6 +2618,7 @@ var control = (function(){
26102618
helper.e(".control-header-search-engine-duckduckgo").disabled=false;
26112619
helper.e(".control-header-search-engine-youtube").disabled=false;
26122620
helper.e(".control-header-search-engine-giphy").disabled=false;
2621+
helper.e(".control-header-search-engine-bing").disabled=false;
26132622
helper.e(".control-header-search-engine-custom").disabled=false;
26142623
helper.e(".control-header-search-text-alignment-label").removeAttribute("disabled");
26152624
helper.e(".control-header-search-text-alignment-left").disabled=false;
@@ -2630,6 +2639,7 @@ var control = (function(){
26302639
helper.e(".control-header-search-engine-duckduckgo").disabled=true;
26312640
helper.e(".control-header-search-engine-youtube").disabled=true;
26322641
helper.e(".control-header-search-engine-giphy").disabled=true;
2642+
helper.e(".control-header-search-engine-bing").disabled=true;
26332643
helper.e(".control-header-search-engine-custom").disabled=true;
26342644
helper.e(".control-header-search-text-alignment-label").setAttribute("disabled","");
26352645
helper.e(".control-header-search-text-alignment-left").disabled=true;

‎src/js/state.js‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ var state = (function(){
8484
url: "https://giphy.com/search/",
8585
name: "Giphy"
8686
},
87+
bing: {
88+
url: "https://www.bing.com/search?q=",
89+
name: "Bing"
90+
},
8791
custom: {
8892
url: "",
8993
name: ""

‎src/js/update.js‎

Lines changed: 40 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -572,8 +572,20 @@ var update = (function(){
572572
returndata;
573573
};
574574

575-
var_update_3270=function(data){
576-
data.version="3.27.0";
575+
// This associative array contains all the updates. Add
576+
// a new entry if you need to modify data.
577+
//
578+
// Example, this assumes the previous version is less than
579+
// 3.28.0, so 3.27.0 would be upgraded in this case.
580+
// versionUpdates["3.28.0"] = function(data){
581+
// return data;
582+
// };
583+
//
584+
// Always add the version in increasing order so the
585+
// most recent version is last.
586+
varversionUpdates={};
587+
588+
versionUpdates["3.27.0"]=function(data){
577589
data.state.header.area.alignment=data.state.header.area.alignment.horizontal;
578590
data.state.header.item.alignment=data.state.header.item.alignment.horizontal;
579591
data.state.header.search.text.alignment=data.state.header.search.text.align;
@@ -584,46 +596,50 @@ var update = (function(){
584596
returndata;
585597
};
586598

587-
// var _update_300 = function(data){
588-
// data.version = 3.00;
589-
// return data;
590-
// };
599+
// Add Bing as a option for the search engines.
600+
versionUpdates["3.28.0"]=function(data){
601+
data.state.header.search.engine.bing={
602+
url: "https://www.bing.com/search?q=",
603+
name: "Bing"
604+
};
605+
returndata;
606+
};
591607

592608
functionrun(data){
593609
if(!("version"indata)){
594610
console.log("\t= running update","1.0.0");
595611
data=_update_100(data);
596612
};
597613
if(typeofdata.version=="number"){
598-
if(data.version<2.00){
614+
if(data.version<2.0){
599615
console.log("\t= running update 2.0.0");
600616
data=_update_200(data);
601617
};
602-
if(data.version<2.10){
618+
if(data.version<2.1){
603619
console.log("\t= running update 2.1.0");
604620
data=_update_210(data);
605621
};
606-
if(data.version<2.30){
622+
if(data.version<2.3){
607623
console.log("\t= running update 2.3.0");
608624
data=_update_230(data);
609625
};
610-
if(data.version<2.40){
626+
if(data.version<2.4){
611627
console.log("\t= running update 2.4.0");
612628
data=_update_240(data);
613629
};
614-
if(data.version<2.50){
630+
if(data.version<2.5){
615631
console.log("\t= running update 2.5.0");
616632
data=_update_250(data);
617633
};
618-
if(data.version<2.70){
634+
if(data.version<2.7){
619635
console.log("\t= running update 2.7.0");
620636
data=_update_270(data);
621637
};
622-
if(data.version<2.80){
638+
if(data.version<2.8){
623639
console.log("\t= running update 2.8.0");
624640
data=_update_280(data);
625641
};
626-
if(data.version<2.90){
642+
if(data.version<2.9){
627643
console.log("\t= running update 2.9.0");
628644
data=_update_290(data);
629645
};
@@ -730,17 +746,24 @@ var update = (function(){
730746
console.log("\t= running update 3.21.0");
731747
data=_update_3210(data);
732748
};
733-
if(version.compare(data.version,"3.27.0")==-1){
734-
console.log("\t= running update 3.27.0");
735-
data=_update_3270(data);
749+
// Shift to a associate array for the configuration update as
750+
// there less code to maintain.
751+
for(varkeyinversionUpdates){
752+
if(version.compare(data.version,key)==-1){
753+
console.log("\t= running update",key);
754+
data=versionUpdates[key](data);
755+
data.version=key;
756+
};
736757
};
737758
};
759+
738760
// if no update is needed
739761
// version bump
740762
if(version.compare(data.version,version.get())==-1){
741763
console.log("\t= nothing to update, version bump to",version.get());
742764
data.version=version.get();
743765
};
766+
744767
returndata;
745768
};
746769

‎src/js/version.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
varversion=(function(){
22

3-
varcurrent="3.27.0";
3+
varcurrent="3.28.0";
44

55
varcompare=function(a,b){
66
varpa=a.split(".");

‎src/manifest.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "nightTab",
33
"short_name": "nightTab",
44
"description": "A neutral new tab page accented with a chosen colour. Customise the layout, style, background and bookmarks in nightTab.",
5-
"version": "3.27.0",
5+
"version": "3.28.0",
66
"manifest_version": 2,
77
"chrome_url_overrides":{
88
"newtab": "index.html"

0 commit comments

Comments
(0)