-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
maddie
committed
Oct 13, 2017
1 parent
ea3fb5d
commit 8d2ff5f
Showing
11 changed files
with
105 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Naprawdę bardzo fajna gra! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
angular.module('app.loader', []) | ||
.provider('ioLoader', function() { | ||
this.scriptUrl = window.location.origin+'/socket.io/socket.io.js'; | ||
|
||
this.$get = function($window, $document, $q) { | ||
var defer = $q.defer(), scriptUrl = this.scriptUrl; | ||
|
||
return { | ||
done: function(){ | ||
var onScriptLoad=function(){return defer.resolve($window.io);}; | ||
console.log("loader --- done"); | ||
if($window.io) { onScriptLoad(); } else { | ||
var scriptTag = $document[0].createElement('script'); | ||
scriptTag.type = 'text/javascript'; | ||
scriptTag.async = true; | ||
scriptTag.src = scriptUrl; | ||
scriptTag.onreadystatechange = function () { | ||
if (this.readyState === 'complete') { | ||
onScriptLoad(); | ||
} | ||
}; | ||
scriptTag.onload = onScriptLoad; | ||
$document[0].getElementsByTagName('head')[0] | ||
.appendChild(scriptTag); | ||
} | ||
return defer.promise; | ||
} | ||
}; | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
angular.module('app.network', []) | ||
.factory('mySocket', function(ioLoader, $q, socketFactory) { | ||
var mySocket = $q.defer(); | ||
ioLoader.done().then(function(io) { | ||
var myIoSocket = io.connect(window.location.hostname); | ||
var aSock = socketFactory({ | ||
ioSocket: myIoSocket | ||
}); | ||
mySocket.resolve(aSock); | ||
}); | ||
return mySocket.promise; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,15 @@ | ||
<div> | ||
<div class="panel play" | ||
<div class="panel play" | ||
ng-repeat="room in ctrl.rooms track by room.id" | ||
ui-sref='game.play({id: room.id})'> | ||
<span ng-bind="room.players.length"></span> Players | ||
</div> | ||
<div class="panel create" | ||
<div id="createButton" class="panel create" | ||
ui-sref='game.play({id: ctrl.createId()})'> | ||
<a>Create a game</a> | ||
</div> | ||
<ul id="messages"></ul> | ||
<form action=""> | ||
<input id="m" autocomplete="off" /><button>Send</button> | ||
</form> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,16 @@ | ||
angular.module('app.menu') | ||
.controller('MenuController', function() { | ||
var ctrl = this; | ||
|
||
var socket = io(); | ||
$('form').submit(function(){ | ||
socket.emit('chat message', $('#m').val()); | ||
$('#m').val(''); | ||
return false; | ||
}); | ||
socket.on('chat message', function(msg){ | ||
$('#messages').append($('<li>').text(msg)); | ||
}); | ||
socket.on('gameUpdated:add', function(data){ | ||
$('#messages').append($('<li>').text("A NEW PLAYER JOINED THE GAME: " + data.player.id)); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
angular.module('app', [ | ||
'ui.router', | ||
'btford.socket-io', | ||
'app.menu', | ||
'app.game' | ||
'app.game', | ||
'app.network', | ||
'app.loader' | ||
]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters