fix w js
This commit is contained in:
@@ -20,6 +20,15 @@ function updateItemState(itemId, isChecked) {
|
||||
}
|
||||
|
||||
function updateProgressBar() {
|
||||
const barPurchased = document.getElementById('progress-bar-purchased');
|
||||
const barNotPurchased = document.getElementById('progress-bar-not-purchased');
|
||||
const barRemaining = document.getElementById('progress-bar-remaining');
|
||||
const progressLabel = document.getElementById('progress-label');
|
||||
|
||||
if (!barPurchased || !barNotPurchased || !barRemaining || !progressLabel) {
|
||||
return;
|
||||
}
|
||||
|
||||
const items = document.querySelectorAll('#items li');
|
||||
const total = items.length;
|
||||
|
||||
@@ -31,18 +40,15 @@ function updateProgressBar() {
|
||||
const percentNotPurchased = total > 0 ? (notPurchased / total) * 100 : 0;
|
||||
const percentRemaining = total > 0 ? (remaining / total) * 100 : 0;
|
||||
|
||||
document.getElementById('progress-bar-purchased').style.width = `${percentPurchased}%`;
|
||||
document.getElementById('progress-bar-not-purchased').style.width = `${percentNotPurchased}%`;
|
||||
document.getElementById('progress-bar-remaining').style.width = `${percentRemaining}%`;
|
||||
barPurchased.style.width = `${percentPurchased}%`;
|
||||
barNotPurchased.style.width = `${percentNotPurchased}%`;
|
||||
barRemaining.style.width = `${percentRemaining}%`;
|
||||
|
||||
// etykieta
|
||||
const progressLabel = document.getElementById('progress-label');
|
||||
const percent = total > 0 ? Math.round((purchased / total) * 100) : 0;
|
||||
progressLabel.textContent = `${percent}%`;
|
||||
progressLabel.classList.toggle('text-white', percent < 51);
|
||||
progressLabel.classList.toggle('text-dark', percent >= 51);
|
||||
|
||||
// liczniki
|
||||
document.getElementById('purchased-count').textContent = purchased;
|
||||
document.getElementById('total-count').textContent = total;
|
||||
document.getElementById('percent-value').textContent = percent;
|
||||
|
@@ -153,7 +153,10 @@ function setupList(listId, username) {
|
||||
countdownBtn.disabled = true;
|
||||
countdownBtn.textContent = '15s';
|
||||
|
||||
li.querySelector('.btn-group')?.prepend(countdownBtn);
|
||||
const btnGroup = li.querySelector('.btn-group');
|
||||
if (btnGroup) {
|
||||
btnGroup.prepend(countdownBtn);
|
||||
}
|
||||
|
||||
let seconds = 15;
|
||||
const intervalId = setInterval(() => {
|
||||
|
@@ -1,10 +1,12 @@
|
||||
let currentItemId = null;
|
||||
window.currentItemId = window.currentItemId ?? null;
|
||||
|
||||
window.openNoteModal = function (event, itemId) {
|
||||
event.stopPropagation();
|
||||
currentItemId = itemId;
|
||||
window.currentItemId = itemId;
|
||||
const noteEl = document.querySelector(`#item-${itemId} small.text-danger`);
|
||||
document.getElementById('noteText').value = noteEl ? noteEl.innerText.replace(/\[|\]|Powód:/g, "").trim() : "";
|
||||
document.getElementById('noteText').value = noteEl
|
||||
? noteEl.innerText.replace(/\[|\]|Powód:/g, "").trim()
|
||||
: "";
|
||||
const modal = new bootstrap.Modal(document.getElementById('noteModal'));
|
||||
modal.show();
|
||||
};
|
||||
@@ -13,11 +15,10 @@ function submitNote(e) {
|
||||
e.preventDefault();
|
||||
const text = document.getElementById('noteText').value;
|
||||
|
||||
if (currentItemId !== null) {
|
||||
socket.emit('update_note', { item_id: currentItemId, note: text });
|
||||
if (window.currentItemId !== null) {
|
||||
socket.emit('update_note', { item_id: window.currentItemId, note: text });
|
||||
|
||||
const modal = bootstrap.Modal.getInstance(document.getElementById('noteModal'));
|
||||
modal.hide();
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user