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