refresh calendar every 15 minutes

master
Dirk Heilig 2024-02-18 10:17:23 +01:00
parent c4f624ab52
commit 7426794e15
1 changed files with 18 additions and 5 deletions

View File

@ -1,4 +1,4 @@
document.addEventListener("DOMContentLoaded", function () {
const calRefresh=function () {
let url =
"https://ical2json.c3re.de/api/?url=https%3A%2F%2Fcloud.c3re.de%2Fremote.php%2Fdav%2Fpublic-calendars%2FRLKKkdjNYgXH8yEz%3Fexport&start=today&end=next+month&maxitems=10";
let xmlHttp = new XMLHttpRequest();
@ -15,6 +15,11 @@ document.addEventListener("DOMContentLoaded", function () {
let box = $("#calendar");
box.removeClass("loading");
try{
for( el of document.querySelectorAll("#calendar li")){
el.remove()
}
}catch(e){}
for (let item of cal) {
let li = $("<li/>");
//li.text(item.summary)
@ -54,7 +59,10 @@ document.addEventListener("DOMContentLoaded", function () {
li.attr("title", item.description);
li.appendTo(box);
}
try{
document.querySelector("#calendar .loading").remove();
}catch(e){}
$(".location", box).click(function () {
navigator.clipboard.writeText($(this).attr("data-loc"));
});
@ -62,4 +70,9 @@ document.addEventListener("DOMContentLoaded", function () {
};
xmlHttp.open("GET", url, true); // true for asynchronous
xmlHttp.send();
}
document.addEventListener("DOMContentLoaded", function(){
calRefresh();
setInterval(calRefresh, 1000*60*15);
});