Initial code
This commit is contained in:
1 parent
7e4d017744
commit
ce297fea12
17 files changed
+1501
No files matched your search
@@ -0,0 +1,2 @@
|
||||
node_modules/
|
||||
.env
|
||||
@@ -0,0 +1,35 @@
|
||||
import Client from './Client.js'
|
||||
|
||||
class Board {
|
||||
static scores = {}
|
||||
|
||||
static addPlayer(client) {
|
||||
if (this.scores[client.ip]) return
|
||||
|
||||
this.scores[client.ip] = 0
|
||||
}
|
||||
|
||||
// static removePlayer(client) {
|
||||
// delete this.scores[client.ip]
|
||||
// }
|
||||
|
||||
static bumpScore(client, score) {
|
||||
this.scores[client.ip] += score
|
||||
}
|
||||
|
||||
static getScore(client) {
|
||||
return this.scores[client.ip]
|
||||
}
|
||||
|
||||
static get rendered() {
|
||||
let list = Object.entries(this.scores).map(([ip, score]) => {
|
||||
return {
|
||||
nick: Client.getByIp(ip).nick,
|
||||
score,
|
||||
}
|
||||
})
|
||||
return list
|
||||
}
|
||||
}
|
||||
|
||||
export default Board
|
||||
@@ -0,0 +1,156 @@
|
||||
import Music from './Music.js'
|
||||
import Queue from './Queue.js'
|
||||
import Board from './Board.js'
|
||||
|
||||
class Client {
|
||||
static list = []
|
||||
static listeners = []
|
||||
|
||||
type = null
|
||||
|
||||
constructor(ws, req) {
|
||||
this.ws = ws
|
||||
ws.client = this
|
||||
this.ip = req.socket.remoteAddress
|
||||
|
||||
console.info(`ws: up ${this.ip}`)
|
||||
|
||||
Client.list.push(this)
|
||||
|
||||
ws.on('close', () => {
|
||||
console.info(`ws: down ${req.socket.remoteAddress}`)
|
||||
Client.list = Client.list.filter((client) => client != this)
|
||||
// Board.removePlayer(this)
|
||||
})
|
||||
|
||||
ws.on('message', (data) => {
|
||||
let payload = JSON.parse(data.toString())
|
||||
|
||||
console.log(payload)
|
||||
|
||||
this.recieve(payload)
|
||||
|
||||
// Client.on('entry', ({ client }) => {
|
||||
|
||||
// })
|
||||
})
|
||||
}
|
||||
|
||||
recieve(payload) {
|
||||
if (payload.whoami) {
|
||||
if (!payload.whoami in ['tv', 'host', 'player']) return
|
||||
|
||||
this.type = payload.whoami
|
||||
console.info(`ws: '${this.type}' registered`)
|
||||
if (this.type == 'tv') Client.broadcast('update')
|
||||
if (this.type == 'player') {
|
||||
Board.addPlayer(this)
|
||||
Client.broadcast('score', this)
|
||||
}
|
||||
}
|
||||
|
||||
// initiated only actions
|
||||
if (this.type == null) return
|
||||
// ###
|
||||
|
||||
if (payload.nick) {
|
||||
if (typeof payload.nick != 'string') return
|
||||
if (payload.nick.trim() == '') return
|
||||
|
||||
this.nick = payload.nick
|
||||
console.info(`ws: '${this.ip}' renamed to '${this.nick}' `)
|
||||
}
|
||||
|
||||
if (payload.entry) {
|
||||
console.info(`ws: '${this.nick}' entered`)
|
||||
|
||||
Queue.add(this)
|
||||
Music.control('Pause')
|
||||
}
|
||||
|
||||
if (payload.host) {
|
||||
if (this.type != 'host') return
|
||||
|
||||
let data = payload.host,
|
||||
action = data.action
|
||||
|
||||
if (action == 'clear') {
|
||||
Queue.clear()
|
||||
Music.setStatus('waiting')
|
||||
}
|
||||
|
||||
if (action == 'play') {
|
||||
Music.control('Play')
|
||||
}
|
||||
|
||||
if (action == 'pause') {
|
||||
Music.control('Pause')
|
||||
}
|
||||
|
||||
if (action == 'next') {
|
||||
Music.control('Next')
|
||||
Queue.clear()
|
||||
}
|
||||
|
||||
if (action == 'nextPlayer') {
|
||||
Queue.nextPlayer()
|
||||
}
|
||||
|
||||
if (action == 'points') {
|
||||
Board.bumpScore(Queue.activeClient, data.points)
|
||||
Client.broadcast('score', Queue.activeClient)
|
||||
}
|
||||
}
|
||||
Client.broadcast('update')
|
||||
}
|
||||
|
||||
send(payload) {
|
||||
this.ws.send(JSON.stringify(payload))
|
||||
}
|
||||
|
||||
static addPlayer(newclient) {
|
||||
Client.list.push(newclient)
|
||||
}
|
||||
|
||||
static removePlayer(oldclient) {
|
||||
Client.list = Client.list.filter((client) => client != oldclient)
|
||||
}
|
||||
|
||||
static trigger(e, p) {
|
||||
Client.listeners.forEach((listener) => {
|
||||
if (listener.e == e) listener.f(p)
|
||||
})
|
||||
}
|
||||
|
||||
static on(e, f) {
|
||||
this.listeners.push({ e, f })
|
||||
}
|
||||
|
||||
static broadcast(event, payload) {
|
||||
if (event == 'update') {
|
||||
Client.getType('tv').forEach((client) => {
|
||||
client.send({
|
||||
queue: Queue.rendered,
|
||||
active: Queue.active,
|
||||
status: Music.status,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
if (event == 'score') {
|
||||
payload.send({
|
||||
points: Board.getScore(payload),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
static getType(type) {
|
||||
return Client.list.filter((client) => client.type == type)
|
||||
}
|
||||
|
||||
static getByIp(ip) {
|
||||
return Client.list.find((client) => client.ip == ip)
|
||||
}
|
||||
}
|
||||
|
||||
export default Client
|
||||
@@ -0,0 +1,123 @@
|
||||
import { exec } from 'child_process'
|
||||
|
||||
class Music {
|
||||
static status = 'waiting'
|
||||
|
||||
static control(action) {
|
||||
const allowed = ['Play', 'Pause', 'Stop', 'Next', 'Previous', 'PlayPause']
|
||||
|
||||
if (!allowed.includes(action)) return
|
||||
|
||||
exec(
|
||||
`dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.${action}`,
|
||||
(error, stdout, stderr) => {
|
||||
if (error) {
|
||||
console.log(`error: ${error.message}`)
|
||||
return
|
||||
}
|
||||
if (stderr) {
|
||||
console.log(`stderr: ${stderr}`)
|
||||
return
|
||||
}
|
||||
// console.log(`stdout: ${stdout}`)
|
||||
}
|
||||
)
|
||||
|
||||
let status = {
|
||||
Play: 'playing',
|
||||
Pause: 'paused',
|
||||
Stop: 'stopped',
|
||||
Next: 'playing',
|
||||
}[action]
|
||||
|
||||
this.setStatus(status)
|
||||
}
|
||||
|
||||
static setStatus(status) {
|
||||
const allowed = ['playing', 'paused', 'waiting']
|
||||
|
||||
if (!allowed.includes(status)) return
|
||||
|
||||
this.status = status
|
||||
}
|
||||
|
||||
static getMeta() {
|
||||
/*
|
||||
method return time=1737905619.455697 sender=:1.419 -> destination=:1.2759 serial=6800 reply_serial=2
|
||||
variant array [
|
||||
dict entry(
|
||||
string "mpris:trackid"
|
||||
variant string "/com/spotify/track/7dxQFzp8zZzgDkaYEXQZIv"
|
||||
)
|
||||
dict entry(
|
||||
string "mpris:length"
|
||||
variant uint64 258453000
|
||||
)
|
||||
dict entry(
|
||||
string "mpris:artUrl"
|
||||
variant string "https://i.scdn.co/image/ab67616d0000b273b01fea159227ea845c2bd72e"
|
||||
)
|
||||
dict entry(
|
||||
string "xesam:album"
|
||||
variant string "Crystal Castles"
|
||||
)
|
||||
dict entry(
|
||||
string "xesam:albumArtist"
|
||||
variant array [
|
||||
string "Crystal Castles"
|
||||
]
|
||||
)
|
||||
dict entry(
|
||||
string "xesam:artist"
|
||||
variant array [
|
||||
string "Crystal Castles"
|
||||
]
|
||||
)
|
||||
dict entry(
|
||||
string "xesam:autoRating"
|
||||
variant double 0.63
|
||||
)
|
||||
dict entry(
|
||||
string "xesam:discNumber"
|
||||
variant int32 1
|
||||
)
|
||||
dict entry(
|
||||
string "xesam:title"
|
||||
variant string "Crimewave"
|
||||
)
|
||||
dict entry(
|
||||
string "xesam:trackNumber"
|
||||
variant int32 3
|
||||
)
|
||||
dict entry(
|
||||
string "xesam:url"
|
||||
variant string "https://open.spotify.com/track/7dxQFzp8zZzgDkaYEXQZIv"
|
||||
)
|
||||
]
|
||||
|
||||
*/
|
||||
|
||||
// primitives
|
||||
// dict entry\(\s+.+ \"(.+)\"\s+variant\s+(.+?) (.+)\s+\)
|
||||
|
||||
// arrays
|
||||
// dict entry\(\s+.+ \"(.+)\"\s+variant\s+(.+?) array \[\s+(.+?)\s+\]\s+\)
|
||||
|
||||
exec(
|
||||
`dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'Metadata'`,
|
||||
(error, stdout, stderr) => {
|
||||
if (error) {
|
||||
console.log(`error: ${error.message}`)
|
||||
return
|
||||
}
|
||||
if (stderr) {
|
||||
console.log(`stderr: ${stderr}`)
|
||||
return
|
||||
}
|
||||
console.log(`stdout: ${stdout}`)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export default Music
|
||||
@@ -0,0 +1,51 @@
|
||||
import Client from './Client.js'
|
||||
import Music from './Music.js'
|
||||
|
||||
class Queue {
|
||||
static array = []
|
||||
static active = null
|
||||
|
||||
static add(client) {
|
||||
if (this.isClientInQueue(client)) {
|
||||
// if (Music.status == 'playing') this.active++
|
||||
return
|
||||
}
|
||||
|
||||
if (this.isEmpty) this.active = 0
|
||||
|
||||
this.push(client)
|
||||
}
|
||||
|
||||
static get isEmpty() {
|
||||
return this.array.length == 0
|
||||
}
|
||||
|
||||
static isClientInQueue(client) {
|
||||
return this.array.includes(client.ip)
|
||||
}
|
||||
|
||||
static push(client) {
|
||||
this.array.push(client.ip)
|
||||
}
|
||||
|
||||
static clear() {
|
||||
this.array = []
|
||||
this.active = null
|
||||
}
|
||||
|
||||
static nextPlayer() {
|
||||
this.active = (this.active + 1) % this.array.length
|
||||
}
|
||||
|
||||
static get rendered() {
|
||||
return this.array.map((ip, i) => {
|
||||
return Client.getByIp(ip)?.nick
|
||||
})
|
||||
}
|
||||
|
||||
static get activeClient() {
|
||||
return Client.getByIp(this.array[this.active])
|
||||
}
|
||||
}
|
||||
|
||||
export default Queue
|
||||
@@ -0,0 +1,24 @@
|
||||
import dotenv from 'dotenv'
|
||||
|
||||
const NODE_ENV = process.env.NODE_ENV,
|
||||
dotfile = {
|
||||
production: '.env',
|
||||
development: '.dev.env',
|
||||
}[NODE_ENV ?? 'production']
|
||||
|
||||
console.info(`env: ${NODE_ENV} | ${dotfile}`)
|
||||
|
||||
const config = dotenv.config({ path: `./${dotfile}` })
|
||||
|
||||
if (config.error) throw `enviroment file ${dotfile} not found`
|
||||
|
||||
const env = {
|
||||
HTTP_PORT: 2500,
|
||||
WS_PORT: 2501,
|
||||
}
|
||||
|
||||
for (let key in env) {
|
||||
process.env[key] && (env[key] = env[key].constructor(process.env[key]))
|
||||
}
|
||||
|
||||
export default env
|
||||
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"name": "songdash",
|
||||
"version": "1.0.0",
|
||||
"description": "A multiplayer party game based on 'Name that Tune' - compete to identify songs the fastest!",
|
||||
"type": "module",
|
||||
"main": "server.js",
|
||||
"scripts": {
|
||||
"start": "node ."
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/Maathias/SongDash.git"
|
||||
},
|
||||
"keywords": [
|
||||
"game",
|
||||
"party-game",
|
||||
"music",
|
||||
"name-that-tune",
|
||||
"multiplayer",
|
||||
"websocket"
|
||||
],
|
||||
"author": "Maathias",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/Maathias/SongDash/issues"
|
||||
},
|
||||
"homepage": "https://github.com/Maathias/SongDash#readme",
|
||||
"dependencies": {
|
||||
"dotenv": "^16.4.5",
|
||||
"express": "^4.18.2",
|
||||
"ws": "^8.11.0"
|
||||
}
|
||||
}
|
||||
Generated
+507
@@ -0,0 +1,507 @@
|
||||
lockfileVersion: '9.0'
|
||||
|
||||
settings:
|
||||
autoInstallPeers: true
|
||||
excludeLinksFromLockfile: false
|
||||
|
||||
importers:
|
||||
|
||||
.:
|
||||
dependencies:
|
||||
dotenv:
|
||||
specifier: ^16.4.5
|
||||
version: 16.4.5
|
||||
express:
|
||||
specifier: ^4.18.2
|
||||
version: 4.18.2
|
||||
ws:
|
||||
specifier: ^8.11.0
|
||||
version: 8.11.0
|
||||
|
||||
packages:
|
||||
|
||||
accepts@1.3.8:
|
||||
resolution: {integrity: sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==}
|
||||
engines: {node: '>= 0.6'}
|
||||
|
||||
array-flatten@1.1.1:
|
||||
resolution: {integrity: sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==}
|
||||
|
||||
body-parser@1.20.1:
|
||||
resolution: {integrity: sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw==}
|
||||
engines: {node: '>= 0.8', npm: 1.2.8000 || >= 1.4.16}
|
||||
|
||||
bytes@3.1.2:
|
||||
resolution: {integrity: sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==}
|
||||
engines: {node: '>= 0.8'}
|
||||
|
||||
call-bind@1.0.2:
|
||||
resolution: {integrity: sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==}
|
||||
|
||||
content-disposition@0.5.4:
|
||||
resolution: {integrity: sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==}
|
||||
engines: {node: '>= 0.6'}
|
||||
|
||||
content-type@1.0.5:
|
||||
resolution: {integrity: sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==}
|
||||
engines: {node: '>= 0.6'}
|
||||
|
||||
cookie-signature@1.0.6:
|
||||
resolution: {integrity: sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==}
|
||||
|
||||
cookie@0.5.0:
|
||||
resolution: {integrity: sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==}
|
||||
engines: {node: '>= 0.6'}
|
||||
|
||||
debug@2.6.9:
|
||||
resolution: {integrity: sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==}
|
||||
peerDependencies:
|
||||
supports-color: '*'
|
||||
peerDependenciesMeta:
|
||||
supports-color:
|
||||
optional: true
|
||||
|
||||
depd@2.0.0:
|
||||
resolution: {integrity: sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==}
|
||||
engines: {node: '>= 0.8'}
|
||||
|
||||
destroy@1.2.0:
|
||||
resolution: {integrity: sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==}
|
||||
engines: {node: '>= 0.8', npm: 1.2.8000 || >= 1.4.16}
|
||||
|
||||
dotenv@16.4.5:
|
||||
resolution: {integrity: sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==}
|
||||
engines: {node: '>=12'}
|
||||
|
||||
ee-first@1.1.1:
|
||||
resolution: {integrity: sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==}
|
||||
|
||||
encodeurl@1.0.2:
|
||||
resolution: {integrity: sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==}
|
||||
engines: {node: '>= 0.8'}
|
||||
|
||||
escape-html@1.0.3:
|
||||
resolution: {integrity: sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==}
|
||||
|
||||
etag@1.8.1:
|
||||
resolution: {integrity: sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==}
|
||||
engines: {node: '>= 0.6'}
|
||||
|
||||
express@4.18.2:
|
||||
resolution: {integrity: sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ==}
|
||||
engines: {node: '>= 0.10.0'}
|
||||
|
||||
finalhandler@1.2.0:
|
||||
resolution: {integrity: sha512-5uXcUVftlQMFnWC9qu/svkWv3GTd2PfUhK/3PLkYNAe7FbqJMt3515HaxE6eRL74GdsriiwujiawdaB1BpEISg==}
|
||||
engines: {node: '>= 0.8'}
|
||||
|
||||
forwarded@0.2.0:
|
||||
resolution: {integrity: sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==}
|
||||
engines: {node: '>= 0.6'}
|
||||
|
||||
fresh@0.5.2:
|
||||
resolution: {integrity: sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==}
|
||||
engines: {node: '>= 0.6'}
|
||||
|
||||
function-bind@1.1.1:
|
||||
resolution: {integrity: sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==}
|
||||
|
||||
get-intrinsic@1.2.1:
|
||||
resolution: {integrity: sha512-2DcsyfABl+gVHEfCOaTrWgyt+tb6MSEGmKq+kI5HwLbIYgjgmMcV8KQ41uaKz1xxUcn9tJtgFbQUEVcEbd0FYw==}
|
||||
|
||||
has-proto@1.0.1:
|
||||
resolution: {integrity: sha512-7qE+iP+O+bgF9clE5+UoBFzE65mlBiVj3tKCrlNQ0Ogwm0BjpT/gK4SlLYDMybDh5I3TCTKnPPa0oMG7JDYrhg==}
|
||||
engines: {node: '>= 0.4'}
|
||||
|
||||
has-symbols@1.0.3:
|
||||
resolution: {integrity: sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==}
|
||||
engines: {node: '>= 0.4'}
|
||||
|
||||
has@1.0.3:
|
||||
resolution: {integrity: sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==}
|
||||
engines: {node: '>= 0.4.0'}
|
||||
|
||||
http-errors@2.0.0:
|
||||
resolution: {integrity: sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==}
|
||||
engines: {node: '>= 0.8'}
|
||||
|
||||
iconv-lite@0.4.24:
|
||||
resolution: {integrity: sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
||||
inherits@2.0.4:
|
||||
resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==}
|
||||
|
||||
ipaddr.js@1.9.1:
|
||||
resolution: {integrity: sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==}
|
||||
engines: {node: '>= 0.10'}
|
||||
|
||||
media-typer@0.3.0:
|
||||
resolution: {integrity: sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==}
|
||||
engines: {node: '>= 0.6'}
|
||||
|
||||
merge-descriptors@1.0.1:
|
||||
resolution: {integrity: sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w==}
|
||||
|
||||
methods@1.1.2:
|
||||
resolution: {integrity: sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==}
|
||||
engines: {node: '>= 0.6'}
|
||||
|
||||
mime-db@1.52.0:
|
||||
resolution: {integrity: sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==}
|
||||
engines: {node: '>= 0.6'}
|
||||
|
||||
mime-types@2.1.35:
|
||||
resolution: {integrity: sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==}
|
||||
engines: {node: '>= 0.6'}
|
||||
|
||||
mime@1.6.0:
|
||||
resolution: {integrity: sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==}
|
||||
engines: {node: '>=4'}
|
||||
hasBin: true
|
||||
|
||||
ms@2.0.0:
|
||||
resolution: {integrity: sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==}
|
||||
|
||||
ms@2.1.3:
|
||||
resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==}
|
||||
|
||||
negotiator@0.6.3:
|
||||
resolution: {integrity: sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==}
|
||||
engines: {node: '>= 0.6'}
|
||||
|
||||
object-inspect@1.12.3:
|
||||
resolution: {integrity: sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g==}
|
||||
|
||||
on-finished@2.4.1:
|
||||
resolution: {integrity: sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==}
|
||||
engines: {node: '>= 0.8'}
|
||||
|
||||
parseurl@1.3.3:
|
||||
resolution: {integrity: sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==}
|
||||
engines: {node: '>= 0.8'}
|
||||
|
||||
path-to-regexp@0.1.7:
|
||||
resolution: {integrity: sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==}
|
||||
|
||||
proxy-addr@2.0.7:
|
||||
resolution: {integrity: sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==}
|
||||
engines: {node: '>= 0.10'}
|
||||
|
||||
qs@6.11.0:
|
||||
resolution: {integrity: sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==}
|
||||
engines: {node: '>=0.6'}
|
||||
|
||||
range-parser@1.2.1:
|
||||
resolution: {integrity: sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==}
|
||||
engines: {node: '>= 0.6'}
|
||||
|
||||
raw-body@2.5.1:
|
||||
resolution: {integrity: sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig==}
|
||||
engines: {node: '>= 0.8'}
|
||||
|
||||
safe-buffer@5.2.1:
|
||||
resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==}
|
||||
|
||||
safer-buffer@2.1.2:
|
||||
resolution: {integrity: sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==}
|
||||
|
||||
send@0.18.0:
|
||||
resolution: {integrity: sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg==}
|
||||
engines: {node: '>= 0.8.0'}
|
||||
|
||||
serve-static@1.15.0:
|
||||
resolution: {integrity: sha512-XGuRDNjXUijsUL0vl6nSD7cwURuzEgglbOaFuZM9g3kwDXOWVTck0jLzjPzGD+TazWbboZYu52/9/XPdUgne9g==}
|
||||
engines: {node: '>= 0.8.0'}
|
||||
|
||||
setprototypeof@1.2.0:
|
||||
resolution: {integrity: sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==}
|
||||
|
||||
side-channel@1.0.4:
|
||||
resolution: {integrity: sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==}
|
||||
|
||||
statuses@2.0.1:
|
||||
resolution: {integrity: sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==}
|
||||
engines: {node: '>= 0.8'}
|
||||
|
||||
toidentifier@1.0.1:
|
||||
resolution: {integrity: sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==}
|
||||
engines: {node: '>=0.6'}
|
||||
|
||||
type-is@1.6.18:
|
||||
resolution: {integrity: sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==}
|
||||
engines: {node: '>= 0.6'}
|
||||
|
||||
unpipe@1.0.0:
|
||||
resolution: {integrity: sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==}
|
||||
engines: {node: '>= 0.8'}
|
||||
|
||||
utils-merge@1.0.1:
|
||||
resolution: {integrity: sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==}
|
||||
engines: {node: '>= 0.4.0'}
|
||||
|
||||
vary@1.1.2:
|
||||
resolution: {integrity: sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==}
|
||||
engines: {node: '>= 0.8'}
|
||||
|
||||
ws@8.11.0:
|
||||
resolution: {integrity: sha512-HPG3wQd9sNQoT9xHyNCXoDUa+Xw/VevmY9FoHyQ+g+rrMn4j6FB4np7Z0OhdTgjx6MgQLK7jwSy1YecU1+4Asg==}
|
||||
engines: {node: '>=10.0.0'}
|
||||
peerDependencies:
|
||||
bufferutil: ^4.0.1
|
||||
utf-8-validate: ^5.0.2
|
||||
peerDependenciesMeta:
|
||||
bufferutil:
|
||||
optional: true
|
||||
utf-8-validate:
|
||||
optional: true
|
||||
|
||||
snapshots:
|
||||
|
||||
accepts@1.3.8:
|
||||
dependencies:
|
||||
mime-types: 2.1.35
|
||||
negotiator: 0.6.3
|
||||
|
||||
array-flatten@1.1.1: {}
|
||||
|
||||
body-parser@1.20.1:
|
||||
dependencies:
|
||||
bytes: 3.1.2
|
||||
content-type: 1.0.5
|
||||
debug: 2.6.9
|
||||
depd: 2.0.0
|
||||
destroy: 1.2.0
|
||||
http-errors: 2.0.0
|
||||
iconv-lite: 0.4.24
|
||||
on-finished: 2.4.1
|
||||
qs: 6.11.0
|
||||
raw-body: 2.5.1
|
||||
type-is: 1.6.18
|
||||
unpipe: 1.0.0
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
bytes@3.1.2: {}
|
||||
|
||||
call-bind@1.0.2:
|
||||
dependencies:
|
||||
function-bind: 1.1.1
|
||||
get-intrinsic: 1.2.1
|
||||
|
||||
content-disposition@0.5.4:
|
||||
dependencies:
|
||||
safe-buffer: 5.2.1
|
||||
|
||||
content-type@1.0.5: {}
|
||||
|
||||
cookie-signature@1.0.6: {}
|
||||
|
||||
cookie@0.5.0: {}
|
||||
|
||||
debug@2.6.9:
|
||||
dependencies:
|
||||
ms: 2.0.0
|
||||
|
||||
depd@2.0.0: {}
|
||||
|
||||
destroy@1.2.0: {}
|
||||
|
||||
dotenv@16.4.5: {}
|
||||
|
||||
ee-first@1.1.1: {}
|
||||
|
||||
encodeurl@1.0.2: {}
|
||||
|
||||
escape-html@1.0.3: {}
|
||||
|
||||
etag@1.8.1: {}
|
||||
|
||||
express@4.18.2:
|
||||
dependencies:
|
||||
accepts: 1.3.8
|
||||
array-flatten: 1.1.1
|
||||
body-parser: 1.20.1
|
||||
content-disposition: 0.5.4
|
||||
content-type: 1.0.5
|
||||
cookie: 0.5.0
|
||||
cookie-signature: 1.0.6
|
||||
debug: 2.6.9
|
||||
depd: 2.0.0
|
||||
encodeurl: 1.0.2
|
||||
escape-html: 1.0.3
|
||||
etag: 1.8.1
|
||||
finalhandler: 1.2.0
|
||||
fresh: 0.5.2
|
||||
http-errors: 2.0.0
|
||||
merge-descriptors: 1.0.1
|
||||
methods: 1.1.2
|
||||
on-finished: 2.4.1
|
||||
parseurl: 1.3.3
|
||||
path-to-regexp: 0.1.7
|
||||
proxy-addr: 2.0.7
|
||||
qs: 6.11.0
|
||||
range-parser: 1.2.1
|
||||
safe-buffer: 5.2.1
|
||||
send: 0.18.0
|
||||
serve-static: 1.15.0
|
||||
setprototypeof: 1.2.0
|
||||
statuses: 2.0.1
|
||||
type-is: 1.6.18
|
||||
utils-merge: 1.0.1
|
||||
vary: 1.1.2
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
finalhandler@1.2.0:
|
||||
dependencies:
|
||||
debug: 2.6.9
|
||||
encodeurl: 1.0.2
|
||||
escape-html: 1.0.3
|
||||
on-finished: 2.4.1
|
||||
parseurl: 1.3.3
|
||||
statuses: 2.0.1
|
||||
unpipe: 1.0.0
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
forwarded@0.2.0: {}
|
||||
|
||||
fresh@0.5.2: {}
|
||||
|
||||
function-bind@1.1.1: {}
|
||||
|
||||
get-intrinsic@1.2.1:
|
||||
dependencies:
|
||||
function-bind: 1.1.1
|
||||
has: 1.0.3
|
||||
has-proto: 1.0.1
|
||||
has-symbols: 1.0.3
|
||||
|
||||
has-proto@1.0.1: {}
|
||||
|
||||
has-symbols@1.0.3: {}
|
||||
|
||||
has@1.0.3:
|
||||
dependencies:
|
||||
function-bind: 1.1.1
|
||||
|
||||
http-errors@2.0.0:
|
||||
dependencies:
|
||||
depd: 2.0.0
|
||||
inherits: 2.0.4
|
||||
setprototypeof: 1.2.0
|
||||
statuses: 2.0.1
|
||||
toidentifier: 1.0.1
|
||||
|
||||
iconv-lite@0.4.24:
|
||||
dependencies:
|
||||
safer-buffer: 2.1.2
|
||||
|
||||
inherits@2.0.4: {}
|
||||
|
||||
ipaddr.js@1.9.1: {}
|
||||
|
||||
media-typer@0.3.0: {}
|
||||
|
||||
merge-descriptors@1.0.1: {}
|
||||
|
||||
methods@1.1.2: {}
|
||||
|
||||
mime-db@1.52.0: {}
|
||||
|
||||
mime-types@2.1.35:
|
||||
dependencies:
|
||||
mime-db: 1.52.0
|
||||
|
||||
mime@1.6.0: {}
|
||||
|
||||
ms@2.0.0: {}
|
||||
|
||||
ms@2.1.3: {}
|
||||
|
||||
negotiator@0.6.3: {}
|
||||
|
||||
object-inspect@1.12.3: {}
|
||||
|
||||
on-finished@2.4.1:
|
||||
dependencies:
|
||||
ee-first: 1.1.1
|
||||
|
||||
parseurl@1.3.3: {}
|
||||
|
||||
path-to-regexp@0.1.7: {}
|
||||
|
||||
proxy-addr@2.0.7:
|
||||
dependencies:
|
||||
forwarded: 0.2.0
|
||||
ipaddr.js: 1.9.1
|
||||
|
||||
qs@6.11.0:
|
||||
dependencies:
|
||||
side-channel: 1.0.4
|
||||
|
||||
range-parser@1.2.1: {}
|
||||
|
||||
raw-body@2.5.1:
|
||||
dependencies:
|
||||
bytes: 3.1.2
|
||||
http-errors: 2.0.0
|
||||
iconv-lite: 0.4.24
|
||||
unpipe: 1.0.0
|
||||
|
||||
safe-buffer@5.2.1: {}
|
||||
|
||||
safer-buffer@2.1.2: {}
|
||||
|
||||
send@0.18.0:
|
||||
dependencies:
|
||||
debug: 2.6.9
|
||||
depd: 2.0.0
|
||||
destroy: 1.2.0
|
||||
encodeurl: 1.0.2
|
||||
escape-html: 1.0.3
|
||||
etag: 1.8.1
|
||||
fresh: 0.5.2
|
||||
http-errors: 2.0.0
|
||||
mime: 1.6.0
|
||||
ms: 2.1.3
|
||||
on-finished: 2.4.1
|
||||
range-parser: 1.2.1
|
||||
statuses: 2.0.1
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
serve-static@1.15.0:
|
||||
dependencies:
|
||||
encodeurl: 1.0.2
|
||||
escape-html: 1.0.3
|
||||
parseurl: 1.3.3
|
||||
send: 0.18.0
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
setprototypeof@1.2.0: {}
|
||||
|
||||
side-channel@1.0.4:
|
||||
dependencies:
|
||||
call-bind: 1.0.2
|
||||
get-intrinsic: 1.2.1
|
||||
object-inspect: 1.12.3
|
||||
|
||||
statuses@2.0.1: {}
|
||||
|
||||
toidentifier@1.0.1: {}
|
||||
|
||||
type-is@1.6.18:
|
||||
dependencies:
|
||||
media-typer: 0.3.0
|
||||
mime-types: 2.1.35
|
||||
|
||||
unpipe@1.0.0: {}
|
||||
|
||||
utils-merge@1.0.1: {}
|
||||
|
||||
vary@1.1.2: {}
|
||||
|
||||
ws@8.11.0: {}
|
||||
@@ -0,0 +1,45 @@
|
||||
<!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" />
|
||||
|
||||
<title>Host - Jaka To Melodia</title>
|
||||
<script src="/socket.js"></script>
|
||||
<style></style>
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
<button onclick="socket.send('host', {action: 'clear'} )">clear</button>
|
||||
<button onclick="socket.send('host', {action: 'play'} )">play</button>
|
||||
<button onclick="socket.send('host', {action: 'pause'} )">pause</button>
|
||||
<button onclick="socket.send('host', {action: 'next'} )">next</button>
|
||||
</div>
|
||||
|
||||
<br />
|
||||
|
||||
<div>
|
||||
<button onclick="socket.send('host', {action: 'points', points: 0.5} )">
|
||||
+.5
|
||||
</button>
|
||||
<button onclick="socket.send('host', {action: 'points', points: 1} )">
|
||||
+1
|
||||
</button>
|
||||
<button onclick="socket.send('host', {action: 'points', points: 2} )">
|
||||
+2
|
||||
</button>
|
||||
<button onclick="socket.send('host', {action: 'nextPlayer'} )">
|
||||
next player
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<br />
|
||||
|
||||
<div id=""></div>
|
||||
|
||||
<script>
|
||||
const socket = new Socket('host')
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,24 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Document</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>
|
||||
<a href="/player.html">Player</a>
|
||||
</h1>
|
||||
|
||||
<h1>
|
||||
<a href="/host.html">Host</a>
|
||||
</h1>
|
||||
|
||||
<h1>
|
||||
<a href="/tv.html">TV</a>
|
||||
</h1>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,57 @@
|
||||
.loader {
|
||||
--outer: var(--fgcolor);
|
||||
--inner: var(--bgcolor);
|
||||
filter: brightness(1.5);
|
||||
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
border-radius: 50%;
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
border: 3px solid;
|
||||
border-color: var(--fgcolor) var(--fgcolor) transparent transparent;
|
||||
box-sizing: border-box;
|
||||
animation: rotation 1s linear infinite;
|
||||
}
|
||||
.loader::after,
|
||||
.loader::before {
|
||||
content: '';
|
||||
box-sizing: border-box;
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
margin: auto;
|
||||
border: 3px solid;
|
||||
border-color: transparent transparent var(--bgcolor) var(--bgcolor);
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border-radius: 50%;
|
||||
box-sizing: border-box;
|
||||
animation: rotationBack 0.5s linear infinite;
|
||||
transform-origin: center center;
|
||||
}
|
||||
.loader::before {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border-color: var(--fgcolor) var(--fgcolor) transparent transparent;
|
||||
animation: rotation 1.5s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes rotation {
|
||||
0% {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
100% {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
@keyframes rotationBack {
|
||||
0% {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
100% {
|
||||
transform: rotate(-360deg);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
.patterned {
|
||||
background: conic-gradient(at 10% 50%, #0000 75%, var(--fgcolor) 0),
|
||||
conic-gradient(at 10% 50%, #0000 75%, var(--fgcolor) 0)
|
||||
calc(1 * var(--pattern)) calc(3 * var(--pattern)),
|
||||
conic-gradient(at 10% 50%, #0000 75%, var(--fgcolor) 0)
|
||||
calc(2 * var(--pattern)) calc(1 * var(--pattern)),
|
||||
conic-gradient(at 10% 50%, #0000 75%, var(--fgcolor) 0)
|
||||
calc(3 * var(--pattern)) calc(4 * var(--pattern)),
|
||||
conic-gradient(at 10% 50%, #0000 75%, var(--fgcolor) 0)
|
||||
calc(4 * var(--pattern)) calc(2 * var(--pattern)),
|
||||
conic-gradient(at 50% 10%, #0000 75%, var(--fgcolor) 0) 0
|
||||
calc(4 * var(--pattern)),
|
||||
conic-gradient(at 50% 10%, #0000 75%, var(--fgcolor) 0)
|
||||
calc(1 * var(--pattern)) calc(2 * var(--pattern)),
|
||||
conic-gradient(at 50% 10%, #0000 75%, var(--fgcolor) 0)
|
||||
calc(2 * var(--pattern)) 0,
|
||||
conic-gradient(at 50% 10%, #0000 75%, var(--fgcolor) 0)
|
||||
calc(3 * var(--pattern)) calc(3 * var(--pattern)),
|
||||
conic-gradient(at 50% 10%, #0000 75%, var(--fgcolor) 0)
|
||||
calc(4 * var(--pattern)) calc(1 * var(--pattern)),
|
||||
var(--bgcolor);
|
||||
background-size: calc(5 * var(--pattern)) calc(5 * var(--pattern));
|
||||
|
||||
backdrop-filter: blur(5px);
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
<!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" />
|
||||
|
||||
<title>Player - Jaka To Melodia</title>
|
||||
<script src="/socket.js"></script>
|
||||
<script src="/wakelock.js"></script>
|
||||
|
||||
<link rel="stylesheet" href="/pattern.css" />
|
||||
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100vh;
|
||||
justify-content: center;
|
||||
overflow: hidden;
|
||||
|
||||
--fgcolor: #e7213b;
|
||||
--bgcolor: #b93834;
|
||||
--pattern: 22px;
|
||||
}
|
||||
|
||||
button {
|
||||
width: calc(100vw - 2rem);
|
||||
height: calc(100vw - 2rem);
|
||||
|
||||
border-radius: 100%;
|
||||
margin: 1rem;
|
||||
background-color: #ee1020;
|
||||
user-select: none;
|
||||
border-width: 4px;
|
||||
}
|
||||
|
||||
button > img {
|
||||
height: 50%;
|
||||
transition: 0.2s;
|
||||
}
|
||||
|
||||
button:active > img {
|
||||
height: 60%;
|
||||
transform: skewx(-49deg);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
#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" />
|
||||
|
||||
<button>
|
||||
<img src="twerk.gif" alt="doopa" />
|
||||
</button>
|
||||
|
||||
<script>
|
||||
const socket = new Socket('player')
|
||||
|
||||
requestWakeLock()
|
||||
|
||||
let nodeButton = document.querySelector('button'),
|
||||
nodeNick = document.querySelector('#nick'),
|
||||
nodePoints = document.querySelector('#points')
|
||||
|
||||
socket.send('nick', localStorage.getItem('nick'))
|
||||
nodeNick.value = localStorage.getItem('nick')
|
||||
|
||||
function enter() {
|
||||
socket.send('enter')
|
||||
}
|
||||
|
||||
nodeButton.addEventListener('mousedown', enter)
|
||||
nodeButton.addEventListener('touchstart', enter)
|
||||
|
||||
function setNick(e) {
|
||||
let nick = e.target.value.trim().toLowerCase()
|
||||
socket.send('nick', nick)
|
||||
localStorage.setItem('nick', nick)
|
||||
}
|
||||
|
||||
nodeNick.addEventListener(
|
||||
'keydown',
|
||||
(e) => e.keyCode === 13 && setNick(e)
|
||||
)
|
||||
nodeNick.addEventListener('blur', setNick)
|
||||
|
||||
socket.bind((data) => {
|
||||
if (data.points) {
|
||||
nodePoints.textContent = data.points
|
||||
}
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,71 @@
|
||||
function playSound() {
|
||||
new Audio('/pop.mp3').play()
|
||||
}
|
||||
|
||||
// var send = {
|
||||
// host: (payload = {}) => {
|
||||
// payload.whoami = 'host'
|
||||
// _send(payload)
|
||||
// },
|
||||
// tv: (payload = {}) => {
|
||||
// payload.whoami = 'tv'
|
||||
// _send(payload)
|
||||
// },
|
||||
// player: (payload = {}) => {
|
||||
// payload.whoami = 'player'
|
||||
// _send(payload)
|
||||
// },
|
||||
// }
|
||||
|
||||
class Socket {
|
||||
deffered = []
|
||||
|
||||
constructor(whoami) {
|
||||
this.ws = new WebSocket('ws://' + location.hostname + ':2501')
|
||||
|
||||
this.ws.onopen = () => {
|
||||
this._send({ whoami })
|
||||
|
||||
if (this.deffered.length) {
|
||||
this.deffered.forEach((payload) => {
|
||||
this._send(payload)
|
||||
})
|
||||
this.deffered = []
|
||||
}
|
||||
}
|
||||
|
||||
this.ws.onclose = () => {
|
||||
// alert('connection lost')
|
||||
location.reload()
|
||||
}
|
||||
}
|
||||
|
||||
_send(payload) {
|
||||
// check if ws is ready
|
||||
if (this.ws.readyState != 1) {
|
||||
this.deffered.push(payload)
|
||||
} else {
|
||||
this.ws.send(JSON.stringify(payload))
|
||||
}
|
||||
}
|
||||
|
||||
send(type, payload) {
|
||||
if (type == 'host') {
|
||||
this._send({ host: payload })
|
||||
}
|
||||
if (type == 'nick') {
|
||||
this._send({ nick: payload })
|
||||
}
|
||||
if (type == 'enter') {
|
||||
this._send({ entry: true })
|
||||
}
|
||||
}
|
||||
|
||||
bind(callback) {
|
||||
this.ws.onmessage = (e) => {
|
||||
let payload = JSON.parse(e.data)
|
||||
console.info(payload)
|
||||
callback(payload)
|
||||
}
|
||||
}
|
||||
}
|
||||
+179
@@ -0,0 +1,179 @@
|
||||
<!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" />
|
||||
|
||||
<title>TV - Jaka To Melodia</title>
|
||||
<script src="/socket.js"></script>
|
||||
<script src="/wakelock.js"></script>
|
||||
|
||||
<link rel="stylesheet" href="/pattern.css" />
|
||||
<link rel="stylesheet" href="/loader.css" />
|
||||
|
||||
<style>
|
||||
body {
|
||||
height: 100vh;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-direction: column;
|
||||
--pattern: 22px;
|
||||
}
|
||||
|
||||
.status {
|
||||
font-size: 150px;
|
||||
}
|
||||
|
||||
.queue {
|
||||
font-size: 30px;
|
||||
font-family: monospace;
|
||||
text-align: left;
|
||||
width: 80vw;
|
||||
counter-reset: poz;
|
||||
}
|
||||
|
||||
.queue > .nick {
|
||||
padding: 0.1em 0.25em 0.2em;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.queue > .nick::before {
|
||||
counter-increment: poz;
|
||||
content: '#' counter(poz) ' ';
|
||||
font-weight: bold;
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
.queue > img {
|
||||
height: 10vh;
|
||||
}
|
||||
|
||||
.nick.active {
|
||||
background-color: #fff6;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
#loader {
|
||||
margin: auto;
|
||||
display: block;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body class="patterned">
|
||||
<div id="status" class="status">⏯</div>
|
||||
|
||||
<span id="spinner" class="loader"></span>
|
||||
|
||||
<div id="queue" class="queue"></div>
|
||||
|
||||
<script>
|
||||
requestWakeLock()
|
||||
|
||||
const statuses = {
|
||||
paused: '⏸',
|
||||
playing: '⏵',
|
||||
waiting: '⏯',
|
||||
},
|
||||
colors = {
|
||||
playing: '#00ff58',
|
||||
paused: '#1b2660',
|
||||
waiting: '#2f3d40',
|
||||
}
|
||||
|
||||
let nodeStatus = document.querySelector('#status'),
|
||||
nodeSpinner = document.querySelector('#spinner'),
|
||||
nodeQueue = document.querySelector('#queue')
|
||||
|
||||
function setStatus(status = 'waiting') {
|
||||
const patternColors = {
|
||||
playing: { fg: '#18dd5c', bg: '#1bc957' },
|
||||
paused: { fg: '#28357d', bg: '#22307b' },
|
||||
waiting: { fg: '#364d69', bg: '#425b79' },
|
||||
}
|
||||
|
||||
console.info('status', status)
|
||||
|
||||
nodeStatus.innerHTML = statuses[status]
|
||||
document.body.style.setProperty('--fgcolor', patternColors[status].fg)
|
||||
document.body.style.setProperty('--bgcolor', patternColors[status].bg)
|
||||
}
|
||||
|
||||
function setQueue(queue, active = 0) {
|
||||
nodeQueue.innerHTML = queue
|
||||
.map(
|
||||
(nick, i) =>
|
||||
`<div class="nick ${i == active && 'active'}">${nick}</div>`
|
||||
)
|
||||
.join('')
|
||||
}
|
||||
|
||||
function showSpinner(show = true) {
|
||||
nodeSpinner.style.display = show ? 'block' : 'none'
|
||||
}
|
||||
|
||||
const socket = new Socket('tv')
|
||||
|
||||
var localStatus = 'waiting',
|
||||
localQueue = [],
|
||||
localActive = 0
|
||||
|
||||
setStatus()
|
||||
|
||||
socket.bind((data) => {
|
||||
if (data.status != localStatus) {
|
||||
localStatus = data.status
|
||||
setStatus(data.status)
|
||||
}
|
||||
|
||||
if (data.active == null) {
|
||||
setQueue([])
|
||||
showSpinner()
|
||||
}
|
||||
|
||||
if (data.queue.length > 0) {
|
||||
setQueue(data.queue, data.active)
|
||||
showSpinner(false)
|
||||
}
|
||||
|
||||
// nodeStatus.innerHTML = statuses[data.status ?? 'waiting']
|
||||
// document.body.style.background = colors[data.status ?? 'waiting']
|
||||
// document.body.style.setProperty(
|
||||
// '--fgcolor',
|
||||
// patternColors[data.status ?? 'waiting'].fg
|
||||
// )
|
||||
// document.body.style.setProperty(
|
||||
// '--bgcolor',
|
||||
// patternColors[data.status ?? 'waiting'].bg
|
||||
// )
|
||||
})
|
||||
|
||||
// ws.onopen = () => {
|
||||
// // clear()
|
||||
// // send.tv()
|
||||
|
||||
// ws.onmessage = (data) => {
|
||||
// // let stats = JSON.parse(data.data)
|
||||
// // if (stats.clear) {
|
||||
// // clear()
|
||||
// // return
|
||||
// // }
|
||||
// // if (stats.queue.length > 0)
|
||||
// // nodeList.innerHTML = stats.queue
|
||||
// // .map(
|
||||
// // (nick) =>
|
||||
// // `<div class="nick ${
|
||||
// // stats.active == nick && 'active'
|
||||
// // }">${nick}</div>`
|
||||
// // )
|
||||
// // .join('')
|
||||
// // nodePlaypause.innerHTML = statuses[stats.status ?? 'waiting']
|
||||
// // document.body.style.background = colors[stats.status ?? 'waiting']
|
||||
// }
|
||||
// }
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,28 @@
|
||||
// The wake lock sentinel.
|
||||
let wakeLock = null
|
||||
|
||||
// Function that attempts to request a wake lock.
|
||||
const requestWakeLock = async () => {
|
||||
try {
|
||||
wakeLock = await navigator.wakeLock.request('screen')
|
||||
wakeLock.addEventListener('release', () => {
|
||||
console.log('Wake Lock was released')
|
||||
})
|
||||
console.log('Wake Lock is active')
|
||||
} catch (err) {
|
||||
console.error(`${err.name}, ${err.message}`)
|
||||
}
|
||||
}
|
||||
|
||||
// Function that attempts to release the wake lock.
|
||||
const releaseWakeLock = async () => {
|
||||
if (!wakeLock) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
await wakeLock.release()
|
||||
wakeLock = null
|
||||
} catch (err) {
|
||||
console.error(`${err.name}, ${err.message}`)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import { WebSocketServer } from 'ws'
|
||||
import express from 'express'
|
||||
|
||||
import env from './env.js'
|
||||
import Client from './Client.js'
|
||||
|
||||
const app = express()
|
||||
|
||||
app.use(express.static('public'))
|
||||
|
||||
app.listen(env.HTTP_PORT, () =>
|
||||
console.log(`http: listening on ${env.HTTP_PORT}`)
|
||||
)
|
||||
|
||||
const wss = new WebSocketServer({
|
||||
port: env.WS_PORT,
|
||||
}).on('listening', () => console.log(`ws: listening on ${env.WS_PORT}`))
|
||||
|
||||
wss.on('connection', (ws, req) => new Client(ws, req))
|
||||
Reference in new issue
Block a user