mirror of https://github.com/Trivernis/whooshy.git
Back- and frontend improvements
- added graphql backend - added mobile support for frontend - improved username form - improved access to html-elements - added toggle to bingo fieldspull/3/head
parent
5cde198890
commit
1e96cbe68e
@ -0,0 +1,90 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var app = require('../app');
|
||||
var debug = require('debug')('whooshy:server');
|
||||
var http = require('http');
|
||||
|
||||
/**
|
||||
* Get port from environment and store in Express.
|
||||
*/
|
||||
|
||||
var port = normalizePort(process.env.PORT || '3000');
|
||||
app.set('port', port);
|
||||
|
||||
/**
|
||||
* Create HTTP server.
|
||||
*/
|
||||
|
||||
var server = http.createServer(app);
|
||||
|
||||
/**
|
||||
* Listen on provided port, on all network interfaces.
|
||||
*/
|
||||
|
||||
server.listen(port);
|
||||
server.on('error', onError);
|
||||
server.on('listening', onListening);
|
||||
|
||||
/**
|
||||
* Normalize a port into a number, string, or false.
|
||||
*/
|
||||
|
||||
function normalizePort(val) {
|
||||
var port = parseInt(val, 10);
|
||||
|
||||
if (isNaN(port)) {
|
||||
// named pipe
|
||||
return val;
|
||||
}
|
||||
|
||||
if (port >= 0) {
|
||||
// port number
|
||||
return port;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Event listener for HTTP server "error" event.
|
||||
*/
|
||||
|
||||
function onError(error) {
|
||||
if (error.syscall !== 'listen') {
|
||||
throw error;
|
||||
}
|
||||
|
||||
var bind = typeof port === 'string'
|
||||
? 'Pipe ' + port
|
||||
: 'Port ' + port;
|
||||
|
||||
// handle specific listen errors with friendly messages
|
||||
switch (error.code) {
|
||||
case 'EACCES':
|
||||
console.error(bind + ' requires elevated privileges');
|
||||
process.exit(1);
|
||||
break;
|
||||
case 'EADDRINUSE':
|
||||
console.error(bind + ' is already in use');
|
||||
process.exit(1);
|
||||
break;
|
||||
default:
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Event listener for HTTP server "listening" event.
|
||||
*/
|
||||
|
||||
function onListening() {
|
||||
var addr = server.address();
|
||||
var bind = typeof addr === 'string'
|
||||
? 'pipe ' + addr
|
||||
: 'port ' + addr.port;
|
||||
debug('Listening on ' + bind);
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
type BingoMutation {
|
||||
|
||||
# creates a game of bingo and returns the game id
|
||||
createGame(words: [String!]!, size: Int = 3): BingoGame
|
||||
|
||||
# submit a bingo to the active game session
|
||||
submitBingo: Boolean
|
||||
|
||||
# toggle a word (heared or not) on the sessions grid
|
||||
toggleWord(word: String, base64Word: String): BingoGrid
|
||||
|
||||
# set the username of the current session
|
||||
setUsername(username: String!): BingoUser
|
||||
}
|
||||
|
||||
type BingoQuery {
|
||||
|
||||
# Returns the currently active bingo game
|
||||
gameInfo(id: ID): BingoGame
|
||||
|
||||
# If there is a bingo in the fields.
|
||||
checkBingo: Boolean
|
||||
|
||||
# Returns the grid of the active bingo game
|
||||
activeGrid: BingoGrid
|
||||
}
|
||||
|
||||
type BingoGame {
|
||||
|
||||
# the id of the bingo game
|
||||
id: ID!
|
||||
|
||||
# the words used in the bingo game
|
||||
words: [String]!
|
||||
|
||||
# the size of the square-grid
|
||||
gridSize: Int
|
||||
|
||||
# an array of players active in the bingo game
|
||||
players(id: ID): [BingoUser]
|
||||
|
||||
# the player-ids that scored a bingo
|
||||
bingos: [String]!
|
||||
|
||||
# if the game has already finished
|
||||
finished: Boolean
|
||||
}
|
||||
|
||||
type BingoUser {
|
||||
|
||||
# the id of the bingo user
|
||||
id: ID!
|
||||
|
||||
# the id of the currently active bingo game
|
||||
game: ID
|
||||
|
||||
# the name of the user
|
||||
username: String
|
||||
}
|
||||
|
||||
type BingoGrid {
|
||||
|
||||
# the grid represented as string matrix
|
||||
wordGrid: [[String]]!
|
||||
|
||||
# the grid represented as bingo field matrix
|
||||
fieldGrid: [[BingoField]]!
|
||||
|
||||
# if there is a bingo
|
||||
bingo: Boolean
|
||||
}
|
||||
|
||||
type BingoField {
|
||||
|
||||
# the word contained in the bingo field
|
||||
word: String
|
||||
|
||||
# if the word was already heared
|
||||
submitted: Boolean!
|
||||
|
||||
base64Word: String
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
# import BingoMutation from 'bingo.graphql'
|
||||
# import BingoQuery from 'bingo.graphql'
|
||||
|
||||
type Query {
|
||||
time: String
|
||||
bingo: BingoQuery
|
||||
}
|
||||
|
||||
type Mutation {
|
||||
bingo: BingoMutation
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,13 +1,15 @@
|
||||
include bingo-layout
|
||||
|
||||
block content
|
||||
if username === 'anonymous'
|
||||
div(class='greyover')
|
||||
div(id='username-form')
|
||||
input(type='text', id='username-input', placeholder='username', value=username)
|
||||
input(type='text', id='username-input', placeholder=username)
|
||||
button(onclick='submitUsername()') Set Username
|
||||
button(id='bingo-button' onclick='submitBingo()', class='hidden') Bingo!
|
||||
div(id='words-container')
|
||||
each val in grid
|
||||
div(class='bingo-word-row')
|
||||
each word in val
|
||||
div(class='bingo-word-panel', onclick=`submitWord('${word}')`, b-word=word, b-sub='false')
|
||||
span= word
|
||||
each field in val
|
||||
div(class='bingo-word-panel', onclick=`submitWord('${field.base64Word}')`, b-word=field.base64Word, b-sub='false')
|
||||
span= field.word
|
||||
button(id='bingo-button' onclick='submitBingo()', class='hidden') Bingo!
|
||||
|
Loading…
Reference in New Issue