2022-01-15 17:16:48 +00:00
|
|
|
Bangle.loadWidgets = function() {
|
2022-01-17 20:18:02 +00:00
|
|
|
global.WIDGETS={};
|
2022-01-15 17:16:48 +00:00
|
|
|
require("Storage").list(/\.wid\.js$/)
|
2022-01-17 20:18:02 +00:00
|
|
|
.forEach(w=>{
|
|
|
|
try { eval(require("Storage").read(w)); }
|
|
|
|
catch (e) { print(w, e); }
|
2022-01-15 17:16:48 +00:00
|
|
|
});
|
2022-01-17 18:40:33 +00:00
|
|
|
const s = require("Storage").readJSON("wid_edit.json", 1) || {},
|
|
|
|
c = s.custom || {};
|
2022-01-15 17:16:48 +00:00
|
|
|
for (const w in c){
|
2022-01-17 20:18:02 +00:00
|
|
|
if (!(w in WIDGETS)) continue; // widget no longer exists
|
|
|
|
// store defaults of customized values in _WIDGETS
|
|
|
|
global._WIDGETS=global._WIDGETS||{};
|
|
|
|
_WIDGETS[w] = {};
|
|
|
|
Object.keys(c[w]).forEach(k => _WIDGETS[w][k] = WIDGETS[w][k]);
|
2022-01-17 18:36:41 +00:00
|
|
|
Object.assign(WIDGETS[w], c[w]);
|
2022-01-15 17:16:48 +00:00
|
|
|
}
|
|
|
|
const W = WIDGETS;
|
|
|
|
WIDGETS = {};
|
|
|
|
Object.keys(W)
|
2022-01-17 19:35:18 +00:00
|
|
|
.sort()
|
2022-01-15 17:16:48 +00:00
|
|
|
.sort((a, b) => (0|W[b].sortorder)-(0|W[a].sortorder))
|
2022-01-17 18:36:41 +00:00
|
|
|
.forEach(k => WIDGETS[k] = W[k]);
|
2022-01-15 17:16:48 +00:00
|
|
|
}
|