diff options
author | RaindropsSys <contact@minteck.org> | 2023-08-15 16:19:43 +0200 |
---|---|---|
committer | RaindropsSys <contact@minteck.org> | 2023-08-15 16:19:43 +0200 |
commit | 7fa10aad3b7fd965a0f97d6298183d4293b9a99f (patch) | |
tree | f93b238cfb3edae1ade6d92a88deaaf8591579b2 | |
parent | 04c6aef158f46f7aac3e71c7100cea952fed87e6 (diff) | |
download | ponyplay-7fa10aad3b7fd965a0f97d6298183d4293b9a99f.tar.gz ponyplay-7fa10aad3b7fd965a0f97d6298183d4293b9a99f.tar.bz2 ponyplay-7fa10aad3b7fd965a0f97d6298183d4293b9a99f.zip |
Updated 5 files and added 2 files (automated)
-rw-r--r-- | web/.idea/php.xml | 1 | ||||
-rw-r--r-- | web/.idea/vcs.xml | 6 | ||||
-rw-r--r-- | web/app.html | 2 | ||||
-rw-r--r-- | web/apps/alarms.html | 4 | ||||
-rw-r--r-- | web/apps/alarms.js | 0 | ||||
-rw-r--r-- | web/src/alarms.js | 22 | ||||
-rw-r--r-- | web/src/notification.js | 6 |
7 files changed, 30 insertions, 11 deletions
diff --git a/web/.idea/php.xml b/web/.idea/php.xml index 88cd1bc..031e5c5 100644 --- a/web/.idea/php.xml +++ b/web/.idea/php.xml @@ -10,4 +10,5 @@ <option name="highlightLevel" value="WARNING" /> <option name="transferred" value="true" /> </component> + <component name="PhpProjectSharedConfiguration" php_language_level="8.2" /> </project>
\ No newline at end of file diff --git a/web/.idea/vcs.xml b/web/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/web/.idea/vcs.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="VcsDirectoryMappings"> + <mapping directory="$PROJECT_DIR$/.." vcs="Git" /> + </component> +</project>
\ No newline at end of file diff --git a/web/app.html b/web/app.html index 06a55b8..6fc31bd 100644 --- a/web/app.html +++ b/web/app.html @@ -282,7 +282,7 @@ <div id="filter" style="background-color: white; position: fixed; inset: 0; z-index: 500; opacity: .1; transition: background-color 2000ms;pointer-events: none;"></div> <div style="position: fixed; bottom: 3vw; left: 4.5vw; z-index: 20; text-shadow: 0 0 .5vw rgba(0, 0, 0, .5);" id="content"> <div id="date">---, -- ---</div> - <div id="time" style="font-size: 8vw; margin-top: 4vw; font-family: MLPFindYourSparkle, 'Google Sans', sans-serif; display: inline-block;" onclick="openApp('Configuration', '/apps/settings.html', false);">--:--</div> + <div id="time" style="font-size: 8vw; margin-top: 4vw; font-family: MLPFindYourSparkle, 'Google Sans', sans-serif; display: inline-block;">--:--</div> <div style="display: inline-block; font-size: 3vw; margin-left: 1vw;"> <img style="vertical-align: middle; width: 3vw; height: 3vw;" id="weather"> <span style="vertical-align: middle;" id="temperature">--°</span> diff --git a/web/apps/alarms.html b/web/apps/alarms.html index 326dd95..0471abd 100644 --- a/web/apps/alarms.html +++ b/web/apps/alarms.html @@ -43,9 +43,9 @@ </style> </head> <body style="background-color: var(--bg);"> - <div id="settings" style="border-top: 1px solid var(--on-elevated); border-left: 1px solid var(--on-elevated); border-right: 1px solid var(--on-elevated);"></div> + <div id="alarms" style="border-top: 1px solid var(--on-elevated); border-left: 1px solid var(--on-elevated); border-right: 1px solid var(--on-elevated);"></div> - <script src="/apps/settings.js"></script> + <script src="/apps/alarms.js"></script> <script src="/src/apptheme.js"></script> </body> </html>
\ No newline at end of file diff --git a/web/apps/alarms.js b/web/apps/alarms.js new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/web/apps/alarms.js diff --git a/web/src/alarms.js b/web/src/alarms.js index 7edaf1a..ed08cc7 100644 --- a/web/src/alarms.js +++ b/web/src/alarms.js @@ -15,7 +15,9 @@ window.alarmShown = false; window.loadingItems.push(() => { // TODO: Actually load alarms - window.alarms = [ + if (!localStorage.getItem("alarms")) localStorage.setItem("alarms", "[]"); + + /*window.alarms = [ { enabled: true, time: new Date(new Date().getTime() + 30000).getTime() - new Date(new Date().toISOString().split("T")[0]).getTime(), @@ -25,23 +27,26 @@ window.loadingItems.push(() => { { enabled: true, time: new Date(new Date().getTime() + 60000).getTime() - new Date(new Date().toISOString().split("T")[0]).getTime(), - repeat: 0b1111100, + repeat: 0b0111110, alarm: 2 } - ]; + ];*/ + window.alarms = JSON.parse(localStorage.getItem("alarms")); refreshAlarms(); setInterval(() => { - let list = window.alarms.filter(i => i.enabled).sort((a, b) => a.time - b.time); + let list = window.alarms.filter(i => i.enabled).filter(i => ("0000000".substring(0, 7 - i.repeat.toString(2).length) + i.repeat.toString(2).substring(new Date().getDay() + 1 === 7 ? 0 : new Date().getDay() + 1, (new Date().getDay() + 1 === 7 ? 0 : new Date().getDay() + 1) + 1) === "1") || i.repeat === 0).sort((a, b) => a.time - b.time); let alarm = 0; if (!list[alarm] || !list[alarm].time) return; - while (new Date().getTime() - (list[alarm].time + new Date(new Date().toISOString().split("T")[0]).getTime()) > 1000) { + while (list[alarm] && new Date().getTime() - (list[alarm].time + new Date(new Date().toISOString().split("T")[0]).getTime()) > 1000) { alarm++; } + if (!list[alarm] || !list[alarm].time) return; + if (new Date().getTime() - (list[alarm].time + new Date(new Date().toISOString().split("T")[0]).getTime()) > 0 && new Date().getTime() - (list[alarm].time + new Date(new Date().toISOString().split("T")[0]).getTime()) <= 1000) { startAlarm(list[alarm].alarm ?? 3); list[alarm].enabled = false; @@ -51,6 +56,7 @@ window.loadingItems.push(() => { }); function startAlarm(ringtone) { + closeApp(); window.alarmShown = true; document.getElementById("alarm").classList.add("show"); window.alarmRingtones[ringtone].play(); @@ -67,8 +73,10 @@ function stopAlarm() { } function refreshAlarms() { - if (window.alarms.filter(i => i.enabled).length > 0) { - let nextAlarmTime = alarms.filter(i => i.enabled).sort((a, b) => a.time - b.time)[0].time + new Date(new Date().toISOString().split("T")[0]).getTime(); + window.alarms = JSON.parse(localStorage.getItem("alarms")); + + if (window.alarms.filter(i => i.enabled).filter(i => ("0000000".substring(0, 7 - i.repeat.toString(2).length) + i.repeat.toString(2).substring(new Date().getDay() + 1 === 7 ? 0 : new Date().getDay() + 1, (new Date().getDay() + 1 === 7 ? 0 : new Date().getDay() + 1) + 1) === "1") || i.repeat === 0).length > 0) { + let nextAlarmTime = alarms.filter(i => i.enabled).filter(i => ("0000000".substring(0, 7 - i.repeat.toString(2).length) + i.repeat.toString(2).substring(new Date().getDay() + 1 === 7 ? 0 : new Date().getDay() + 1, (new Date().getDay() + 1 === 7 ? 0 : new Date().getDay() + 1) + 1) === "1") || i.repeat === 0).sort((a, b) => a.time - b.time)[0].time + new Date(new Date().toISOString().split("T")[0]).getTime(); document.getElementById("alarm-coming-time").innerText = fixed(new Date(nextAlarmTime).getHours(), 2) + ":" + fixed(new Date(nextAlarmTime).getMinutes(), 2); document.getElementById("alarm-coming").style.display = ""; } else { diff --git a/web/src/notification.js b/web/src/notification.js index 1a7841a..b70a694 100644 --- a/web/src/notification.js +++ b/web/src/notification.js @@ -30,4 +30,8 @@ function sendNotification(app, icon, title, description, image, persistent) { }, 100); return id; -}
\ No newline at end of file +} + +window.loadingItems.push(async () => { + sendNotification("Ponyplay System", await renderIcon("system", true), "Alarms are currently experimental", "Expect alarms to not go off when needed or to encounter other issues related to alarms.", null, false); +});
\ No newline at end of file |