2019-03-26 00:31:51 +01:00
|
|
|
var greeting = (function() {
|
|
|
|
|
2019-04-02 13:23:18 +02:00
|
|
|
var bind = function() {
|
|
|
|
window.setInterval(function() {
|
|
|
|
clear();
|
|
|
|
render();
|
|
|
|
}, 1000);
|
|
|
|
};
|
|
|
|
|
2019-03-26 00:31:51 +01:00
|
|
|
var clear = function() {
|
|
|
|
var greeting = helper.e(".greeting");
|
|
|
|
while (greeting.lastChild) {
|
|
|
|
greeting.removeChild(greeting.lastChild);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
var render = function() {
|
|
|
|
var _greeting = function() {
|
|
|
|
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)];
|
2019-04-26 14:48:37 +02:00
|
|
|
},
|
|
|
|
hello: function() {
|
|
|
|
return "Hello";
|
|
|
|
},
|
|
|
|
hi: function() {
|
|
|
|
return "Hi";
|
2019-03-26 00:31:51 +01:00
|
|
|
}
|
|
|
|
};
|
2019-04-26 14:48:37 +02:00
|
|
|
var string = message[state.get().header.greeting.type]();
|
2019-03-26 00:31:51 +01:00
|
|
|
if (state.get().header.greeting.name != "" && state.get().header.greeting.name != undefined) {
|
2019-04-26 14:48:37 +02:00
|
|
|
string = string + ", " + state.get().header.greeting.name;
|
2019-03-26 00:31:51 +01:00
|
|
|
};
|
|
|
|
var greetingItem = helper.makeNode({
|
|
|
|
tag: "span",
|
|
|
|
attr: [{
|
|
|
|
key: "class",
|
|
|
|
value: "greeting-item"
|
|
|
|
}]
|
|
|
|
});
|
|
|
|
var greetingItemText = helper.makeNode({
|
|
|
|
tag: "span",
|
2019-04-26 14:48:37 +02:00
|
|
|
text: string,
|
2019-03-26 00:31:51 +01:00
|
|
|
attr: [{
|
|
|
|
key: "class",
|
|
|
|
value: "greeting-item-text"
|
|
|
|
}]
|
|
|
|
});
|
|
|
|
greetingItem.appendChild(greetingItemText);
|
|
|
|
greeting.appendChild(greetingItem);
|
|
|
|
};
|
|
|
|
if (state.get().header.greeting.show) {
|
|
|
|
_greeting();
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
var init = function() {
|
2019-04-02 13:23:18 +02:00
|
|
|
bind();
|
2019-03-26 00:31:51 +01:00
|
|
|
render();
|
|
|
|
};
|
|
|
|
|
|
|
|
// exposed methods
|
|
|
|
return {
|
|
|
|
init: init,
|
|
|
|
render: render,
|
|
|
|
clear: clear
|
|
|
|
};
|
|
|
|
|
|
|
|
})();
|