chat server is going to be in its own dir

This commit is contained in:
Sergey Lyubka 2014-02-07 13:04:02 +00:00
parent 877c4dc698
commit 6f8751b479
7 changed files with 8 additions and 8 deletions

View File

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -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);