Skip to content

Commit 9880f14

Browse files
authored
Merge pull request #901 from CSA-Coders-2025/main
teacherEmail and flush queue
2 parents 4535492 + 25850cb commit 9880f14

1 file changed

Lines changed: 38 additions & 2 deletions

File tree

_layouts/bathroom/scanner.html

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,25 @@
145145
.button{
146146
z-index:99;
147147
}
148+
.top-right-button {
149+
position: absolute;
150+
top: 20px;
151+
right: 20px;
152+
background-color: #007bff;
153+
color: white;
154+
border: none;
155+
padding: 12px 20px;
156+
font-size: 16px;
157+
border-radius: 5px;
158+
cursor: pointer;
159+
z-index: 100;
160+
transition: background-color 0.3s ease-in-out;
161+
}
162+
163+
.top-right-button:hover {
164+
background-color: #0056b3;
165+
}
166+
148167
</style>
149168
</head>
150169
<!-- <body class="occupied-glow"> -->
@@ -160,7 +179,7 @@
160179
</div>
161180
</div>
162181

163-
182+
<button id="flush" class="top-right-button">Flush Queue</button>
164183

165184
<div class="map-container">
166185
<img src="https://i.ibb.co/tMQ1mTy6/map.png" alt="Map">
@@ -181,8 +200,9 @@
181200

182201
// Constants
183202
const REFRESH_INTERVAL = 60000; // 1 minute refresh interval
184-
const teacherName = "jmort1021@gmail.com";
185203
let teacherEmail = localStorage.getItem('teacherEmail') || teacherName;
204+
const teacherName = teacherEmail;
205+
186206
const tinkleURL = javaURI + '/api/tinkle/add';
187207
const deleteOptions = { ...fetchOptions2, method: 'POST' };
188208

@@ -192,6 +212,22 @@
192212
return storedUsers ? JSON.parse(storedUsers) : {};
193213
}
194214

215+
// Flush Queue
216+
document.getElementById('flush').addEventListener('click', async function() {
217+
const currentAway = document.getElementById('current-away').textContent.trim();
218+
219+
if (currentAway !== 'Nobody') {
220+
// Remove current user from queue
221+
await removeFromQueue();
222+
removeUser(currentAway);
223+
document.getElementById('current-away').innerHTML = 'Nobody';
224+
checkStatusAndUpdateUI();
225+
} else {
226+
// Remove next person from queue
227+
await removeFromQueue();
228+
}
229+
});
230+
195231
// Save users to localStorage
196232
function saveUsers() {
197233
localStorage.setItem('users', JSON.stringify(users));

0 commit comments

Comments
 (0)