mirror of https://github.com/espruino/BangleApps
parent
63711f6a0c
commit
c4d5713471
|
@ -8,7 +8,6 @@
|
|||
"tags": "widget,lock",
|
||||
"supports": ["BANGLEJS","BANGLEJS2"],
|
||||
"storage": [
|
||||
{"name":"widlockunlock.wid.js","url":"widget.js"},
|
||||
{"name":"widlockunlock.settings.js","url":"settings.js"}
|
||||
{"name":"widlockunlock.wid.js","url":"widget.js"}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
"use strict";
|
||||
(function (back) {
|
||||
var storage = require('Storage');
|
||||
var filename = 'lockunlock.settings.json';
|
||||
var settings = Object.assign(storage.readJSON(filename, true) || {}, { location: "tl" });
|
||||
var save = function () {
|
||||
return storage.writeJSON(filename, settings);
|
||||
};
|
||||
var locations = ["tl", "tr"];
|
||||
var menu = {
|
||||
'': { 'title': 'Lock/Unlock' },
|
||||
'< Back': back,
|
||||
'Location': {
|
||||
value: (function () {
|
||||
var i = locations.indexOf(settings.location);
|
||||
return i < 0 ? 0 : i;
|
||||
})(),
|
||||
min: 0,
|
||||
max: locations.length - 1,
|
||||
wrap: true,
|
||||
format: function (v) { return locations[v]; },
|
||||
onchange: function (v) {
|
||||
settings.location = locations[v];
|
||||
save();
|
||||
},
|
||||
},
|
||||
};
|
||||
E.showMenu(menu);
|
||||
});
|
|
@ -1,39 +0,0 @@
|
|||
((back: () => void) => {
|
||||
type Location = "tl" | "tr";
|
||||
type Settings = {
|
||||
location: Location;
|
||||
};
|
||||
|
||||
const storage = require('Storage');
|
||||
|
||||
const filename = 'lockunlock.settings.json';
|
||||
const settings: Settings = Object.assign(
|
||||
storage.readJSON(filename, true) || {},
|
||||
{ location: "tl" }
|
||||
);
|
||||
|
||||
const save = () =>
|
||||
storage.writeJSON(filename, settings);
|
||||
|
||||
const locations: Array<Location> = [ "tl", "tr" ];
|
||||
|
||||
const menu = {
|
||||
'': { 'title': 'Lock/Unlock' },
|
||||
'< Back': back,
|
||||
'Location': {
|
||||
value: (() => {
|
||||
const i = locations.indexOf(settings.location);
|
||||
return i < 0 ? 0 : i;
|
||||
})(),
|
||||
min: 0,
|
||||
max: locations.length - 1,
|
||||
wrap: true,
|
||||
format: (v: number) => locations[v]!,
|
||||
onchange: (v: number) => {
|
||||
settings.location = locations[v]!;
|
||||
save();
|
||||
},
|
||||
},
|
||||
};
|
||||
E.showMenu(menu);
|
||||
});
|
|
@ -1,9 +1,5 @@
|
|||
WIDGETS["lockunlock"] = {
|
||||
area: (() => {
|
||||
const settings = require("Storage")
|
||||
.readJSON("lockunlock.settings.json", true) || {};
|
||||
return settings.location || "tl";
|
||||
})(),
|
||||
area: "tl",
|
||||
sortorder: 10,
|
||||
width: 14,
|
||||
draw: w => {
|
||||
|
|
Loading…
Reference in New Issue