Commit 58bf2c9d by Иван Кубота

connected event

parent bee4f43b
......@@ -112,7 +112,10 @@ const wss = new WebSocket.Server({
// should not be compressed.
}
});
console.log('WS LISTEN port: '+env.WS_PORT)
wss.on('connection', function connection(ws) {
ws.send(JSON.stringify({type: 'connected', data: null}));
});
console.log('WS LISTEN port: '+env.WS_PORT);
global.log = function(type, data){
try{
wss.clients.forEach(function each(client) {
......
......@@ -57,10 +57,10 @@
padding: 4px;
border-bottom: 1px solid #ccc;
}
.correct {
.question.correct {
background: #62ac6e;
}
.incorrect {
.question.incorrect {
background: #ac6862;
}
</style>
......@@ -95,7 +95,11 @@
log = document.querySelectorAll('.log')[0];
var attemptsHash = {},
questionsHashGlobal = {};
var actions = {
connected: function(data){
D.div({cls: 'msg', renderTo: log}, D.span({cls: 'msg-bold'}, 'Connected'));
},
answerQuiz: function(data){
questionsHashGlobal[data.question.id].el.className = 'question '+(data.question.correct?'correct': 'incorrect')
/*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment