Add files via upload

master
Purple-Tentacle 2020-03-31 23:17:46 +02:00 committed by GitHub
parent 175c46fa28
commit b3da3806b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 101 additions and 0 deletions

1
apps/daysl/app-icon.js Normal file
View File

@ -0,0 +1 @@
require("heatshrink").decompress(atob("mEwwMB//D/4CgwHDFYPDgICBAoQCB/4CKADmAAgcBIARCCAqQAXF/4v24CtDgYFR"))

67
apps/daysl/app.js Normal file
View File

@ -0,0 +1,67 @@
g.clear();
Bangle.loadWidgets();
Bangle.drawWidgets();
const storage = require('Storage');
let settings;
function updateSettings() {
storage.write('daysleft.json', settings);
}
function resetSettings() {
settings = {
day : 17,
month : 6,
year: 1981
};
updateSettings();
}
settings = storage.readJSON('daysleft.json',1);
if (!settings) resetSettings();
function showMenu() {
const datemenu = {
'': {
'title': 'Set Date',
'predraw': function() {
datemenu.Date.value = settings.day;
datemenu.Month.value = settings.month;
datemenu.Year.value = settings.year;
}
},
'Day': {
value: settings.day,
min: 1,
max: 31,
step: 1,
onchange: v => {
settings.day = v;
updateSettings();
}
},
'Month': {
value: settings.month,
min: 1,
max: 12,
step: 1,
onchange: v => {
settings.month = v;
updateSettings();
}
},
'Year': {
value: settings.year,
step: 1,
onchange: v => {
settings.year = v;
updateSettings();
}
}
};
datemenu['-Exit-'] = ()=>{load();};
return E.showMenu(datemenu);
}
showMenu();

BIN
apps/daysl/app.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 287 B

33
apps/daysl/widget.js Normal file
View File

@ -0,0 +1,33 @@
const storage = require('Storage');
let settings;
function updateSettings() {
storage.write('daysleft.json', settings);
}
function resetSettings() {
settings = {
day : 17,
month : 6,
year: 1981
};
updateSettings();
}
settings = storage.readJSON('daysleft.json',1);
if (!settings) resetSettings();
var dd = settings.day+1,
mm = settings.month-1,
yy = settings.year;
const oneDay = 24 * 60 * 60 * 1000; // hours*minutes*seconds*milliseconds
const targetDate = new Date(yy, mm, dd);
const today = new Date();
const diffDays = Math.round(Math.abs((targetDate - today) / oneDay));
WIDGETS["daysl"]={area:"tl",width:40,draw:function(){
g.setFont("6x8", 1);
g.drawString(diffDays,this.x+12,this.y+12);
}};