Author: ktlili
Date: Fri Oct 5 16:01:32 2007
New Revision: 18766
URL: https://svndev.jahia.net/websvn/listing.php?sc=3D1&rev=3D18766&repname=
=3Djahia
Log:
- fix JAHIA-1978: <br> or enter + shift
- fix accent + big text bug
- add username in order to know who send the message
Modified:
branches/JAHIA-5-0-SP-BRANCH/core/src/webapp/jsp/jahia/chat/chat.jsp
Modified: branches/JAHIA-5-0-SP-BRANCH/core/src/webapp/jsp/jahia/chat/chat.=
jsp
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-SP=
-BRANCH/core/src/webapp/jsp/jahia/chat/chat.jsp&rev=3D18766&repname=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/JAHIA-5-0-SP-BRANCH/core/src/webapp/jsp/jahia/chat/chat.jsp (o=
riginal)
+++ branches/JAHIA-5-0-SP-BRANCH/core/src/webapp/jsp/jahia/chat/chat.jsp Fr=
i Oct 5 16:01:32 2007
@@ -14,7 +14,8 @@
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
---%><%@ page import=3D"org.jahia.bin.Jahia" %>
+--%>
+<%@ page import=3D"org.jahia.bin.Jahia" %>
<%@ page import=3D"org.jahia.params.ParamBean" %>
<%@ page import=3D"org.jahia.registries.ServicesRegistry" %>
<%@ page import=3D"org.jahia.services.usermanager.JahiaUser" %>
@@ -53,12 +54,15 @@
if (offsince =3D=3D null) offsince =3D "";
JahiaUser targetuser =3D service.lookupUser(userkey);
String targetname =3D "";
- if (targetuser !=3D null) targetname =3D targetuser.getUsername();
+ if (targetuser !=3D null) {
+ targetname =3D targetuser.getUsername();
+ }
JahiaUser currentuser =3D (JahiaUser) session.getAttribute(ParamBean.S=
ESSION_USER);
=
%>
<html>
-<head><title><%=3DgetRessource("org.jahia.chat.title", locale)%> | <%=3Dta=
rgetname%></title>
+<head><title><%=3DgetRessource("org.jahia.chat.title", locale)%> | <%=3Dta=
rgetname%>
+</title>
<!--link rel=3D"stylesheet"
href=3D"<!--jahia:serverHttpPath/>/jsp/jahia/engines/css/menu.css" t=
ype=3D"text/css"/-->
<link rel=3D"stylesheet" href=3D"<jahia:serverHttpPath/>/jsp/jahia/css/col=
orsAndStyles.css" type=3D"text/css"/>
@@ -68,7 +72,7 @@
font-style: normal;
}
=
- /* message from you to others */
+ /* message from you to others */
.mymessage {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 11px;
@@ -76,7 +80,7 @@
=
}
=
- /* message from others to you */
+ /* message from others to you */
.yourmessage {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 11px;
@@ -107,21 +111,25 @@
var currentmessage =3D "";
var posinfield =3D 0;
var pastedflag =3D false;
-var ukey=3D"<%=3Duserkey%>";
-var uoff=3D"<%=3Doffsince%>";
+var ukey =3D "<%=3Duserkey%>";
+var uoff =3D "<%=3Doffsince%>";
=
-ns4 =3D (document.layers) ?1:0;
-ie =3D (document.all) ?1:0;
+ns4 =3D (document.layers) ? 1 : 0;
+ie =3D (document.all) ? 1 : 0;
=
=
function submitenter(e)
{
// todo support of deletion
var characterCode;
- var shift =3D e.shiftKey;//used to carriage return
- var ctrl =3D e.ctrlKey;//used to cut,copy,paste on pc
- var alt =3D e.altKey;//unused
- var meta =3D ((ns4) ? e.modifiers && Event.META_MASK : e.metaKey) ? "=
meta " :"";//used to mac "apple" command
+ var shift =3D e.shiftKey;
+ //used to carriage return
+ var ctrl =3D e.ctrlKey;
+ //used to cut,copy,paste on pc
+ var alt =3D e.altKey;
+ //unused
+ var meta =3D ((ns4) ? e.modifiers && Event.META_MASK : e.metaKey) ? " =
meta " : "";
+ //used to mac "apple" command
if (e && e.which) { // (NN4+)
//e =3D e
characterCode =3D e.which //character code is contained in NN4's w=
hich property
@@ -130,11 +138,11 @@
}
//alert(characterCode+" shift:"+shift+" ctrl:"+ctrl+" alt:"+alt+" meta=
:"+meta);
=
- thechar =3D String.fromCharCode(characterCode);
+ var thechar =3D String.fromCharCode(characterCode);
if (pastedflag) {
//previous entry is a paste
- longueur =3D $('message').value.length;
- pasted =3D $('message').value.substring(posinfield, longueur);
+ var longueur =3D $('message').value.length;
+ var pasted =3D $('message').value.substring(posinfield, longueur);
//alert(pasted);
currentmessage =3D currentmessage + pasted;
posinfield =3D longueur;
@@ -142,21 +150,19 @@
return true;
}
if (characterCode =3D=3D 13 && !shift) { //(enter key+ pashift)
- //$('message').value =3D currentmessage;
- //currentmessage =3D '';
- //posinfield =3D 0;
send();
return false;
} else if (characterCode =3D=3D 13 && shift) {
- currentmessage =3D currentmessage + "<br>";
+ currentmessage =3D currentmessage + "<br/>";
+ //$('message').value =3D $('message').value+"<br/>";
return true;
- } else if (characterCode =3D=3D 118 && meta =3D=3D " meta " ) {
+ } else if (characterCode =3D=3D 118 && meta =3D=3D " meta ") {
// macintosh copypaste
pastedflag =3D true;
return true;
- } else if (characterCode =3D=3D 118 && ctrl ) {
- //pcs copypaste
- pastedflag =3D true;
+ } else if (characterCode =3D=3D 118 && ctrl) {
+ //pcs copypaste
+ pastedflag =3D true;
return true;
} else {
currentmessage =3D currentmessage + thechar;
@@ -166,22 +172,22 @@
}
=
=
-function update(request){
- //do nothing 4 now
- //alert("update"+request.responseText);
+function update(request) {
+ //do nothing 4 now
+ //alert("update"+request.responseText);
}
-function error(request){
- //alert("error"+request.responseText);
+function error(request) {
+ //alert("error"+request.responseText);
}
//function to get all remaining messages
function showResponse(request) {
=
- xdoc =3D request.responseXML;
+ var xdoc =3D request.responseXML;
var list =3D xdoc.getElementsByTagName('message');
for (i =3D 0; i < list.length; i++) {
-
thetime=3Dlist[i].getElementsByTagName('tstamp')[0].firstChild.data;
- themessage =3Dlist[i].getElementsByTagName('body')[0].firstChild.d=
ata;
- displayReceivedMessage(themessage,thetime)
+ thetime =3D list[i].getElementsByTagName('tstamp')[0].firstChild.d=
ata;
+ themessage =3D list[i].getElementsByTagName('body')[0].firstChild.=
data;
+ displayReceivedMessage(themessage, thetime)
}
=
//$('discussion').innerHTML =3D total;
@@ -193,91 +199,96 @@
=
var xdoc =3D request.responseXML;
=
- total =3D $('discussion').innerHTML;
- var themessage=3D"";
+ var total =3D $('discussion').innerHTML;
+ var themessage =3D "";
list =3D xdoc.getElementsByTagName('message');
if (list.length > 0) {
- msg =3D xdoc.getElementsByTagName('body');
- timemess =3D xdoc.getElementsByTagName('tstamp');
- themessage=3Dmsg[0].firstChild.data;
- displayReceivedMessage(themessage,timemess[0].firstChild.data)
+ var msg =3D xdoc.getElementsByTagName('body');
+ var timemess =3D xdoc.getElementsByTagName('tstamp');
+ themessage =3D msg[0].firstChild.data;
+ displayReceivedMessage(themessage, timemess[0].firstChild.data)
=
} else {
- //alert("no message");
+ //alert("no message");
}
=
}
=
// to send a message
function send() {
- if(ukey=3D=3D"unkown" || uoff!=3D"") return;
+ if (ukey =3D=3D "unkown" || uoff !=3D "") return;
var message =3D $('message').value;
- if (message =3D=3D '') return false;
+ if (message =3D=3D '') {
+ return false;
+ }
=
- //alert(message);
+ //alert(message);
//check the html
message =3D checkHTML(message);
=
- //display the message
+ //display the message
displaySendMessage(message);
- $('message').value =3D '';
+ $('message').value =3D '';
=
- // Send message
- var args =3D "message=3D" + escape(message) + "&targetuser=3D<%=3Duser=
key%>";
+ // Send message
+ var args =3D "message=3D" + encodeURIComponent(message) + "&targetuser=
=3D<%=3Duserkey%>";
//alert("args:"+args);
- do_ajax =3D new Ajax.Request(ajaxurl, {parameters: args, onFailed:erro=
r, onComplete: update});
+ var do_ajax =3D new Ajax.Request(ajaxurl, {parameters: args, onFailed:=
error, onComplete: update});
+ delete do_ajax;
=
}
=
-function displayReceivedMessage(m,d){
- var htmlcode=3D"";
- var date =3D new Date();
- if(m.indexOf("<code>") !=3D-1) {
- them=3Dm;
- py=3Dm.indexOf("<code>")+6;
- px=3Dm.lastIndexOf("</code>");
- htmlcode=3Dm.substring(py,px);
- //alert("htmlcode:"+htmlcode);
- htmlcode=3Dhtmlcode.replace(/</g, '<');
- htmlcode=3Dhtmlcode.replace(/>/g, '>');
- them=3Dm.substring(0,py)+htmlcode+m.substring(px,m.length);
- m=3Dthem;
- }
- //alert("the message to display:"+m);
-
- //update the window
- total =3D $('discussion').innerHTML;
- mintime =3D date.getMinutes();
- if (mintime < 10) mintime =3D "0" + mintime;
-
- total =3D total + "<span class=3D\"yourmessage\">" + d + " =
<b>" + m + "</b></span><br>";
- $('discussion').innerHTML =3D total;
+function displayReceivedMessage(m, d) {
+ var htmlcode =3D "";
+ var date =3D new Date();
+ if (m.indexOf("<code>") !=3D -1) {
+ var them =3D m;
+ var py =3D m.indexOf("<code>") + 6;
+ var px =3D m.lastIndexOf("</code>");
+ htmlcode =3D m.substring(py, px);
+ //alert("htmlcode:"+htmlcode);
+ htmlcode =3D htmlcode.replace(/</g, '<');
+ htmlcode =3D htmlcode.replace(/>/g, '>');
+ them =3D m.substring(0, py) + htmlcode + m.substring(px, m.length);
+ m =3D them;
+ }
+ //alert("the message to display:"+m);
+
+ //update the window
+ var total =3D $('discussion').innerHTML;
+ var mintime =3D date.getMinutes();
+ if (mintime < 10) {
+ mintime =3D "0" + mintime;
+ }
+
+ total =3D total + "<span class=3D\"yourmessage\"> <%=3Dtargetname%> ["=
+ d + "] : <b>" + m + "</b></span>";
+ $('discussion').innerHTML =3D total + "<br/><br/>";
}
=
=
-function displaySendMessage(m){
- var htmlcode=3D"";
- var date =3D new Date();
- if(m.indexOf("<code>") !=3D-1) {
- them=3Dm;
- py=3Dm.indexOf("<code>")+6;
- px=3Dm.lastIndexOf("</code>");
- htmlcode=3Dm.substring(py,px);
- //alert("htmlcode:"+htmlcode);
- htmlcode=3Dhtmlcode.replace(/</g, '<');
- htmlcode=3Dhtmlcode.replace(/>/g, '>');
- them=3Dm.substring(0,py)+htmlcode+m.substring(px,m.length);
- m=3Dthem;
- }
- //alert("the message to display:"+m);
-
- //update the window
- total =3D $('discussion').innerHTML;
- mintime =3D date.getMinutes();
+function displaySendMessage(m) {
+ var htmlcode =3D "";
+ var date =3D new Date();
+ if (m.indexOf("<code>") !=3D -1) {
+ var them =3D m;
+ var py =3D m.indexOf("<code>") + 6;
+ var px =3D m.lastIndexOf("</code>");
+ htmlcode =3D m.substring(py, px);
+ //alert("htmlcode:"+htmlcode);
+ htmlcode =3D htmlcode.replace(/</g, '<');
+ htmlcode =3D htmlcode.replace(/>/g, '>');
+ them =3D m.substring(0, py) + htmlcode + m.substring(px, m.length);
+ m =3D them;
+ }
+ //alert("the message to display:" + m);
+
+ //update the window
+ var total =3D $('discussion').innerHTML;
+ var mintime =3D date.getMinutes();
if (mintime < 10) mintime =3D "0" + mintime;
=
- total =3D total + "<span class=3D\"mymessage\">" + date.getHours() + "=
:" + mintime + " <b>" + m + "</b></span>";
- $('discussion').innerHTML =3D total + "<br>";
+ total =3D total + "<span class=3D\"mymessage\">" + "<%=3Dcurrentuser.g=
etUsername()%> [" + date.getHours() + ":" + mintime + "] : <b>" =
+ m + "</b></span>";
+ $('discussion').innerHTML =3D total + "<br/><br/>";
}
=
// to add code tags
@@ -286,39 +297,67 @@
var mess =3D m;
var p1 =3D m.indexOf("<");
var p2 =3D m.lastIndexOf(">");
-
var mycode =3D "";
if (p1 !=3D -1 || p2 !=3D -1) {
- if(p2=3D=3D-1) p2=3Dm.length -1;
- if(p1=3D=3D-1) p1=3D0;
- mycode =3D "<pre><code>" + m.substring(p1, p2 + 1)+ "</code></pre>=
";
- var m1 =3D m.substring(0, p1);
- var m2 =3D m.substring(p2 + 1, m.length);
- //alert(m1+" "+mycode+" "+m2);
- mess =3D m1 + mycode + m2;
+ if (p2 =3D=3D -1) {
+ p2 =3D m.length - 1;
+ }
+ if (p1 =3D=3D -1) {
+ p1 =3D 0;
+ }
+ var htmlCode =3D m.substring(p1, p2 + 1);
+ if (htmlCode) {
+ htmlCode =3D htmlCode.toLowerCase();
+ if (htmlCode !=3D "<br>" && htmlCode !=3D "<br/>") {
+ mycode =3D "<pre><code>" + m.substring(p1, p2 + 1) + "</co=
de></pre>";
+ var m1 =3D m.substring(0, p1);
+ var m2 =3D m.substring(p2 + 1, m.length);
+ //alert(m1+" "+mycode+" "+m2);
+ mess =3D m1 + mycode + m2;
+ }
+ }
+
+ }
+ // deal with \n
+ while (mess.indexOf("\r\n") !=3D -1) {
+ mess =3D mess.replace("\r\n", "<br>");
+ }
+
+ while (mess.indexOf("\n") !=3D -1) {
+ mess =3D mess.replace("\n", "<br>");
}
+
+ while (mess.indexOf("\r") !=3D -1) {
+ mess =3D mess.replace("\r", "<br>");
+ }
+
//alert("end of checkHTML:"+mess);
return mess;
}
=
+
+
//this function is used when the window open ONLY
function getMessages() {
//alert("getmessages");
- if(ukey=3D=3D"unkown") return;
+ if (ukey =3D=3D "unkown") return;
var args =3D "targetuser=3D<%=3Duserkey%>" + "&op=3DgetMessages";
- do_ajax =3D new Ajax.Request(ajaxurl, {parameters: args, onComplete: s=
howResponse});
+ var do_ajax =3D new Ajax.Request(ajaxurl, {parameters: args, onComplet=
e: showResponse});
+ delete do_ajax;
=
}
//to get last messages
function getLastMessage() {
//alert("getlast");
var args =3D "targetuser=3D<%=3Duserkey%>" + "&op=3DgetLast";
- do_ajax =3D new Ajax.Request(ajaxurl, {parameters: args, onComplete: s=
howLast});
+ var do_ajax =3D new Ajax.Request(ajaxurl, {parameters: args, onComplet=
e: showLast});
+ delete do_ajax;
}
=
function checkMessages() {
//the ajax periodical object
- checker =3D new PeriodicalExecuter(getLastMessage, 1);
+ var checker =3D new PeriodicalExecuter(getLastMessage, 1);
+ delete checker;
}
=
//get all messages waiting and start the checker
@@ -340,10 +379,13 @@
width=3D"48" height=3D"48" border=3D"0"></=
td>
<td align=3D"left"><br>
=
- <h3><%=3DgetRessource("org.jahia.chat.window.title", local=
e)%> <%=3Dtargetname%></h3>
- <% if(!offsince.equals("")){
+ <h3><%=3DgetRessource("org.jahia.chat.window.title", local=
e)%> <%=3Dtargetname%>
+ </h3>
+ <% if (!offsince.equals("")) {
%>
- <%=3Dtargetname%> <content:engineResourceBundle resou=
rceName=3D"org.jahia.chat.window.message.offline"/> <%=3Doffsince%>
+ <%=3Dtargetname%>
+ <content:engineResourceBundle resourceName=3D"org.jahia.ch=
at.window.message.offline"/>
+ <%=3Doffsince%>
<%
}
%>
@@ -352,45 +394,64 @@
<div id=3D"buttons">
<div class=3D"button">
<a href=3D"javascript:window.close();"
- title=3D"<%=3DgetRessource("org.jahia.chat.wind=
ow.close", locale)%>"><%=3DgetRessource("org.jahia.chat.window.close", loca=
le)%></a>
+ title=3D"<%=3DgetRessource("org.jahia.chat.wind=
ow.close", locale)%>"><%=3DgetRessource("org.jahia.chat.window.close", loca=
le)%>
+ </a>
</div>
</div>
</td>
</tr>
- <tr><td colspan=3D"3" width=3D"420px" height=3D"300px" valign=3D"t=
op"><div id=3D"discussion"></div></td></tr>
-<% if(offsince.equals("")){
- %>
- <tr><td colspan=3D"3"><%=3DgetRessource("org.jahia.chat.window.mes=
sage.prefix", locale)%> <%=3Dtargetname%>
- , <%=3DgetRessource("org.jahia.chat.window.message.postfix", l=
ocale)%> :</td></tr>
- <tr><td colspan=3D"3">
- <form id=3D"talk" method=3D"get">
- <textarea id=3D"message" name=3D"message" rows=3D"3" cols=
=3D"60" wrap=3Dhard
- onkeypress=3D"submitenter(event)"></textarea>
- </form>
- </td>
+ <tr>
+ <td colspan=3D"3" width=3D"420px" height=3D"300px" valign=3D"t=
op">
+ <div id=3D"discussion"></div>
+ </td>
+ </tr>
+ <% if (offsince.equals("")) {
+ %>
+ <tr>
+ <td colspan=3D"3"><%=3DgetRessource("org.jahia.chat.window.mes=
sage.prefix", locale)%> <%=3Dtargetname%>
+ , <%=3DgetRessource("org.jahia.chat.window.message.postfix=
", locale)%> :
+ </td>
+ </tr>
+ <tr>
+ <td colspan=3D"3">
+ <form id=3D"talk" method=3D"get">
+ <textarea id=3D"message" name=3D"message" rows=3D"3" c=
ols=3D"60" wrap=3Dhard
+ onkeypress=3D"submitenter(event)"></textarea>
+ </form>
+ </td>
<!--td><a href=3D"javascript:send();" title=3D"envoyer le mess=
age"><img src=3D"<//%=3Drequest.getContextPath()%>/jsp/jahia/engines/images=
/user1_message.gif" width=3D"48" height=3D"48" border=3D"0"></a><br></td-->
</tr>
<%}%>
- <tr><td colspan=3D"3">
- <table border=3D"0" width=3D"100%">
- <tr><td width=3D"48"><img name=3D"logo" src=3D"../images/l=
ogo-jahia.gif" border=3D"0" width=3D"45" height=3D"34"></td><td><img src=
=3D"<%=3Drequest.getContextPath()%>/jsp/jahia/engines/images/pix.gif" borde=
r=3D"0" width=3D"10" height=3D"15">
-
- <div id=3D"copyright"><%=3DJahia.COPYRIGHT%> <jahia:e=
ngineResourceBundle resourceName=3D"org.jahia.Jahia.copyright.label"/></div>
- <span class=3D"version">Jahia <%=3DJahia.VERSION%>.<%=3DJa=
hia.PATCH_NUMBER%> r<%=3DJahia.BUILD_NUMBER%></span>
-
- </td></tr></table>
- </td></tr>
+ <tr>
+ <td colspan=3D"3">
+ <table border=3D"0" width=3D"100%">
+ <tr>
+ <td width=3D"48"><img name=3D"logo" src=3D"../imag=
es/logo-jahia.gif" border=3D"0" width=3D"45"
+ height=3D"34"></td>
+ <td><img src=3D"<%=3Drequest.getContextPath()%>/js=
p/jahia/engines/images/pix.gif" border=3D"0"
+ width=3D"10" height=3D"15">
+
+ <div id=3D"copyright"><%=3DJahia.COPYRIGHT%>&n=
bsp;
+ <jahia:engineResourceBundle resourceName=
=3D"org.jahia.Jahia.copyright.label"/>
+ </div>
+ <span class=3D"version">Jahia <%=3DJahia.VERSI=
ON%>.<%=3DJahia.PATCH_NUMBER%> r<%=3DJahia.BUILD_NUMBER%></span>
+
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
</table>
<div id=3D"poweredby">
<span>Powered by Jahia</span>
</div>
</div>
-<% if(offsince.equals("")){
- %>
+<% if (offsince.equals("")) {
+%>
<script language=3D"javascript">
$('message').focus();
</script>
- <%}%>
+<%}%>
=
</body>
</html>
_______________________________________________
cvs_list mailing list
[email protected]
http://lists.jahia.org/cgi-bin/mailman/listinfo/cvs_list