2022-10-27 19:27:02 +00:00
|
|
|
Bangle.loadWidgets = (o => ()=>{
|
|
|
|
o();
|
|
|
|
const s = require("Storage").readJSON("wid_edit.json", 1) || {};
|
|
|
|
const 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
|
2022-10-27 19:27:02 +00:00
|
|
|
if (!global._WIDGETS) global._WIDGETS = {};
|
|
|
|
if (!global._WIDGETS[w]) global._WIDGETS[w] = {};
|
2022-11-06 12:36:14 +00:00
|
|
|
Object.keys(c[w]).forEach(k => global._WIDGETS[w][k] = global.WIDGETS[w][k]);
|
2022-10-27 19:27:02 +00:00
|
|
|
//overide values in widget with configured ones
|
2022-11-06 12:36:14 +00:00
|
|
|
Object.assign(global.WIDGETS[w], c[w]);
|
2022-01-15 17:16:48 +00:00
|
|
|
}
|
2022-11-06 12:36:14 +00:00
|
|
|
const W = global.WIDGETS;
|
|
|
|
global.WIDGETS = {};
|
2022-01-15 17:16:48 +00:00
|
|
|
Object.keys(W)
|
2023-07-31 21:04:20 +00:00
|
|
|
.sort() // sort alphabetically. the next sort is stable and preserves this if sortorder matches
|
2022-01-15 17:16:48 +00:00
|
|
|
.sort((a, b) => (0|W[b].sortorder)-(0|W[a].sortorder))
|
2022-11-06 12:36:14 +00:00
|
|
|
.forEach(k => global.WIDGETS[k] = W[k]);
|
2022-10-27 19:27:02 +00:00
|
|
|
})(Bangle.loadWidgets);
|