|
@ -69,6 +69,7 @@ angular.module('starter.controllers', []) |
|
|
localStorage.setItem("c_username", $scope.loginData.username); |
|
|
localStorage.setItem("c_username", $scope.loginData.username); |
|
|
localStorage.setItem("c_token", response.data.token); |
|
|
localStorage.setItem("c_token", response.data.token); |
|
|
localStorage.setItem("c_userid", response.data.userid); |
|
|
localStorage.setItem("c_userid", response.data.userid); |
|
|
|
|
|
localStorage.setItem("c_avatar", response.data.avatar); |
|
|
}else{ |
|
|
}else{ |
|
|
console.log("login failed"); |
|
|
console.log("login failed"); |
|
|
} |
|
|
} |
|
@ -109,6 +110,8 @@ angular.module('starter.controllers', []) |
|
|
$scope.logout = function(){ |
|
|
$scope.logout = function(){ |
|
|
localStorage.removeItem("c_username"); |
|
|
localStorage.removeItem("c_username"); |
|
|
localStorage.removeItem("c_token"); |
|
|
localStorage.removeItem("c_token"); |
|
|
|
|
|
localStorage.removeItem("c_avatar"); |
|
|
|
|
|
localStorage.removeItem("c_userid"); |
|
|
$window.location.reload(true); |
|
|
$window.location.reload(true); |
|
|
}; |
|
|
}; |
|
|
}) |
|
|
}) |
|
@ -374,7 +377,8 @@ angular.module('starter.controllers', []) |
|
|
$scope.newjoin={ |
|
|
$scope.newjoin={ |
|
|
travelId: $stateParams.travelId, |
|
|
travelId: $stateParams.travelId, |
|
|
joinedUserId: localStorage.getItem("c_userid"), |
|
|
joinedUserId: localStorage.getItem("c_userid"), |
|
|
joinedUsername: localStorage.getItem("c_username") |
|
|
|
|
|
|
|
|
joinedUsername: localStorage.getItem("c_username"), |
|
|
|
|
|
joinedAvatar: localStorage.getItem("c_avatar") |
|
|
}; |
|
|
}; |
|
|
$http({ |
|
|
$http({ |
|
|
url: urlapi + 'travels/join/' + $stateParams.travelId, |
|
|
url: urlapi + 'travels/join/' + $stateParams.travelId, |
|
@ -391,6 +395,9 @@ angular.module('starter.controllers', []) |
|
|
// failed
|
|
|
// failed
|
|
|
}); |
|
|
}); |
|
|
}; |
|
|
}; |
|
|
|
|
|
$scope.unjoinTravel = function(){ |
|
|
|
|
|
console.log("unjoin"); |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
/* adding comment */ |
|
|
/* adding comment */ |
|
|
$scope.doingNewComment=false; |
|
|
$scope.doingNewComment=false; |
|
@ -405,6 +412,7 @@ angular.module('starter.controllers', []) |
|
|
$scope.doNewComment = function() { |
|
|
$scope.doNewComment = function() { |
|
|
$scope.newComment.commentUserId=localStorage.getItem("c_userid"); |
|
|
$scope.newComment.commentUserId=localStorage.getItem("c_userid"); |
|
|
$scope.newComment.commentUsername=localStorage.getItem("c_username"); |
|
|
$scope.newComment.commentUsername=localStorage.getItem("c_username"); |
|
|
|
|
|
$scope.newComment.commentAvatar=localStorage.getItem("c_avatar"); |
|
|
console.log($scope.newComment); |
|
|
console.log($scope.newComment); |
|
|
$http({ |
|
|
$http({ |
|
|
url: urlapi + 'travels/comment/' + $stateParams.travelId, |
|
|
url: urlapi + 'travels/comment/' + $stateParams.travelId, |
|
@ -425,6 +433,21 @@ console.log($scope.newComment); |
|
|
}); |
|
|
}); |
|
|
$scope.closeNewComment(); |
|
|
$scope.closeNewComment(); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$scope.arrayObjectIndexOf = function(myArray, searchTerm, property) { |
|
|
|
|
|
if(myArray) |
|
|
|
|
|
{ |
|
|
|
|
|
for(var i = 0, len = myArray.length; i < len; i++) { |
|
|
|
|
|
if (myArray[i][property] === searchTerm){ |
|
|
|
|
|
//console.log("i: " + i);
|
|
|
|
|
|
return i; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
//console.log("i: -1");
|
|
|
|
|
|
return -1; |
|
|
|
|
|
} |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
.controller('UsersCtrl', function($scope, $http, $ionicModal, $timeout) { |
|
|
.controller('UsersCtrl', function($scope, $http, $ionicModal, $timeout) { |
|
|