From 2b87580fc132872266c07b76455192539953b697 Mon Sep 17 00:00:00 2001 From: Humberto Alfonso Díaz Date: Mon, 9 Dec 2019 09:43:26 +0100 Subject: FUNCT Add date & time configuration as mockup --- src/index.js | 3 ++ src/js/date.js | 93 +++++++++++++++++++++++++++++++++++++ src/templates/date.template.html | 99 ++++++++++++++++++++++++++++++++++++++++ src/templates/main.template.html | 2 +- 4 files changed, 196 insertions(+), 1 deletion(-) create mode 100644 src/js/date.js create mode 100644 src/templates/date.template.html (limited to 'src') diff --git a/src/index.js b/src/index.js index 0c34be4..5f640a8 100644 --- a/src/index.js +++ b/src/index.js @@ -20,6 +20,7 @@ import { api } from 'agl-js-api'; import * as bluetooth from './js/bluetooth'; import * as wifi from './js/wifi'; import * as wired from './js/wired'; +import * as date from './js/date'; /* CSS */ import './styles/app.scss'; @@ -27,9 +28,11 @@ import './styles/app.scss'; window.bluetooth = bluetooth; window.wifi = wifi; window.wired = wired; +window.date = date; api.init(); app.init(); bluetooth.init(); wifi.init(); wired.init(); +date.init(); diff --git a/src/js/date.js b/src/js/date.js new file mode 100644 index 0000000..81f3dbc --- /dev/null +++ b/src/js/date.js @@ -0,0 +1,93 @@ +import Mustache from 'mustache'; +import { load as load_template } from './templates'; +import * as app from './app'; + +var monthNames = ["January", "February", "March", "April", "May", "June", + "July", "August", "September", "October", "November", "December" +]; + +var template; +var page = { + date: { + days: [], + months: [], + years: [], + isDay: function() { + var now = new Date(); + return now.getDate() === this; + }, + getMonthName: function() { + return monthNames[this]; + }, + isMonth: function() { + var now = new Date(); + return now.getMonth() === this; + }, + isYear: function() { + var now = new Date(); + return now.getFullYear() === this; + } + }, + time: { + hours: [], + minutes: [], + ampm: ['AM', 'PM'], + isHour: function() { + var now = new Date(); + return now.getHours()%12 === this; + }, + isMinutes: function() { + var now = new Date(); + return now.getMinutes() === this; + }, + isAmpm: function (){ + var now = new Date(); + if( this === 'AM' && now.getHours() < 12 ) { + return true; + } else { + return false; + } + } + } +} + +function render(){ + document.body.innerHTML = Mustache.render(template, page); +} + +export function init() { + for ( var i=0; i<31; i++) { + page.date.days[i] = i+1; + }; + + for ( var i = 0; i < 50; i++){ + page.date.years[i] = 2010 + i; + }; + + for ( var i = 0; i < 12; i++){ + page.date.months[i] = i; + }; + + for ( var i=0; i<12; i++ ) { + page.time.hours[i] = i+1; + }; + + for ( var i=0; i<60; i++ ) { + page.time.minutes[i] = i + } + + load_template('date.template.html').then(function(result) { + template = result; + Mustache.parse(template); + }, function(error) { + console.error('ERROR Loading date template', error); + }); +} + +export function show() { + render(); +} + +export function hide() { + app.show(); +} \ No newline at end of file diff --git a/src/templates/date.template.html b/src/templates/date.template.html new file mode 100644 index 0000000..72d9b3c --- /dev/null +++ b/src/templates/date.template.html @@ -0,0 +1,99 @@ +
+

+
+
+ +
+
+ Date & Time +
+
+

+
+
+ Date +
+
+
+
+
+
+
+ +
+
+ +
+
+ +
+
+
+
+
+
+
+ Time +
+
+
+
+
+
+
+ +
+
+ +
+
+ +
+
+
+
+
+
+
+ +
+
+
\ No newline at end of file diff --git a/src/templates/main.template.html b/src/templates/main.template.html index f121092..b030710 100644 --- a/src/templates/main.template.html +++ b/src/templates/main.template.html @@ -6,7 +6,7 @@
-
+
Date & Time
-- cgit 1.2.3-korg