prettier + add a button ig

This commit is contained in:
lda committed 2025-06-05 07:12:12 +07:00
1 parent 50a90db0b2
commit 41e9cfcb6c
15 files changed
+86 -28

No files matched your search

+3
View File
@@ -0,0 +1,3 @@
# Ignore artifacts:
build
coverage
+1
View File
@@ -0,0 +1 @@
{}
+40 -11
View File
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
@@ -26,23 +26,47 @@
<div id="manual-url-input" class="col">
<label for="ics_file" class="form-label">ICS URL</label>
<input type="text" id="ics_file" class="form-control" placeholder="Paste .ics URL or API endpoint here" />
<input
type="text"
id="ics_file"
class="form-control"
placeholder="Paste .ics URL or API endpoint here"
/>
</div>
<div id="args-form" class="col-12" style="display: none;">
<div id="args-form" class="col-12" style="display: none">
<label for="be_url" class="form-label">Calendar URL</label>
<input type="text" id="be_url" class="form-control mb-2" placeholder="Enter .ics URL to query" />
<input
type="text"
id="be_url"
class="form-control mb-2"
placeholder="Enter .ics URL to query"
/>
<label for="regex_exc" class="form-label">Regex Exclude Rules</label>
<input type="text" id="regex_exc" class="form-control mb-2" placeholder="Enter regex to exclude events" />
<input
type="text"
id="regex_exc"
class="form-control mb-2"
placeholder="Enter regex to exclude events"
/>
<label for="regex_inc" class="form-label">Regex Include Rules</label>
<input type="text" id="regex_inc" class="form-control mb-2" placeholder="Enter regex to include events" />
<input
type="text"
id="regex_inc"
class="form-control mb-2"
placeholder="Enter regex to include events"
/>
</div>
<div class="col-12 d-flex justify-content-end flex-wrap gap-2">
<button type="button" class="btn btn-primary" id="ics_run">New Calendar</button>
<button type="button" class="btn btn-secondary" id="ics_add">Add a Calendar</button>
<button type="button" class="btn btn-primary" id="ics_run">
New Calendar
</button>
<button type="button" class="btn btn-secondary" id="ics_add">
Add a Calendar
</button>
</div>
</form>
@@ -55,9 +79,14 @@
class="card-header mt-1 d-flex justify-content-between align-items-center bg-transparent border-0"
>
<h4 class="mb-0">Event Sources</h4>
<button id="reload" class="btn btn-outline-primary btn-sm">
<i class="bi bi-arrow-clockwise"></i> Reload
</button>
<div>
<button id="reload" class="btn btn-outline-primary btn-sm">
<i class="bi bi-arrow-clockwise"></i> Reload
</button>
<button id="refetch_all" class="btn btn-outline-primary btn-sm">
<i class="bi bi-arrow-clockwise"></i> Refetch All
</button>
</div>
</div>
<div id="event-source-list" class="card-body">
<!-- Event source cards will be dynamically added here -->
+17
View File
@@ -23,6 +23,7 @@
},
"devDependencies": {
"@types/node": "^22.15.21",
"prettier": "3.5.3",
"typescript": "^5.8.3",
"vite": "^6.3.5"
}
@@ -3494,6 +3495,22 @@
"url": "https://opencollective.com/preact"
}
},
"node_modules/prettier": {
"version": "3.5.3",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.5.3.tgz",
"integrity": "sha512-QQtaxnoDJeAkDvDKWCLiwIXkTgRhwYDEQCghU9Z6q03iyek/rxRh/2lC3HB7P8sWT2xC/y5JDctPLBIGzHKbhw==",
"dev": true,
"license": "MIT",
"bin": {
"prettier": "bin/prettier.cjs"
},
"engines": {
"node": ">=14"
},
"funding": {
"url": "https://github.com/prettier/prettier?sponsor=1"
}
},
"node_modules/rollup": {
"version": "4.41.0",
"resolved": "https://registry.npmjs.org/rollup/-/rollup-4.41.0.tgz",
+3 -1
View File
@@ -6,10 +6,12 @@
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
"preview": "vite preview",
"pretty": "prettier --write ."
},
"devDependencies": {
"@types/node": "^22.15.21",
"prettier": "3.5.3",
"typescript": "^5.8.3",
"vite": "^6.3.5"
},
+1 -1
View File
@@ -26,7 +26,7 @@ export function initializeCalendar(
element: HTMLElement,
url: string | URL,
onEventMouseEnter: (arg: EventHoveringArg) => void,
onEventMouseLeave: (arg: EventHoveringArg) => void
onEventMouseLeave: (arg: EventHoveringArg) => void,
): Calendar {
if (calendar) {
calendar.destroy();
+6 -5
View File
@@ -16,7 +16,7 @@ export interface CustomEventSource extends EventSourceApi {
export function addEventSourceCard(
eventSourceList: HTMLElement,
source: CustomEventSource
source: CustomEventSource,
) {
const internalEventSource = source.internalEventSource;
const card = document.createElement("div");
@@ -72,7 +72,7 @@ export function addEventSourceCard(
export function updateLoadingStatus(
loadingStatus: HTMLElement,
source: CustomEventSource
source: CustomEventSource,
) {
loadingStatus.textContent = source.internalEventSource.isFetching
? "Fetching in progress"
@@ -81,8 +81,8 @@ export function updateLoadingStatus(
export const rerender_all_statuses = (
eventSourceList: HTMLElement,
calendar: Calendar | null
) =>
calendar: Calendar | null,
) => {
setTimeout(() => {
eventSourceList.innerHTML = "";
calendar?.getEventSources().forEach((eventSource) => {
@@ -93,7 +93,8 @@ export const rerender_all_statuses = (
!eventSourceList.innerHTML
? (parent.style.display = "none")
: (parent.style.display = "");
}) && undefined;
});
};
// eventSourceList.innerHTML = `
// <div id="placeholder-message" class="alert alert-warning">
-1
View File
@@ -16,7 +16,6 @@ export function getFormParams(): Record<string, string> {
const manualUrlInput = getElementById<HTMLElement>("manual-url-input");
const argsForm = getElementById<HTMLElement>("args-form");
export function handle_form_change(mode: string): void {
if (mode === "manual") {
manualUrlInput.style.display = "block";
argsForm.style.display = "none";
+8 -2
View File
@@ -17,6 +17,7 @@ const placeholder_message = getElementById<HTMLElement>("placeholder-message");
const eventSourceList = getElementById<HTMLElement>("event-source-list");
const eventmanage = getElementById<HTMLElement>("event-source-management");
const reload_button = getElementById<HTMLButtonElement>("reload");
const what_all = getElementById<HTMLButtonElement>("refetch_all");
const urlMode = getElementById<HTMLSelectElement>("url_mode");
urlMode.addEventListener("change", () => {
@@ -58,9 +59,13 @@ function fetch_url_form() {
}
function handleReloadClick(): void {
const calendar = getCalendarInstance();
rerender_all_statuses(eventSourceList, calendar);
loading_callback(undefined);
}
const handleRefetchAllClick = (): void => {
const calendar = getCalendarInstance();
if (calendar) calendar.refetchEvents();
loading_callback(undefined);
};
export const loading_callback = (_: unknown) => {
const calendar = getCalendarInstance();
@@ -70,3 +75,4 @@ export const loading_callback = (_: unknown) => {
confirm_button.addEventListener("click", handleConfirmClick);
add_button.addEventListener("click", handleAddClick);
reload_button.addEventListener("click", handleReloadClick);
what_all.addEventListener("click", handleRefetchAllClick);
+2 -2
View File
@@ -7,7 +7,7 @@ export function queryLocalhost(params: Record<string, string>): string {
export function queryCustomUrl(
baseUrl: string,
params: Record<string, string>
params: Record<string, string>,
): string | null {
return constructUrl(baseUrl, params);
}
@@ -23,7 +23,7 @@ export function queryCustomUrl(
export function manageUrl(
mode: string,
base_url: string,
params: Record<string, string>
params: Record<string, string>,
): string | null {
if (mode === "manual") {
const url = create_url(base_url);
+1 -1
View File
@@ -27,7 +27,7 @@ export function newTippy(info: tippyHoverArgs): void {
currentTippy = tippy(info.el, {
content: formatTooltip(
info.event.title,
info.event.extendedProps.description
info.event.extendedProps.description,
),
allowHTML: true,
theme: "light",
+1 -1
View File
@@ -25,7 +25,7 @@ export function linkify(text: string): string {
const escapedText = escapeHtml(text);
return escapedText.replace(
/(https?:\/\/\S+)/g,
'<a href="$1" target="_blank" rel="noopener noreferrer">$1</a>'
'<a href="$1" target="_blank" rel="noopener noreferrer">$1</a>',
);
}
+1 -1
View File
@@ -20,7 +20,7 @@ export function create_url(input: string): string | null {
*/
export function constructUrl(
baseUrl: string,
params: Record<string, string>
params: Record<string, string>,
): string | null {
let url;
try {
+1 -1
View File
@@ -14,4 +14,4 @@
},
"include": ["src/**/*", "vite-env.d.ts"],
"exclude": ["node_modules", "dist"]
}
}
+1 -1
View File
@@ -1 +1 @@
/// <reference types="vite/client" />
/// <reference types="vite/client" />