mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-06 03:13:42 -05:00
21 lines
567 B
JavaScript
21 lines
567 B
JavaScript
const socket = io();
|
|
const jobId = document.querySelector("[data-job-id]").dataset.jobId;
|
|
|
|
socket.on('connect', () => {
|
|
console.log('Connected to server');
|
|
});
|
|
|
|
|
|
// Join a room
|
|
socket.emit("join", { room: `job-${jobId}` });
|
|
console.log("🧠 Joined room:", `job-${jobId}`);
|
|
|
|
// Listen for job updates
|
|
socket.on("job_update", function (data) {
|
|
const el = document.querySelector(`[data-key="${data.key}"]`);
|
|
if (el) {
|
|
el.textContent = "✅ Real-time update success!";
|
|
el.classList.add("text-success"); // Add a class instead
|
|
}
|
|
});
|