Skip to content

Commit

Permalink
you can now message other users without being prompted for who you ar…
Browse files Browse the repository at this point in the history
…e and who you want to message
  • Loading branch information
paulyi326 committed Jul 25, 2014
1 parent 0f0021a commit 94f314b
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 13 deletions.
3 changes: 2 additions & 1 deletion www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@

<!-- // <script src="lib/angular-socket-io/socket.js"></script> -->
<!-- // <script src="lib/angular-socket-io/mock/socket-io.js"></script> -->
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="https://cdn.socket.io/socket.io-1.0.0.js"></script>
<!--<script> var socket = io('http://ice-chat.cloudapp.net:80'); </script> -->
<script> var socket = io('http://ice-chat.cloudapp.net:80'); </script>

<script src="js/app.js"></script>
<script src='js/controllers/SignInCtrl.js'></script>
Expand Down
10 changes: 8 additions & 2 deletions www/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,14 @@ app.run(function($ionicPlatform, $rootScope, MatchLoader, Events, $http, $window
$rootScope.listenerSet = false;

// $rootScope.currentUser = $http call to get current user;
$rootScope.currentUser = {id: 714089305303365, name: 'paul'};
// socket.emit('join', {user: $rootScope.currentUser.id});
$http({
url: 'http://zavadil7.cloudapp.net/currentuser?apiKey=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhcGlLZXkiOiJ6b3VuZHNfcGVla2luZyJ9.U-2sjzUTITlXuetMgYJJFEQ6LJQ-5mx1dLwUa6xQfFI&token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJmYl9pZCI6IjcxNDA4OTMwNTMwMzM2NSJ9.VhKU-hHYhjboq882KWufV9_Mj4V9iOljM5yb_aC1wZg',
method: "GET"
}).success(function(currentUser){
console.log(currentUser);
$rootScope.currentUser = currentUser;
socket.emit('join', {user: $rootScope.currentUser.id});
});

Events.getEvents().success(function(results) {
for (var i = 0; i < results.events.length; i++) {
Expand Down
4 changes: 2 additions & 2 deletions www/js/controllers/SpecificMatchCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ app.controller('SpecificMatchCtrl', function($scope, $state, $ionicModal, $rootS
$scope.msg.msg = '';

$scope.sendMessage = function() {
// var user = prompt('who do you want to send this to?')
var currentUser = $rootScope.currentUser.fb_id;
socket.emit('chat message', {msg: $scope.msg.msg, to: $stateParams.matchId, from: currentUser});
$scope.msg.msg = '';
return false;
Expand All @@ -21,7 +21,7 @@ app.controller('SpecificMatchCtrl', function($scope, $state, $ionicModal, $rootS
$scope.displayMessage = function() {
if (!$rootScope.listenerSet) {
socket.on('chat message', function(msg){
// should only append to a somwhere holding
// should only append to somwhere holding
// only msg.sender + receiver message
var from = msg.from;
var li = $('<li>').addClass('item').text(msg.msg);
Expand Down
12 changes: 4 additions & 8 deletions www/js/services/matchLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,16 @@ app.factory('MatchLoader', function($http) {

loadAllMatches: function() {
return $http({
url: '',
url: 'http://zavadil7.cloudapp.net/allcandidates/?apiKey=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhcGlLZXkiOiJ6b3VuZHNfcGVla2luZyJ9.U-2sjzUTITlXuetMgYJJFEQ6LJQ-5mx1dLwUa6xQfFI&token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJmYl9pZCI6IjcxNDA4OTMwNTMwMzM2NSJ9.VhKU-hHYhjboq882KWufV9_Mj4V9iOljM5yb_aC1wZg',
method: "GET"
}).success(function(data){
data.reverse();
});
})
},

loadCurrentMatches: function() {
return $http({
url: '',
url: 'http://zavadil7.cloudapp.net/matches/?apiKey=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhcGlLZXkiOiJ6b3VuZHNfcGVla2luZyJ9.U-2sjzUTITlXuetMgYJJFEQ6LJQ-5mx1dLwUa6xQfFI&token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJmYl9pZCI6IjcxNDA4OTMwNTMwMzM2NSJ9.VhKU-hHYhjboq882KWufV9_Mj4V9iOljM5yb_aC1wZg',
method: "GET"
}).success(function(data){
console.log(data);
});
})
}

};
Expand Down
11 changes: 11 additions & 0 deletions www/js/services/tokenMakerReal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
app.factory('TokenMaker', function($window) {

var TokenMaker = {
eventApi: function() {
return '4IP4VYD2JFW2MOT2Y7EC';
}
};

return TokenMaker;

});

0 comments on commit 94f314b

Please sign in to comment.