2022-08-25 20:16:43 +00:00
|
|
|
(() => {
|
2022-10-24 11:22:35 +00:00
|
|
|
function getAlertText() {
|
|
|
|
const medicalinfo = require("medicalinfo").load();
|
|
|
|
const alertText = ((Array.isArray(medicalinfo.medicalAlert)) && (medicalinfo.medicalAlert[0])) ? medicalinfo.medicalAlert[0] : "";
|
|
|
|
return (g.wrapString(alertText, g.getWidth()).length === 1) ? alertText : "MEDICAL ALERT";
|
|
|
|
}
|
|
|
|
|
2022-08-25 20:16:43 +00:00
|
|
|
// Top right star of life logo
|
2022-10-24 11:22:35 +00:00
|
|
|
WIDGETS["widmedatr"] = {
|
2022-08-25 20:16:43 +00:00
|
|
|
area: "tr",
|
|
|
|
width: 24,
|
2022-10-24 11:22:35 +00:00
|
|
|
draw: function () {
|
2022-08-25 20:16:43 +00:00
|
|
|
g.reset();
|
|
|
|
g.setColor("#f00");
|
|
|
|
g.drawImage(atob("FhYBAAAAA/AAD8AAPwAc/OD/P8P8/x/z/n+/+P5/wP58A/nwP5/x/v/n/P+P8/w/z/Bz84APwAA/AAD8AAAAAA=="), this.x + 1, this.y + 1);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-10-24 11:22:35 +00:00
|
|
|
// Bottom medical alert text
|
|
|
|
WIDGETS["widmedabl"] = {
|
2022-08-25 20:16:43 +00:00
|
|
|
area: "bl",
|
2022-10-24 11:22:35 +00:00
|
|
|
width: Bangle.CLOCK ? Bangle.appRect.w : 0,
|
|
|
|
draw: function () {
|
2022-08-25 20:16:43 +00:00
|
|
|
// Only show the widget on clocks
|
|
|
|
if (!Bangle.CLOCK) return;
|
|
|
|
|
|
|
|
g.reset();
|
|
|
|
g.setBgColor(g.theme.dark ? "#fff" : "#f00");
|
|
|
|
g.setColor(g.theme.dark ? "#f00" : "#fff");
|
2022-10-24 11:22:35 +00:00
|
|
|
g.setFont("Vector", 16);
|
|
|
|
g.setFontAlign(0, 0);
|
2022-08-25 20:16:43 +00:00
|
|
|
g.clearRect(this.x, this.y, this.x + this.width - 1, this.y + 23);
|
2022-10-24 11:22:35 +00:00
|
|
|
|
|
|
|
const alertText = getAlertText();
|
|
|
|
g.drawString(alertText, this.width / 2, this.y + (23 / 2));
|
2022-08-25 20:16:43 +00:00
|
|
|
}
|
|
|
|
};
|
2022-10-24 11:22:35 +00:00
|
|
|
|
|
|
|
Bangle.on("touch", (_, c) => {
|
|
|
|
const bl = WIDGETS.widmedabl;
|
|
|
|
const tr = WIDGETS.widmedatr;
|
|
|
|
if ((bl && c.x >= bl.x && c.x < bl.x + bl.width && c.y >= bl.y && c.y <= bl.y + 24)
|
|
|
|
|| (tr && c.x >= tr.x && c.x < tr.x + tr.width && c.y >= tr.y && c.y <= tr.y + 24)) {
|
|
|
|
load("medicalinfo.app.js");
|
|
|
|
}
|
|
|
|
});
|
2022-08-25 20:16:43 +00:00
|
|
|
})();
|