Skip to content

Commit

Permalink
user interface and looks
Browse files Browse the repository at this point in the history
  • Loading branch information
sudheeshshetty committed Oct 22, 2016
1 parent 7a325b6 commit 600731f
Show file tree
Hide file tree
Showing 842 changed files with 491 additions and 370 deletions.
Empty file modified LICENSE.md
100644 → 100755
Empty file.
Empty file modified README.md
100644 → 100755
Empty file.
87 changes: 54 additions & 33 deletions controller/controller.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ module.exports = function (app,io){
var user={
"name":req.body.name,
"handle":req.body.handle,
"password":req.body.password,
"phone":req.body.phone,
"email":req.body.email,
};
Expand Down Expand Up @@ -46,19 +47,24 @@ module.exports = function (app,io){
var private=null;
var users={};
var keys={};
app.get('/login',function(req,res){

app.post('/login',function(req,res){
console.log("FUKKKK");
console.log(req.body.handle);
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader("Access-Control-Allow-Method","'GET, POST, OPTIONS, PUT, PATCH, DELETE'");
handle = req.query.handle;
models.user.findOne({"handle":handle},function(err,doc){
handle = req.body.handle;
models.user.findOne({"handle":req.body.handle, "password":req.body.password},function(err,doc){
if(err){
res.json(err);
res.send(err);
}
if(doc==null){
res.send("User has not registered");
}
else{
res.sendFile(path.resolve(__dirname+"/../views/chat1.html"));
console.log("Asas"+__dirname);
// res.sendFile(path.resolve(__dirname+"/../views/chat1.html"));
res.send("success");
}

});
Expand Down Expand Up @@ -158,36 +164,51 @@ module.exports = function (app,io){
app.post('/friend_request/confirmed',function(req,res){
console.log("friend request confirmed : "+req.body);
if(req.body.confirm=="Yes"){
models.user.update({
"handle":req.body.my_handle,
"friends.name":req.body.friend_handle
},{
'$set':{
"friends.$.status":"Friend"
}
},function(err,doc){
if(err){res.json(err);}
else{
models.user.find({
"handle" : req.body.friend_handle,
"friends.name":req.body.my_handle
},function(err,doc){
if(err){
res.json(err);
}
else if(doc.length!=0){
console.log("Friend request confirmed : "+doc.length);
console.log("Friend request confirmed : friend request already sent "+doc);
res.send("Friend request already accepted");
}
else{
models.user.update({
"handle":req.body.my_handle,
"friends.name":req.body.friend_handle
},{
'$set':{
"friends.$.status":"Friend"
}
},function(err,doc){
if(err){res.json(err);}
else{

console.log("friend request confirmed : Inside yes confirmed");
io.to(users[req.body.friend_handle]).emit('friend', req.body.my_handle);
io.to(users[req.body.my_handle]).emit('friend', req.body.friend_handle);
}
});
models.user.update({
handle:req.body.friend_handle
},{
$push:{
friends:{
name: req.body.my_handle,
status: "Friend"
}
console.log("friend request confirmed : Inside yes confirmed");
io.to(users[req.body.friend_handle]).emit('friend', req.body.my_handle);
io.to(users[req.body.my_handle]).emit('friend', req.body.friend_handle);
}
});
models.user.update({
handle:req.body.friend_handle
},{
$push:{
friends:{
name: req.body.my_handle,
status: "Friend"
}
}
},{upsert:true},function(err,doc){
if(err){res.json(err);}
// else{
// console.log(doc);
// }
});
}
},{upsert:true},function(err,doc){
if(err){res.json(err);}
// else{
// console.log(doc);
// }
});
}
else{
Expand Down
1 change: 1 addition & 0 deletions model/model.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ mongoose.connect('mongodb://localhost/mongodb');
module.exports.user=mongoose.model('User',new Schema({
name:String,
handle: String,
password: String,
phone:String,
email:String,
friends:[]
Expand Down
Empty file modified package.json
100644 → 100755
Empty file.
Empty file modified screenshots/chat.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified screenshots/online_users.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified screenshots/recieving_request.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified screenshots/sending_request.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified server.js
100644 → 100755
Empty file.
128 changes: 106 additions & 22 deletions views/angular/controller.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var app = angular.module('myapp',['ngMaterial']);
var app = angular.module('myapp',['ngMaterial','ui.router']);

app.factory('socket', ['$rootScope', function($rootScope) {
var socket = io.connect();
Expand All @@ -13,7 +13,49 @@ app.factory('socket', ['$rootScope', function($rootScope) {
};
}]);

app.controller('myController',['$scope','socket','$http','$mdDialog','$compile',function($scope,socket,$http,$mdDialog,$compile){
app.config(['$stateProvider','$urlRouterProvider',function($stateProvider,$urlRouterProvider){
$urlRouterProvider.otherwise('/');
$stateProvider
.state('login',{
url:'/',
views:{
'body':{
templateUrl:'/views/login.html',
controller:'registerController'
}
}
})
.state('loggedin',{
url:'/login',
views:{
'body':{
templateUrl:'/views/chat.html',
controller:'myController'
}
}
})
}]);




app.directive('myEnter', function () {
return function (scope, element, attrs) {
element.bind("keydown keypress", function (event) {
if(event.which === 13) {
scope.$apply(function (){
scope.$eval(attrs.myEnter);
});

event.preventDefault();
}
});
};
});


app.controller('myController',['$scope','socket','$http','$mdDialog','$compile','$location','$state',function($scope,socket,$http,$mdDialog,$compile,$location,$state){
url= location.host;
$scope.users=[];
$scope.online_friends=[];
$scope.allfriends=[];
Expand Down Expand Up @@ -75,7 +117,7 @@ app.controller('myController',['$scope','socket','$http','$mdDialog','$compile',
// }
// };

$http({method: 'POST',url:'http://localhost:8080/friend_request',data})//, headers:config})
$http({method: 'POST',url:'http://'+url+'/friend_request',data})//, headers:config})
.success(function (data) {
console.log(data)
})
Expand All @@ -96,14 +138,14 @@ app.controller('myController',['$scope','socket','$http','$mdDialog','$compile',

$mdDialog.show(confirm).then(function() {
data['confirm']="Yes";
$http({method: 'POST',url:'http://localhost:8080/friend_request/confirmed', data//, headers:{
$http({method: 'POST',url:'http://'+url+'/friend_request/confirmed', data//, headers:{
//'Content-Type': 'application/json'
//}
})
}, function() {
data['confirm']="No";

$http({method: 'POST',url:'http://localhost:8080/friend_request/confirmed', data//, headers:{
$http({method: 'POST',url:'http://'+url+'/friend_request/confirmed', data//, headers:{
// 'Content-Type': 'application/json'
//}
})
Expand Down Expand Up @@ -312,27 +354,69 @@ app.controller('myController',['$scope','socket','$http','$mdDialog','$compile',
}
}
}

//displays the popups. Displays based on the maximum number of popups that can be displayed on the current viewport width
function display_popups()
{
document.getElementById(popups[popups.length-2]+"01").className=document.getElementById(popups[popups.length-2]+"01").className.replace(/(?:^|\s)popup-box-on(?!\S)/g , '');
document.getElementById(popups[popups.length-1]+"01").className += "popup-box-on";
}
//
// //displays the popups. Displays based on the maximum number of popups that can be displayed on the current viewport width
// function display_popups()
// {
// document.getElementById(popups[popups.length-2]+"01").className=document.getElementById(popups[popups.length-2]+"01").className.replace(/(?:^|\s)popup-box-on(?!\S)/g , '');
// document.getElementById(popups[popups.length-1]+"01").className += "popup-box-on";
// }

}]);

app.service('encrypt', function() {
this.hash =function(str){
h = 7;
letters = "abcdefghijklmnopqrstuvwxyz-_1234567890@!#$%&*.,"
for (var i=0;i<str.length;i++){
h = (h * 37 + letters.indexOf(str[i]))
}
return h
}
});

app.directive('myEnter', function () {
return function (scope, element, attrs) {
element.bind("keydown keypress", function (event) {
if(event.which === 13) {
scope.$apply(function (){
scope.$eval(attrs.myEnter);
});
app.controller('registerController',['$scope','encrypt','$http','$state',function($scope,encrypt,$http,$state){
url= location.host;

event.preventDefault();
$scope.user={
'name':'',
'handle':'',
'password':'',
'email':'',
'phone':''
};

$scope.login_data={
'handle':'',
'password':''
};

$scope.Register = function(){
$scope.user.password=encrypt.hash($scope.user.password);

$http({method: 'POST',url:'http://'+url+'/register', data:$scope.user})//, headers:config})
.success(function (data) {
console.log(data)
})
.error(function (data) {
//add error handling
console.log(data)
});
}

$scope.login = function(){
console.log("login");
$scope.login_data.password=encrypt.hash($scope.login_data.password);
console.log($scope.login_data);
$http({ method: 'POST', url:'http://'+url+'/login', data:$scope.login_data })//, headers:config})
.success(function (data) {
if(data=="success"){
$state.go('loggedin');
}
})
.error(function (data) {
//add error handling
console.log(data)
});
};
});
}
}]);
Empty file modified views/bootstrap/fonts/glyphicons-halflings-regular.eot
100644 → 100755
Empty file.
Empty file modified views/bootstrap/fonts/glyphicons-halflings-regular.svg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified views/bootstrap/fonts/glyphicons-halflings-regular.ttf
100644 → 100755
Empty file.
Empty file modified views/bootstrap/fonts/glyphicons-halflings-regular.woff
100644 → 100755
Empty file.
Empty file modified views/bootstrap/fonts/glyphicons-halflings-regular.woff2
100644 → 100755
Empty file.
Loading

0 comments on commit 600731f

Please sign in to comment.