style(templates): normalize quote style in WebSocket script in admin template
- Normalize inconsistent quote usage in admin WebSocket script tag - Change window.location.protocol comparison from single to double quotes - Change error message quotes from single to double quotes - No functional changes - pure formatting cleanup Improves code consistency by standardizing quote style throughout the admin WebSocket initialization script.
This commit is contained in:
+16
-15
@@ -12,61 +12,62 @@ templ Admin(user User) {
|
|||||||
<script>
|
<script>
|
||||||
let scanWs = null;
|
let scanWs = null;
|
||||||
function connectScanWebSocket() {
|
function connectScanWebSocket() {
|
||||||
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
|
const protocol =
|
||||||
|
window.location.protocol === "https:" ? "wss:" : "ws:";
|
||||||
const wsUrl = `${protocol}//${window.location.host}/ws/sync?token={ user.Token }`;
|
const wsUrl = `${protocol}//${window.location.host}/ws/sync?token={ user.Token }`;
|
||||||
scanWs = new WebSocket(wsUrl);
|
scanWs = new WebSocket(wsUrl);
|
||||||
|
|
||||||
scanWs.onmessage = function(event) {
|
scanWs.onmessage = function (event) {
|
||||||
try {
|
try {
|
||||||
const message = JSON.parse(event.data);
|
const message = JSON.parse(event.data);
|
||||||
switch (message.type) {
|
switch (message.type) {
|
||||||
case 'scan_progress':
|
case "scan_progress":
|
||||||
updateScanProgress(message.data);
|
updateScanProgress(message.data);
|
||||||
break;
|
break;
|
||||||
case 'scan_complete':
|
case "scan_complete":
|
||||||
showScanComplete(message.data);
|
showScanComplete(message.data);
|
||||||
stopScanStatusPolling();
|
stopScanStatusPolling();
|
||||||
break;
|
break;
|
||||||
case 'scan_error':
|
case "scan_error":
|
||||||
showScanError(message.data);
|
showScanError(message.data);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to parse WebSocket message:', error);
|
console.error("Failed to parse WebSocket message:", error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
scanWs.onerror = function(error) {
|
scanWs.onerror = function (error) {
|
||||||
console.error('WebSocket error:', error);
|
console.error("WebSocket error:", error);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateScanProgress(data) {
|
function updateScanProgress(data) {
|
||||||
const progressBar = document.getElementById('scan-progress-bar');
|
const progressBar = document.getElementById("scan-progress-bar");
|
||||||
if (progressBar) {
|
if (progressBar) {
|
||||||
progressBar.style.width = (data.progress * 100) + '%';
|
progressBar.style.width = data.progress * 100 + "%";
|
||||||
}
|
}
|
||||||
|
|
||||||
const progressText = document.getElementById('scan-progress-text');
|
const progressText = document.getElementById("scan-progress-text");
|
||||||
if (progressText) {
|
if (progressText) {
|
||||||
progressText.textContent = `${data.files_scanned} files scanned (${data.new_items} new)`;
|
progressText.textContent = `${data.files_scanned} files scanned (${data.new_items} new)`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function showScanComplete(data) {
|
function showScanComplete(data) {
|
||||||
console.log('Scan complete:', data);
|
console.log("Scan complete:", data);
|
||||||
}
|
}
|
||||||
|
|
||||||
function showScanError(data) {
|
function showScanError(data) {
|
||||||
console.error('Scan error:', data);
|
console.error("Scan error:", data);
|
||||||
}
|
}
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener("DOMContentLoaded", function () {
|
||||||
connectScanWebSocket();
|
connectScanWebSocket();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body class="theme-tokyo-night" x-data="admin">
|
<body x-data="admin" x-init="loadWatchStatus()" class="theme-tokyo-night" x-data="admin">
|
||||||
@Header(user, "/admin")
|
@Header(user, "/admin")
|
||||||
<div class="flex min-h-screen" style="background-color: var(--bg-primary)">
|
<div class="flex min-h-screen" style="background-color: var(--bg-primary)">
|
||||||
@AdminSidebar(user, "/admin")
|
@AdminSidebar(user, "/admin")
|
||||||
|
|||||||
Reference in New Issue
Block a user