Skip to content

Commit 50ebd3f

Browse files
committed
[feature] adding youtube and name input for custom search to header options
1 parent a342f44 commit 50ebd3f

File tree

6 files changed

+48
-6
lines changed

6 files changed

+48
-6
lines changed

‎index.html‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,10 @@ <h1 class="menu-header">Search</h1>
221221
<inputid="control-header-search-engine-duckduckgo" class="control-header-search-engine-duckduckgo" type="radio" name="control-header-search-engine" value="duckduckgo" tabindex="1">
222222
<labelfor="control-header-search-engine-duckduckgo"><spanclass="label-icon"></span>Duck Duck Go</label>
223223
</div>
224+
<divclass="radio-wrap form-indent-1">
225+
<inputid="control-header-search-engine-youtube" class="control-header-search-engine-youtube" type="radio" name="control-header-search-engine" value="youtube" tabindex="1">
226+
<labelfor="control-header-search-engine-youtube"><spanclass="label-icon"></span>YouTube</label>
227+
</div>
224228
<divclass="radio-wrap form-indent-1">
225229
<inputid="control-header-search-engine-giphy" class="control-header-search-engine-giphy" type="radio" name="control-header-search-engine" value="giphy" tabindex="1">
226230
<labelfor="control-header-search-engine-giphy"><spanclass="label-icon"></span>Giphy</label>
@@ -229,9 +233,15 @@ <h1 class="menu-header">Search</h1>
229233
<inputid="control-header-search-engine-custom" class="control-header-search-engine-custom" type="radio" name="control-header-search-engine" value="custom" tabindex="1">
230234
<labelfor="control-header-search-engine-custom"><spanclass="label-icon"></span>Custom</label>
231235
</div>
236+
<divclass="input-wrap form-indent-2">
237+
<labelfor="control-header-search-engine-custom-name">Name</label>
238+
<inputid="control-header-search-engine-custom-name" class="control-header-search-engine-custom-name" type="text" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" placeholder="Search engine name" tabindex="1">
239+
</div>
232240
<divclass="input-wrap form-indent-2">
233241
<labelfor="control-header-search-engine-custom-url">URL</label>
234242
<inputid="control-header-search-engine-custom-url" class="control-header-search-engine-custom-url" type="text" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" placeholder="https://" tabindex="1">
243+
<pclass="input-helper small muted">Eneter a web address with the search parameters, eg: "https://vimeo.com/search?q="</p>
244+
<pclass="input-helper small muted">nightTab would add the search term entered into the Search input at the end of the above URL</p>
235245
</div>
236246
</div>
237247
<divclass="menu-item">
@@ -258,8 +268,8 @@ <h1 class="menu-header">Horizontal Alignment</h1>
258268
<divclass="radio-wrap">
259269
<inputid="control-layout-alignment-horizontal-right" class="control-layout-alignment-horizontal-right" type="radio" name="control-layout-alignment-horizontal" value="right" tabindex="1">
260270
<labelfor="control-layout-alignment-horizontal-right"><spanclass="label-icon"></span>Right</label>
271+
<pclass="input-helper small muted">Effects may not be visible if the Search box is set to grow to fill available space.</p>
261272
</div>
262-
<pclass="input-helper small muted">Effects may not be visible if the Search box is set to grow to fill available space.</p>
263273
</div>
264274
<divclass="menu-item">
265275
<h1class="menu-header">Vertical Alignment</h1>

‎js/control.js‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,15 @@ var control = (function(){
203203
dependents();
204204
search.render();
205205
}
206+
},{
207+
element: helper.e(".control-header-search-engine-youtube"),
208+
path: "header.search.engine.selected",
209+
type: "radio",
210+
func: function(){
211+
render();
212+
dependents();
213+
search.render();
214+
}
206215
},{
207216
element: helper.e(".control-header-search-engine-giphy"),
208217
path: "header.search.engine.selected",
@@ -221,6 +230,12 @@ var control = (function(){
221230
dependents();
222231
search.render();
223232
}
233+
},{
234+
element: helper.e(".control-header-search-engine-custom-name"),
235+
path: "header.search.engine.custom.name",
236+
func: function(){
237+
search.render();
238+
}
224239
},{
225240
element: helper.e(".control-header-search-engine-custom-url"),
226241
path: "header.search.engine.custom.url",
@@ -802,6 +817,7 @@ var control = (function(){
802817
}else{
803818
helper.removeClass(html,"is-header-search-grow");
804819
};
820+
helper.e(".control-header-search-engine-custom-name").value=state.get().header.search.engine.custom.name;
805821
helper.e(".control-header-search-engine-custom-url").value=state.get().header.search.engine.custom.url;
806822
};
807823
var_alignment=function(){
@@ -1021,9 +1037,13 @@ var control = (function(){
10211037
helper.e(".control-header-search-engine-label").setAttribute("disabled","");
10221038
};
10231039
if(state.get().header.search.show&&state.get().header.search.engine.selected==="custom"){
1040+
helper.e("[for=control-header-search-engine-custom-name]").removeAttribute("disabled");
1041+
helper.e(".control-header-search-engine-custom-name").disabled=false;
10241042
helper.e("[for=control-header-search-engine-custom-url]").removeAttribute("disabled");
10251043
helper.e(".control-header-search-engine-custom-url").disabled=false;
10261044
}else{
1045+
helper.e("[for=control-header-search-engine-custom-name]").setAttribute("disabled","");
1046+
helper.e(".control-header-search-engine-custom-name").disabled=true;
10271047
helper.e("[for=control-header-search-engine-custom-url]").setAttribute("disabled","");
10281048
helper.e(".control-header-search-engine-custom-url").disabled=true;
10291049
};

‎js/search.js‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,7 @@ var search = (function(){
7272
}else{
7373
placeholder="Search";
7474
};
75-
if(state.get().header.search.engine.selected!="custom"){
76-
placeholder=placeholder+" "+state.get().header.search.engine[state.get().header.search.engine.selected].name;
77-
};
75+
placeholder=placeholder+" "+state.get().header.search.engine[state.get().header.search.engine.selected].name;
7876
searchInput.setAttribute("placeholder",placeholder);
7977
search.setAttribute("action",state.get().header.search.engine[state.get().header.search.engine.selected].url);
8078
};

‎js/state.js‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,17 @@ var state = (function(){
3838
url: "https://duckduckgo.com/",
3939
name: "Duck Duck Go"
4040
},
41+
youtube: {
42+
url: "https://www.youtube.com/results?search_query=",
43+
name: "YouTube"
44+
},
4145
giphy: {
4246
url: "https://giphy.com/search/",
4347
name: "Giphy"
4448
},
4549
custom: {
46-
url: ""
50+
url: "",
51+
name: ""
4752
}
4853
}
4954
},

‎js/update.js‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,15 @@ var update = (function(){
261261
data.state.header.search.engine.giphy.name="Giphy";
262262
data.version="2.17.0";
263263
};
264+
if(version.compare(data.version,"2.19.0")==-1){
265+
console.log("\t -- running update","2.19.0");
266+
data.state.header.search.engine.youtube={
267+
url: "https://www.youtube.com/results?search_query=",
268+
name: "YouTube"
269+
};
270+
data.state.header.search.engine.custom.name="";
271+
data.version="2.19.0";
272+
};
264273
};
265274
// if no update is needed
266275
// version bump

‎js/version.js‎

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

33
// version is normally bumped when the state needs changing or any new functionality is added
4-
varcurrent="2.18.0";
4+
varcurrent="2.19.0";
55

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

0 commit comments

Comments
(0)