Skip to content

Commit

Permalink
make it better
Browse files Browse the repository at this point in the history
  • Loading branch information
sumitjangir123 committed Aug 20, 2020
1 parent 3e53892 commit 6a3040b
Show file tree
Hide file tree
Showing 34 changed files with 2,468 additions and 1,681 deletions.
34 changes: 33 additions & 1 deletion assets/js/chat_engine.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,33 @@

function live(data){
document.getElementById(data.user_email).style.display="inline-block";
new Noty({
theme: 'metroui',
text: data.user_email+' is '+'live',
type: 'success',
layout: 'topRight',
timeout: 2000
}).show();
}

function notlive(data){
console.log(data);
document.getElementById(data.user_email).style.display="none";
new Noty({
theme: 'metroui',
text: data.user_email+' is '+'offline',
type: 'success',
layout: 'topRight',
timeout: 2000
}).show();
}

class ChatEngine{
constructor(chatBoxId,userEmail){
this.chatBox= $(`#${chatBoxId}`);
this.userEmail= userEmail;
this.socket= io.connect('http://107.21.187.244:5000');
this.socket= io.connect('http://localhost:5000');
// http://107.21.187.244:5000
if(this.userEmail){
this.connectionHandler();
}
Expand All @@ -21,6 +46,13 @@ class ChatEngine{

self.socket.on('user_joined',function(data){
console.log('a user joined!',data);
live(data);
});

self.socket.on('diss',function(data){

notlive(data);
console.log('user dissconnected ',data);
});

});
Expand Down
5 changes: 5 additions & 0 deletions config/chat_sockets.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
module.exports.chatSockets= function(socketServer){
let io= require('socket.io')(socketServer);

var temp;
io.sockets.on('connection',function(socket){
console.log('new connection received',socket.id);


socket.on('disconnect',function(){
io.in(temp.chatroom).emit('diss',temp);
console.log('socket disconnected !');
});

Expand All @@ -15,6 +18,8 @@ module.exports.chatSockets= function(socketServer){

//if we want to emit in a specific chat room
io.in(data.chatroom).emit('user_joined',data);

temp=data;
});

//detect send message and broadcast to everyone in the room
Expand Down
12 changes: 6 additions & 6 deletions config/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ const development= {
secure: false, // true for 465, false for other ports
auth: {
user: '[email protected]',
pass: ''
pass: 'thunderbird1234'
}
},
google_client_id: "",
google_client_secret: "",
google_client_id: "922852696533-qrr4lrcdb3uj5sjdjcqi1g90fc5mpsoq.apps.googleusercontent.com",
google_client_secret: "Vu8_IYaYygO-z07kp80i7356",
google_call_back_url: "http://localhost:8000/users/auth/google/callback",

facebook_client_id: "",
facebook_client_secret: "",
facebook_client_id: "549980429009358",
facebook_client_secret: "3f007a155b585a2b535979052b07b5fd",
facebook_call_back_url: "http://localhost:8000/users/auth/facebook/callback",

jwt_secret: 'codeial',
Expand Down Expand Up @@ -75,4 +75,4 @@ const production= {
}

// eval(process.env.THUNDER_ENVIRONMENT)==undefined ? development : eval(process.env.THUNDER_ENVIRONMENT)
module.exports= production;
module.exports= development;
10 changes: 10 additions & 0 deletions controllers/home_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,13 @@ module.exports.about= async function(req,res){
console.log(error);
}
}

module.exports.policies= async function(req,res){
try {
return res.render('privacyPolicies',{
title: "privacy policies"
})
} catch (error) {
console.log(error);
}
}
16 changes: 16 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,22 @@ gulp.task('images', function(done){
done();
});

gulp.task('images', function(done){
console.log('compressing images...');
gulp.src('./assets/**/*.+(png|jpg|gif|svg|jpeg)')
.pipe(imagemin())
.pipe(rev())
.pipe(gulp.dest('./public/assets'))
.pipe(rev.manifest({
cwd: 'public',
merge: true
}))
.pipe(gulp.dest('./public/assets'));
done();
});




// empty the public/assets directory
gulp.task('clean:assets', function(done){
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 6a3040b

Please sign in to comment.