mirror of
https://github.com/cesanta/mongoose.git
synced 2024-11-25 03:29:00 +08:00
chat server is going to be in its own dir
This commit is contained in:
parent
877c4dc698
commit
6f8751b479
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
@ -3,7 +3,7 @@
|
|||||||
var chat = {
|
var chat = {
|
||||||
// Backend URL, string.
|
// Backend URL, string.
|
||||||
// 'http://backend.address.com' or '' if backend is the same as frontend
|
// 'http://backend.address.com' or '' if backend is the same as frontend
|
||||||
backendUrl: '',
|
backendUrl: 'api.lp',
|
||||||
maxVisibleMessages: 10,
|
maxVisibleMessages: 10,
|
||||||
errorMessageFadeOutTimeoutMs: 2000,
|
errorMessageFadeOutTimeoutMs: 2000,
|
||||||
errorMessageFadeOutTimer: null,
|
errorMessageFadeOutTimer: null,
|
||||||
@ -49,9 +49,7 @@ chat.refresh = function(data) {
|
|||||||
|
|
||||||
chat.getMessages = function(enter_loop) {
|
chat.getMessages = function(enter_loop) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
dataType: 'jsonp',
|
data: {last_id: chat.lastMessageId, cmd: 'get_messages'},
|
||||||
url: chat.backendUrl + '/ajax/get_messages',
|
|
||||||
data: {last_id: chat.lastMessageId},
|
|
||||||
success: chat.refresh,
|
success: chat.refresh,
|
||||||
error: function() {
|
error: function() {
|
||||||
},
|
},
|
||||||
@ -82,9 +80,7 @@ chat.handleMessageInput = function(ev) {
|
|||||||
return;
|
return;
|
||||||
//input.disabled = true;
|
//input.disabled = true;
|
||||||
$.ajax({
|
$.ajax({
|
||||||
dataType: 'jsonp',
|
data: { text: input.value, cmd: 'send_message' },
|
||||||
url: chat.backendUrl + '/ajax/send_message',
|
|
||||||
data: {text: input.value},
|
|
||||||
success: function(ev) {
|
success: function(ev) {
|
||||||
input.value = '';
|
input.value = '';
|
||||||
input.disabled = false;
|
input.disabled = false;
|
||||||
@ -98,6 +94,10 @@ chat.handleMessageInput = function(ev) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
$.ajaxSetup({
|
||||||
|
dataType: 'json',
|
||||||
|
url: chat.backendUrl
|
||||||
|
});
|
||||||
$('.menu-item').click(chat.handleMenuItemClick);
|
$('.menu-item').click(chat.handleMenuItemClick);
|
||||||
$('.message-input').keypress(chat.handleMessageInput);
|
$('.message-input').keypress(chat.handleMessageInput);
|
||||||
chat.getMessages(true);
|
chat.getMessages(true);
|
Loading…
Reference in New Issue
Block a user