Skip to content

Commit 984ea3a

Browse files
committed
[feature] add custom header greeting
1 parent 39c0a9c commit 984ea3a

File tree

9 files changed

+80
-18
lines changed

9 files changed

+80
-18
lines changed

‎package-lock.json‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nightTab",
3-
"version": "6.4.0",
3+
"version": "6.5.0",
44
"description": "A neutral new tab page accented with a chosen colour. Customise the layout, style, background and bookmarks in nightTab.",
55
"main": "index.js",
66
"scripts":{

‎src/html/menu/content/header/greeting.html‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,17 @@ <h1 class="menu-item-header-text">Greeting</h1>
2424
<inputid="control-header-greeting-type-hi" class="control-header-greeting-type-hi" type="radio" name="control-header-greeting-type" value="hi" tabindex="-1">
2525
<labelfor="control-header-greeting-type-hi"><spanclass="label-icon"></span> "Hi..."</label>
2626
</div>
27+
<divclass="form-wrap">
28+
<inputid="control-header-greeting-type-custom" class="control-header-greeting-type-custom" type="radio" name="control-header-greeting-type" value="custom" tabindex="-1">
29+
<labelfor="control-header-greeting-type-custom"><spanclass="label-icon"></span> Custom</label>
30+
</div>
31+
<divclass="form-wrap">
32+
<divclass="form-indent">
33+
<divclass="form-wrap">
34+
<inputid="control-header-greeting-custom" class="control-header-greeting-custom" type="text" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="1">
35+
</div>
36+
</div>
37+
</div>
2738
<hr>
2839
<divclass="form-wrap">
2940
<labelfor="control-header-greeting-name">Name</label>

‎src/js/control.js‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -991,6 +991,7 @@ var control = (function(){
991991
path: "header.greeting.type",
992992
type: "radio",
993993
func: function(){
994+
render.dependents();
994995
greeting.render.clear();
995996
greeting.render.all();
996997
}
@@ -999,13 +1000,32 @@ var control = (function(){
9991000
path: "header.greeting.type",
10001001
type: "radio",
10011002
func: function(){
1003+
render.dependents();
10021004
greeting.render.clear();
10031005
greeting.render.all();
10041006
}
10051007
},{
10061008
element: ".control-header-greeting-type-hi",
10071009
path: "header.greeting.type",
10081010
type: "radio",
1011+
func: function(){
1012+
render.dependents();
1013+
greeting.render.clear();
1014+
greeting.render.all();
1015+
}
1016+
},{
1017+
element: ".control-header-greeting-type-custom",
1018+
path: "header.greeting.type",
1019+
type: "radio",
1020+
func: function(){
1021+
render.dependents();
1022+
greeting.render.clear();
1023+
greeting.render.all();
1024+
}
1025+
},{
1026+
element: ".control-header-greeting-custom",
1027+
path: "header.greeting.custom",
1028+
type: "text",
10091029
func: function(){
10101030
greeting.render.clear();
10111031
greeting.render.all();
@@ -10916,13 +10936,23 @@ var control = (function(){
1091610936
".control-header-greeting-type-good",
1091710937
".control-header-greeting-type-hello",
1091810938
".control-header-greeting-type-hi",
10939+
".control-header-greeting-type-custom",
1091910940
"[for=control-header-greeting-size-range]",
1092010941
".control-header-greeting-size-range",
1092110942
".control-header-greeting-size-number",
1092210943
".control-header-greeting-size-default",
1092310944
".control-header-greeting-newline"
1092410945
]
1092510946
}
10947+
},{
10948+
condition: function(){
10949+
return(state.get.current().header.greeting.show&&state.get.current().header.greeting.type==="custom");
10950+
},
10951+
dependents: function(){
10952+
return[
10953+
".control-header-greeting-custom"
10954+
]
10955+
}
1092610956
}],
1092710957
clock: [{
1092810958
condition: function(){

‎src/js/greeting.js‎

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,39 @@ var greeting = (function(){
2323
render.all=function(){
2424
if(state.get.current().header.greeting.show){
2525
vargreeting=helper.e(".greeting");
26-
varmessage={
27-
good: function(){
28-
vartime=helper.getDateTime();
29-
varmessage=["Good night","Good morning","Good afternoon","Good evening"];
30-
returnmessage[Math.floor(time.hours/6)];
31-
},
32-
hello: function(){
33-
return"Hello";
34-
},
35-
hi: function(){
36-
return"Hi";
37-
}
26+
varmessage=function(){
27+
switch(state.get.current().header.greeting.type){
28+
case"good":
29+
vartime=helper.getDateTime();
30+
varmessage=["Good night","Good morning","Good afternoon","Good evening"];
31+
returnmessage[Math.floor(time.hours/6)];
32+
break;
33+
34+
case"hello":
35+
return"Hello";
36+
37+
case"hi":
38+
return"Hi";
39+
40+
case"custom":
41+
returnhelper.trimString(state.get.current().header.greeting.custom);
42+
};
3843
};
39-
varstring=message[state.get.current().header.greeting.type]();
44+
45+
varstring=message();
46+
4047
if(helper.checkIfValidString(state.get.current().header.greeting.name)){
41-
string=string+", "+helper.trimString(state.get.current().header.greeting.name)
48+
if(state.get.current().header.greeting.type==="custom"){
49+
if(helper.checkIfValidString(state.get.current().header.greeting.custom)){
50+
string=string+", "+helper.trimString(state.get.current().header.greeting.name)
51+
}else{
52+
string=string+helper.trimString(state.get.current().header.greeting.name)
53+
};
54+
}else{
55+
string=string+", "+helper.trimString(state.get.current().header.greeting.name)
56+
};
4257
};
58+
4359
vargreetingItem=helper.node("span|class:greeting-item");
4460
vargreetingItemText=helper.node("span:"+string+"|class:greeting-item-text");
4561
greetingItem.appendChild(greetingItemText);

‎src/js/state.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ var state = (function(){
1515
greeting: {
1616
show: false,
1717
type: "good",
18+
custom: "",
1819
name: "",
1920
size: 1,
2021
newLine: false

‎src/js/update.js‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1383,6 +1383,10 @@ var update = (function(){
13831383
data.state.background.visual=backgroundData;
13841384
deletedata.state.background.image;
13851385
returndata;
1386+
},
1387+
"6.5.0": function(data){
1388+
data.state.header.greeting.custom="";
1389+
returndata;
13861390
}
13871391
};
13881392

‎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="6.4.0";
3+
varcurrent="6.5.0";
44

55
varname="Jaded Raven";
66

‎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": "6.4.0",
5+
"version": "6.5.0",
66
"manifest_version": 2,
77
"chrome_url_overrides":{
88
"newtab": "index.html"

0 commit comments

Comments
(0)