Location: PHPKode > projects > OpenCollab > openc/templates/chat/tpl.simple.html
<style>
.chatlist {
	width:100%;
	background-color:yellow;
	overflow:auto;
}
.chatinput {
	width:100%;
	background-color:red;
	padding:0 0 0 3px;
}
</style>
<div class='chatlist'></div>
<div class='chatinput'>
<form method="post" action="<?= getLink('chat/send/'.$VAR['id']);?>" target="submitiframe" onSubmit="sendMsg();return(true);">
<input type='hidden' id='message2' name="message">
Nachricht:<br>
<input type='text' style='width:92%' id='message'><input type='submit' value='Ok' style='width:6%;'>
</div>
<div style='display:none;'>
<iframe src='' name='submitiframe'></iframe>
</div>

<script>
function sendMsg() {
	// {{{
	var d = new Date();
	var msg = new Object();
	var s = d.getSeconds();if(s<10) s = "0"+s;
	var m = d.getMinutes();if(m<10) m = "0"+m;
	var h = d.getHours();if(h<10) h = "0"+h;
	msg.date = h+":"+m+":"+s;
	msg.from = '<csml:profil/<?= me();?>/userName />';
	msg.text = $('#message').val();
	insertMsg(msg);
	$('#message2').val($('#message').val());
	$('#message').val('');
	
	// }}}
}
function insertMsg(msg) {
	// {{{
	var html = "<table><tr>";
	html += "<td valign=top>"+msg.date+"</td>";
	html += "<td valign=top style='font-weight:bold;'>"+msg.from+"</td>";
	html += "<td valign=top>"+msg.text+"</td>";
	html += '</tr></table>';
	
	$('.chatlist').append(html);

	// }}}
}
function setNewDim() {
	// {{{
	var viewportWidth = $(window).width();
	var viewportHeight = window.innerHeight ? window.innerHeight : $(window).height();
	$('.chatlist').height(viewportHeight-40-3);
	$('.chatinput').height(40);
	// }}}
}

var setPMMax = 5;
var pm = 1;
function pollMessages(type) {
	// {{{
	pm--;
	if(pm<=0) {
// 		  dataType: 'json',
		
		$.ajax({
		  url: "<?= getLink('chat/poll/'.$VAR['id'].'/');?>"+type,
		  async: true,
		  success: function (data) {
		  	// {{{
		  	//$('.chatlist').html(data);
		  	if(data!='[]') {
		  		var M = eval(data);
		  		for(var i=0;i<M.length;i++) {
		  			insertMsg(M[i]);
		  		}
		  		
		  	}
		  	// }}}
		  }
		});
		type = 'new';

		
		pm=setPMMax;
	}
	setTimeout("pollMessages('"+type+"');",100);
	// }}}
}

$(function() {
		setNewDim();
		setTimeout("pollMessages('first');",100);
});
$(window).resize(function() {
		setNewDim();
});
</script>
Return current item: OpenCollab