copilot cooked again

This commit is contained in:
lda committed 2025-05-22 20:58:41 +07:00
1 parent 6a56cc10a7
commit 9e193bc924
5 files changed
+147 -113

No files matched your search

+28
View File
@@ -14,6 +14,7 @@
"@fullcalendar/icalendar": "^6.1.17",
"@fullcalendar/list": "^6.1.17",
"@fullcalendar/multimonth": "^6.1.17",
"@fullcalendar/rrule": "^6.1.17",
"@fullcalendar/timegrid": "^6.1.17",
"bootstrap": "^5.3.6",
"bootstrap-icons": "^1.13.1",
@@ -506,6 +507,16 @@
"@fullcalendar/core": "~6.1.17"
}
},
"node_modules/@fullcalendar/rrule": {
"version": "6.1.17",
"resolved": "https://registry.npmjs.org/@fullcalendar/rrule/-/rrule-6.1.17.tgz",
"integrity": "sha512-p4CgAQQA/2HJUMmznhTE2b/YDiYyQsixs6D3/oM0+cCS0Sxm5zdWpfqwrMY3pr4iNwzJKKO4HGPwdtOLvAeJXw==",
"license": "MIT",
"peerDependencies": {
"@fullcalendar/core": "~6.1.17",
"rrule": "^2.6.0"
}
},
"node_modules/@fullcalendar/timegrid": {
"version": "6.1.17",
"resolved": "https://registry.npmjs.org/@fullcalendar/timegrid/-/timegrid-6.1.17.tgz",
@@ -1046,6 +1057,16 @@
"fsevents": "~2.3.2"
}
},
"node_modules/rrule": {
"version": "2.8.1",
"resolved": "https://registry.npmjs.org/rrule/-/rrule-2.8.1.tgz",
"integrity": "sha512-hM3dHSBMeaJ0Ktp7W38BJZ7O1zOgaFEsn41PDk+yHoEtfLV+PoJt9E9xAlZiWgf/iqEqionN0ebHFZIDAp+iGw==",
"license": "BSD-3-Clause",
"peer": true,
"dependencies": {
"tslib": "^2.4.0"
}
},
"node_modules/source-map-js": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz",
@@ -1082,6 +1103,13 @@
"@popperjs/core": "^2.9.0"
}
},
"node_modules/tslib": {
"version": "2.8.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",
"integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
"license": "0BSD",
"peer": true
},
"node_modules/vite": {
"version": "6.3.5",
"resolved": "https://registry.npmjs.org/vite/-/vite-6.3.5.tgz",
+1
View File
@@ -18,6 +18,7 @@
"@fullcalendar/icalendar": "^6.1.17",
"@fullcalendar/list": "^6.1.17",
"@fullcalendar/multimonth": "^6.1.17",
"@fullcalendar/rrule": "^6.1.17",
"@fullcalendar/timegrid": "^6.1.17",
"bootstrap": "^5.3.6",
"bootstrap-icons": "^1.13.1",
+70
View File
@@ -0,0 +1,70 @@
import { Calendar } from "@fullcalendar/core";
import iCalendarPlugin from "@fullcalendar/icalendar";
import rrulePlugin from "@fullcalendar/rrule";
import listPlugin from "@fullcalendar/list";
import dayGridPlugin from "@fullcalendar/daygrid";
import timeGridPlugin from "@fullcalendar/timegrid";
import bootstrap5Plugin from "@fullcalendar/bootstrap5";
import { getNextColor } from "./color_generator";
import { formatTooltip } from "./tooltip_parser";
let calendar = null;
export function initializeCalendar(
element,
url,
onEventMouseEnter,
onEventMouseLeave
) {
if (calendar) {
calendar.destroy();
}
calendar = new Calendar(element, {
plugins: [
iCalendarPlugin,
rrulePlugin,
bootstrap5Plugin,
listPlugin,
timeGridPlugin,
dayGridPlugin,
],
themeSystem: "bootstrap5",
initialView: "listWeek",
navLinks: true,
dayMaxEvents: true,
nowIndicator: true,
weekNumbers: true,
headerToolbar: {
left: "prev,next",
center: "title",
right: "today dayGridMonth,timeGridWeek,timeGridDay,listMonth",
},
views: {
dayGridMonth: { buttonText: "Month" },
timeGridWeek: { buttonText: "Week" },
timeGridDay: { buttonText: "Day" },
listMonth: { buttonText: "List" },
},
events: {
url: url,
format: "ics",
color: getNextColor(),
},
eventMouseEnter: onEventMouseEnter,
eventMouseLeave: onEventMouseLeave,
});
calendar.render();
}
export function addEventSource(url) {
if (calendar) {
calendar.addEventSource({
url: url,
format: "ics",
color: getNextColor(),
});
}
}
+15 -113
View File
@@ -1,27 +1,18 @@
import { Calendar } from "@fullcalendar/core";
import iCalendarPlugin from "@fullcalendar/icalendar";
import listPlugin from "@fullcalendar/list";
import dayGridPlugin from "@fullcalendar/daygrid";
import timeGridPlugin from "@fullcalendar/timegrid";
// import multiMonthPlugin from "@fullcalendar/multimonth";
import { initializeCalendar, addEventSource } from "./calendar";
import { newTippy, tippyDie } from "./tooltip";
import { create_url } from "./utils";
import "bootstrap/dist/css/bootstrap.css";
import "bootstrap-icons/font/bootstrap-icons.css";
import bootstrap5Plugin from "@fullcalendar/bootstrap5";
import tippy, { followCursor } from "tippy.js";
import "tippy.js/dist/tippy.css";
import { getNextColor } from "./color_generator";
import { formatTooltip } from "./tooltip_parser";
import { create_url } from "./utils";
const text_field = document.getElementById("ics_file");
const confirm_button = document.getElementById("ics_run");
const add_button = document.getElementById("ics_add");
const cal_ele = document.getElementById("calendar");
const placeholder_message = document.getElementById("placeholder-message");
let currentTippy = null;
let calendar = null;
function showPlaceholder() {
placeholder_message.style.display = "block";
@@ -33,113 +24,24 @@ function hidePlaceholder() {
cal_ele.style.display = "block";
}
const new_tippy = (info) => {
if (info.el._tippy === currentTippy) {
currentTippy.show();
} // what does this even MEAN
else {
// if (info.event.extendedProps.description)
// Destroy previous tippy if exists
if (currentTippy) {
currentTippy.destroy();
currentTippy = null;
}
currentTippy = tippy(info.el, {
content: formatTooltip(
info.event.title,
info.event.extendedProps.description
),
allowHTML: true,
theme: "light",
interactive: true,
// interactiveDebounce: 200,
interactiveBorder: 20,
delay: [0, 300],
// trigger: "manual", // this to then call .show()/
// followCursor: "initial",
// plugins: [followCursor],
});
// Show the tooltip
// currentTippy.show();
}
// console.log(currentTippy);
};
const tippy_die = (info) => {
// only hide. when another comes current will be killed
currentTippy.hideWithInteractivity(info.jsEvent);
};
confirm_button.addEventListener("click", (_e) => {
console.log("nawgh:", text_field.value);
confirm_button.addEventListener("click", () => {
const url = create_url(text_field.value);
if (!url && text_field.value) return alert("Please input valid url.");
if (calendar) calendar.destroy();
if (!text_field.value /* && !calendar */) {
showPlaceholder(); // Show placeholder if no URL is provided
if (!text_field.value) {
showPlaceholder();
return;
}
hidePlaceholder(); // Hide placeholder when loading starts
calendar = new Calendar(cal_ele, {
// calendar config
plugins: [
bootstrap5Plugin,
listPlugin,
iCalendarPlugin,
timeGridPlugin,
dayGridPlugin,
],
themeSystem: "bootstrap5", // Enable Bootstrap 5 theme
initialView: "listWeek",
// multiMonthMaxColumns: 1,
navLinks: true,
dayMaxEvents: true,
eventMaxStack: 3,
dayMaxEventRows: true,
nowIndicator: true,
weekNumbers: true,
headerToolbar: {
left: "prev,next",
center: "title",
right: "today dayGridMonth,timeGridWeek,timeGridDay,listMonth",
// views
},
views: {
dayGridMonth: { buttonText: "Month" },
timeGridWeek: { buttonText: "Week" },
timeGridDay: { buttonText: "Day" },
listMonth: { buttonText: "List" },
},
events: {
url: url,
format: "ics",
color: getNextColor(),
},
// eventClick: new_tippy,
eventMouseEnter: new_tippy,
eventMouseLeave: tippy_die,
});
// end calendar config
calendar.render();
hidePlaceholder();
initializeCalendar(cal_ele, url, newTippy, tippyDie);
});
// text_field.value = "http://127.0.0.1:8080/filtered-ics";
// confirm_button.click();
// wow
add_button.addEventListener("click", () => {
if (calendar) {
const url = create_url(text_field.value);
if (!url)
return text_field.value ? alert("Please input valid url.") : undefined;
calendar.addEventSource({
url: text_field.value,
format: "ics",
color: getNextColor(),
});
const url = create_url(text_field.value);
if (!url) {
if (text_field.value) alert("Please input valid url.");
return;
}
addEventSource(url);
});
+33
View File
@@ -0,0 +1,33 @@
import tippy from "tippy.js";
import "tippy.js/dist/tippy.css";
import { formatTooltip } from "./tooltip_parser";
let currentTippy = null;
export function newTippy(info) {
if (info.el._tippy === currentTippy) {
currentTippy.show();
} else {
if (currentTippy) {
currentTippy.destroy();
currentTippy = null;
}
currentTippy = tippy(info.el, {
content: formatTooltip(
info.event.title,
info.event.extendedProps.description
),
allowHTML: true,
theme: "light",
interactive: true,
interactiveBorder: 20,
delay: [0, 300],
});
}
}
export function tippyDie(info) {
if (currentTippy) {
currentTippy.hideWithInteractivity(info.jsEvent);
}
}