-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
149e5e3
commit 9a41bc9
Showing
13 changed files
with
364 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
https://chatgpt.com/share/dc75c8d2-06a6-4459-9698-8513f33aee3d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
{#https://chatgpt.com/share/dc75c8d2-06a6-4459-9698-8513f33aee3d#} | ||
{% extends "templates/base.html" %} | ||
{% set game_name = "Pošta - Tabule" %} | ||
{% block content %} | ||
<div class="container"> | ||
<h1>Informace o frontách</h1> | ||
<div class="row" id="queue_info"> | ||
<div class="col-md-4"> | ||
<div class="card"> | ||
<div class="card-body"> | ||
<h3 class="card-title">Příjem</h3> | ||
<p>Čekajících: <span id="prijem_count">0</span></p> | ||
<ul id="prijem_list" class="list-group"></ul> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="col-md-4"> | ||
<div class="card"> | ||
<div class="card-body"> | ||
<h3 class="card-title">Odeslání</h3> | ||
<p>Čekajících: <span id="odeslani_count">0</span></p> | ||
<ul id="odeslani_list" class="list-group"></ul> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="col-md-4"> | ||
<div class="card"> | ||
<div class="card-body"> | ||
<h3 class="card-title">Los</h3> | ||
<p>Čekajících: <span id="los_count">0</span></p> | ||
<ul id="los_list" class="list-group"></ul> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<script> | ||
const forrestLib = new ForrestHubLib(); | ||
|
||
const updateQueueDisplay = (queue, countElement, listElement) => { | ||
const count = queue ? queue.length : 0; | ||
countElement.innerText = count; | ||
listElement.innerHTML = ''; | ||
|
||
(queue || []).slice(0, 3).forEach(ticket => { | ||
const li = document.createElement('li'); | ||
li.className = 'list-group-item'; | ||
li.textContent = `Číslo: ${ticket.number}`; | ||
listElement.appendChild(li); | ||
}); | ||
}; | ||
|
||
const updateAllQueues = () => { | ||
Promise.all([ | ||
forrestLib.getKey('prijem_queue', []), | ||
forrestLib.getKey('odeslani_queue', []), | ||
forrestLib.getKey('los_queue', []) | ||
]).then(([prijem, odeslani, los]) => { | ||
updateQueueDisplay(prijem, document.getElementById('prijem_count'), document.getElementById('prijem_list')); | ||
updateQueueDisplay(odeslani, document.getElementById('odeslani_count'), document.getElementById('odeslani_list')); | ||
updateQueueDisplay(los, document.getElementById('los_count'), document.getElementById('los_list')); | ||
}); | ||
}; | ||
|
||
// Automatické aktualizace přes addEventListenerKey | ||
forrestLib.addEventListenerKey('prijem_queue', (data) => { | ||
updateQueueDisplay(data, document.getElementById('prijem_count'), document.getElementById('prijem_list')); | ||
}); | ||
|
||
forrestLib.addEventListenerKey('odeslani_queue', (data) => { | ||
updateQueueDisplay(data, document.getElementById('odeslani_count'), document.getElementById('odeslani_list')); | ||
}); | ||
|
||
forrestLib.addEventListenerKey('los_queue', (data) => { | ||
updateQueueDisplay(data, document.getElementById('los_count'), document.getElementById('los_list')); | ||
}); | ||
|
||
// Počáteční načtení stavu front | ||
updateAllQueues(); | ||
</script> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
{#https://chatgpt.com/share/dc75c8d2-06a6-4459-9698-8513f33aee3d#} | ||
{% extends "templates/base.html" %} | ||
{% set game_name = "Pošta - Generování lístečků" %} | ||
{% block content %} | ||
<div class="container"> | ||
<h1>Generování čekacích lístečků</h1> | ||
<p>Vyberte kategorii:</p> | ||
<button id="generate_prijem" class="btn btn-primary">Příjem</button> | ||
<button id="generate_odeslani" class="btn btn-secondary">Odeslání</button> | ||
<button id="generate_los" class="btn btn-success">Los</button> | ||
<div id="generated_number" style="margin-top: 20px;"></div> | ||
<div id="waiting_message" style="margin-top: 20px; display:none;"></div> | ||
<div id="last_generated" style="margin-top: 30px;"> | ||
<h4>Poslední 3 čísla</h4> | ||
<ul id="last_tickets" class="list-group"></ul> | ||
</div> | ||
</div> | ||
|
||
<script> | ||
const forrestLib = new ForrestHubLib(); | ||
let lastGeneratedTickets = JSON.parse(localStorage.getItem('lastTickets')) || []; | ||
let hideInfoTimer, hideGeneratedTicketTimer; | ||
|
||
const updateLastTicketsDisplay = () => { | ||
const listElement = document.getElementById('last_tickets'); | ||
listElement.innerHTML = ''; | ||
|
||
lastGeneratedTickets.slice(-3).forEach(ticket => { | ||
const li = document.createElement('li'); | ||
li.className = 'list-group-item'; | ||
li.innerHTML = `Číslo: ${ticket.number} (${ticket.category}), Čas: ${ticket.time}`; | ||
listElement.appendChild(li); | ||
}); | ||
}; | ||
|
||
const generateTicket = (category) => { | ||
const randomNum = Math.floor(100 + Math.random() * 900); | ||
const timestamp = new Date().toLocaleTimeString(); | ||
const ticket = { number: randomNum, time: timestamp, category }; | ||
|
||
forrestLib.getKey(category, []).then((queue = []) => { | ||
queue.push(ticket); | ||
return forrestLib.setKeyBroadcast(category, queue); | ||
}).then(() => { | ||
const generatedNumberElement = document.getElementById('generated_number'); | ||
generatedNumberElement.innerHTML = ` | ||
<h2>Číslo ${ticket.number}</h2> | ||
<p>Kategorie: ${category}</p> | ||
<p>Čas: ${ticket.time}</p> | ||
`; | ||
generatedNumberElement.style.display = 'block'; | ||
|
||
// Resetovat timer pro schování informace o posledním lístku | ||
if (hideGeneratedTicketTimer) clearTimeout(hideGeneratedTicketTimer); | ||
hideGeneratedTicketTimer = setTimeout(() => { | ||
generatedNumberElement.style.display = 'none'; | ||
}, 10000); | ||
|
||
// Zobraz informaci o čekání | ||
forrestLib.getKey(category, []).then((queue = []) => { | ||
const positionInQueue = queue.length - 1; // Kolik lidí je před vámi | ||
const waitingMessageElement = document.getElementById('waiting_message'); | ||
waitingMessageElement.style.display = 'block'; | ||
waitingMessageElement.innerHTML = ` | ||
<p>Před vámi je ${positionInQueue} lidí. Prosím, počkejte.</p> | ||
`; | ||
|
||
// Resetovat timer pro schování informace o čekání | ||
if (hideInfoTimer) clearTimeout(hideInfoTimer); | ||
hideInfoTimer = setTimeout(() => { | ||
waitingMessageElement.style.display = 'none'; | ||
}, 10000); | ||
}); | ||
|
||
// Ulož lístek do paměti prohlížeče | ||
lastGeneratedTickets.push(ticket); | ||
if (lastGeneratedTickets.length > 3) lastGeneratedTickets.shift(); // Udržuj jen poslední 3 | ||
localStorage.setItem('lastTickets', JSON.stringify(lastGeneratedTickets)); | ||
|
||
// Aktualizovat zobrazení posledních lístků | ||
updateLastTicketsDisplay(); | ||
}); | ||
}; | ||
|
||
document.getElementById('generate_prijem').addEventListener('click', () => generateTicket('prijem_queue')); | ||
document.getElementById('generate_odeslani').addEventListener('click', () => generateTicket('odeslani_queue')); | ||
document.getElementById('generate_los').addEventListener('click', () => generateTicket('los_queue')); | ||
|
||
// Načíst poslední generovaná čísla při načtení stránky | ||
document.addEventListener('DOMContentLoaded', updateLastTicketsDisplay); | ||
</script> | ||
{% endblock %} |
Oops, something went wrong.