You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.1 KiB
JavaScript
49 lines
1.1 KiB
JavaScript
Vue.use(VueSocketio, 'http://metinseylan.com:1923');
|
|
|
|
new Vue({
|
|
el: '.container',
|
|
data: {
|
|
join: false,
|
|
name: null,
|
|
users: null,
|
|
message: null,
|
|
messages: {}
|
|
},
|
|
methods: {
|
|
joinChat: function (name) {
|
|
if (name) {
|
|
this.$socket.emit('join', name);
|
|
}
|
|
},
|
|
send: function (message) {
|
|
if (message) {
|
|
this.$socket.emit('send', message);
|
|
this.$set('message', null);
|
|
}
|
|
}
|
|
},
|
|
watch: {
|
|
messages: function () {
|
|
setTimeout(function () {
|
|
$('.messages ul').scrollTop(999999999);
|
|
}, 100)
|
|
}
|
|
},
|
|
sockets: {
|
|
users: function (users) {
|
|
this.$set('users', users);
|
|
},
|
|
joined: function () {
|
|
this.$set('join', true)
|
|
},
|
|
messages: function (data) {
|
|
this.$set('messages', data);
|
|
},
|
|
onmessage: function (data) {
|
|
this.messages.push(data);
|
|
},
|
|
adduser: function (user) {
|
|
this.users.push(user);
|
|
}
|
|
}
|
|
}); |