added chatSend() function
This commit is contained in:
parent
b5654208ee
commit
71d29198bd
2 changed files with 27 additions and 0 deletions
21
web/chat.js
21
web/chat.js
|
|
@ -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
|
||||||
|
|
@ -212,6 +212,12 @@ DynMap.prototype = {
|
||||||
type: 'text',
|
type: 'text',
|
||||||
value: 'not working yet'
|
value: 'not working yet'
|
||||||
})
|
})
|
||||||
|
.keydown(function(event) {
|
||||||
|
if (event.keyCode == '13') {
|
||||||
|
event.preventDefault();
|
||||||
|
alert(this.value);
|
||||||
|
}
|
||||||
|
})
|
||||||
.appendTo(chat);
|
.appendTo(chat);
|
||||||
var chatcursor = me.chatcursor = $('<span/>')
|
var chatcursor = me.chatcursor = $('<span/>')
|
||||||
.attr({ id: 'chatcursor'})
|
.attr({ id: 'chatcursor'})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue