fix: Restore global scope for UI functions by separating qa.js from inline script
This commit is contained in:
parent
c24b33143d
commit
79559ba6f0
@ -922,7 +922,8 @@
|
||||
</div>
|
||||
|
||||
<!-- Master Interactive JavaScript Application -->
|
||||
<script type="module">
|
||||
<script src="./qa.js"></script>
|
||||
<script>
|
||||
let scene, camera, renderer, controls;
|
||||
let groupSkeleton, groupSheets, groupFacade, groupDrives, groupFans, groupPcba, groupIsolatedPart;
|
||||
let raycaster, mouse;
|
||||
@ -2219,8 +2220,7 @@
|
||||
renderer.render(scene, camera);
|
||||
}
|
||||
|
||||
import { loadQaChecklist } from './qa.js';
|
||||
|
||||
|
||||
window.onload = function() {
|
||||
loadQaChecklist();
|
||||
init3D();
|
||||
|
||||
26
viewer/qa.js
26
viewer/qa.js
@ -1,5 +1,5 @@
|
||||
// QA Checklist API Client
|
||||
export async function loadQaChecklist() {
|
||||
async function loadQaChecklist() {
|
||||
try {
|
||||
const res = await fetch('/api/qa');
|
||||
if (!res.ok) throw new Error("Failed to load QA data");
|
||||
@ -8,7 +8,7 @@ export async function loadQaChecklist() {
|
||||
const container = document.getElementById('qa-checklist-container');
|
||||
if (!container) return;
|
||||
|
||||
container.innerHTML = ''; // Clear hardcoded items
|
||||
container.innerHTML = '';
|
||||
|
||||
tasks.forEach(task => {
|
||||
const div = document.createElement('div');
|
||||
@ -20,7 +20,9 @@ export async function loadQaChecklist() {
|
||||
checkbox.dataset.id = task.id;
|
||||
checkbox.addEventListener('change', async (e) => {
|
||||
await toggleQaTask(task.id, e.target.checked);
|
||||
updateQAProgress();
|
||||
if (typeof updateQAProgress === 'function') {
|
||||
updateQAProgress();
|
||||
}
|
||||
});
|
||||
|
||||
const label = document.createElement('label');
|
||||
@ -31,22 +33,15 @@ export async function loadQaChecklist() {
|
||||
container.appendChild(div);
|
||||
});
|
||||
|
||||
// Expose function to global scope since HTML uses inline onchange="updateQAProgress()" for some reason
|
||||
window.updateQAProgress = () => {
|
||||
const total = document.querySelectorAll('.check-item input').length;
|
||||
const checked = document.querySelectorAll('.check-item input:checked').length;
|
||||
const pct = Math.round((checked / total) * 100) || 0;
|
||||
document.getElementById('qa-progress-label').innerText = `${pct}% Complete`;
|
||||
document.getElementById('qa-progress-bar').style.width = `${pct}%`;
|
||||
};
|
||||
|
||||
window.updateQAProgress();
|
||||
if (typeof updateQAProgress === 'function') {
|
||||
updateQAProgress();
|
||||
}
|
||||
} catch (err) {
|
||||
console.error("QA Loading Error:", err);
|
||||
}
|
||||
}
|
||||
|
||||
export async function toggleQaTask(id, is_completed) {
|
||||
async function toggleQaTask(id, is_completed) {
|
||||
try {
|
||||
await fetch(`/api/qa/${id}`, {
|
||||
method: 'PUT',
|
||||
@ -57,3 +52,6 @@ export async function toggleQaTask(id, is_completed) {
|
||||
console.error("Failed to update QA task", err);
|
||||
}
|
||||
}
|
||||
|
||||
window.loadQaChecklist = loadQaChecklist;
|
||||
window.toggleQaTask = toggleQaTask;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user