Files
wehub-resource-sync e071084ebe
govulncheck / govulncheck (push) Waiting to run
Harness (E2E) / Harnesses (mock LLM) (push) Waiting to run
Harness (E2E) / Provider harnesses (live LLM conformance) (push) Waiting to run
Lint / golangci-lint (push) Waiting to run
Run Tests / Unit Tests (push) Waiting to run
Run Tests / Etcd Integration Tests (push) Waiting to run
chore: import upstream snapshot with attribution
2026-07-13 12:40:33 +08:00

35 lines
1.4 KiB
JavaScript

// Minimal JS for reactive form submissions
document.addEventListener('DOMContentLoaded', function() {
document.querySelectorAll('form[data-reactive]')?.forEach(function(form) {
form.addEventListener('submit', async function(e) {
e.preventDefault();
const formData = new FormData(form);
const params = {};
for (const [key, value] of formData.entries()) {
params[key] = value;
}
const action = form.getAttribute('action');
const method = form.getAttribute('method') || 'POST';
try {
const resp = await fetch(action, {
method,
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(params)
});
const data = await resp.json();
// Find or create a response container
let respDiv = form.querySelector('.js-response');
if (!respDiv) {
respDiv = document.createElement('div');
respDiv.className = 'js-response';
form.appendChild(respDiv);
}
respDiv.innerHTML = '<pre>' + JSON.stringify(data, null, 2) + '</pre>';
} catch (err) {
alert('Error: ' + err);
}
});
});
});