mirror of
https://github.com/MasterAcnolo/Freedom-Loader.git
synced 2026-07-29 18:25:47 +02:00
refactor: add full documentation and fix theme loading robustness
- Add JSDoc comments across frontend and backend modules - Improve code readability and maintainability with consistent documentation style - Document Electron IPC handlers, UI utilities, and theme system - Add missing function/class documentation in theme loader and app services - Minor structural improvements and cleanup across Electron main process modules - Minor fixes on variable names
This commit is contained in:
@@ -1,35 +1,42 @@
|
||||
// Clipboard paste functionality for URL input
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const pasteBtn = document.getElementById('pasteBtn');
|
||||
const urlInput = document.getElementById('UrlInput');
|
||||
/**
|
||||
* Initializes clipboard paste functionality for the URL input field.
|
||||
*
|
||||
* When the user clicks the paste button, the system attempts to read
|
||||
* the clipboard content and inject it into the URL input field.
|
||||
* It also triggers an input event to notify any bound listeners.
|
||||
*/
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
const pasteBtn = document.getElementById("pasteBtn");
|
||||
const urlInput = document.getElementById("UrlInput");
|
||||
|
||||
if (pasteBtn && urlInput) {
|
||||
pasteBtn.addEventListener('click', async () => {
|
||||
try {
|
||||
// Read text from clipboard
|
||||
const text = await navigator.clipboard.readText();
|
||||
|
||||
// Paste into the URL input
|
||||
urlInput.value = text;
|
||||
|
||||
// Trigger input event to ensure any listeners are notified
|
||||
urlInput.dispatchEvent(new Event('input', { bubbles: true }));
|
||||
|
||||
// Optional: Focus the input
|
||||
urlInput.focus();
|
||||
|
||||
// Visual feedback
|
||||
pasteBtn.style.backgroundColor = 'var(--form-button-bg-hover-color)';
|
||||
setTimeout(() => {
|
||||
pasteBtn.style.backgroundColor = '';
|
||||
}, 200);
|
||||
|
||||
} catch (err) {
|
||||
console.error('Failed to read clipboard:', err);
|
||||
|
||||
// Fallback: prompt user if clipboard API fails
|
||||
alert('Unable to access clipboard. Please paste manually using Ctrl+V.');
|
||||
}
|
||||
});
|
||||
if (!pasteBtn || !urlInput) return;
|
||||
|
||||
/**
|
||||
* Handles clipboard paste action triggered by the paste button.
|
||||
* Reads clipboard text and inserts it into the URL input field.
|
||||
*/
|
||||
pasteBtn.addEventListener("click", async () => {
|
||||
try {
|
||||
const text = await navigator.clipboard.readText();
|
||||
|
||||
urlInput.value = text;
|
||||
|
||||
// Notify frameworks / listeners bound to input changes
|
||||
urlInput.dispatchEvent(new Event("input", { bubbles: true }));
|
||||
|
||||
urlInput.focus();
|
||||
|
||||
// Temporary UI feedback on paste action
|
||||
pasteBtn.style.backgroundColor = "var(--form-button-bg-hover-color)";
|
||||
setTimeout(() => {
|
||||
pasteBtn.style.backgroundColor = "";
|
||||
}, 200);
|
||||
} catch (err) {
|
||||
console.error("Clipboard access failed:", err);
|
||||
|
||||
alert(
|
||||
"Unable to access clipboard. Please paste manually using Ctrl+V."
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user