[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qsos-commits] qsos/apps/xuleditor/chrome/content editor.js ed...
From: |
Raphaël Semeteys |
Subject: |
[Qsos-commits] qsos/apps/xuleditor/chrome/content editor.js ed... |
Date: |
Sun, 25 Feb 2007 09:59:26 +0000 |
CVSROOT: /sources/qsos
Module name: qsos
Changes by: Raphaël Semeteys <rsemeteys> 07/02/25 09:59:26
Modified files:
apps/xuleditor/chrome/content: editor.js editor.xul
Log message:
Chat area is now a html:div element which allows inner text styling
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qsos/apps/xuleditor/chrome/content/editor.js?cvsroot=qsos&r1=1.21&r2=1.22
http://cvs.savannah.gnu.org/viewcvs/qsos/apps/xuleditor/chrome/content/editor.xul?cvsroot=qsos&r1=1.19&r2=1.20
Patches:
Index: editor.js
===================================================================
RCS file: /sources/qsos/qsos/apps/xuleditor/chrome/content/editor.js,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -b -r1.21 -r1.22
--- editor.js 24 Feb 2007 23:37:14 -0000 1.21
+++ editor.js 25 Feb 2007 09:59:25 -0000 1.22
@@ -22,8 +22,9 @@
** editor.js: functions associated with the editor.xul file
**
** TODO:
-** - Chat: find a way to colorize text in "conversation" textbox
+** - Chat: remove unavailable users from roster
** - Chat: let user change it's nickname
+** - Chat: smileys replacement
*/
//Object "Document" representing data in the QSOS XML file
@@ -75,15 +76,17 @@
prefManager.setCharPref("extensions.qsos-xuled.nick", nick);
}
document.getElementById("chat-start").setAttribute("disabled", "true");
+ document.getElementById('t-s').selectedIndex = 3;
doLogin();
}
+//Replace some HTML reserved characters
function htmlEnc(str) {
str = str.replace(/&/g,"&");
str = str.replace(/</g,"<");
str = str.replace(/>/g,">");
str = str.replace(/\"/g,""");
- str = str.replace(/\n/g,"<br />");
+ str = str.replace(/\n/g,"<html:br />");
return str;
}
@@ -116,8 +119,36 @@
//JSJaC message handler
function handleMessage(aJSJaCPacket) {
var conversation = document.getElementById('conversation');
- conversation.value += getUserNick(aJSJaCPacket.getFrom())+': ' +
aJSJaCPacket.getBody() + '\n';
- conversation.inputField.scrollTop = conversation.inputField.scrollHeight -
conversation.inputField.clientHeight;
+ var usernick = getUserNick(aJSJaCPacket.getFrom());
+ var msg = htmlEnc(aJSJaCPacket.getBody());
+
+ var nickcolor;
+ switch(usernick) {
+ case nick:
+ nickcolor = 'blue';
+ break
+ case 'Chatroom':
+ nickcolor = 'red';
+ break
+ default:
+ nickcolor = 'black';
+ }
+
+ var msgcolor;
+ if (msg.indexOf(nick) != -1) {
+ msgcolor = 'green';
+ } else {
+ msgcolor = 'black';
+ }
+
+ conversation.innerHTML +=
+ "<html:span style='font-weight: bold; color: " + nickcolor + "'>" +
+ usernick + ": </html:span>" +
+ "<html:span style='color: " + msgcolor + "'>" + msg + "</html:span>" +
+ "<html:br />";
+
+ //Scroll to the bottom of the conversation view
+ conversation.scrollTop = conversation.scrollHeight;
}
//JSJaC presence handler
Index: editor.xul
===================================================================
RCS file: /sources/qsos/qsos/apps/xuleditor/chrome/content/editor.xul,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- editor.xul 24 Feb 2007 23:02:37 -0000 1.19
+++ editor.xul 25 Feb 2007 09:59:25 -0000 1.20
@@ -4,7 +4,7 @@
<!DOCTYPE window SYSTEM "chrome://qsos-xuled/locale/editor.dtd">
<window id="QSOS" title="&QSOS.label;" width="800px" height="600px"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
-
+ xmlns:html="http://www.w3.org/1999/xhtml"
onload="init();">
<script type="application/x-javascript" src="jsjac/xmlextras.js"></script>
<script type="application/x-javascript" src="jsjac/JSJaCPacket.js"></script>
@@ -144,7 +144,7 @@
<hbox flex = "1">
<vbox flex = "5">
<label value="&chat-conversation;"/>
- <textbox id="conversation" multiline="true" rows="20"
readonly="true"/>
+ <html:div id="conversation" flex="1"/>
<label value="&chat-input;" control="input"/>
<textbox id="input" multiline="true" rows="2"/>
<textbox id="err" multiline="true" rows="2" hidden="true"/>