From 4ff8e9a52cefa526a52c81cf4f2599c46d01b60f Mon Sep 17 00:00:00 2001 From: Gabriele Monaco Date: Fri, 25 Nov 2022 08:59:07 +0100 Subject: [PATCH] Fixed sched clkinfo icons and sorting --- apps/sched/clkinfo.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/apps/sched/clkinfo.js b/apps/sched/clkinfo.js index 578089c1e..52f553988 100644 --- a/apps/sched/clkinfo.js +++ b/apps/sched/clkinfo.js @@ -1,16 +1,9 @@ (function() { const alarm = require('sched'); const iconAlarmOn = atob("GBiBAAAAAAAAAAYAYA4AcBx+ODn/nAP/wAf/4A/n8A/n8B/n+B/n+B/n+B/n+B/h+B/4+A/+8A//8Af/4AP/wAH/gAB+AAAAAAAAAA=="); - const iconAlarmOff = - atob("GBjBAP////8AAAAAAAAGAGAOAHAcfjg5/5wD/8AH/+AP5/AP5/Af5/gf5/gf5wAf5gAf4Hgf+f4P+bYP8wMH84cD84cB8wMAebYAAf4AAHg="); - //atob("GBjBAP//AAAAAAAAAAAGAGAOAHAcfjg5/5wD/8AH/+AP5/AP5/Af5/gf5/gf5wAf5gAf4Hgf+f4P+bYP8wMH84cD84cB8wMAebYAAf4AAHg="); - - const iconTimerOn = - atob("GBjBAP////8AAAAAAAAAAAAH/+AH/+ABgYABgYABgYAA/wAA/wAAfgAAPAAAPAAAfgAA5wAAwwABgYABgYABgYAH/+AH/+AAAAAAAAAAAAA="); - //atob("GBjBAP//AAAAAAAAAAAAAAAH/+AH/+ABgYABgYABgYAA/wAA/wAAfgAAPAAAPAAAfgAA5wAAwwABgYABgYABgYAH/+AH/+AAAAAAAAAAAAA="); - const iconTimerOff = - atob("GBjBAP////8AAAAAAAAAAAAH/+AH/+ABgYABgYABgYAA/wAA/wAAfgAAPAAAPAAAfgAA5HgAwf4BgbYBgwMBg4cH84cH8wMAAbYAAf4AAHg="); - //atob("GBjBAP//AAAAAAAAAAAAAAAH/+AH/+ABgYABgYABgYAA/wAA/wAAfgAAPAAAPAAAfgAA5HgAwf4BgbYBgwMBg4cH84cH8wMAAbYAAf4AAHg="); + const iconAlarmOff = atob("GBiBAAAAAAAAAAYAYA4AcBx+ODn/nAP/wAf/4A/n8A/n8B/n+B/n+B/nAB/mAB/geB/5/g/5tg/zAwfzhwPzhwHzAwB5tgAB/gAAeA=="); + const iconTimerOn = atob("GBiBAAAAAAAAAAAAAAf/4Af/4AGBgAGBgAGBgAD/AAD/AAB+AAA8AAA8AAB+AADnAADDAAGBgAGBgAGBgAf/4Af/4AAAAAAAAAAAAA=="); + const iconTimerOff = atob("GBiBAAAAAAAAAAAAAAf/4Af/4AGBgAGBgAGBgAD/AAD/AAB+AAA8AAA8AAB+AADkeADB/gGBtgGDAwGDhwfzhwfzAwABtgAB/gAAeA=="); //from 0 to max, the higher the closer to fire (as in a progress bar) function getAlarmValue(a){ @@ -49,14 +42,21 @@ return require("time_utils").formatTime(a.t); } + //workaround for sorting undefined values + function getAlarmOrder(a) { + let val = alarm.getTimeToAlarm(a); + if(typeof val == "undefined") return 86400*1000; + return val; + } + var img = iconAlarmOn; //get only alarms not created by other apps var alarmItems = { name: "Alarms", img: img, items: alarm.getAlarms().filter(a=>!a.appid) - .sort((a,b)=>alarm.getTimeToAlarm(a)-alarm.getTimeToAlarm(b)) - //.sort((a,b)=>getAlarmMinutes(a)-getAlarmMinutes(b)) + //.sort((a,b)=>alarm.getTimeToAlarm(a)-alarm.getTimeToAlarm(b)) + .sort((a,b)=>getAlarmOrder(a)-getAlarmOrder(b)) .map((a, i)=>({ name: null, get: () => ({ text: getAlarmText(a), img: getAlarmIcon(a),