Implement webchat and badge notifications
This commit is contained in:
@@ -1,8 +1,21 @@
|
||||
function sendChat(message) {
|
||||
$.post('/api/chat', {'message': message}, function(data) {
|
||||
$('#chat-line').val('');
|
||||
$('#chat-line').disabled = false;
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
$('#server-interaction .drawer').each(function() {
|
||||
var canvas = $(this).children('.canvas');
|
||||
$(this, '.drawer-label').click(function() {
|
||||
$(this).children('.drawer-label').click(function() {
|
||||
canvas.slideToggle("blind");
|
||||
});
|
||||
});
|
||||
$('#chat-line').keypress(function(evt) {
|
||||
if (evt.charCode == 13) {
|
||||
$('#chat-line').disabled = true;
|
||||
sendChat($('#chat-line').val());
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@@ -1,12 +1,23 @@
|
||||
function pollMessages() {
|
||||
$.get('/api/poll/0', function(data) {
|
||||
function pollMessages(id) {
|
||||
$.get('/api/poll/'+id, function(data) {
|
||||
if (id == 0)
|
||||
$('#chat-display').html('');
|
||||
$('#balance-display').html(data['user-info']['balance']);
|
||||
$(data['events']).each(function(idx, evt) {
|
||||
if (evt['type'] == "chat") {
|
||||
$('#chat-display').append("<li>"+evt['payload']['sender']+": "+evt['payload']['message']);
|
||||
} else if (evt['type'] == 'join') {
|
||||
$('#chat-display').append("<li><em>"+evt['payload']['player']+" has joined</em></li>");
|
||||
} else if (evt['type'] == 'quit') {
|
||||
$('#chat-display').append("<li><em>"+evt['payload']['player']+" has quit</em></li>");
|
||||
}
|
||||
});
|
||||
window.setTimeout(function() {pollMessages(data['poll-id'])}, 1);
|
||||
});
|
||||
}
|
||||
|
||||
function poll() {
|
||||
pollMessages();
|
||||
window.setTimeout(pollMessages, 3000);
|
||||
pollMessages(0);
|
||||
}
|
||||
|
||||
$(document).ready(function () {
|
||||
|
Reference in New Issue
Block a user