added chatSend() function

This commit is contained in:
Arthur Mayer 2011-02-18 10:21:55 +01:00
parent 5ddaf940ed
commit 10f93c02c1
2 changed files with 27 additions and 0 deletions

View File

@ -0,0 +1,21 @@
function sendChat(message) {
var ip;
$.ajax({
type: "GET",
url: "http://jsonip.appspot.com/?callback=?",
dataType: "jsonp",
success: function(getip) {
var data = { name: getip.ip, message: message };
$.ajax({
type: 'POST',
url: '/up/sendmessage',
data: data,
dataType: 'json',
success: function(response) {
//handle response
}
});
}
});
}
//curl -d '{"name":"Nickname","message":"Hello"}' http://localhost:8123/up/sendmessage

View File

@ -212,6 +212,12 @@ DynMap.prototype = {
type: 'text',
value: 'not working yet'
})
.keydown(function(event) {
if (event.keyCode == '13') {
event.preventDefault();
alert(this.value);
}
})
.appendTo(chat);
var chatcursor = me.chatcursor = $('<span/>')
.attr({ id: 'chatcursor'})