forked from FOSS/BangleApps
clkinfocal added settings menu for different date formats
parent
e4bbc5a6f1
commit
dc3ba06e9e
|
@ -1 +1,2 @@
|
|||
0.01: New App!
|
||||
0.02: added settings options to change date format
|
||||
|
|
|
@ -1,5 +1,21 @@
|
|||
(function() {
|
||||
require("Font4x8Numeric").add(Graphics);
|
||||
|
||||
var settings = require("Storage").readJSON("clkinfocal.json",1)||{};
|
||||
settings.fmt = settings.fmt||0;
|
||||
|
||||
var getDateString = function(dt) {
|
||||
var fmt = 1; // get from settings
|
||||
switch(settings.fmt) {
|
||||
case 2: // dd MMM
|
||||
return '' + dt.getDate() + ' ' + require("locale").month(dt,1).toUpperCase();
|
||||
case 1: // DDD dd
|
||||
return require("locale").dow(dt,1).toUpperCase() + ' ' + dt.getDate();
|
||||
default: // DDD
|
||||
return require("locale").dow(dt,1).toUpperCase();
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
name: "Bangle",
|
||||
items: [
|
||||
|
@ -10,7 +26,7 @@
|
|||
g.drawImage(atob("FhgBDADAMAMP/////////////////////8AADwAAPAAA8AADwAAPAAA8AADwAAPAAA8AADwAAPAAA8AADwAAP///////"),1,0);
|
||||
g.setFont("6x15").setFontAlign(0,0).drawString(d.getDate(),11,17);
|
||||
return {
|
||||
text : require("locale").dow(d,1).toUpperCase(),
|
||||
text : getDateString(d),
|
||||
img : g.asImage("string")
|
||||
};
|
||||
},
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{ "id": "clkinfocal",
|
||||
"name": "Calendar Clockinfo",
|
||||
"version":"0.01",
|
||||
"version":"0.02",
|
||||
"description": "For clocks that display 'clockinfo' (messages that can be cycled through using the clock_info module) this displays the day of the month in the icon, and the weekday",
|
||||
"icon": "app.png",
|
||||
"screenshots": [{"url":"screenshot.png"}],
|
||||
|
@ -8,6 +8,9 @@
|
|||
"tags": "clkinfo,calendar",
|
||||
"supports" : ["BANGLEJS2"],
|
||||
"storage": [
|
||||
{"name":"clkinfocal.clkinfo.js","url":"clkinfo.js"}
|
||||
]
|
||||
{"name":"clkinfocal.clkinfo.js","url":"clkinfo.js"},
|
||||
{"name":"clkinfocal.settings.js","url":"settings.js"}
|
||||
|
||||
],
|
||||
"data": [{"name":"clkinfocal.json"}]
|
||||
}
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
(function(back) {
|
||||
const SETTINGS_FILE = "clkinfocal.json";
|
||||
|
||||
// initialize with default settings...
|
||||
let s = {'fmt': 0};
|
||||
|
||||
// and overwrite them with any saved values
|
||||
// this way saved values are preserved if a new version adds more settings
|
||||
const storage = require('Storage');
|
||||
let settings = storage.readJSON(SETTINGS_FILE, 1) || {};
|
||||
const saved = settings || {};
|
||||
for (const key in saved) {
|
||||
s[key] = saved[key];
|
||||
}
|
||||
|
||||
function save() {
|
||||
settings = s;
|
||||
storage.write(SETTINGS_FILE, settings);
|
||||
}
|
||||
|
||||
var date_options = ["DDD","DDD dd","dd MMM"];
|
||||
|
||||
E.showMenu({
|
||||
'': { 'title': 'Cal Clkinfo' },
|
||||
'< Back': back,
|
||||
'Format': {
|
||||
value: 0 | date_options.indexOf(s.fmt),
|
||||
min: 0, max: 2,
|
||||
format: v => date_options[v],
|
||||
onchange: v => {
|
||||
s.fmt = date_options[v];
|
||||
save();
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
});
|
Loading…
Reference in New Issue