summaryrefslogtreecommitdiffstats
path: root/src/js/time.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/js/time.js')
-rw-r--r--src/js/time.js37
1 files changed, 28 insertions, 9 deletions
diff --git a/src/js/time.js b/src/js/time.js
index 55165c7..1757257 100644
--- a/src/js/time.js
+++ b/src/js/time.js
@@ -1,9 +1,25 @@
+import { load as load_template } from './templates';
import Mustache from 'mustache';
var template;
+var root;
+var page = {
+ date: {
+ day: '',
+ hour: ''
+ },
+ weather: {
+ icon: 'fas fa-cloud-sun-rain',
+ temperature: '20ÂșC'
+ }
+}
var days = ['SUNDAY', 'MONDAY', 'TUESDAY', 'WEDNESDAY', 'THURSDAY', 'FRIDAY', 'SATURDAY'];
+function show() {
+ root.innerHTML = Mustache.render(template, page);
+}
+
function formatAMPM(date) {
var hours = date.getHours();
var minutes = date.getMinutes();
@@ -18,16 +34,19 @@ function formatAMPM(date) {
function initInterval() {
setInterval(function() {
var date = new Date();
- document.getElementById('timeContainer').innerHTML = Mustache.render(template, {
- day: days[date.getDay()],
- hour: formatAMPM(date)
- });
+ page.date.day = days[date.getDay()],
+ page.date.hour = formatAMPM(date);
+ show();
}, 1000);
}
-export function init() {
- template = document.getElementById('time-template').innerHTML;
- Mustache.parse(template);
-
- initInterval();
+export function init(node) {
+ load_template('time.template.html').then(function(result) {
+ template = result;
+ root = node;
+ Mustache.parse(template);
+ initInterval();
+ }, function(error) {
+ console.error('ERRROR loading main template', error);
+ });
} \ No newline at end of file