whitespace fixes
This commit is contained in:
1 parent
6563c00dec
commit
8bb81b394a
4 files changed
+660
-643
No files matched your search
+38
-38
@@ -3,51 +3,51 @@ import logger from '../logger.js'
|
||||
import env from '../env.js'
|
||||
|
||||
export default class Qr {
|
||||
static #cache = null
|
||||
static #host = null
|
||||
static #cache = null
|
||||
static #host = null
|
||||
|
||||
static init(host) {
|
||||
if (!host) return logger.warn('env', 'SERVER_HOST is not defined, QR codes will not be generated')
|
||||
static init(host) {
|
||||
if (!host) return logger.warn('env', 'SERVER_HOST is not defined, QR codes will not be generated')
|
||||
this.#host = host
|
||||
logger.info('Qr', 'host for qr', host)
|
||||
}
|
||||
}
|
||||
|
||||
static serve() {
|
||||
return async (req, res, next) => {
|
||||
if (req.path !== '/qr') return next()
|
||||
static serve() {
|
||||
return async (req, res, next) => {
|
||||
if (req.path !== '/qr') return next()
|
||||
|
||||
try {
|
||||
if (this.host === null) {
|
||||
res.status(500).send('QR code generation is not configured')
|
||||
throw new Error('SERVER_HOST is not defined')
|
||||
}
|
||||
try {
|
||||
if (this.host === null) {
|
||||
res.status(500).send('QR code generation is not configured')
|
||||
throw new Error('SERVER_HOST is not defined')
|
||||
}
|
||||
|
||||
if (!this.#cache) {
|
||||
const payload = this.#payload()
|
||||
this.#cache = await this.#generate(payload)
|
||||
}
|
||||
if (!this.#cache) {
|
||||
const payload = this.#payload()
|
||||
this.#cache = await this.#generate(payload)
|
||||
}
|
||||
|
||||
res.setHeader('Content-Type', 'image/png')
|
||||
res.setHeader('Cache-Control', 'public, max-age=3600')
|
||||
res.send(this.#cache)
|
||||
} catch (error) {
|
||||
logger.error('http', 'QR code generation error:', error)
|
||||
res.status(500).send('Failed to generate QR code')
|
||||
}
|
||||
}
|
||||
}
|
||||
res.setHeader('Content-Type', 'image/png')
|
||||
res.setHeader('Cache-Control', 'public, max-age=3600')
|
||||
res.send(this.#cache)
|
||||
} catch (error) {
|
||||
logger.error('http', 'QR code generation error:', error)
|
||||
res.status(500).send('Failed to generate QR code')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static async #generate(data) {
|
||||
return await QRCode.toBuffer(data, {
|
||||
errorCorrectionLevel: 'M',
|
||||
type: 'png',
|
||||
width: 512,
|
||||
margin: 2,
|
||||
})
|
||||
}
|
||||
static async #generate(data) {
|
||||
return await QRCode.toBuffer(data, {
|
||||
errorCorrectionLevel: 'M',
|
||||
type: 'png',
|
||||
width: 512,
|
||||
margin: 2,
|
||||
})
|
||||
}
|
||||
|
||||
static #payload() {
|
||||
const port = env.HTTP_PORT
|
||||
return `http://${this.#host}:${port}/player`
|
||||
}
|
||||
static #payload() {
|
||||
const port = env.HTTP_PORT
|
||||
return `http://${this.#host}:${port}/player`
|
||||
}
|
||||
}
|
||||
+329
-317
@@ -1,283 +1,284 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>SongDash Debug</title>
|
||||
<style>
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'Courier New', monospace;
|
||||
background: #1a1a1a;
|
||||
color: #e0e0e0;
|
||||
padding: 10px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 16px;
|
||||
margin-bottom: 10px;
|
||||
color: #00ff00;
|
||||
border-bottom: 1px solid #333;
|
||||
padding-bottom: 5px;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 14px;
|
||||
margin: 15px 0 5px 0;
|
||||
color: #00aaff;
|
||||
}
|
||||
|
||||
.section {
|
||||
margin-bottom: 15px;
|
||||
border: 1px solid #333;
|
||||
padding: 10px;
|
||||
background: #0a0a0a;
|
||||
}
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
margin: 5px 0;
|
||||
}
|
||||
|
||||
th,
|
||||
td {
|
||||
text-align: left;
|
||||
padding: 4px 8px;
|
||||
border: 1px solid #333;
|
||||
}
|
||||
|
||||
th {
|
||||
background: #222;
|
||||
color: #ffaa00;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
td {
|
||||
background: #111;
|
||||
}
|
||||
|
||||
.status {
|
||||
display: inline-block;
|
||||
padding: 2px 6px;
|
||||
border-radius: 3px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.status.connected {
|
||||
background: #004400;
|
||||
color: #00ff00;
|
||||
}
|
||||
|
||||
.status.disconnected {
|
||||
background: #440000;
|
||||
color: #ff0000;
|
||||
}
|
||||
|
||||
.status.playing {
|
||||
background: #004400;
|
||||
color: #00ff00;
|
||||
}
|
||||
|
||||
.status.paused {
|
||||
background: #444400;
|
||||
color: #ffff00;
|
||||
}
|
||||
|
||||
.status.waiting {
|
||||
background: #444444;
|
||||
color: #888888;
|
||||
}
|
||||
|
||||
.status.active {
|
||||
background: #000044;
|
||||
color: #00aaff;
|
||||
}
|
||||
|
||||
.type-tv {
|
||||
background: #440044;
|
||||
color: #ff00ff;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.type-host {
|
||||
background: #004444;
|
||||
color: #00ffff;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.type-debug {
|
||||
background: #444400;
|
||||
color: #ffff00;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.timestamp {
|
||||
float: right;
|
||||
color: #666;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.key-value {
|
||||
display: grid;
|
||||
grid-template-columns: 150px 1fr;
|
||||
gap: 5px;
|
||||
margin: 3px 0;
|
||||
}
|
||||
|
||||
.key {
|
||||
color: #888;
|
||||
}
|
||||
|
||||
.value {
|
||||
color: #e0e0e0;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.empty {
|
||||
color: #666;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.json {
|
||||
background: #000;
|
||||
border: 1px solid #333;
|
||||
padding: 5px;
|
||||
margin: 5px 0;
|
||||
overflow-x: auto;
|
||||
font-size: 11px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>SongDash Debug Panel <span class="timestamp" id="timestamp">--</span></h1>
|
||||
|
||||
<div class="section">
|
||||
<h2>Music Status</h2>
|
||||
<div class="key-value">
|
||||
<div class="key">Status:</div>
|
||||
<div class="value"><span id="music-status" class="status">--</span></div>
|
||||
</div>
|
||||
<div class="key-value">
|
||||
<div class="key">Platform:</div>
|
||||
<div class="value" id="music-platform">--</div>
|
||||
</div>
|
||||
<div class="key-value">
|
||||
<div class="key">Listeners:</div>
|
||||
<div class="value" id="music-listeners">--</div>
|
||||
</div>
|
||||
<div class="key-value">
|
||||
<div class="key">Metadata:</div>
|
||||
<div class="value">
|
||||
<div id="music-metadata-author">--</div>
|
||||
<div id="music-metadata-track">--</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="section">
|
||||
<h2>Queue (<span id="queue-length">0</span> players)</h2>
|
||||
<table id="queue-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Pos</th>
|
||||
<th>IP</th>
|
||||
<th>Nick</th>
|
||||
<th>Status</th>
|
||||
<th>Time</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="queue-body">
|
||||
<tr>
|
||||
<td colspan="5" class="empty">No players in queue</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="section">
|
||||
<h2>Scoreboard (<span id="board-total">0</span> players)</h2>
|
||||
<table id="board-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>IP</th>
|
||||
<th>Nick</th>
|
||||
<th>Score</th>
|
||||
<th>Connected</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="board-body">
|
||||
<tr>
|
||||
<td colspan="4" class="empty">No scores recorded</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="section">
|
||||
<h2>Clients (<span id="client-count">0</span> total)</h2>
|
||||
<table id="client-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>IP</th>
|
||||
<th>Type</th>
|
||||
<th>Nick</th>
|
||||
<th>User-Agent</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="client-body">
|
||||
<tr>
|
||||
<td colspan="4" class="empty">No clients connected</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<script src="/socket.js"></script>
|
||||
<script>
|
||||
const socket = new Socket('debug')
|
||||
|
||||
socket.on('update', data => {
|
||||
updateDebug(data)
|
||||
})
|
||||
|
||||
function updateDebug(data) {
|
||||
// Update timestamp
|
||||
document.getElementById('timestamp').textContent = new Date(data.timestamp).toLocaleTimeString()
|
||||
|
||||
// Update Music Status
|
||||
const musicStatus = document.getElementById('music-status')
|
||||
musicStatus.textContent = data.music.status
|
||||
musicStatus.className = 'status ' + data.music.status
|
||||
|
||||
document.getElementById('music-platform').textContent = data.music.platform || '--'
|
||||
document.getElementById('music-listeners').textContent = data.music.listenerCount
|
||||
|
||||
if (data.music.metadata && data.music.metadata.author && data.music.metadata.track) {
|
||||
const metadataText = `${data.music.metadata.author} - ${data.music.metadata.track}`
|
||||
document.getElementById('music-metadata-author').textContent = metadataText
|
||||
document.getElementById('music-metadata-track').textContent = ''
|
||||
} else {
|
||||
document.getElementById('music-metadata-author').textContent = '--'
|
||||
document.getElementById('music-metadata-track').textContent = ''
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>SongDash Debug</title>
|
||||
<style>
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
// Update Queue
|
||||
document.getElementById('queue-length').textContent = data.queue.length
|
||||
const queueBody = document.getElementById('queue-body')
|
||||
body {
|
||||
font-family: 'Courier New', monospace;
|
||||
background: #1a1a1a;
|
||||
color: #e0e0e0;
|
||||
padding: 10px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
if (data.queue.queue.length === 0) {
|
||||
queueBody.innerHTML = '<tr><td colspan="5" class="empty">No players in queue</td></tr>'
|
||||
} else {
|
||||
queueBody.innerHTML = data.queue.queue.map(item => `
|
||||
h1 {
|
||||
font-size: 16px;
|
||||
margin-bottom: 10px;
|
||||
color: #00ff00;
|
||||
border-bottom: 1px solid #333;
|
||||
padding-bottom: 5px;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 14px;
|
||||
margin: 15px 0 5px 0;
|
||||
color: #00aaff;
|
||||
}
|
||||
|
||||
.section {
|
||||
margin-bottom: 15px;
|
||||
border: 1px solid #333;
|
||||
padding: 10px;
|
||||
background: #0a0a0a;
|
||||
}
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
margin: 5px 0;
|
||||
}
|
||||
|
||||
th,
|
||||
td {
|
||||
text-align: left;
|
||||
padding: 4px 8px;
|
||||
border: 1px solid #333;
|
||||
}
|
||||
|
||||
th {
|
||||
background: #222;
|
||||
color: #ffaa00;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
td {
|
||||
background: #111;
|
||||
}
|
||||
|
||||
.status {
|
||||
display: inline-block;
|
||||
padding: 2px 6px;
|
||||
border-radius: 3px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.status.connected {
|
||||
background: #004400;
|
||||
color: #00ff00;
|
||||
}
|
||||
|
||||
.status.disconnected {
|
||||
background: #440000;
|
||||
color: #ff0000;
|
||||
}
|
||||
|
||||
.status.playing {
|
||||
background: #004400;
|
||||
color: #00ff00;
|
||||
}
|
||||
|
||||
.status.paused {
|
||||
background: #444400;
|
||||
color: #ffff00;
|
||||
}
|
||||
|
||||
.status.waiting {
|
||||
background: #444444;
|
||||
color: #888888;
|
||||
}
|
||||
|
||||
.status.active {
|
||||
background: #000044;
|
||||
color: #00aaff;
|
||||
}
|
||||
|
||||
.type-tv {
|
||||
background: #440044;
|
||||
color: #ff00ff;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.type-host {
|
||||
background: #004444;
|
||||
color: #00ffff;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.type-debug {
|
||||
background: #444400;
|
||||
color: #ffff00;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.timestamp {
|
||||
float: right;
|
||||
color: #666;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.key-value {
|
||||
display: grid;
|
||||
grid-template-columns: 150px 1fr;
|
||||
gap: 5px;
|
||||
margin: 3px 0;
|
||||
}
|
||||
|
||||
.key {
|
||||
color: #888;
|
||||
}
|
||||
|
||||
.value {
|
||||
color: #e0e0e0;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.empty {
|
||||
color: #666;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.json {
|
||||
background: #000;
|
||||
border: 1px solid #333;
|
||||
padding: 5px;
|
||||
margin: 5px 0;
|
||||
overflow-x: auto;
|
||||
font-size: 11px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>SongDash Debug Panel <span class="timestamp" id="timestamp">--</span></h1>
|
||||
|
||||
<div class="section">
|
||||
<h2>Music Status</h2>
|
||||
<div class="key-value">
|
||||
<div class="key">Status:</div>
|
||||
<div class="value"><span id="music-status" class="status">--</span></div>
|
||||
</div>
|
||||
<div class="key-value">
|
||||
<div class="key">Platform:</div>
|
||||
<div class="value" id="music-platform">--</div>
|
||||
</div>
|
||||
<div class="key-value">
|
||||
<div class="key">Listeners:</div>
|
||||
<div class="value" id="music-listeners">--</div>
|
||||
</div>
|
||||
<div class="key-value">
|
||||
<div class="key">Metadata:</div>
|
||||
<div class="value">
|
||||
<div id="music-metadata-author">--</div>
|
||||
<div id="music-metadata-track">--</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="section">
|
||||
<h2>Queue (<span id="queue-length">0</span> players)</h2>
|
||||
<table id="queue-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Pos</th>
|
||||
<th>IP</th>
|
||||
<th>Nick</th>
|
||||
<th>Status</th>
|
||||
<th>Time</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="queue-body">
|
||||
<tr>
|
||||
<td colspan="5" class="empty">No players in queue</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="section">
|
||||
<h2>Scoreboard (<span id="board-total">0</span> players)</h2>
|
||||
<table id="board-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>IP</th>
|
||||
<th>Nick</th>
|
||||
<th>Score</th>
|
||||
<th>Connected</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="board-body">
|
||||
<tr>
|
||||
<td colspan="4" class="empty">No scores recorded</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="section">
|
||||
<h2>Clients (<span id="client-count">0</span> total)</h2>
|
||||
<table id="client-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>IP</th>
|
||||
<th>Type</th>
|
||||
<th>Nick</th>
|
||||
<th>User-Agent</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="client-body">
|
||||
<tr>
|
||||
<td colspan="4" class="empty">No clients connected</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<script src="/socket.js"></script>
|
||||
<script>
|
||||
const socket = new Socket('debug')
|
||||
|
||||
socket.on('update', data => {
|
||||
updateDebug(data)
|
||||
})
|
||||
|
||||
function updateDebug(data) {
|
||||
// Update timestamp
|
||||
document.getElementById('timestamp').textContent = new Date(data.timestamp).toLocaleTimeString()
|
||||
|
||||
// Update Music Status
|
||||
const musicStatus = document.getElementById('music-status')
|
||||
musicStatus.textContent = data.music.status
|
||||
musicStatus.className = 'status ' + data.music.status
|
||||
|
||||
document.getElementById('music-platform').textContent = data.music.platform || '--'
|
||||
document.getElementById('music-listeners').textContent = data.music.listenerCount
|
||||
|
||||
if (data.music.metadata && data.music.metadata.author && data.music.metadata.track) {
|
||||
const metadataText = `${data.music.metadata.author} - ${data.music.metadata.track}`
|
||||
document.getElementById('music-metadata-author').textContent = metadataText
|
||||
document.getElementById('music-metadata-track').textContent = ''
|
||||
} else {
|
||||
document.getElementById('music-metadata-author').textContent = '--'
|
||||
document.getElementById('music-metadata-track').textContent = ''
|
||||
}
|
||||
|
||||
// Update Queue
|
||||
document.getElementById('queue-length').textContent = data.queue.length
|
||||
const queueBody = document.getElementById('queue-body')
|
||||
|
||||
if (data.queue.queue.length === 0) {
|
||||
queueBody.innerHTML = '<tr><td colspan="5" class="empty">No players in queue</td></tr>'
|
||||
} else {
|
||||
queueBody.innerHTML = data.queue.queue
|
||||
.map(
|
||||
item => `
|
||||
<tr>
|
||||
<td>${item.position + 1}</td>
|
||||
<td>${item.ip}</td>
|
||||
@@ -285,52 +286,63 @@
|
||||
<td>${item.isActive ? '<span class="status active">ACTIVE</span>' : ''}</td>
|
||||
<td>${item.time !== null ? item.time.toFixed(4) + 's' : '--'}</td>
|
||||
</tr>
|
||||
`).join('')
|
||||
}
|
||||
`
|
||||
)
|
||||
.join('')
|
||||
}
|
||||
|
||||
// Update Scoreboard
|
||||
document.getElementById('board-total').textContent = data.board.totalPlayers
|
||||
const boardBody = document.getElementById('board-body')
|
||||
// Update Scoreboard
|
||||
document.getElementById('board-total').textContent = data.board.totalPlayers
|
||||
const boardBody = document.getElementById('board-body')
|
||||
|
||||
if (data.board.scores.length === 0) {
|
||||
boardBody.innerHTML = '<tr><td colspan="4" class="empty">No scores recorded</td></tr>'
|
||||
} else {
|
||||
boardBody.innerHTML = data.board.scores.map(item => `
|
||||
if (data.board.scores.length === 0) {
|
||||
boardBody.innerHTML = '<tr><td colspan="4" class="empty">No scores recorded</td></tr>'
|
||||
} else {
|
||||
boardBody.innerHTML = data.board.scores
|
||||
.map(
|
||||
item => `
|
||||
<tr>
|
||||
<td>${item.ip}</td>
|
||||
<td>${item.nick}</td>
|
||||
<td>${item.score}</td>
|
||||
<td><span class="status ${item.connected ? 'connected' : 'disconnected'}">${item.connected ? 'YES' : 'NO'}</span></td>
|
||||
<td><span class="status ${item.connected ? 'connected' : 'disconnected'}">${
|
||||
item.connected ? 'YES' : 'NO'
|
||||
}</span></td>
|
||||
</tr>
|
||||
`).join('')
|
||||
}
|
||||
`
|
||||
)
|
||||
.join('')
|
||||
}
|
||||
|
||||
// Update Clients
|
||||
document.getElementById('client-count').textContent = data.client.clients.length
|
||||
const clientBody = document.getElementById('client-body')
|
||||
// Update Clients
|
||||
document.getElementById('client-count').textContent = data.client.clients.length
|
||||
const clientBody = document.getElementById('client-body')
|
||||
|
||||
if (data.client.clients.length === 0) {
|
||||
clientBody.innerHTML = '<tr><td colspan="4" class="empty">No clients connected</td></tr>'
|
||||
} else {
|
||||
// Sort clients: special types (tv, host, debug) first, then players
|
||||
const specialTypes = ['tv', 'host', 'debug']
|
||||
const sortedClients = [...data.client.clients].sort((a, b) => {
|
||||
const aSpecial = specialTypes.includes(a.type)
|
||||
const bSpecial = specialTypes.includes(b.type)
|
||||
if (aSpecial && !bSpecial) return -1
|
||||
if (!aSpecial && bSpecial) return 1
|
||||
return 0
|
||||
})
|
||||
if (data.client.clients.length === 0) {
|
||||
clientBody.innerHTML = '<tr><td colspan="4" class="empty">No clients connected</td></tr>'
|
||||
} else {
|
||||
// Sort clients: special types (tv, host, debug) first, then players
|
||||
const specialTypes = ['tv', 'host', 'debug']
|
||||
const sortedClients = [...data.client.clients].sort((a, b) => {
|
||||
const aSpecial = specialTypes.includes(a.type)
|
||||
const bSpecial = specialTypes.includes(b.type)
|
||||
if (aSpecial && !bSpecial) return -1
|
||||
if (!aSpecial && bSpecial) return 1
|
||||
return 0
|
||||
})
|
||||
|
||||
clientBody.innerHTML = sortedClients.map(item => {
|
||||
let uaDisplay = '--'
|
||||
let uaTitle = '--'
|
||||
if (item.userAgent) {
|
||||
uaDisplay = `${item.userAgent.browser || 'Unknown'} / ${item.userAgent.os || 'Unknown'} / ${item.userAgent.device}`
|
||||
uaTitle = item.userAgent.raw
|
||||
}
|
||||
const typeClass = specialTypes.includes(item.type) ? `type-${item.type}` : ''
|
||||
return `
|
||||
clientBody.innerHTML = sortedClients
|
||||
.map(item => {
|
||||
let uaDisplay = '--'
|
||||
let uaTitle = '--'
|
||||
if (item.userAgent) {
|
||||
uaDisplay = `${item.userAgent.browser || 'Unknown'} / ${item.userAgent.os || 'Unknown'} / ${
|
||||
item.userAgent.device
|
||||
}`
|
||||
uaTitle = item.userAgent.raw
|
||||
}
|
||||
const typeClass = specialTypes.includes(item.type) ? `type-${item.type}` : ''
|
||||
return `
|
||||
<tr>
|
||||
<td>${item.ip}</td>
|
||||
<td class="${typeClass}">${item.type || '--'}</td>
|
||||
@@ -338,10 +350,10 @@
|
||||
<td title="${uaTitle}">${uaDisplay}</td>
|
||||
</tr>
|
||||
`
|
||||
}).join('')
|
||||
})
|
||||
.join('')
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
+91
-91
@@ -1,118 +1,118 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
|
||||
<title>Player - Jaka To Melodia</title>
|
||||
<script src="/socket.js"></script>
|
||||
<script src="/wakelock.js"></script>
|
||||
<title>Player - Jaka To Melodia</title>
|
||||
<script src="/socket.js"></script>
|
||||
<script src="/wakelock.js"></script>
|
||||
|
||||
<link rel="stylesheet" href="/pattern.css" />
|
||||
<link rel="stylesheet" href="/pattern.css" />
|
||||
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100vh;
|
||||
justify-content: center;
|
||||
overflow: hidden;
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100vh;
|
||||
justify-content: center;
|
||||
overflow: hidden;
|
||||
|
||||
--fgcolor: #e7213b;
|
||||
--bgcolor: #b93834;
|
||||
--pattern: 22px;
|
||||
}
|
||||
--fgcolor: #e7213b;
|
||||
--bgcolor: #b93834;
|
||||
--pattern: 22px;
|
||||
}
|
||||
|
||||
button {
|
||||
width: calc(100vw - 2rem);
|
||||
height: calc(100vw - 2rem);
|
||||
button {
|
||||
width: calc(100vw - 2rem);
|
||||
height: calc(100vw - 2rem);
|
||||
|
||||
border-radius: 100%;
|
||||
margin: 1rem;
|
||||
background-color: #ee1020;
|
||||
user-select: none;
|
||||
border-width: 4px;
|
||||
}
|
||||
border-radius: 100%;
|
||||
margin: 1rem;
|
||||
background-color: #ee1020;
|
||||
user-select: none;
|
||||
border-width: 4px;
|
||||
}
|
||||
|
||||
button > img {
|
||||
height: 50%;
|
||||
transition: 0.2s;
|
||||
}
|
||||
button > img {
|
||||
height: 50%;
|
||||
transition: 0.2s;
|
||||
}
|
||||
|
||||
button:active > img {
|
||||
height: 60%;
|
||||
transform: skewx(-49deg);
|
||||
}
|
||||
button:active > img {
|
||||
height: 60%;
|
||||
transform: skewx(-49deg);
|
||||
}
|
||||
|
||||
button:active {
|
||||
background-color: #bb1020;
|
||||
}
|
||||
button:active {
|
||||
background-color: #bb1020;
|
||||
}
|
||||
|
||||
input {
|
||||
width: calc(100vw - 2rem);
|
||||
box-sizing: border-box;
|
||||
margin: 1rem;
|
||||
margin-bottom: 0;
|
||||
font-size: 1rem;
|
||||
text-align: center;
|
||||
font-family: monospace;
|
||||
}
|
||||
input {
|
||||
width: calc(100vw - 2rem);
|
||||
box-sizing: border-box;
|
||||
margin: 1rem;
|
||||
margin-bottom: 0;
|
||||
font-size: 1rem;
|
||||
text-align: center;
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
#score {
|
||||
font-family: monospace;
|
||||
box-sizing: border-box;
|
||||
padding: 1em;
|
||||
background-color: #fff6;
|
||||
font-size: 1rem;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body class="patterned">
|
||||
<!-- <div id="score">
|
||||
#score {
|
||||
font-family: monospace;
|
||||
box-sizing: border-box;
|
||||
padding: 1em;
|
||||
background-color: #fff6;
|
||||
font-size: 1rem;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body class="patterned">
|
||||
<!-- <div id="score">
|
||||
<span>Punkty:</span>
|
||||
<span id="points">0</span>
|
||||
</div> -->
|
||||
|
||||
<input type="text" id="nick" placeholder="nick" maxlength="20" />
|
||||
<input type="text" id="nick" placeholder="nick" maxlength="20" />
|
||||
|
||||
<button>
|
||||
<!-- <img src="twerk.gif" alt="doopa" /> -->
|
||||
</button>
|
||||
<button>
|
||||
<!-- <img src="twerk.gif" alt="doopa" /> -->
|
||||
</button>
|
||||
|
||||
<script>
|
||||
const socket = new Socket('player')
|
||||
<script>
|
||||
const socket = new Socket('player')
|
||||
|
||||
requestWakeLock()
|
||||
requestWakeLock()
|
||||
|
||||
// Cache DOM elements
|
||||
const nodeButton = document.querySelector('button'),
|
||||
nodeNick = document.querySelector('#nick'),
|
||||
nodePoints = document.querySelector('#points')
|
||||
// Cache DOM elements
|
||||
const nodeButton = document.querySelector('button'),
|
||||
nodeNick = document.querySelector('#nick'),
|
||||
nodePoints = document.querySelector('#points')
|
||||
|
||||
// Initialize nickname
|
||||
const savedNick = localStorage.getItem('nick') || ''
|
||||
nodeNick.value = savedNick
|
||||
socket.player('setNick', { nick: savedNick })
|
||||
// Initialize nickname
|
||||
const savedNick = localStorage.getItem('nick') || ''
|
||||
nodeNick.value = savedNick
|
||||
socket.player('setNick', { nick: savedNick })
|
||||
|
||||
// Handle button press
|
||||
nodeButton.addEventListener('mousedown', () => socket.player('enter'))
|
||||
nodeButton.addEventListener('touchstart', () => socket.player('enter'), { passive: true })
|
||||
// Handle button press
|
||||
nodeButton.addEventListener('mousedown', () => socket.player('enter'))
|
||||
nodeButton.addEventListener('touchstart', () => socket.player('enter'), { passive: true })
|
||||
|
||||
// Handle nickname changes
|
||||
const setNick = e => {
|
||||
const nick = e.target.value.trim().toLowerCase()
|
||||
socket.player('setNick', { nick })
|
||||
localStorage.setItem('nick', nick)
|
||||
}
|
||||
// Handle nickname changes
|
||||
const setNick = e => {
|
||||
const nick = e.target.value.trim().toLowerCase()
|
||||
socket.player('setNick', { nick })
|
||||
localStorage.setItem('nick', nick)
|
||||
}
|
||||
|
||||
nodeNick.addEventListener('change', setNick)
|
||||
nodeNick.addEventListener('change', setNick)
|
||||
|
||||
// // Update points display using custom event listener
|
||||
// socket.on('points', points => {
|
||||
// nodePoints.textContent = points
|
||||
// })
|
||||
</script>
|
||||
</body>
|
||||
// // Update points display using custom event listener
|
||||
// socket.on('points', points => {
|
||||
// nodePoints.textContent = points
|
||||
// })
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
+202
-197
@@ -1,245 +1,250 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
|
||||
<title>TV - Jaka To Melodia</title>
|
||||
<script src="/socket.js"></script>
|
||||
<script src="/wakelock.js"></script>
|
||||
<title>TV - Jaka To Melodia</title>
|
||||
<script src="/socket.js"></script>
|
||||
<script src="/wakelock.js"></script>
|
||||
|
||||
<link rel="stylesheet" href="/common.css" />
|
||||
<link rel="stylesheet" href="/pattern.css" />
|
||||
<link rel="stylesheet" href="/loader.css" />
|
||||
<link rel="stylesheet" href="/common.css" />
|
||||
<link rel="stylesheet" href="/pattern.css" />
|
||||
<link rel="stylesheet" href="/loader.css" />
|
||||
|
||||
<style>
|
||||
body {
|
||||
height: 100vh;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
--pattern: 22px;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
<style>
|
||||
body {
|
||||
height: 100vh;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
--pattern: 22px;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.section {
|
||||
flex: 1;
|
||||
padding: 2rem;
|
||||
overflow-y: auto;
|
||||
background: #0005;
|
||||
--margin: 1em;
|
||||
margin: var(--margin);
|
||||
border-radius: 1em;
|
||||
}
|
||||
.section {
|
||||
flex: 1;
|
||||
padding: 2rem;
|
||||
overflow-y: auto;
|
||||
background: #0005;
|
||||
--margin: 1em;
|
||||
margin: var(--margin);
|
||||
border-radius: 1em;
|
||||
}
|
||||
|
||||
.section.l {
|
||||
margin-right: calc(var(--margin) / 2);
|
||||
}
|
||||
.section.l {
|
||||
margin-right: calc(var(--margin) / 2);
|
||||
}
|
||||
|
||||
.section.r {
|
||||
margin-left: calc(var(--margin) / 2);
|
||||
}
|
||||
.section.r {
|
||||
margin-left: calc(var(--margin) / 2);
|
||||
}
|
||||
|
||||
.section .title {
|
||||
font-size: 2.5rem;
|
||||
font-weight: bold;
|
||||
margin-bottom: 1.5rem;
|
||||
text-align: center;
|
||||
color: #fff;
|
||||
font-family: monospace;
|
||||
border-bottom: 1px solid #fff3;
|
||||
padding-bottom: 0.5em;
|
||||
}
|
||||
.section .title {
|
||||
font-size: 2.5rem;
|
||||
font-weight: bold;
|
||||
margin-bottom: 1.5rem;
|
||||
text-align: center;
|
||||
color: #fff;
|
||||
font-family: monospace;
|
||||
border-bottom: 1px solid #fff3;
|
||||
padding-bottom: 0.5em;
|
||||
}
|
||||
|
||||
#status {
|
||||
position: fixed;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
z-index: -1;
|
||||
pointer-events: none;
|
||||
font-size: 500px;
|
||||
--opacity: 0.25;
|
||||
text-shadow: 0 0 20px rgba(0, 0, 0, var(--opacity));
|
||||
color: rgba(0, 0, 0, var(--opacity));
|
||||
}
|
||||
#status {
|
||||
position: fixed;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
z-index: -1;
|
||||
pointer-events: none;
|
||||
/* display: flex;
|
||||
align-items: center;
|
||||
justify-content: center; */
|
||||
font-size: 500px;
|
||||
--opacity: 0.25;
|
||||
text-shadow: 0 0 20px rgba(0, 0, 0, var(--opacity));
|
||||
color: rgba(0, 0, 0, var(--opacity));
|
||||
}
|
||||
|
||||
#queue {
|
||||
font-size: 30px;
|
||||
font-family: monospace;
|
||||
text-align: left;
|
||||
counter-reset: poz;
|
||||
}
|
||||
#queue {
|
||||
font-size: 30px;
|
||||
font-family: monospace;
|
||||
text-align: left;
|
||||
counter-reset: poz;
|
||||
}
|
||||
|
||||
#queue > .nick {
|
||||
display: flex;
|
||||
padding: 0.8rem 1.5rem;
|
||||
margin: 0.5rem 0;
|
||||
background-color: rgba(255, 255, 255, 0.15);
|
||||
border-radius: 0.5rem;
|
||||
color: #fff;
|
||||
}
|
||||
#queue > .nick {
|
||||
display: flex;
|
||||
/* justify-content: space-between;
|
||||
align-items: center; */
|
||||
padding: 0.8rem 1.5rem;
|
||||
margin: 0.5rem 0;
|
||||
background-color: rgba(255, 255, 255, 0.15);
|
||||
border-radius: 0.5rem;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
#queue > .nick::before {
|
||||
counter-increment: poz;
|
||||
content: '#' counter(poz) ' ';
|
||||
font-weight: bold;
|
||||
color: #ccc;
|
||||
padding-right: 1em;
|
||||
width: 1.5em;
|
||||
}
|
||||
#queue > .nick::before {
|
||||
counter-increment: poz;
|
||||
content: '#' counter(poz) ' ';
|
||||
font-weight: bold;
|
||||
color: #ccc;
|
||||
padding-right: 1em;
|
||||
width: 1.5em;
|
||||
}
|
||||
|
||||
#queue > .nick::after {
|
||||
content: attr(data-time);
|
||||
margin-left: auto;
|
||||
font-weight: bold;
|
||||
color: #eee;
|
||||
min-width: 4em;
|
||||
text-align: right;
|
||||
}
|
||||
#queue > .nick::after {
|
||||
content: attr(data-time);
|
||||
margin-left: auto;
|
||||
font-weight: bold;
|
||||
color: #eee;
|
||||
min-width: 4em;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
#queue > img {
|
||||
height: 10vh;
|
||||
}
|
||||
#queue > img {
|
||||
height: 10vh;
|
||||
}
|
||||
|
||||
#queue .nick.active {
|
||||
outline: 2px solid #fff;
|
||||
}
|
||||
#queue .nick.active {
|
||||
outline: 2px solid #fff;
|
||||
}
|
||||
|
||||
#qr-modal {
|
||||
display: none;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: rgba(0, 0, 0, 0.9);
|
||||
z-index: 1000;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
#qr-modal {
|
||||
display: none;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: rgba(0, 0, 0, 0.9);
|
||||
z-index: 1000;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
#qr-modal.show {
|
||||
display: flex;
|
||||
}
|
||||
#qr-modal.show {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
#qr-modal .content {
|
||||
background-color: white;
|
||||
padding: 2rem;
|
||||
border-radius: 1rem;
|
||||
text-align: center;
|
||||
max-width: 90vw;
|
||||
max-height: 90vh;
|
||||
}
|
||||
#qr-modal .content {
|
||||
background-color: white;
|
||||
padding: 2rem;
|
||||
border-radius: 1rem;
|
||||
text-align: center;
|
||||
max-width: 90vw;
|
||||
max-height: 90vh;
|
||||
}
|
||||
|
||||
#qr-modal .content img {
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
border-radius: 0.5rem;
|
||||
}
|
||||
#qr-modal .content img {
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
border-radius: 0.5rem;
|
||||
}
|
||||
|
||||
#scoreboard {
|
||||
width: 100%;
|
||||
font-size: 1.5rem;
|
||||
font-family: monospace;
|
||||
}
|
||||
#scoreboard {
|
||||
width: 100%;
|
||||
font-size: 1.5rem;
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
#scoreboard .item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 0.8rem 1.5rem;
|
||||
margin: 0.5rem 0;
|
||||
background-color: rgba(255, 255, 255, 0.15);
|
||||
border-radius: 0.5rem;
|
||||
color: #fff;
|
||||
}
|
||||
#scoreboard .item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 0.8rem 1.5rem;
|
||||
margin: 0.5rem 0;
|
||||
background-color: rgba(255, 255, 255, 0.15);
|
||||
border-radius: 0.5rem;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
#scoreboard .item .rank i {
|
||||
font-size: 2rem;
|
||||
}
|
||||
#scoreboard .item .rank i {
|
||||
font-size: 2rem;
|
||||
}
|
||||
|
||||
#scoreboard .item:nth-child(1) .rank {
|
||||
color: gold;
|
||||
}
|
||||
#scoreboard .item:nth-child(1) .rank {
|
||||
color: gold;
|
||||
}
|
||||
|
||||
#scoreboard .item:nth-child(2) .rank {
|
||||
color: silver;
|
||||
}
|
||||
#scoreboard .item:nth-child(2) .rank {
|
||||
color: silver;
|
||||
}
|
||||
|
||||
#scoreboard .item:nth-child(3) .rank {
|
||||
color: #cd7f32;
|
||||
/* Bronze */
|
||||
}
|
||||
#scoreboard .item:nth-child(3) .rank {
|
||||
color: #cd7f32;
|
||||
/* Bronze */
|
||||
}
|
||||
|
||||
#scoreboard .item > .rank {
|
||||
font-weight: bold;
|
||||
margin-right: 1rem;
|
||||
min-width: 2.5rem;
|
||||
}
|
||||
#scoreboard .item > .rank {
|
||||
font-weight: bold;
|
||||
margin-right: 1rem;
|
||||
min-width: 2.5rem;
|
||||
}
|
||||
|
||||
#scoreboard .item > .nick {
|
||||
flex: 1;
|
||||
text-align: left;
|
||||
}
|
||||
#scoreboard .item > .nick {
|
||||
flex: 1;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
#scoreboard .item > .score {
|
||||
font-weight: bold;
|
||||
min-width: 3rem;
|
||||
text-align: right;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
#scoreboard .item > .score {
|
||||
font-weight: bold;
|
||||
min-width: 3rem;
|
||||
text-align: right;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body class="patterned">
|
||||
<!-- Status Indicator -->
|
||||
<div id="status" class="status"></div>
|
||||
<body class="patterned">
|
||||
<!-- Status Indicator -->
|
||||
<div id="status" class="status"></div>
|
||||
|
||||
<!-- Left: Queue -->
|
||||
<div class="section l">
|
||||
<div class="title">
|
||||
<i class="icon-stopwatch"></i>
|
||||
</div>
|
||||
<div id="queue">
|
||||
<!-- Example
|
||||
<!-- Left: Queue -->
|
||||
<div class="section l">
|
||||
<div class="title">
|
||||
<i class="icon-stopwatch"></i>
|
||||
</div>
|
||||
<div id="queue">
|
||||
<!-- Example
|
||||
<div class="nick active"> </div>
|
||||
-->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Right: Scoreboard -->
|
||||
<div class="section r">
|
||||
<div class="title">
|
||||
<i class="icon-award"></i>
|
||||
</div>
|
||||
<div id="scoreboard">
|
||||
<!-- Example
|
||||
<!-- Right: Scoreboard -->
|
||||
<div class="section r">
|
||||
<div class="title">
|
||||
<i class="icon-award"></i>
|
||||
</div>
|
||||
<div id="scoreboard">
|
||||
<!-- Example
|
||||
<div class="item">
|
||||
<span class="rank"> </span>
|
||||
<span class="nick"> </span>
|
||||
<span class="score"> </span>
|
||||
</div>
|
||||
-->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- QR Modal -->
|
||||
<div id="qr-modal">
|
||||
<div class="content">
|
||||
<img src="/qr" alt="QR Code" />
|
||||
<!-- QR Modal -->
|
||||
<div id="qr-modal">
|
||||
<div class="content">
|
||||
<img src="/qr" alt="QR Code" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// SETUP
|
||||
const statuses = {
|
||||
paused: '<i class="icon-pause-circled"></i>',
|
||||
playing: '<i class="icon-play-circled"></i>',
|
||||
waiting: '<i class="icon-stop-circled"></i>',
|
||||
}
|
||||
<script>
|
||||
// SETUP
|
||||
const statuses = {
|
||||
paused: '<i class="icon-pause-circled"></i>',
|
||||
playing: '<i class="icon-play-circled"></i>',
|
||||
waiting: '<i class="icon-stop-circled"></i>',
|
||||
}
|
||||
|
||||
const nodeStatus = document.querySelector('#status'),
|
||||
nodeQueue = document.querySelector('#queue'),
|
||||
|
||||
Reference in new issue
Block a user