Commit 2d6cfa42 authored by DoNaTio s.r.o.'s avatar DoNaTio s.r.o.
Browse files

disconnect button

parent 016548b8
......@@ -17,24 +17,6 @@
</entry>
</component>
<component name="ProjectRootManager" version="2" />
<component name="SvnConfiguration" maxAnnotateRevisions="500" myUseAcceleration="nothing" myAutoUpdateAfterCommit="false" cleanupOnStartRun="false" SSL_PROTOCOLS="sslv3">
<option name="USER" value="" />
<option name="PASSWORD" value="" />
<option name="mySSHConnectionTimeout" value="30000" />
<option name="mySSHReadTimeout" value="30000" />
<option name="LAST_MERGED_REVISION" />
<option name="MERGE_DRY_RUN" value="false" />
<option name="MERGE_DIFF_USE_ANCESTRY" value="true" />
<option name="UPDATE_LOCK_ON_DEMAND" value="false" />
<option name="IGNORE_SPACES_IN_MERGE" value="false" />
<option name="CHECK_NESTED_FOR_QUICK_MERGE" value="false" />
<option name="IGNORE_SPACES_IN_ANNOTATE" value="true" />
<option name="SHOW_MERGE_SOURCES_IN_ANNOTATE" value="true" />
<option name="FORCE_UPDATE" value="false" />
<option name="IGNORE_EXTERNALS" value="false" />
<configuration useDefault="false">$USER_HOME$/.subversion</configuration>
<myIsUseDefaultProxy>false</myIsUseDefaultProxy>
</component>
<component name="masterDetails">
<states>
<state key="ScopeChooserConfigurable.UI">
......
......@@ -56,7 +56,8 @@ io.on('connection', function (socket) {
});
// when the user disconnects.. perform this
socket.on('disconnect', function () {
socket.on('disconnectUser', function (data) {
console.log(data);
//// remove the username from global usernames list
//if (addedUser) {
// delete usernames[socket.username];
......
/**
* Ball
* @type {{x: number, y: number, r: number, c: string, vx: number, vy: number, draw: Function}}
*/
module.exports = {
x: 50,
y: 50,
r: 5,
c: "white",
vx: 4,
vy: 8,
ctx,
init: function(){
var canvas = document.getElementById('table');
ctx = canvas.getContext('2d');
ctx.beginPath();
ctx.arc(100, 10, 2, 0, Math.PI*2, true);
ctx.closePath();
ctx.fill();
},
// Function for drawing ball on canvas
draw: function() {
ctx.beginPath();
ctx.fillStyle = this.c;
ctx.arc(this.x, this.y, this.r, 0, Math.PI*2, false);
ctx.fill();
}
};
\ No newline at end of file
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>PiPo</title>
<link rel="stylesheet" href="style.css">
<meta charset="UTF-8">
<title>PiPo</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
......@@ -15,22 +15,26 @@
<div class="racket racket5"></div>
<div class="racket racket6"></div>
</div>
<ul class="pages">
<ul class="pages">
<li class="chat page">
<div class="chatArea">
<ul class="messages"></ul>
</div>
<div class="chatArea">
<a class="disconnectBtn" href="#">Logout</a>
<ul class="messages"></ul>
<canvas id="table"></canvas>
</div>
</li>
<li class="login page">
<div class="form">
<h3 class="title">What's your nickname?</h3>
<input class="usernameInput" type="text" maxlength="14" />
</div>
<div class="form">
<h3 class="title">What's your nickname?</h3>
<input class="usernameInput" type="text" maxlength="14"/>
</div>
</li>
</ul>
</ul>
<script src="https://code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="/socket.io/socket.io.js"></script>
<script src="/main.js"></script>
<script src="https://code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="/socket.io/socket.io.js"></script>
<script src="/main.js"></script>
</body>
</html>
\ No newline at end of file
......@@ -64,8 +64,6 @@ $(function () {
});
$(document).mousemove(function(event){
//console.log('user');
//console.log(user);
var d = {
id:user.id,
x:event.pageX,
......@@ -91,8 +89,6 @@ $(function () {
socket.on('show racket', function(data){
//console.log(data);
//var racket = JSON.parse(data.playersCollection);
drawRacket(data);
})
// Whenever the server emits 'user joined', log it in the chat body
......@@ -108,7 +104,15 @@ $(function () {
});
function drawRacket(data){
var id = data.id;
$('div.racket'+id).css({ left:data.x, top: data.y});
$('div.racket' + data.id).css({ left:data.x + 20, top: data.y + 20});
}
$('.disconnectBtn').click(function(){
socket.emit('disconnectUser', user);
});
});
......@@ -155,6 +155,7 @@ ul {
top:0;
width: 30px;
height: 30px;
z-index: 99999;
}
.racket1{ background: url(images/racket.png) no-repeat; }
.racket2{ background: url(images/racket-green.png) no-repeat; }
......@@ -162,3 +163,6 @@ ul {
.racket4{ background: url(images/azure.png) no-repeat; }
.racket5{ background: pink; }
.racket6{ background: gray; }
#table{width: 800px; height: 400px; background-color: green;}
\ No newline at end of file
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