diff options
author | Humberto Alfonso Díaz <humberto.alfonso@asvito.es> | 2019-12-11 08:39:27 +0100 |
---|---|---|
committer | Lorenzo Tilve <ltilve@igalia.com> | 2020-02-04 19:12:47 +0100 |
commit | 6d8916c58d823b13b89477f59bf05373e87f3a98 (patch) | |
tree | 97142e38adc872fe58999b7d01f806d66153be3e /src/js/time.js | |
parent | fb39b8f31f9323f5e56670de2f382f7b19daed08 (diff) |
RESTRUCT Upadate homescreen layout
Diffstat (limited to 'src/js/time.js')
-rw-r--r-- | src/js/time.js | 37 |
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 |