2020-01-17 11:43:26 +00:00
|
|
|
// This runs after a 'fresh' boot
|
2022-10-21 10:31:26 +00:00
|
|
|
var s = require("Storage").readJSON("setting.json",1)||{};
|
2022-11-01 14:21:27 +00:00
|
|
|
/* If were being called from JS code in order to load the clock quickly (eg from a launcher)
|
|
|
|
and the clock in question doesn't have widgets, force a normal 'load' as this will then
|
|
|
|
reset everything and remove the widgets. */
|
|
|
|
if (global.__FILE__ && !s.clockHasWidgets) {load();throw "Clock has no widgets, can't fast load";}
|
|
|
|
// Otherwise continue to try and load the clock
|
2022-10-21 10:42:18 +00:00
|
|
|
var _clkApp = require("Storage").read(s.clock);
|
|
|
|
if (!_clkApp) {
|
|
|
|
_clkApp = require("Storage").list(/\.info$/)
|
2020-06-10 08:04:48 +00:00
|
|
|
.map(file => {
|
|
|
|
const app = require("Storage").readJSON(file,1);
|
|
|
|
if (app && app.type == "clock") {
|
|
|
|
return app;
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.filter(x=>x)
|
|
|
|
.sort((a, b) => a.sortorder - b.sortorder)[0];
|
2022-10-21 10:42:18 +00:00
|
|
|
if (_clkApp){
|
|
|
|
s.clock = _clkApp.src;
|
2022-11-01 14:21:27 +00:00
|
|
|
_clkApp = require("Storage").read(_clkApp.src);
|
|
|
|
s.clockHasWidgets = _clkApp.includes("Bangle.loadWidgets");
|
2022-10-21 10:31:26 +00:00
|
|
|
require("Storage").writeJSON("setting.json", s);
|
|
|
|
}
|
2020-04-04 16:25:58 +00:00
|
|
|
}
|
2022-10-21 10:31:26 +00:00
|
|
|
delete s;
|
2022-10-21 10:42:18 +00:00
|
|
|
if (!_clkApp) _clkApp=`E.showMessage("No Clock Found");setWatch(()=>{Bangle.showLauncher();}, global.BTN2||BTN, {repeat:false,edge:"falling"});`;
|
|
|
|
eval(_clkApp);
|
|
|
|
delete _clkApp;
|