a bit more ajax work on chat and chatsvc and some fiddling with layouts

This commit is contained in:
friendica 2014-01-30 01:00:46 -08:00
parent 080928f214
commit 6c6a9b963a
4 changed files with 29 additions and 13 deletions

View File

@ -155,7 +155,7 @@ function chatroom_leave($observer_xchan,$room_id,$client) {
function chatroom_list($uid) { function chatroom_list($uid) {
$r = q("select cr_name, cr_id, count(cp_id) as cr_inroom from chatroom left join chatpresence on cr_id = cp_room where cr_uid = %d group by cp_id order by cr_name", $r = q("select cr_name, cr_id, count(cp_id) as cr_inroom from chatroom left join chatpresence on cr_id = cp_room where cr_uid = %d group by cr_name order by cr_name",
intval($uid) intval($uid)
); );

View File

@ -59,7 +59,8 @@ function chatsvc_post(&$a) {
dbesc(datetime_convert()), dbesc(datetime_convert()),
dbesc($text) dbesc($text)
); );
$ret['success'] = true;
json_return_and_die($ret);
} }
function chatsvc_content(&$a) { function chatsvc_content(&$a) {

View File

@ -1 +1 @@
2014-01-29.572 2014-01-30.573

View File

@ -1,11 +1,12 @@
<div id="chatContainer"> <div id="chatContainer" style="height: 100%; width: 100%; position: absolute; right: 0; bottom: 0;">
<div id="chatTopBar" class="rounded"></div> <div id="chatTopBar" style="float: left; height: 80%;"></div>
<div id="chatLineHolder"></div> <div id="chatLineHolder"></div>
<div id="chatUsers" class="rounded"></div> <div id="chatUsers" style="float: right; width: 120px; height: 100%; border: 1px solid #000;" ></div>
<div id="chatBottomBar" class="rounded"> <div class="clear"></div>
<div id="chatBottomBar" style="position: absolute; bottom: 0; height: 150px;">
<div class="tip"></div> <div class="tip"></div>
<form id="chat-form" method="post" action="#"> <form id="chat-form" method="post" action="#">
@ -20,24 +21,38 @@
<script> <script>
var room_id = {{$room_id}}; var room_id = {{$room_id}};
var last_chat = 0;
var chat_timer = null;
$('#chat-form').submit(function(ev) { $('#chat-form').submit(function(ev) {
$('body').css('cursor','wait'); $('body').css('cursor','wait');
$.post("chatsvc", $('#chat-form').serialize(),function(data) { $.post("chatsvc", $('#chat-form').serialize(),function(data) {
load_chats(data); if(chat_timer) clearTimeout(chat_timer);
load_chats();
$('body').css('cursor','auto'); $('body').css('cursor','auto');
},'json'); },'json');
ev.preventDefault(); ev.preventDefault();
}); });
function load_chats(data) { function load_chats() {
var chat_data = data;
if(! data) { $.get("chatsvc?f=&room_id=" + room_id + '&last=' + last_chat,function(data) {
$.get("chatsvc?f=&room_id=" + room_id,function(data) { if(data.success) {
chat_data = $this; update_inroom(data.inroom);
update_chats(data.chats);
}); });
} }
chat_timer = setTimeout(load_chats,10000);
} }
function update_inroom(inroom) {
}
function update_chats(chats) {
}
</script> </script>