I am working on java gmail like chat application for my project. I found a source code which is in PHP. So, i have to change it to java now. 10 marks for anyone can provide me with the full java code. Thanks.
Source code:
<html>
<head>
<script type="text/javascript" src="prototype/prototype.js"></script>
<script type="text/javascript">
// <![CDATA[
document.observe('dom:loaded', function() {
function sendForm(event){
// we stop the default submit behaviour
Event.stop(event);
var linebr=document.createElement('br');
var oOptions = {
method: "POST",
parameters: Form.serialize("chatForm"),
asynchronous: true,
onFailure: function (oXHR) {
$('send_status').update(oXHR.statusText);
},
onLoading: function (oXHR) {
$('send_status').update('Sending data ... Loading...');
document.getElementById('line').value = '';
},
onSuccess: function(oXHR) {
$('chat_history').innerHTML = $('chat_history').innerHTML + oXHR.responseText;
$('send_status').update('');
$('chat_history').scrollTop = $('chat_history').scrollHeight; // scroll div to end
document.getElementById('line').focus(); // set the focus to the text chat area
}
};
var oRequest = new Ajax.Updater({success: oOptions.onSuccess.bindAsEventListener(oOptions)}, 'poc/chat/post', oOptions);
}
Event.observe('chat_submit', 'click', sendForm, false);
});
// ]]>
function refreshChatHistory(){
document.getElementById('line').focus(); // set the focus to the text chat area
var oOptions = {
method: "GET",
frequency: 3,
decay: 1,
insertion: Insertion.Bottom,
asynchronous: true,
onFailure: function (oXHR) {
$('send_status').update(oXHR.statusText);
},
onSuccess: function(oXHR) {
// $('chat_history').innerHTML = $('chat_history').innerHTML + oXHR.responseText;
$('send_status').update('');
$('chat_history').scrollTop = $('chat_history').scrollHeight; // scroll div to end
}
};
var oRequest = new Ajax.PeriodicalUpdater('chat_history', 'poc/chat/post' , oOptions);
}
</script>
</head>
<body onload="refreshChatHistory()">
....
...
..
</body>
</html>
Source code:
<html>
<head>
<script type="text/javascript" src="prototype/prototype.js"></script>
<script type="text/javascript">
// <![CDATA[
document.observe('dom:loaded', function() {
function sendForm(event){
// we stop the default submit behaviour
Event.stop(event);
var linebr=document.createElement('br');
var oOptions = {
method: "POST",
parameters: Form.serialize("chatForm"),
asynchronous: true,
onFailure: function (oXHR) {
$('send_status').update(oXHR.statusText);
},
onLoading: function (oXHR) {
$('send_status').update('Sending data ... Loading...');
document.getElementById('line').value = '';
},
onSuccess: function(oXHR) {
$('chat_history').innerHTML = $('chat_history').innerHTML + oXHR.responseText;
$('send_status').update('');
$('chat_history').scrollTop = $('chat_history').scrollHeight; // scroll div to end
document.getElementById('line').focus(); // set the focus to the text chat area
}
};
var oRequest = new Ajax.Updater({success: oOptions.onSuccess.bindAsEventListener(oOptions)}, 'poc/chat/post', oOptions);
}
Event.observe('chat_submit', 'click', sendForm, false);
});
// ]]>
function refreshChatHistory(){
document.getElementById('line').focus(); // set the focus to the text chat area
var oOptions = {
method: "GET",
frequency: 3,
decay: 1,
insertion: Insertion.Bottom,
asynchronous: true,
onFailure: function (oXHR) {
$('send_status').update(oXHR.statusText);
},
onSuccess: function(oXHR) {
// $('chat_history').innerHTML = $('chat_history').innerHTML + oXHR.responseText;
$('send_status').update('');
$('chat_history').scrollTop = $('chat_history').scrollHeight; // scroll div to end
}
};
var oRequest = new Ajax.PeriodicalUpdater('chat_history', 'poc/chat/post' , oOptions);
}
</script>
</head>
<body onload="refreshChatHistory()">
....
...
..
</body>
</html>