1
0
Fork 0

Rolled back agenda clkinfo

master
glemco 2022-11-26 20:12:08 +01:00 committed by Gabriele Monaco
parent 18d91bf5f9
commit a011f929fd
2 changed files with 10 additions and 20 deletions

View File

@ -7,4 +7,3 @@
0.07: Clkinfo improvements.
0.08: Fix error in clkinfo (didn't require Storage & locale)
Fix clkinfo icon
0.09: Clkinfo new fields and filter past events.

View File

@ -1,34 +1,25 @@
(function() {
var agendaItems = {
name: "Agenda",
img: atob("GBiBAAAAAAAAAADGMA///w///wf//wAAAA///w///w///w///x///h///h///j///D///X//+f//8wAABwAADw///w///wf//gAAAA=="),
dynamic: true,
items: []
};
var storage = require("Storage");
name: "Agenda",
img: atob("GBiBAAAAAAAAAADGMA///w///wf//wAAAA///w///w///w///x///h///h///j///D///X//+f//8wAABwAADw///w///wf//gAAAA=="),
items: []
};
var locale = require("locale");
var now = new Date();
var agenda = (storage.readJSON("android.calendar.json",true)||[])
.filter(ev=>ev.timestamp + ev.durationInSeconds > now/1000)
.sort((a,b)=>a.timestamp - b.timestamp);
var settings = storage.readJSON("agenda.settings.json",true)||{};
var agenda = require("Storage").readJSON("android.calendar.json")
.filter(ev=>ev.timestamp + ev.durationInSeconds > now/1000)
.sort((a,b)=>a.timestamp - b.timestamp);
agenda.forEach((entry, i) => {
var title = entry.title.slice(0,12);
var date = new Date(entry.timestamp*1000);
var dateStr = locale.date(date).replace(/\d\d\d\d/,"");
var dateStrToday = locale.date(new Date()).replace(/\d\d\d\d/,"");
var timeStr = locale.time(date);
//maybe not the most efficient..
var shortTxt = (dateStrToday == dateStr) ? timeStr : dateStr;
dateStr += entry.durationInSeconds < 86400 ? "/ " + locale.time(date,1) : "";
if(!settings.pastEvents && entry.timestamp + entry.durationInSeconds < (new Date())/1000)
return;
agendaItems.items.push({
name: null,
get: () => ({ text: title + "\n" + dateStr, short: shortTxt, img: null}),
name: "Agenda "+i,
get: () => ({ text: title + "\n" + dateStr, img: null}),
show: function() { agendaItems.items[i].emit("redraw"); },
hide: function () {}
});