mirror of
https://github.com/zombieFox/nightTab.git
synced 2024-12-29 10:09:04 +01:00
[refactor] improve date render and bind
This commit is contained in:
parent
faa3471db1
commit
acba96b531
@ -822,8 +822,8 @@ var control = (function() {
|
||||
func: function() {
|
||||
render();
|
||||
dependents();
|
||||
date.clear();
|
||||
date.render();
|
||||
date.render.clear();
|
||||
date.render.all();
|
||||
greeting.clear();
|
||||
greeting.render();
|
||||
transitional.clear();
|
||||
@ -835,8 +835,8 @@ var control = (function() {
|
||||
type: "radio",
|
||||
func: function() {
|
||||
dependents();
|
||||
date.clear();
|
||||
date.render();
|
||||
date.render.clear();
|
||||
date.render.all();
|
||||
greeting.clear();
|
||||
greeting.render();
|
||||
transitional.clear();
|
||||
@ -847,8 +847,8 @@ var control = (function() {
|
||||
path: "header.date.day.weekStart",
|
||||
type: "radio",
|
||||
func: function() {
|
||||
date.clear();
|
||||
date.render();
|
||||
date.render.clear();
|
||||
date.render.all();
|
||||
greeting.clear();
|
||||
greeting.render();
|
||||
transitional.clear();
|
||||
@ -859,8 +859,8 @@ var control = (function() {
|
||||
path: "header.date.day.weekStart",
|
||||
type: "radio",
|
||||
func: function() {
|
||||
date.clear();
|
||||
date.render();
|
||||
date.render.clear();
|
||||
date.render.all();
|
||||
greeting.clear();
|
||||
greeting.render();
|
||||
transitional.clear();
|
||||
@ -872,8 +872,8 @@ var control = (function() {
|
||||
type: "radio",
|
||||
func: function() {
|
||||
dependents();
|
||||
date.clear();
|
||||
date.render();
|
||||
date.render.clear();
|
||||
date.render.all();
|
||||
greeting.clear();
|
||||
greeting.render();
|
||||
transitional.clear();
|
||||
@ -884,8 +884,8 @@ var control = (function() {
|
||||
path: "header.date.day.length",
|
||||
type: "radio",
|
||||
func: function() {
|
||||
date.clear();
|
||||
date.render();
|
||||
date.render.clear();
|
||||
date.render.all();
|
||||
greeting.clear();
|
||||
greeting.render();
|
||||
transitional.clear();
|
||||
@ -896,8 +896,8 @@ var control = (function() {
|
||||
path: "header.date.day.length",
|
||||
type: "radio",
|
||||
func: function() {
|
||||
date.clear();
|
||||
date.render();
|
||||
date.render.clear();
|
||||
date.render.all();
|
||||
greeting.clear();
|
||||
greeting.render();
|
||||
transitional.clear();
|
||||
@ -910,8 +910,8 @@ var control = (function() {
|
||||
func: function() {
|
||||
render();
|
||||
dependents();
|
||||
date.clear();
|
||||
date.render();
|
||||
date.render.clear();
|
||||
date.render.all();
|
||||
greeting.clear();
|
||||
greeting.render();
|
||||
transitional.clear();
|
||||
@ -922,8 +922,8 @@ var control = (function() {
|
||||
path: "header.date.date.display",
|
||||
type: "radio",
|
||||
func: function() {
|
||||
date.clear();
|
||||
date.render();
|
||||
date.render.clear();
|
||||
date.render.all();
|
||||
greeting.clear();
|
||||
greeting.render();
|
||||
transitional.clear();
|
||||
@ -934,8 +934,8 @@ var control = (function() {
|
||||
path: "header.date.date.display",
|
||||
type: "radio",
|
||||
func: function() {
|
||||
date.clear();
|
||||
date.render();
|
||||
date.render.clear();
|
||||
date.render.all();
|
||||
greeting.clear();
|
||||
greeting.render();
|
||||
transitional.clear();
|
||||
@ -946,8 +946,8 @@ var control = (function() {
|
||||
path: "header.date.date.ordinal",
|
||||
type: "checkbox",
|
||||
func: function() {
|
||||
date.clear();
|
||||
date.render();
|
||||
date.render.clear();
|
||||
date.render.all();
|
||||
greeting.clear();
|
||||
greeting.render();
|
||||
transitional.clear();
|
||||
@ -960,8 +960,8 @@ var control = (function() {
|
||||
func: function() {
|
||||
render();
|
||||
dependents();
|
||||
date.clear();
|
||||
date.render();
|
||||
date.render.clear();
|
||||
date.render.all();
|
||||
greeting.clear();
|
||||
greeting.render();
|
||||
transitional.clear();
|
||||
@ -973,8 +973,8 @@ var control = (function() {
|
||||
type: "radio",
|
||||
func: function() {
|
||||
dependents();
|
||||
date.clear();
|
||||
date.render();
|
||||
date.render.clear();
|
||||
date.render.all();
|
||||
greeting.clear();
|
||||
greeting.render();
|
||||
transitional.clear();
|
||||
@ -985,8 +985,8 @@ var control = (function() {
|
||||
path: "header.date.month.ordinal",
|
||||
type: "checkbox",
|
||||
func: function() {
|
||||
date.clear();
|
||||
date.render();
|
||||
date.render.clear();
|
||||
date.render.all();
|
||||
greeting.clear();
|
||||
greeting.render();
|
||||
transitional.clear();
|
||||
@ -998,8 +998,8 @@ var control = (function() {
|
||||
type: "radio",
|
||||
func: function() {
|
||||
dependents();
|
||||
date.clear();
|
||||
date.render();
|
||||
date.render.clear();
|
||||
date.render.all();
|
||||
greeting.clear();
|
||||
greeting.render();
|
||||
transitional.clear();
|
||||
@ -1010,8 +1010,8 @@ var control = (function() {
|
||||
path: "header.date.month.length",
|
||||
type: "radio",
|
||||
func: function() {
|
||||
date.clear();
|
||||
date.render();
|
||||
date.render.clear();
|
||||
date.render.all();
|
||||
greeting.clear();
|
||||
greeting.render();
|
||||
transitional.clear();
|
||||
@ -1022,8 +1022,8 @@ var control = (function() {
|
||||
path: "header.date.month.length",
|
||||
type: "radio",
|
||||
func: function() {
|
||||
date.clear();
|
||||
date.render();
|
||||
date.render.clear();
|
||||
date.render.all();
|
||||
greeting.clear();
|
||||
greeting.render();
|
||||
transitional.clear();
|
||||
@ -1036,8 +1036,8 @@ var control = (function() {
|
||||
func: function() {
|
||||
render();
|
||||
dependents();
|
||||
date.clear();
|
||||
date.render();
|
||||
date.render.clear();
|
||||
date.render.all();
|
||||
greeting.clear();
|
||||
greeting.render();
|
||||
transitional.clear();
|
||||
@ -1048,8 +1048,8 @@ var control = (function() {
|
||||
path: "header.date.year.display",
|
||||
type: "radio",
|
||||
func: function() {
|
||||
date.clear();
|
||||
date.render();
|
||||
date.render.clear();
|
||||
date.render.all();
|
||||
greeting.clear();
|
||||
greeting.render();
|
||||
transitional.clear();
|
||||
@ -1060,8 +1060,8 @@ var control = (function() {
|
||||
path: "header.date.year.display",
|
||||
type: "radio",
|
||||
func: function() {
|
||||
date.clear();
|
||||
date.render();
|
||||
date.render.clear();
|
||||
date.render.all();
|
||||
greeting.clear();
|
||||
greeting.render();
|
||||
transitional.clear();
|
||||
@ -1072,8 +1072,8 @@ var control = (function() {
|
||||
path: "header.date.separator.show",
|
||||
type: "checkbox",
|
||||
func: function() {
|
||||
date.clear();
|
||||
date.render();
|
||||
date.render.clear();
|
||||
date.render.all();
|
||||
greeting.clear();
|
||||
greeting.render();
|
||||
transitional.clear();
|
||||
@ -1084,8 +1084,8 @@ var control = (function() {
|
||||
path: "header.date.format",
|
||||
type: "radio",
|
||||
func: function() {
|
||||
date.clear();
|
||||
date.render();
|
||||
date.render.clear();
|
||||
date.render.all();
|
||||
greeting.clear();
|
||||
greeting.render();
|
||||
transitional.clear();
|
||||
@ -1096,8 +1096,8 @@ var control = (function() {
|
||||
path: "header.date.format",
|
||||
type: "radio",
|
||||
func: function() {
|
||||
date.clear();
|
||||
date.render();
|
||||
date.render.clear();
|
||||
date.render.all();
|
||||
greeting.clear();
|
||||
greeting.render();
|
||||
transitional.clear();
|
||||
|
@ -1,22 +1,7 @@
|
||||
var date = (function() {
|
||||
|
||||
var bind = function() {
|
||||
window.setInterval(function() {
|
||||
clear();
|
||||
render();
|
||||
}, 1000);
|
||||
};
|
||||
|
||||
var clear = function() {
|
||||
var date = helper.e(".date");
|
||||
while (date.lastChild) {
|
||||
date.removeChild(date.lastChild);
|
||||
};
|
||||
};
|
||||
|
||||
var _makeTimeObject = function() {
|
||||
var date = helper.getDateTime();
|
||||
return date;
|
||||
return helper.getDateTime();
|
||||
};
|
||||
|
||||
var _month = function(index) {
|
||||
@ -29,11 +14,29 @@ var date = (function() {
|
||||
return all[index];
|
||||
};
|
||||
|
||||
var render = function() {
|
||||
var _date = function() {
|
||||
var bind = {};
|
||||
|
||||
bind.tick = function() {
|
||||
window.setInterval(function() {
|
||||
render.clear();
|
||||
render.all();
|
||||
}, 1000);
|
||||
};
|
||||
|
||||
var render = {};
|
||||
|
||||
render.clear = function() {
|
||||
var date = helper.e(".date");
|
||||
while (date.lastChild) {
|
||||
date.removeChild(date.lastChild);
|
||||
};
|
||||
};
|
||||
|
||||
render.all = function() {
|
||||
if (state.get().header.date.date.show || state.get().header.date.day.show || state.get().header.date.month.show || state.get().header.date.year.show) {
|
||||
var date = helper.e(".date");
|
||||
var dateObject = _makeTimeObject();
|
||||
var action = {
|
||||
var wordOrNumber = {
|
||||
day: {
|
||||
word: function(value) {
|
||||
return _day(value);
|
||||
@ -86,48 +89,20 @@ var date = (function() {
|
||||
}
|
||||
}
|
||||
};
|
||||
dateObject.day = action.day[state.get().header.date.day.display](dateObject.day);
|
||||
dateObject.date = action.date[state.get().header.date.date.display](dateObject.date);
|
||||
dateObject.month = action.month[state.get().header.date.month.display](dateObject.month);
|
||||
dateObject.year = action.year[state.get().header.date.year.display](dateObject.year);
|
||||
dateObject.day = wordOrNumber.day[state.get().header.date.day.display](dateObject.day);
|
||||
dateObject.date = wordOrNumber.date[state.get().header.date.date.display](dateObject.date);
|
||||
dateObject.month = wordOrNumber.month[state.get().header.date.month.display](dateObject.month);
|
||||
dateObject.year = wordOrNumber.year[state.get().header.date.year.display](dateObject.year);
|
||||
if (state.get().header.date.day.display == "word" && state.get().header.date.day.length == "short") {
|
||||
dateObject.day = dateObject.day.substring(0, 3);
|
||||
};
|
||||
if (state.get().header.date.month.display == "word" && state.get().header.date.month.length == "short") {
|
||||
dateObject.month = dateObject.month.substring(0, 3);
|
||||
};
|
||||
var elementDay = helper.makeNode({
|
||||
tag: "span",
|
||||
text: dateObject.day,
|
||||
attr: [{
|
||||
key: "class",
|
||||
value: "date-item date-day"
|
||||
}]
|
||||
});
|
||||
var elementDate = helper.makeNode({
|
||||
tag: "span",
|
||||
text: dateObject.date,
|
||||
attr: [{
|
||||
key: "class",
|
||||
value: "date-item date-date"
|
||||
}]
|
||||
});
|
||||
var elementMonth = helper.makeNode({
|
||||
tag: "span",
|
||||
text: dateObject.month,
|
||||
attr: [{
|
||||
key: "class",
|
||||
value: "date-item date-month"
|
||||
}]
|
||||
});
|
||||
var elementyear = helper.makeNode({
|
||||
tag: "span",
|
||||
text: dateObject.year,
|
||||
attr: [{
|
||||
key: "class",
|
||||
value: "date-item date-year"
|
||||
}]
|
||||
});
|
||||
var elementDay = helper.node("span:" + dateObject.day + "|class:date-item date-day");
|
||||
var elementDate = helper.node("span:" + dateObject.date + "|class:date-item date-date");
|
||||
var elementMonth = helper.node("span:" + dateObject.month + "|class:date-item date-month");
|
||||
var elementyear = helper.node("span:" + dateObject.year + "|class:date-item date-year");
|
||||
if (state.get().header.date.day.show) {
|
||||
date.appendChild(elementDay);
|
||||
};
|
||||
@ -178,22 +153,18 @@ var date = (function() {
|
||||
};
|
||||
};
|
||||
};
|
||||
if (state.get().header.date.date.show || state.get().header.date.day.show || state.get().header.date.month.show || state.get().header.date.year.show) {
|
||||
_date();
|
||||
};
|
||||
};
|
||||
|
||||
var init = function() {
|
||||
render();
|
||||
bind();
|
||||
render.all();
|
||||
bind.tick();
|
||||
};
|
||||
|
||||
// exposed methods
|
||||
return {
|
||||
init: init,
|
||||
bind: bind,
|
||||
render: render,
|
||||
clear: clear
|
||||
render: render
|
||||
};
|
||||
|
||||
})();
|
||||
|
@ -1,6 +1,6 @@
|
||||
var version = (function() {
|
||||
|
||||
var current = "3.35.0";
|
||||
var current = "3.36.0";
|
||||
|
||||
var compare = function(a, b) {
|
||||
var pa = a.split(".");
|
||||
|
@ -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": "3.35.0",
|
||||
"version": "3.36.0",
|
||||
"manifest_version": 2,
|
||||
"chrome_url_overrides": {
|
||||
"newtab": "index.html"
|
||||
|
Loading…
Reference in New Issue
Block a user