mirror of
https://github.com/zombieFox/nightTab.git
synced 2025-02-16 18:20:49 +01:00
[feature] add custom header greeting
This commit is contained in:
parent
39c0a9c846
commit
984ea3ac36
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "nightTab",
|
||||
"version": "6.4.0",
|
||||
"version": "6.5.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "nightTab",
|
||||
"version": "6.4.0",
|
||||
"version": "6.5.0",
|
||||
"description": "A neutral new tab page accented with a chosen colour. Customise the layout, style, background and bookmarks in nightTab.",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
@ -24,6 +24,17 @@
|
||||
<input id="control-header-greeting-type-hi" class="control-header-greeting-type-hi" type="radio" name="control-header-greeting-type" value="hi" tabindex="-1">
|
||||
<label for="control-header-greeting-type-hi"><span class="label-icon"></span> "Hi..."</label>
|
||||
</div>
|
||||
<div class="form-wrap">
|
||||
<input id="control-header-greeting-type-custom" class="control-header-greeting-type-custom" type="radio" name="control-header-greeting-type" value="custom" tabindex="-1">
|
||||
<label for="control-header-greeting-type-custom"><span class="label-icon"></span> Custom</label>
|
||||
</div>
|
||||
<div class="form-wrap">
|
||||
<div class="form-indent">
|
||||
<div class="form-wrap">
|
||||
<input id="control-header-greeting-custom" class="control-header-greeting-custom" type="text" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="1">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="form-wrap">
|
||||
<label for="control-header-greeting-name">Name</label>
|
||||
|
@ -991,6 +991,7 @@ var control = (function() {
|
||||
path: "header.greeting.type",
|
||||
type: "radio",
|
||||
func: function() {
|
||||
render.dependents();
|
||||
greeting.render.clear();
|
||||
greeting.render.all();
|
||||
}
|
||||
@ -999,6 +1000,7 @@ var control = (function() {
|
||||
path: "header.greeting.type",
|
||||
type: "radio",
|
||||
func: function() {
|
||||
render.dependents();
|
||||
greeting.render.clear();
|
||||
greeting.render.all();
|
||||
}
|
||||
@ -1006,6 +1008,24 @@ var control = (function() {
|
||||
element: ".control-header-greeting-type-hi",
|
||||
path: "header.greeting.type",
|
||||
type: "radio",
|
||||
func: function() {
|
||||
render.dependents();
|
||||
greeting.render.clear();
|
||||
greeting.render.all();
|
||||
}
|
||||
}, {
|
||||
element: ".control-header-greeting-type-custom",
|
||||
path: "header.greeting.type",
|
||||
type: "radio",
|
||||
func: function() {
|
||||
render.dependents();
|
||||
greeting.render.clear();
|
||||
greeting.render.all();
|
||||
}
|
||||
}, {
|
||||
element: ".control-header-greeting-custom",
|
||||
path: "header.greeting.custom",
|
||||
type: "text",
|
||||
func: function() {
|
||||
greeting.render.clear();
|
||||
greeting.render.all();
|
||||
@ -10916,6 +10936,7 @@ var control = (function() {
|
||||
".control-header-greeting-type-good",
|
||||
".control-header-greeting-type-hello",
|
||||
".control-header-greeting-type-hi",
|
||||
".control-header-greeting-type-custom",
|
||||
"[for=control-header-greeting-size-range]",
|
||||
".control-header-greeting-size-range",
|
||||
".control-header-greeting-size-number",
|
||||
@ -10923,6 +10944,15 @@ var control = (function() {
|
||||
".control-header-greeting-newline"
|
||||
]
|
||||
}
|
||||
}, {
|
||||
condition: function() {
|
||||
return (state.get.current().header.greeting.show && state.get.current().header.greeting.type === "custom");
|
||||
},
|
||||
dependents: function() {
|
||||
return [
|
||||
".control-header-greeting-custom"
|
||||
]
|
||||
}
|
||||
}],
|
||||
clock: [{
|
||||
condition: function() {
|
||||
|
@ -23,23 +23,39 @@ var greeting = (function() {
|
||||
render.all = function() {
|
||||
if (state.get.current().header.greeting.show) {
|
||||
var greeting = helper.e(".greeting");
|
||||
var message = {
|
||||
good: function() {
|
||||
var time = helper.getDateTime();
|
||||
var message = ["Good night", "Good morning", "Good afternoon", "Good evening"];
|
||||
return message[Math.floor(time.hours / 6)];
|
||||
},
|
||||
hello: function() {
|
||||
return "Hello";
|
||||
},
|
||||
hi: function() {
|
||||
return "Hi";
|
||||
}
|
||||
var message = function() {
|
||||
switch (state.get.current().header.greeting.type) {
|
||||
case "good":
|
||||
var time = helper.getDateTime();
|
||||
var message = ["Good night", "Good morning", "Good afternoon", "Good evening"];
|
||||
return message[Math.floor(time.hours / 6)];
|
||||
break;
|
||||
|
||||
case "hello":
|
||||
return "Hello";
|
||||
|
||||
case "hi":
|
||||
return "Hi";
|
||||
|
||||
case "custom":
|
||||
return helper.trimString(state.get.current().header.greeting.custom);
|
||||
};
|
||||
};
|
||||
var string = message[state.get.current().header.greeting.type]();
|
||||
|
||||
var string = message();
|
||||
|
||||
if (helper.checkIfValidString(state.get.current().header.greeting.name)) {
|
||||
string = string + ", " + helper.trimString(state.get.current().header.greeting.name)
|
||||
if (state.get.current().header.greeting.type === "custom") {
|
||||
if (helper.checkIfValidString(state.get.current().header.greeting.custom)) {
|
||||
string = string + ", " + helper.trimString(state.get.current().header.greeting.name)
|
||||
} else {
|
||||
string = string + helper.trimString(state.get.current().header.greeting.name)
|
||||
};
|
||||
} else {
|
||||
string = string + ", " + helper.trimString(state.get.current().header.greeting.name)
|
||||
};
|
||||
};
|
||||
|
||||
var greetingItem = helper.node("span|class:greeting-item");
|
||||
var greetingItemText = helper.node("span:" + string + "|class:greeting-item-text");
|
||||
greetingItem.appendChild(greetingItemText);
|
||||
|
@ -15,6 +15,7 @@ var state = (function() {
|
||||
greeting: {
|
||||
show: false,
|
||||
type: "good",
|
||||
custom: "",
|
||||
name: "",
|
||||
size: 1,
|
||||
newLine: false
|
||||
|
@ -1383,6 +1383,10 @@ var update = (function() {
|
||||
data.state.background.visual = backgroundData;
|
||||
delete data.state.background.image;
|
||||
return data;
|
||||
},
|
||||
"6.5.0": function(data) {
|
||||
data.state.header.greeting.custom = "";
|
||||
return data;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
var version = (function() {
|
||||
|
||||
var current = "6.4.0";
|
||||
var current = "6.5.0";
|
||||
|
||||
var name = "Jaded Raven";
|
||||
|
||||
|
@ -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": "6.4.0",
|
||||
"version": "6.5.0",
|
||||
"manifest_version": 2,
|
||||
"chrome_url_overrides": {
|
||||
"newtab": "index.html"
|
||||
|
Loading…
Reference in New Issue
Block a user