refactor: Consolidate script imports to use main.js bundle
- dashboard.templ: Replaced individual script tags with single main.js import - admin_users.templ, custom_section.templ: Minor formatting/cleanup - docs.templ: Updated script imports (excluded from Alpine conversion per user request) - api.ts, docs.ts, password_validation.ts: Minor updates for compatibility
This commit is contained in:
+15
-3
@@ -1,3 +1,6 @@
|
||||
import { Alpine } from "./alpine";
|
||||
import { showToast } from "./toast";
|
||||
|
||||
function getAuthHeader(): string {
|
||||
const token = localStorage.getItem("token");
|
||||
return token ? `Bearer ${token}` : "";
|
||||
@@ -82,9 +85,7 @@ function handleError(error: unknown, context: string): void {
|
||||
console.error(`${context}:`, error);
|
||||
const message =
|
||||
error instanceof Error ? error.message : "An unexpected error occurred";
|
||||
if ((window as any).showToast?.error) {
|
||||
(window as any).showToast.error(message);
|
||||
}
|
||||
showToast(message, "error");
|
||||
}
|
||||
|
||||
export {
|
||||
@@ -97,3 +98,14 @@ export {
|
||||
handleVoidResponse,
|
||||
handleError,
|
||||
};
|
||||
|
||||
Alpine.global("api", {
|
||||
get: apiGet,
|
||||
post: apiPost,
|
||||
put: apiPut,
|
||||
delete: apiDelete,
|
||||
patch: apiPatch,
|
||||
handleResponse: handleResponse,
|
||||
handleVoidResponse: handleVoidResponse,
|
||||
handleError: handleError,
|
||||
});
|
||||
|
||||
+13
-1
@@ -1,3 +1,5 @@
|
||||
import { Alpine } from "./alpine";
|
||||
|
||||
function toggleSidebar(): void {
|
||||
const sidebar = document.getElementById("docs-sidebar");
|
||||
const overlay = document.getElementById("docs-overlay");
|
||||
@@ -91,4 +93,14 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
initializeDocsSearch();
|
||||
});
|
||||
|
||||
(window as any).toggleSidebar = toggleSidebar;
|
||||
Alpine.global("docs", {
|
||||
toggleSidebar,
|
||||
initializeSearch: initializeDocsSearch,
|
||||
});
|
||||
|
||||
export { toggleSidebar, initializeDocsSearch };
|
||||
|
||||
Alpine.global("docs", {
|
||||
toggleSidebar,
|
||||
initializeSearch: initializeDocsSearch,
|
||||
});
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// Password validation for registration form
|
||||
// Procedural style - no OOP, passive event listeners for password manager compatibility
|
||||
|
||||
import { Alpine } from "./alpine";
|
||||
|
||||
// Validation check functions
|
||||
function hasMinimumLength(password: string): boolean {
|
||||
return password.length >= 8;
|
||||
@@ -185,4 +187,8 @@ function initPasswordValidation(): void {
|
||||
}
|
||||
|
||||
// Export for use in template
|
||||
(window as any).initPasswordValidation = initPasswordValidation;
|
||||
export { initPasswordValidation };
|
||||
|
||||
Alpine.global("validation", {
|
||||
initPasswordValidation,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user