From 639d9b7dc5c7b0ba1ed0a6b7b851c18840f472dd Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Fri, 25 Nov 2022 16:08:26 +0000 Subject: [PATCH] agenda 0.08: Fix error in clkinfo (didn't require Storage & locale) --- apps/agenda/ChangeLog | 3 ++- apps/agenda/agenda.clkinfo.js | 48 +++++++++++++++++------------------ apps/agenda/metadata.json | 2 +- 3 files changed, 27 insertions(+), 26 deletions(-) diff --git a/apps/agenda/ChangeLog b/apps/agenda/ChangeLog index 0a7916810..bbde4d80b 100644 --- a/apps/agenda/ChangeLog +++ b/apps/agenda/ChangeLog @@ -4,4 +4,5 @@ 0.04: Added awareness of allDay field 0.05: Displaying calendar colour and name 0.06: Added clkinfo for clocks. -0.07: Clkinfo improvements. \ No newline at end of file +0.07: Clkinfo improvements. +0.08: Fix error in clkinfo (didn't require Storage & locale) diff --git a/apps/agenda/agenda.clkinfo.js b/apps/agenda/agenda.clkinfo.js index 6c2ddb3da..84da715b9 100644 --- a/apps/agenda/agenda.clkinfo.js +++ b/apps/agenda/agenda.clkinfo.js @@ -1,29 +1,29 @@ (function() { - var agendaItems = { - name: "Agenda", - img: atob("GBiBAf////////85z/AAAPAAAPgAAP////AAAPAAAPAAAPAAAOAAAeAAAeAAAcAAA8AAAoAABgAADP//+P//8PAAAPAAAPgAAf///w=="), - items: [] - }; + var agendaItems = { + name: "Agenda", + img: atob("GBiBAf////////85z/AAAPAAAPgAAP////AAAPAAAPAAAPAAAOAAAeAAAeAAAcAAA8AAAoAABgAADP//+P//8PAAAPAAAPgAAf///w=="), + items: [] + }; + var locale = require("locale"); + var now = new Date(); + var agenda = require("Storage").readJSON("android.calendar.json") + .filter(ev=>ev.timestamp + ev.durationInSeconds > now/1000) + .sort((a,b)=>a.timestamp - b.timestamp); - var now = new Date(); - var agenda = storage.readJSON("android.calendar.json") - .filter(ev=>ev.timestamp + ev.durationInSeconds > now/1000) - .sort((a,b)=>a.timestamp - b.timestamp); + agenda.forEach((entry, i) => { - agenda.forEach((entry, i) => { + var title = entry.title.slice(0,18); + var date = new Date(entry.timestamp*1000); + var dateStr = locale.date(date).replace(/\d\d\d\d/,""); + dateStr += entry.durationInSeconds < 86400 ? "/ " + locale.time(date,1) : ""; - var title = entry.title.slice(0,18); - var date = new Date(entry.timestamp*1000); - var dateStr = locale.date(date).replace(/\d\d\d\d/,""); - dateStr += entry.durationInSeconds < 86400 ? "/ " + locale.time(date,1) : ""; + agendaItems.items.push({ + name: null, + get: () => ({ text: title + "\n" + dateStr, img: null}), + show: function() { agendaItems.items[i].emit("redraw"); }, + hide: function () {} + }); + }); - agendaItems.items.push({ - name: null, - get: () => ({ text: title + "\n" + dateStr, img: null}), - show: function() { agendaItems.items[i].emit("redraw"); }, - hide: function () {} - }); - }); - - return agendaItems; -}) \ No newline at end of file + return agendaItems; +}) diff --git a/apps/agenda/metadata.json b/apps/agenda/metadata.json index 4436e143c..7e49e3f96 100644 --- a/apps/agenda/metadata.json +++ b/apps/agenda/metadata.json @@ -1,7 +1,7 @@ { "id": "agenda", "name": "Agenda", - "version": "0.07", + "version": "0.08", "description": "Simple agenda", "icon": "agenda.png", "screenshots": [{"url":"screenshot_agenda_overview.png"}, {"url":"screenshot_agenda_event1.png"}, {"url":"screenshot_agenda_event2.png"}],