* Message entry using Kevin Roth's excellent cross-platform richtext
authorArt Cancro <ajc@citadel.org>
Mon, 31 May 2004 20:34:11 +0000 (20:34 +0000)
committerArt Cancro <ajc@citadel.org>
Mon, 31 May 2004 20:34:11 +0000 (20:34 +0000)
  editing script.

37 files changed:
webcit/ChangeLog
webcit/README.txt
webcit/auth.c
webcit/messages.c
webcit/roomops.c
webcit/serv_func.c
webcit/static/bgcolor.gif [new file with mode: 0644]
webcit/static/blackdot.gif [new file with mode: 0644]
webcit/static/bold.gif [new file with mode: 0644]
webcit/static/centre.gif [new file with mode: 0644]
webcit/static/copy.gif [new file with mode: 0644]
webcit/static/cut.gif [new file with mode: 0644]
webcit/static/email.gif [new file with mode: 0644]
webcit/static/hr.gif [new file with mode: 0644]
webcit/static/hyperlink.gif [new file with mode: 0644]
webcit/static/image.gif [new file with mode: 0644]
webcit/static/indent.gif [new file with mode: 0644]
webcit/static/italic.gif [new file with mode: 0644]
webcit/static/justifyfull.gif [new file with mode: 0644]
webcit/static/left_just.gif [new file with mode: 0644]
webcit/static/list.gif [new file with mode: 0644]
webcit/static/numbered_list.gif [new file with mode: 0644]
webcit/static/outdent.gif [new file with mode: 0644]
webcit/static/palette.htm [new file with mode: 0644]
webcit/static/paste.gif [new file with mode: 0644]
webcit/static/redo.gif [new file with mode: 0644]
webcit/static/richtext.js [new file with mode: 0644]
webcit/static/richtext_compressed.js [new file with mode: 0644]
webcit/static/right_just.gif [new file with mode: 0644]
webcit/static/rte.css [new file with mode: 0644]
webcit/static/smiley.gif [new file with mode: 0644]
webcit/static/spellcheck.gif [new file with mode: 0644]
webcit/static/textcolor.gif [new file with mode: 0644]
webcit/static/underline.gif [new file with mode: 0644]
webcit/static/undo.gif [new file with mode: 0644]
webcit/webcit.c
webcit/webcit.h

index fbd4e47fe4278cc832c9ed8eb282adde0055d4b2..a81b38814ccde4549e19264439f91af4b090c897 100644 (file)
@@ -1,4 +1,8 @@
 $Log$
+Revision 510.5  2004/05/31 20:34:11  ajc
+* Message entry using Kevin Roth's excellent cross-platform richtext
+  editing script.
+
 Revision 510.4  2004/05/31 15:54:13  ajc
 * "text" and "HTML" options for message entry.
 
@@ -1821,3 +1825,4 @@ Sun Dec  6 19:50:55 EST 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
 
 1998-12-03 Nathan Bryant <bryant@cs.usm.maine.edu>
        * webserver.c: warning fix
+
index 4b5692297c2494a6e2f44468a44cf9f5b420f50e..aa1b553b85d98ef0881645c28e018336f4ea50f0 100644 (file)
@@ -6,6 +6,7 @@
        Nathan Bryant
        Nick Grossman
        Andru Luvisi
+        Kevin Roth
  
 This program is free software released under the terms of the GNU General
 Public License.  Please read COPYING.txt for more licensing information.
index 5f44773948daf0d5df5d4e6b1c52fb9e3c1cb890..c6a280e9cfa362788ea5293b6bd1dd388c3e341c 100644 (file)
@@ -49,7 +49,7 @@ void display_login(char *mesg)
        output_headers(3);
 
        if (mesg != NULL) if (strlen(mesg) > 0) {
-               stresc(buf, mesg, 0);
+               stresc(buf, mesg, 0, 0);
                svprintf("mesg", WCS_STRING, "%s", buf);
        }
 
index 7f373d2f81c865a761b52121ad8c9b39b9fa8066..fbb15c96b23e45f344e18fa2b70b8bf3502c42b6 100644 (file)
@@ -1482,13 +1482,13 @@ void display_enter(void)
        now = time(NULL);
        fmt_date(buf, now);
        strcat(&buf[strlen(buf)], " <I>from</I> ");
-       stresc(&buf[strlen(buf)], WC->wc_username, 1);
+       stresc(&buf[strlen(buf)], WC->wc_username, 1, 1);
        if (strlen(bstr("recp")) > 0) {
                strcat(&buf[strlen(buf)], " <I>to</I> ");
-               stresc(&buf[strlen(buf)], bstr("recp"), 1);
+               stresc(&buf[strlen(buf)], bstr("recp"), 1, 1);
        }
        strcat(&buf[strlen(buf)], " <I>in</I> ");
-       stresc(&buf[strlen(buf)], WC->wc_roomname, 1);
+       stresc(&buf[strlen(buf)], WC->wc_roomname, 1, 1);
        svprintf("BOXTITLE", WCS_STRING, buf);
        do_template("beginbox");
 
@@ -1496,13 +1496,15 @@ void display_enter(void)
 
        wprintf("<FORM ENCTYPE=\"multipart/form-data\" "
                "METHOD=\"POST\" ACTION=\"/post\" "
-               "NAME=\"enterform\">\n");
+               "NAME=\"enterform\""
+               "onSubmit=\"return submitForm();\""
+               ">\n");
        wprintf("<INPUT TYPE=\"hidden\" NAME=\"recp\" VALUE=\"%s\">\n",
                bstr("recp"));
        wprintf("<INPUT TYPE=\"hidden\" NAME=\"postseq\" VALUE=\"%ld\">\n",
                now);
-       wprintf("<IMG SRC=\"static/enter.gif\" ALIGN=MIDDLE ALT=\" \" "
-               "onLoad=\"document.enterform.msgtext.focus();\" >");
+       wprintf("<IMG SRC=\"static/enter.gif\" ALIGN=MIDDLE ALT=\" \">");
+               /* "onLoad=\"document.enterform.msgtext.focus();\" " */
        wprintf("<FONT SIZE=-1>Subject (optional):</FONT>"
                "<INPUT TYPE=\"text\" NAME=\"subject\" VALUE=\"");
        escputs(bstr("subject"));
@@ -1511,20 +1513,39 @@ void display_enter(void)
        );
 
        wprintf("<INPUT TYPE=\"radio\" NAME=\"msg_format\"");
-       if (strcasecmp(bstr("msg_format"), "html")) wprintf("CHECKED ");
+       if (!strcasecmp(bstr("msg_format"), "text")) wprintf("CHECKED ");
        wprintf("VALUE=\"text\">text&nbsp;\n");
 
        wprintf("<INPUT TYPE=\"radio\" NAME=\"msg_format\"");
-       if (!strcasecmp(bstr("msg_format"), "html")) wprintf("CHECKED ");
+       if (strcasecmp(bstr("msg_format"), "text")) wprintf("CHECKED ");
        wprintf("VALUE=\"html\">HTML&nbsp;\n");
 
        wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Save message\">"
                "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\"><BR>\n");
 
+       wprintf("<SCRIPT language=\"JavaScript\" type=\"text/javascript\" "
+               "src=\"static/richtext.js\"></SCRIPT>\n"
+               "<SCRIPT language=\"JavaScript\" type=\"text/javascript\">\n"
+               "function submitForm() { \n"
+               "  updateRTE('msgtext'); \n"
+               "  return true; \n"
+               "} \n"
+               "  \n"
+               "initRTE(\"static/\", \"static/\", \"\"); \n"
+               "</script> \n"
+               "<noscript>JAVASCRIPT MUST BE ENABLED.</noscript> \n"
+               "<SCRIPT language=\"javascript\" type=\"text/javascript\"> \n"
+               "writeRichText('msgtext', '");
+       msgescputs(bstr("msgtext"));
+       wprintf("', '100%%', 200, true, false); \n"
+               "</script> \n");
+
+/*
        wprintf("<TEXTAREA NAME=\"msgtext\" wrap=soft ROWS=25 COLS=80 "
                "WIDTH=80>");
        escputs(bstr("msgtext"));
        wprintf("</TEXTAREA><BR>\n");
+*/
 
        /* Enumerate any attachments which are already in place... */
        for (att = WC->first_attachment; att != NULL; att = att->next) {
index 042144d6352431a72e05cfa113ea476a15081aca..eab01a968176785317a68b5568ba582c49b67cd6 100644 (file)
@@ -114,7 +114,7 @@ void room_tree_list(struct roomlisting *rp)
        urlescputs(rmname);
        wprintf("\"");
        wprintf(">");
-       escputs1(rmname, 1);
+       escputs1(rmname, 1, 1);
        if ((f & QR_DIRECTORY) && (f & QR_NETWORK))
                wprintf("}");
        else if (f & QR_DIRECTORY)
@@ -1360,7 +1360,7 @@ void display_whok(void)
         }
         
         output_headers(1);
-       stresc(buf, WC->wc_roomname, 1);
+       stresc(buf, WC->wc_roomname, 1, 1);
        svprintf("BOXTITLE", WCS_STRING, "Access control list for %s", buf);
        do_template("beginbox");
 
@@ -1986,7 +1986,7 @@ void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
 
                        /* Begin inner box */
                        extract(buf, fold[i].name, levels-1);
-                       stresc(boxtitle, buf, 1);
+                       stresc(boxtitle, buf, 1, 0);
                        svprintf("BOXTITLE", WCS_STRING, boxtitle);
                        do_template("beginbox");
 
index 98fb3c0714d8a27b28793f672b7a1676b98bcf0b..924f0a0892a87dd34a248ab18277d61246e831d4 100644 (file)
@@ -193,7 +193,7 @@ void text_to_server(char *ptr, int convert_to_html)
                        }
                } else if ((convert_to_html)&&(strchr("#&;`'|*?-~<>^()[]{}$\\", ch) != NULL)) {
                        sprintf(conv, "%c", ch);
-                       stresc(&buf[strlen(buf)], conv, 0);
+                       stresc(&buf[strlen(buf)], conv, 0, 0);
                } else {
                        a = strlen(buf);
                        buf[a + 1] = 0;
diff --git a/webcit/static/bgcolor.gif b/webcit/static/bgcolor.gif
new file mode 100644 (file)
index 0000000..55fcf1b
Binary files /dev/null and b/webcit/static/bgcolor.gif differ
diff --git a/webcit/static/blackdot.gif b/webcit/static/blackdot.gif
new file mode 100644 (file)
index 0000000..f79319f
Binary files /dev/null and b/webcit/static/blackdot.gif differ
diff --git a/webcit/static/bold.gif b/webcit/static/bold.gif
new file mode 100644 (file)
index 0000000..bdb3259
Binary files /dev/null and b/webcit/static/bold.gif differ
diff --git a/webcit/static/centre.gif b/webcit/static/centre.gif
new file mode 100644 (file)
index 0000000..f98c86a
Binary files /dev/null and b/webcit/static/centre.gif differ
diff --git a/webcit/static/copy.gif b/webcit/static/copy.gif
new file mode 100644 (file)
index 0000000..faebb18
Binary files /dev/null and b/webcit/static/copy.gif differ
diff --git a/webcit/static/cut.gif b/webcit/static/cut.gif
new file mode 100644 (file)
index 0000000..ca60a1a
Binary files /dev/null and b/webcit/static/cut.gif differ
diff --git a/webcit/static/email.gif b/webcit/static/email.gif
new file mode 100644 (file)
index 0000000..eb355f0
Binary files /dev/null and b/webcit/static/email.gif differ
diff --git a/webcit/static/hr.gif b/webcit/static/hr.gif
new file mode 100644 (file)
index 0000000..c98da9d
Binary files /dev/null and b/webcit/static/hr.gif differ
diff --git a/webcit/static/hyperlink.gif b/webcit/static/hyperlink.gif
new file mode 100644 (file)
index 0000000..1fb1a4a
Binary files /dev/null and b/webcit/static/hyperlink.gif differ
diff --git a/webcit/static/image.gif b/webcit/static/image.gif
new file mode 100644 (file)
index 0000000..8cbba16
Binary files /dev/null and b/webcit/static/image.gif differ
diff --git a/webcit/static/indent.gif b/webcit/static/indent.gif
new file mode 100644 (file)
index 0000000..2abb6b2
Binary files /dev/null and b/webcit/static/indent.gif differ
diff --git a/webcit/static/italic.gif b/webcit/static/italic.gif
new file mode 100644 (file)
index 0000000..8b1485b
Binary files /dev/null and b/webcit/static/italic.gif differ
diff --git a/webcit/static/justifyfull.gif b/webcit/static/justifyfull.gif
new file mode 100644 (file)
index 0000000..b12528b
Binary files /dev/null and b/webcit/static/justifyfull.gif differ
diff --git a/webcit/static/left_just.gif b/webcit/static/left_just.gif
new file mode 100644 (file)
index 0000000..505c5d9
Binary files /dev/null and b/webcit/static/left_just.gif differ
diff --git a/webcit/static/list.gif b/webcit/static/list.gif
new file mode 100644 (file)
index 0000000..b3018d9
Binary files /dev/null and b/webcit/static/list.gif differ
diff --git a/webcit/static/numbered_list.gif b/webcit/static/numbered_list.gif
new file mode 100644 (file)
index 0000000..d1a4dbc
Binary files /dev/null and b/webcit/static/numbered_list.gif differ
diff --git a/webcit/static/outdent.gif b/webcit/static/outdent.gif
new file mode 100644 (file)
index 0000000..fa3c1b6
Binary files /dev/null and b/webcit/static/outdent.gif differ
diff --git a/webcit/static/palette.htm b/webcit/static/palette.htm
new file mode 100644 (file)
index 0000000..af4954b
--- /dev/null
@@ -0,0 +1,126 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+<head>
+       <title>Text Color</title>
+       <script language="JavaScript" type="text/javascript">
+       <!--
+       function selectColor(color) {
+               self.parent.setColor(color);
+       }
+       
+       function InitColorPalette() {
+               if (document.getElementsByTagName)
+                       var x = document.getElementsByTagName('TD');
+               else if (document.all)
+                       var x = document.all.tags('TD');
+               for (var i=0;i<x.length;i++) {
+                       x[i].onmouseover = over;
+                       x[i].onmouseout = out;
+                       x[i].onclick = click;
+               }
+       }
+       
+       function over() {
+               this.style.border='1px dotted white';
+       }
+       
+       function out() {
+               this.style.border='1px solid gray';
+       }
+       
+       function click() {
+               selectColor(this.id);
+       }
+       //-->
+       </script>
+</head>
+<body bgcolor="white" onLoad="InitColorPalette()" leftmargin="0" rightmargin="0" marginwidth="0" marginheight="0" topmargin="0" bottommargin="0">
+<table width="150" height="100" cellpadding="0" cellspacing="1" border="1" align="center">
+       <tr>
+               <td id="#FFFFFF" bgcolor="#FFFFFF" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#FFCCCC" bgcolor="#FFCCCC" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#FFCC99" bgcolor="#FFCC99" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#FFFF99" bgcolor="#FFFF99" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#FFFFCC" bgcolor="#FFFFCC" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#99FF99" bgcolor="#99FF99" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#99FFFF" bgcolor="#99FFFF" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#CCFFFF" bgcolor="#CCFFFF" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#CCCCFF" bgcolor="#CCCCFF" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#FFCCFF" bgcolor="#FFCCFF" width="10" height="10"><img width="1" height="1"></td>
+       </tr>
+       <tr>
+               <td id="#CCCCCC" bgcolor="#CCCCCC" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#FF6666" bgcolor="#FF6666" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#FF9966" bgcolor="#FF9966" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#FFFF66" bgcolor="#FFFF66" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#FFFF33" bgcolor="#FFFF33" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#66FF99" bgcolor="#66FF99" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#33FFFF" bgcolor="#33FFFF" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#66FFFF" bgcolor="#66FFFF" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#9999FF" bgcolor="#9999FF" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#FF99FF" bgcolor="#FF99FF" width="10" height="10"><img width="1" height="1"></td>
+       </tr>
+       <tr>
+               <td id="#C0C0C0" bgcolor="#C0C0C0" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#FF0000" bgcolor="#FF0000" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#FF9900" bgcolor="#FF9900" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#FFCC66" bgcolor="#FFCC66" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#FFFF00" bgcolor="#FFFF00" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#33FF33" bgcolor="#33FF33" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#66CCCC" bgcolor="#66CCCC" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#33CCFF" bgcolor="#33CCFF" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#6666CC" bgcolor="#6666CC" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#CC66CC" bgcolor="#CC66CC" width="10" height="10"><img width="1" height="1"></td>
+       </tr>
+       <tr>
+               <td id="#999999" bgcolor="#999999" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#CC0000" bgcolor="#CC0000" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#FF6600" bgcolor="#FF6600" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#FFCC33" bgcolor="#FFCC33" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#FFCC00" bgcolor="#FFCC00" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#33CC00" bgcolor="#33CC00" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#00CCCC" bgcolor="#00CCCC" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#3366FF" bgcolor="#3366FF" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#6633FF" bgcolor="#6633FF" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#CC33CC" bgcolor="#CC33CC" width="10" height="10"><img width="1" height="1"></td>
+       </tr>
+       <tr>
+               <td id="#666666" bgcolor="#666666" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#990000" bgcolor="#990000" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#CC6600" bgcolor="#CC6600" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#CC9933" bgcolor="#CC9933" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#999900" bgcolor="#999900" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#009900" bgcolor="#009900" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#339999" bgcolor="#339999" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#3333FF" bgcolor="#3333FF" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#6600CC" bgcolor="#6600CC" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#993399" bgcolor="#993399" width="10" height="10"><img width="1" height="1"></td>
+       </tr>
+       <tr>
+               <td id="#333333" bgcolor="#333333" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#660000" bgcolor="#660000" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#993300" bgcolor="#993300" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#996633" bgcolor="#996633" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#666600" bgcolor="#666600" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#006600" bgcolor="#006600" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#336666" bgcolor="#336666" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#000099" bgcolor="#000099" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#333399" bgcolor="#333399" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#663366" bgcolor="#663366" width="10" height="10"><img width="1" height="1"></td>
+       </tr>
+       <tr>
+               <td id="#000000" bgcolor="#000000" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#330000" bgcolor="#330000" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#663300" bgcolor="#663300" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#663333" bgcolor="#663333" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#333300" bgcolor="#333300" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#003300" bgcolor="#003300" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#003333" bgcolor="#003333" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#000066" bgcolor="#000066" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#330099" bgcolor="#330099" width="10" height="10"><img width="1" height="1"></td>
+               <td id="#330033" bgcolor="#330033" width="10" height="10"><img width="1" height="1"></td>
+       </tr>
+</table>
+</body>
+</html>
diff --git a/webcit/static/paste.gif b/webcit/static/paste.gif
new file mode 100644 (file)
index 0000000..9bcc76a
Binary files /dev/null and b/webcit/static/paste.gif differ
diff --git a/webcit/static/redo.gif b/webcit/static/redo.gif
new file mode 100644 (file)
index 0000000..b51d6b8
Binary files /dev/null and b/webcit/static/redo.gif differ
diff --git a/webcit/static/richtext.js b/webcit/static/richtext.js
new file mode 100644 (file)
index 0000000..fe4cae3
--- /dev/null
@@ -0,0 +1,600 @@
+// Cross-Browser Rich Text Editor
+// http://www.kevinroth.com/rte/demo.htm
+// Written by Kevin Roth (kevin@NOSPAMkevinroth.com - remove NOSPAM)
+
+//init variables
+var isRichText = false;
+var rng;
+var currentRTE;
+var allRTEs = "";
+
+var isIE;
+var isGecko;
+var isSafari;
+var isKonqueror;
+
+var imagesPath;
+var includesPath;
+var cssFile;
+
+
+function initRTE(imgPath, incPath, css) {
+       //set browser vars
+       var ua = navigator.userAgent.toLowerCase();
+       isIE = ((ua.indexOf("msie") != -1) && (ua.indexOf("opera") == -1) && (ua.indexOf("webtv") == -1)); 
+       isGecko = (ua.indexOf("gecko") != -1);
+       isSafari = (ua.indexOf("safari") != -1);
+       isKonqueror = (ua.indexOf("konqueror") != -1);
+       
+       //check to see if designMode mode is available
+       if (document.getElementById && document.designMode && !isSafari && !isKonqueror) {
+               isRichText = true;
+       }
+       
+       if (!isIE) document.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT | Event.MOUSEDOWN | Event.MOUSEUP);
+       document.onmouseover = raiseButton;
+       document.onmouseout  = normalButton;
+       document.onmousedown = lowerButton;
+       document.onmouseup   = raiseButton;
+       
+       //set paths vars
+       imagesPath = imgPath;
+       includesPath = incPath;
+       cssFile = css;
+       
+       if (isRichText) document.writeln('<style type="text/css">@import "' + includesPath + 'rte.css";</style>');
+       
+       //for testing standard textarea, uncomment the following line
+       //isRichText = false;
+}
+
+function writeRichText(rte, html, width, height, buttons, readOnly) {
+       if (isRichText) {
+               if (allRTEs.length > 0) allRTEs += ";";
+               allRTEs += rte;
+               writeRTE(rte, html, width, height, buttons, readOnly);
+       } else {
+               writeDefault(rte, html, width, height, buttons, readOnly);
+       }
+}
+
+function writeDefault(rte, html, width, height, buttons, readOnly) {
+       if (!readOnly) {
+               document.writeln('<textarea name="' + rte + '" id="' + rte + '" style="width: ' + width + 'px; height: ' + height + 'px;">' + html + '</textarea>');
+       } else {
+               document.writeln('<textarea name="' + rte + '" id="' + rte + '" style="width: ' + width + 'px; height: ' + height + 'px;" readonly>' + html + '</textarea>');
+       }
+}
+
+function raiseButton(e) {
+       if (isIE) {
+               var el = window.event.srcElement;
+       } else {
+               var el= e.target;
+       }
+       
+       className = el.className;
+       if (className == 'rteImage' || className == 'rteImageLowered') {
+               el.className = 'rteImageRaised';
+       }
+}
+
+function normalButton(e) {
+       if (isIE) {
+               var el = window.event.srcElement;
+       } else {
+               var el= e.target;
+       }
+       
+       className = el.className;
+       if (className == 'rteImageRaised' || className == 'rteImageLowered') {
+               el.className = 'rteImage';
+       }
+}
+
+function lowerButton(e) {
+       if (isIE) {
+               var el = window.event.srcElement;
+       } else {
+               var el= e.target;
+       }
+       
+       className = el.className;
+       if (className == 'rteImage' || className == 'rteImageRaised') {
+               el.className = 'rteImageLowered';
+       }
+}
+
+function writeRTE(rte, html, width, height, buttons, readOnly) {
+       if (readOnly) buttons = false;
+       
+       //adjust minimum table widths
+       if (isIE) {
+               if (buttons && (width < 600)) width = 600;
+               var tablewidth = width;
+       } else {
+               if (buttons && (width < 500)) width = 500;
+               var tablewidth = width + 4;
+       }
+       
+       if (buttons == true) {
+               document.writeln('<table class="rteBack" cellpadding=2 cellspacing=0 id="Buttons1_' + rte + '" width="' + tablewidth + '">');
+               document.writeln('      <tr>');
+               document.writeln('              <td>');
+               document.writeln('                      <select id="formatblock_' + rte + '" onchange="Select(\'' + rte + '\', this.id);">');
+               document.writeln('                              <option value="">[Style]</option>');
+               document.writeln('                              <option value="<p>">Paragraph</option>');
+               document.writeln('                              <option value="<h1>">Heading 1 <h1></option>');
+               document.writeln('                              <option value="<h2>">Heading 2 <h2></option>');
+               document.writeln('                              <option value="<h3>">Heading 3 <h3></option>');
+               document.writeln('                              <option value="<h4>">Heading 4 <h4></option>');
+               document.writeln('                              <option value="<h5>">Heading 5 <h5></option>');
+               document.writeln('                              <option value="<h6>">Heading 6 <h6></option>');
+               document.writeln('                              <option value="<address>">Address <ADDR></option>');
+               document.writeln('                              <option value="<pre>">Formatted <pre></option>');
+               document.writeln('                      </select>');
+               document.writeln('              </td>');
+               document.writeln('              <td>');
+               document.writeln('                      <select id="fontname_' + rte + '" onchange="Select(\'' + rte + '\', this.id)">');
+               document.writeln('                              <option value="Font" selected>[Font]</option>');
+               document.writeln('                              <option value="Arial, Helvetica, sans-serif">Arial</option>');
+               document.writeln('                              <option value="Courier New, Courier, mono">Courier New</option>');
+               document.writeln('                              <option value="Times New Roman, Times, serif">Times New Roman</option>');
+               document.writeln('                              <option value="Verdana, Arial, Helvetica, sans-serif">Verdana</option>');
+               document.writeln('                      </select>');
+               document.writeln('              </td>');
+               document.writeln('              <td>');
+               document.writeln('                      <select unselectable="on" id="fontsize_' + rte + '" onchange="Select(\'' + rte + '\', this.id);">');
+               document.writeln('                              <option value="Size">[Size]</option>');
+               document.writeln('                              <option value="1">1</option>');
+               document.writeln('                              <option value="2">2</option>');
+               document.writeln('                              <option value="3">3</option>');
+               document.writeln('                              <option value="4">4</option>');
+               document.writeln('                              <option value="5">5</option>');
+               document.writeln('                              <option value="6">6</option>');
+               document.writeln('                              <option value="7">7</option>');
+               document.writeln('                      </select>');
+               document.writeln('              </td>');
+               document.writeln('              <td width="100%">');
+               document.writeln('              </td>');
+               document.writeln('      </tr>');
+               document.writeln('</table>');
+               document.writeln('<table class="rteBack" cellpadding="0" cellspacing="0" id="Buttons2_' + rte + '" width="' + tablewidth + '">');
+               document.writeln('      <tr>');
+               document.writeln('              <td><img class="rteImage" src="' + imagesPath + 'bold.gif" width="25" height="24" alt="Bold" title="Bold" onClick="FormatText(\'' + rte + '\', \'bold\', \'\')"></td>');
+               document.writeln('              <td><img class="rteImage" src="' + imagesPath + 'italic.gif" width="25" height="24" alt="Italic" title="Italic" onClick="FormatText(\'' + rte + '\', \'italic\', \'\')"></td>');
+               document.writeln('              <td><img class="rteImage" src="' + imagesPath + 'underline.gif" width="25" height="24" alt="Underline" title="Underline" onClick="FormatText(\'' + rte + '\', \'underline\', \'\')"></td>');
+               document.writeln('              <td><img class="rteVertSep" src="' + imagesPath + 'blackdot.gif" width="1" height="20" border="0" alt=""></td>');
+               document.writeln('              <td><img class="rteImage" src="' + imagesPath + 'left_just.gif" width="25" height="24" alt="Align Left" title="Align Left" onClick="FormatText(\'' + rte + '\', \'justifyleft\', \'\')"></td>');
+               document.writeln('              <td><img class="rteImage" src="' + imagesPath + 'centre.gif" width="25" height="24" alt="Center" title="Center" onClick="FormatText(\'' + rte + '\', \'justifycenter\', \'\')"></td>');
+               document.writeln('              <td><img class="rteImage" src="' + imagesPath + 'right_just.gif" width="25" height="24" alt="Align Right" title="Align Right" onClick="FormatText(\'' + rte + '\', \'justifyright\', \'\')"></td>');
+               document.writeln('              <td><img class="rteImage" src="' + imagesPath + 'justifyfull.gif" width="25" height="24" alt="Justify Full" title="Justify Full" onclick="FormatText(\'' + rte + '\', \'justifyfull\', \'\')"></td>');
+               document.writeln('              <td><img class="rteVertSep" src="' + imagesPath + 'blackdot.gif" width="1" height="20" border="0" alt=""></td>');
+               document.writeln('              <td><img class="rteImage" src="' + imagesPath + 'hr.gif" width="25" height="24" alt="Horizontal Rule" title="Horizontal Rule" onClick="FormatText(\'' + rte + '\', \'inserthorizontalrule\', \'\')"></td>');
+               document.writeln('              <td><img class="rteVertSep" src="' + imagesPath + 'blackdot.gif" width="1" height="20" border="0" alt=""></td>');
+               document.writeln('              <td><img class="rteImage" src="' + imagesPath + 'numbered_list.gif" width="25" height="24" alt="Ordered List" title="Ordered List" onClick="FormatText(\'' + rte + '\', \'insertorderedlist\', \'\')"></td>');
+               document.writeln('              <td><img class="rteImage" src="' + imagesPath + 'list.gif" width="25" height="24" alt="Unordered List" title="Unordered List" onClick="FormatText(\'' + rte + '\', \'insertunorderedlist\', \'\')"></td>');
+               document.writeln('              <td><img class="rteVertSep" src="' + imagesPath + 'blackdot.gif" width="1" height="20" border="0" alt=""></td>');
+               document.writeln('              <td><img class="rteImage" src="' + imagesPath + 'outdent.gif" width="25" height="24" alt="Outdent" title="Outdent" onClick="FormatText(\'' + rte + '\', \'outdent\', \'\')"></td>');
+               document.writeln('              <td><img class="rteImage" src="' + imagesPath + 'indent.gif" width="25" height="24" alt="Indent" title="Indent" onClick="FormatText(\'' + rte + '\', \'indent\', \'\')"></td>');
+               document.writeln('              <td><div id="forecolor_' + rte + '"><img class="rteImage" src="' + imagesPath + 'textcolor.gif" width="25" height="24" alt="Text Color" title="Text Color" onClick="FormatText(\'' + rte + '\', \'forecolor\', \'\')"></div></td>');
+               document.writeln('              <td><div id="hilitecolor_' + rte + '"><img class="rteImage" src="' + imagesPath + 'bgcolor.gif" width="25" height="24" alt="Background Color" title="Background Color" onClick="FormatText(\'' + rte + '\', \'hilitecolor\', \'\')"></div></td>');
+               document.writeln('              <td><img class="rteVertSep" src="' + imagesPath + 'blackdot.gif" width="1" height="20" border="0" alt=""></td>');
+               document.writeln('              <td><img class="rteImage" src="' + imagesPath + 'hyperlink.gif" width="25" height="24" alt="Insert Link" title="Insert Link" onClick="FormatText(\'' + rte + '\', \'createlink\')"></td>');
+               document.writeln('              <td><img class="rteImage" src="' + imagesPath + 'image.gif" width="25" height="24" alt="Add Image" title="Add Image" onClick="AddImage(\'' + rte + '\')"></td>');
+               if (isIE) {
+                       document.writeln('              <td><img class="rteImage" src="' + imagesPath + 'spellcheck.gif" width="25" height="24" alt="Spell Check" title="Spell Check" onClick="checkspell()"></td>');
+               }
+//             document.writeln('              <td><img class="rteVertSep" src="' + imagesPath + 'blackdot.gif" width="1" height="20" border="0" alt=""></td>');
+//             document.writeln('              <td><img class="rteImage" src="' + imagesPath + 'cut.gif" width="25" height="24" alt="Cut" title="Cut" onClick="FormatText(\'' + rte + '\', \'cut\')"></td>');
+//             document.writeln('              <td><img class="rteImage" src="' + imagesPath + 'copy.gif" width="25" height="24" alt="Copy" title="Copy" onClick="FormatText(\'' + rte + '\', \'copy\')"></td>');
+//             document.writeln('              <td><img class="rteImage" src="' + imagesPath + 'paste.gif" width="25" height="24" alt="Paste" title="Paste" onClick="FormatText(\'' + rte + '\', \'paste\')"></td>');
+//             document.writeln('              <td><img class="rteVertSep" src="' + imagesPath + 'blackdot.gif" width="1" height="20" border="0" alt=""></td>');
+//             document.writeln('              <td><img class="rteImage" src="' + imagesPath + 'undo.gif" width="25" height="24" alt="Undo" title="Undo" onClick="FormatText(\'' + rte + '\', \'undo\')"></td>');
+//             document.writeln('              <td><img class="rteImage" src="' + imagesPath + 'redo.gif" width="25" height="24" alt="Redo" title="Redo" onClick="FormatText(\'' + rte + '\', \'redo\')"></td>');
+               document.writeln('              <td width="100%"></td>');
+               document.writeln('      </tr>');
+               document.writeln('</table>');
+       }
+       document.writeln('<iframe id="' + rte + '" name="' + rte + '" width="' + width + 'px" height="' + height + 'px"></iframe>');
+       if (!readOnly) document.writeln('<br /><input type="checkbox" id="chkSrc' + rte + '" onclick="toggleHTMLSrc(\'' + rte + '\');" />&nbsp;View Source');
+       document.writeln('<iframe width="154" height="104" id="cp' + rte + '" src="' + includesPath + 'palette.htm" marginwidth="0" marginheight="0" scrolling="no" style="visibility:hidden; display: none; position: absolute;"></iframe>');
+       document.writeln('<input type="hidden" id="hdn' + rte + '" name="' + rte + '" value="">');
+       document.getElementById('hdn' + rte).value = html;
+       enableDesignMode(rte, html, readOnly);
+}
+
+function enableDesignMode(rte, html, readOnly) {
+       var frameHtml = "<html id=\"" + rte + "\">\n";
+       frameHtml += "<head>\n";
+       //to reference your stylesheet, set href property below to your stylesheet path and uncomment
+       if (cssFile.length > 0) {
+               frameHtml += "<link media=\"all\" type=\"text/css\" href=\"" + cssFile + "\" rel=\"stylesheet\">\n";
+       } else {
+               frameHtml += "<style>\n";
+               frameHtml += "body {\n";
+               frameHtml += "  background: #FFFFFF;\n";
+               frameHtml += "  margin: 0px;\n";
+               frameHtml += "  padding: 0px;\n";
+               frameHtml += "}\n";
+               frameHtml += "</style>\n";
+       }
+       frameHtml += "</head>\n";
+       frameHtml += "<body>\n";
+       frameHtml += html + "\n";
+       frameHtml += "</body>\n";
+       frameHtml += "</html>";
+       
+       if (document.all) {
+               var oRTE = frames[rte].document;
+               oRTE.open();
+               oRTE.write(frameHtml);
+               oRTE.close();
+               if (!readOnly) oRTE.designMode = "On";
+       } else {
+               try {
+                       if (!readOnly) document.getElementById(rte).contentDocument.designMode = "on";
+                       try {
+                               var oRTE = document.getElementById(rte).contentWindow.document;
+                               oRTE.open();
+                               oRTE.write(frameHtml);
+                               oRTE.close();
+                               if (isGecko && !readOnly) {
+                                       //attach a keyboard handler for gecko browsers to make keyboard shortcuts work
+                                       oRTE.addEventListener("keypress", kb_handler, true);
+                               }
+                       } catch (e) {
+                               alert("Error preloading content.");
+                       }
+               } catch (e) {
+                       //gecko may take some time to enable design mode.
+                       //Keep looping until able to set.
+                       if (isGecko) {
+                               setTimeout("enableDesignMode('" + rte + "', '" + html + "', " + readOnly + ");", 10);
+                       } else {
+                               return false;
+                       }
+               }
+       }
+}
+
+function updateRTEs() {
+       var vRTEs = allRTEs.split(";");
+       for (var i = 0; i < vRTEs.length; i++) {
+               updateRTE(vRTEs[i]);
+       }
+}
+
+function updateRTE(rte) {
+       if (!isRichText) return;
+       
+       //set message value
+       var oHdnMessage = document.getElementById('hdn' + rte);
+       var oRTE = document.getElementById(rte);
+       var readOnly = false;
+       
+       //check for readOnly mode
+       if (document.all) {
+               if (frames[rte].document.designMode != "On") readOnly = true;
+       } else {
+               if (document.getElementById(rte).contentDocument.designMode != "on") readOnly = true;
+       }
+       
+       if (isRichText && !readOnly) {
+               //if viewing source, switch back to design view
+               if (document.getElementById("chkSrc" + rte).checked) {
+                       document.getElementById("chkSrc" + rte).checked = false;
+                       toggleHTMLSrc(rte);
+               }
+               
+               if (oHdnMessage.value == null) oHdnMessage.value = "";
+               if (document.all) {
+                       oHdnMessage.value = frames[rte].document.body.innerHTML;
+               } else {
+                       oHdnMessage.value = oRTE.contentWindow.document.body.innerHTML;
+               }
+               
+               //if there is no content (other than formatting) set value to nothing
+               if (stripHTML(oHdnMessage.value.replace("&nbsp;", " ")) == "" 
+                       && oHdnMessage.value.toLowerCase().search("<hr") == -1
+                       && oHdnMessage.value.toLowerCase().search("<img") == -1) oHdnMessage.value = "";
+               //fix for gecko
+               if (escape(oHdnMessage.value) == "%3Cbr%3E%0D%0A%0D%0A%0D%0A") oHdnMessage.value = "";
+       }
+}
+
+function toggleHTMLSrc(rte) {
+       //contributed by Bob Hutzel (thanks Bob!)
+       var oRTE;
+       if (document.all) {
+               oRTE = frames[rte].document;
+       } else {
+               oRTE = document.getElementById(rte).contentWindow.document;
+       }
+       
+       if (document.getElementById("chkSrc" + rte).checked) {
+               document.getElementById("Buttons1_" + rte).style.visibility = "hidden";
+               document.getElementById("Buttons2_" + rte).style.visibility = "hidden";
+               if (document.all) {
+                       oRTE.body.innerText = oRTE.body.innerHTML;
+               } else {
+                       var htmlSrc = oRTE.createTextNode(oRTE.body.innerHTML);
+                       oRTE.body.innerHTML = "";
+                       oRTE.body.appendChild(htmlSrc);
+               }
+       } else {
+               document.getElementById("Buttons1_" + rte).style.visibility = "visible";
+               document.getElementById("Buttons2_" + rte).style.visibility = "visible";
+               if (document.all) {
+                       //fix for IE
+                       var output = escape(oRTE.body.innerText);
+                       output = output.replace("%3CP%3E%0D%0A%3CHR%3E", "%3CHR%3E");
+                       output = output.replace("%3CHR%3E%0D%0A%3C/P%3E", "%3CHR%3E");
+                       
+                       oRTE.body.innerHTML = unescape(output);
+               } else {
+                       var htmlSrc = oRTE.body.ownerDocument.createRange();
+                       htmlSrc.selectNodeContents(oRTE.body);
+                       oRTE.body.innerHTML = htmlSrc.toString();
+               }
+       }
+}
+
+//Function to format text in the text box
+function FormatText(rte, command, option) {
+       var oRTE;
+       if (document.all) {
+               oRTE = frames[rte];
+               
+               //get current selected range
+               var selection = oRTE.document.selection; 
+               if (selection != null) {
+                       rng = selection.createRange();
+               }
+       } else {
+               oRTE = document.getElementById(rte).contentWindow;
+               
+               //get currently selected range
+               var selection = oRTE.getSelection();
+               rng = selection.getRangeAt(selection.rangeCount - 1).cloneRange();
+       }
+       
+       try {
+               if ((command == "forecolor") || (command == "hilitecolor")) {
+                       //save current values
+                       parent.command = command;
+                       currentRTE = rte;
+                       
+                       //position and show color palette
+                       buttonElement = document.getElementById(command + '_' + rte);
+                       // Ernst de Moor: Fix the amount of digging parents up, in case the RTE editor itself is displayed in a div.
+                       document.getElementById('cp' + rte).style.left = getOffsetLeft(buttonElement, 4) + "px";
+                       document.getElementById('cp' + rte).style.top = (getOffsetTop(buttonElement, 4) + buttonElement.offsetHeight + 4) + "px";
+                       if (document.getElementById('cp' + rte).style.visibility == "hidden") {
+                               document.getElementById('cp' + rte).style.visibility = "visible";
+                               document.getElementById('cp' + rte).style.display = "inline";
+                       } else {
+                               document.getElementById('cp' + rte).style.visibility = "hidden";
+                               document.getElementById('cp' + rte).style.display = "none";
+                       }
+               } else if (command == "createlink") {
+                       var szURL = prompt("Enter a URL:", "");
+                       try {
+                               //ignore error for blank urls
+                               oRTE.document.execCommand("Unlink", false, null);
+                               oRTE.document.execCommand("CreateLink", false, szURL);
+                       } catch (e) {
+                               //do nothing
+                       }
+               } else {
+                       oRTE.focus();
+                       oRTE.document.execCommand(command, false, option);
+                       oRTE.focus();
+               }
+       } catch (e) {
+               alert(e);
+       }
+}
+
+//Function to set color
+function setColor(color) {
+       var rte = currentRTE;
+       var oRTE;
+       if (document.all) {
+               oRTE = frames[rte];
+       } else {
+               oRTE = document.getElementById(rte).contentWindow;
+       }
+       
+       var parentCommand = parent.command;
+       if (document.all) {
+               //retrieve selected range
+               var sel = oRTE.document.selection; 
+               if (parentCommand == "hilitecolor") parentCommand = "backcolor";
+               if (sel != null) {
+                       var newRng = sel.createRange();
+                       newRng = rng;
+                       newRng.select();
+               }
+       }
+       oRTE.focus();
+       oRTE.document.execCommand(parentCommand, false, color);
+       oRTE.focus();
+       document.getElementById('cp' + rte).style.visibility = "hidden";
+       document.getElementById('cp' + rte).style.display = "none";
+}
+
+//Function to add image
+function AddImage(rte) {
+       var oRTE;
+       if (document.all) {
+               oRTE = frames[rte];
+               
+               //get current selected range
+               var selection = oRTE.document.selection; 
+               if (selection != null) {
+                       rng = selection.createRange();
+               }
+       } else {
+               oRTE = document.getElementById(rte).contentWindow;
+               
+               //get currently selected range
+               var selection = oRTE.getSelection();
+               rng = selection.getRangeAt(selection.rangeCount - 1).cloneRange();
+       }
+       
+       imagePath = prompt('Enter Image URL:', 'http://');                              
+       if ((imagePath != null) && (imagePath != "")) {
+               oRTE.focus();
+               oRTE.document.execCommand('InsertImage', false, imagePath);
+               oRTE.focus();
+       }
+}
+
+//function to perform spell check
+function checkspell() {
+       try {
+               var tmpis = new ActiveXObject("ieSpell.ieSpellExtension");
+               tmpis.CheckAllLinkedDocuments(document);
+       }
+       catch(exception) {
+               if(exception.number==-2146827859) {
+                       if (confirm("ieSpell not detected.  Click Ok to go to download page."))
+                               window.open("http://www.iespell.com/download.php","DownLoad");
+               } else {
+                       alert("Error Loading ieSpell: Exception " + exception.number);
+               }
+       }
+}
+
+// Ernst de Moor: Fix the amount of digging parents up, in case the RTE editor itself is displayed in a div.
+function getOffsetTop(elm, parents_up) {
+       var mOffsetTop = elm.offsetTop;
+       var mOffsetParent = elm.offsetParent;
+       
+       if(!parents_up) {
+               parents_up = 10000; // arbitrary big number
+       }
+       while(parents_up>0 && mOffsetParent) {
+               mOffsetTop += mOffsetParent.offsetTop;
+               mOffsetParent = mOffsetParent.offsetParent;
+               parents_up--;
+       }
+       
+       return mOffsetTop;
+}
+
+// Ernst de Moor: Fix the amount of digging parents up, in case the RTE editor itself is displayed in a div.
+function getOffsetLeft(elm, parents_up) {
+       var mOffsetLeft = elm.offsetLeft;
+       var mOffsetParent = elm.offsetParent;
+       
+       if(!parents_up) {
+               parents_up = 10000; // arbitrary big number
+       }
+       while(parents_up>0 && mOffsetParent) {
+               mOffsetLeft += mOffsetParent.offsetLeft;
+               mOffsetParent = mOffsetParent.offsetParent;
+               parents_up--;
+       }
+       
+       return mOffsetLeft;
+}
+
+function Select(rte, selectname) {
+       var oRTE;
+       if (document.all) {
+               oRTE = frames[rte];
+               
+               //get current selected range
+               var selection = oRTE.document.selection; 
+               if (selection != null) {
+                       rng = selection.createRange();
+               }
+       } else {
+               oRTE = document.getElementById(rte).contentWindow;
+               
+               //get currently selected range
+               var selection = oRTE.getSelection();
+               rng = selection.getRangeAt(selection.rangeCount - 1).cloneRange();
+       }
+       
+       var idx = document.getElementById(selectname).selectedIndex;
+       // First one is always a label
+       if (idx != 0) {
+               var selected = document.getElementById(selectname).options[idx].value;
+               var cmd = selectname.replace('_' + rte, '');
+               oRTE.focus();
+               oRTE.document.execCommand(cmd, false, selected);
+               oRTE.focus();
+               document.getElementById(selectname).selectedIndex = 0;
+       }
+}
+
+function kb_handler(evt) {
+       var rte = evt.target.id;
+       
+       //contributed by Anti Veeranna (thanks Anti!)
+       if (evt.ctrlKey) {
+               var key = String.fromCharCode(evt.charCode).toLowerCase();
+               var cmd = '';
+               switch (key) {
+                       case 'b': cmd = "bold"; break;
+                       case 'i': cmd = "italic"; break;
+                       case 'u': cmd = "underline"; break;
+               };
+
+               if (cmd) {
+                       FormatText(rte, cmd, true);
+                       //evt.target.ownerDocument.execCommand(cmd, false, true);
+                       // stop the event bubble
+                       evt.preventDefault();
+                       evt.stopPropagation();
+               }
+       }
+}
+
+function docChanged (evt) {
+       alert('changed');
+}
+
+function stripHTML(oldString) {
+       var newString = oldString.replace(/(<([^>]+)>)/ig,"");
+       
+       //replace carriage returns and line feeds
+   newString = newString.replace(/\r\n/g," ");
+   newString = newString.replace(/\n/g," ");
+   newString = newString.replace(/\r/g," ");
+       
+       //trim string
+       newString = trim(newString);
+       
+       return newString;
+}
+
+function trim(inputString) {
+   // Removes leading and trailing spaces from the passed string. Also removes
+   // consecutive spaces and replaces it with one space. If something besides
+   // a string is passed in (null, custom object, etc.) then return the input.
+   if (typeof inputString != "string") return inputString;
+   var retValue = inputString;
+   var ch = retValue.substring(0, 1);
+       
+   while (ch == " ") { // Check for spaces at the beginning of the string
+      retValue = retValue.substring(1, retValue.length);
+      ch = retValue.substring(0, 1);
+   }
+   ch = retValue.substring(retValue.length-1, retValue.length);
+       
+   while (ch == " ") { // Check for spaces at the end of the string
+      retValue = retValue.substring(0, retValue.length-1);
+      ch = retValue.substring(retValue.length-1, retValue.length);
+   }
+       
+       // Note that there are two spaces in the string - look for multiple spaces within the string
+   while (retValue.indexOf("  ") != -1) {
+               // Again, there are two spaces in each of the strings
+      retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length);
+   }
+   return retValue; // Return the trimmed string back to the user
+}
diff --git a/webcit/static/richtext_compressed.js b/webcit/static/richtext_compressed.js
new file mode 100644 (file)
index 0000000..6164dc5
--- /dev/null
@@ -0,0 +1 @@
+$="­Û=ú;­rng;­curr»Õ;­allÕs¯¢;­isIE;­isGüo;­isSafari;­isK¼quãor;­§;­ô;­cssFiý;functi¼ ðitÕ(imgPath,ðcPath,cssÖ­ua=navigator.usãAg»óÉisIE=(Ëmsie¢)!=-1)&&Ëopãa¢)==-1)&&Ëwebtv¢)==-1)ÉisGüo=Ëgüo¢)!=-1ÉisSafari=Ësafari¢)!=-1ÉisK¼quãor=Ëk¼quãor¢)!=-1)º¤ým»ById&&¨dÏ&&!isSafari&&!isK¼quãorÖÛ=true;}â!isIE)¨captureEv»s(Ev».MOUSEOVER|Ev».MOUSEOUT|Ev».MOUSEDOWN|Ev».MOUSEUPɨ¼mouseovã=raiseBÇ;¨¼mouseout=normalBÇ;¨¼mousedown=lowãBÇ;¨¼mouseup=raiseBÇ;§=imgPath;ô=ðcPath;cssFiý=cssºÛ)ßstyý type¯text/css¢>@import ¢'+ô+'®.css¢;</styý>'É´writeRichText×ht,bÇs,ÃÖâÛÖâallÕsÞ>0)allÕs+¯;¢;allÕs+=®;writeÕ×ht,bÇs,Ã)ÄwriteDefault×ht,bÇs,ÃÉ}´writeDefault×ht,bÇs,ÃÖâ!ÃÖßtextarea nȯª¢ id¯ª¢ styý¯Ó: '+Ó+'px; ù: '+ù+'px;¢>'+î+'</textarea>')Äßtextarea nȯª¢ id¯ª¢ styý¯Ó: '+Ó+'px; ù: '+ù+'px;¢ read¼ly>'+î+'</textarea>'É}´raiseÿ.Ѻø'||øLowãed'Öel.Ñ='®IáRaised';}´normalÿ.ѺøRaised'||øLowãed'Öel.Ñ='®Iá';}´lowãÿ.Ѻø'||øRaised'Öel.Ñ='®IáLowãed';}´writeÕ×ht,bÇs,ÃÖâÃ)bÇs=úºisIEÖâbÇs&&(Ó<600))Ó=600;­tabýÓ=ÓÄâbÇs&&(Ó<500))Ó=500;­tabýÓ=Ó+4;}âbÇs==trueÖßtabý class¯®Back¢ cellpaddðg=2 cellspacðg=0 id¯BÇs1_ª¢©'+tabýÓ+'¢õtr¦<td¦       <s¬ id¯formatblock_ª¢ ¼chû¯S¬(\\'ª\\', this.idÉ¢¦               <« à¯¢>[Styý]°¯<p>¢>Paragraph°¯<h1Ú1 <h1>°¯<h2Ú2 <h2>°¯<h3Ú3 <h3>°¯<h4Ú4 <h4>°¯<h5Ú5 <h5>°¯<h6Ú6 <h6>°¯<address>¢>Address <ADDR>°¯<pre>¢>Formatted <pre></«¦    </s¬¦</td¦<td¦  <s¬ id¯f¼tnÈ_ª¢ ¼chû¯S¬(\\'ª\\', this.id)¢¦             <« à¯F¼t¢ s¬ed>[F¼t]°¯Arial, Helvetica, sans-sãif¢>Arial°¯Couriã New, Couriã, m¼o¢>Couriã New°¯Times New Roman, Times, sãif¢>Times New Roman°¯Vãdana, Arial, Helvetica, sans-sãif¢>Vãdana</«¦   </s¬¦</td¦<td¦  <s¬ uns¬abý¯¼¢ id¯f¼tsize_ª¢ ¼chû¯S¬(\\'ª\\', this.idÉ¢¦                <« à¯Size¢>[Size]°¯1¢>1°¯2¢>2°¯3¢>3°¯4¢>4°¯5¢>5°¯6¢>6°¯7¢>7</«¦ </s¬¦</td¦<td©100%¢¦</tdõ/tr>'Éß/tabý>'Éßtabý class¯®Back¢ cellpaddðg¯0¢ cellspacðg¯0¢ id¯BÇs2_ª¢©'+tabýÓ+'¢õtr¦<td²'+§+'boldÂBoldÐBoldÀboldÌitalicÂItalicÐItalicÀitalicÌundãlðeÂUndãlðeÐUndãlðeÀundãlðe¸\\')¢æ§+'ýft_justÂAlign LeftÐAlign LeftÀjustifyýftÌc»reÂC»ãÐC»ãÀjustifyc»ãÌright_justÂAlign RightÐAlign RightÀjustifyrightÌjustifyfullÂJustify FullÐJustify Full¢ ¼c½t(\\'ª¸justifyfull¸\\')¢æ§+'hrÂHoriz¼tal RuýÐHoriz¼tal RuýÀðsãthoriz¼talruý¸\\')¢æ§+'numbãed_listÂOrdãed ListÐOrdãed ListÀðsãtordãedlistÌlistÂUnordãed ListÐUnordãed ListÀðsãtunordãedlist¸\\')¢æ§+'outd»ÂOutd»ÐOutd»Àoutd»Ìðd»ÂInd»ÐInd»Àðd»¸\\')¢µ><div id¯foreí_ª¢²'+§+'textíÂText ColorÐText ColorÀforeí¸\\')¢></divµ><div id¯hiliteí_ª¢²'+§+'bgíÂBackground ColorÐBackground ColorÀhiliteí¸\\')¢></divæ§+'hypãlðkÂInsãt LðkÐInsãt LðkÀcreatelðk\\')¢µ²'+§+'iáÂAdd IáÐAdd Iᢠ¼Click¯AddIá(\\'ª\\')¢></td>')ºisIEÖ£ln('               <td²'+§+'spellchüÂSpell ChüÐSpell Chü¢ ¼Click¯chüspell()¢></td>'É}£ln('         <td©100%¢></tdõ/tr>'Éß/tabý>'É}ßiï id¯ª¢ nȯª¢©'+Ó+'px¢ ù¯'+ù+'px¢></iï>')º!Ã)ßbr /><ðput type¯chübox¢ id¯chkSrcª¢ ¼click¯toggýHTMLSrc(\\'ª\\'É¢ />&nbsp;View Source'Éßiï©154¢ ù¯104¢ id¯cpª¢ src¯'+ô+'paýtte.htm¢ margðÓ¯0¢ margðù¯0¢ scrollðg¯no¢ styý¯visibility:hidden; display: n¼e; positi¼: absolute;¢></iï>'Éßðput type÷ id¯hdnª¢ nȯª¢ à¯¢>'É¥'hdn'+®).à=î;enabýDÏ(®,î,ÃÉ´enabýDÏ(®,î,ÃÖ­ïHtml¯<î id=\\¢¢+®+¢\\¢>¾+¯<head>\\n¢ºcssFiýÞ>0ÖïHtml+¯<lðk media=\\¢all\\¢ type=\\¢text/css\\¢ href=\\¢¢+cssFiý+¢\\¢ rel=\\¢styýsheet\\¢>\\n¢ÄïHtml+¯<styý>¾+¯body {¾+¯      background: #FFFFFF;¾+¯ margð: 0px;¾+¯  paddðg: 0px;¾+¯}¾+¯</styý>\\n¢;}ïHtml+¯</head>¾+¯<body>¾+=î+¢¾+¯</body>¾+¯</î>¢º¨allÖ­oÕ=ïs[®].docum»;¹open(ɹwrite(ïHtmlɹclose()º!Ã)¹dϯOn¢Ätry{â!Ã)¥®).c¼t»Docum».dϯ¼¢;try{­oÕ=¥®).Î.docum»;¹open(ɹwrite(ïHtmlɹclose()ºisGüo&&!ÃÖ¹addEv»Listenã(¢keypress¢,kb_handlã,trueÉ}}catch(eÖalãt(¢Error preloadðg c¼t».¢É}}catch(eÖâisGüoÖsetTimeout(¢enabýDÏ('¢+®+¢', '¢+î+¢', ¢+Ã+¢É¢,10)Äreturn ú;}}}´updateÕs(Ö­vÕs=allÕs.split(¢;¢Éfor(­i=0;i<vÕsÞ;i++ÖupdateÕ(vÕs[i]É}´updateÕ(®Öâ!Û)return;­oHdnMessage=¥'hdn'+®É­oÕ=¥®É­Ã=úº¨allÖâïs[®].¨dÏ!¯On¢)Ã=trueÄ⥮).c¼t»Docum».dÏ!¯¼¢)Ã=true;}âÛ&&!ÃÖ⥢chkSrc¢+®).chüedÖ¥¢chkSrc¢+®).chüed=ú;toggýHTMLSrc(®É}â¿à==null)¿à¯¢º¨allÖ¿à=ïs[®].¨ÊÄ¿à=¹Î.¨Ê;}âstripHTML(¿àÜ¢&nbsp;¢,¢ ¢))=¯¢&&¿àó).search(¢<hr¢)==-1&&¿àó).search(¢<img¢)==-1)¿à¯¢ºescape(¿à)=¯%3Cbr%3E%0D%0A%0D%0A%0D%0A¢)¿à¯¢;}´toggýHTMLSrc(®Öç=ïs[®].docum»ÄoÕ=¥®).Î.docum»;}⥢chkSrc¢+®).chüedÖ¥¢BÇs1_¢Í÷;¥¢BÇs2_¢Í÷º¨allÖ¹body.ðnãText=¹ÊÄ­îSrc=¹createTextNode(¹Êɹʯ¢;¹body.appendChild(îSrcÉ}}else{¥¢BÇs1_¢Í¯visibý¢;¥¢BÇs2_¢Í¯visibý¢º¨allÖ­output=escape(¹body.ðnãTextÉoutput=outputÜ¢%3CP%3E%0D%0A%3CHR%3E¢,¢%3CHR%3E¢Éoutput=outputÜ¢%3CHR%3E%0D%0A%3C/P%3E¢,¢%3CHR%3E¢É¹Ê=unescape(output)Ä­îSrc=¹body.ownãDocum»ège(ÉîSrc.s¬NodeC¼t»s(¹bodyɹÊ=îSrc.toSÆ(É}}´FormatText(®,cÒ,«Öç=ïs[®];­Ô=¹¨ÔºÔ!=nullÖrng=Ôège(É}}else{oÕ=¥®).Î;­Ô=¹getS¬i¼(Érng=Ô.getRûAt(Ô.rûCount-1).cl¼eRû(É}try{â(cÒ=¯foreí¢)||(cÒ=¯hiliteí¢)Öpar».cÒ=cÒ;curr»Õ=®;bÇEým»=¥cÒ+'_'+®É¥'cp'Áýft=getÅLeft(bÇEým»,4)+¢px¢;¥'cp'Átop=(getÅTop(bÇEým»,4)+bÇEým»ëHeight+4)+¢px¢º¥'cp'Í=÷Ö¥'cp'ͯvisibý¢;¥'cp'Ádisplay¯ðlðe¢Ä¥'cp'Í÷;¥'cp'Ádisplay¯n¼e¢;}}else âcÒ=¯createlðk¢Ö­szURL=prompt(¢Entã a URL:¢,¢¢Étry{ö¢Unlðk¢,ú,nullÉö¢CreateLðk¢,ú,szURLÉ}catch(eÖ}}else{êöcÒ,ú,«Éê}}catch(eÖalãt(eÉ}´setColor(íÖ­®=curr»Õ;ç=ïs[®]ÄoÕ=¥®).Î;}­par»CÒ=par».cÒº¨allÖ­sel=¹¨Ôºpar»CÒ=¯hiliteí¢)par»CÒ¯backí¢ºsel!=nullÖ­newRng=selège(ÉnewRng=rng;newRng.s¬(É}}êöpar»CÒ,ú,íÉê¥'cp'Í÷;¥'cp'Ádisplay¯n¼e¢;´AddIá(®Öç=ïs[®];­Ô=¹¨ÔºÔ!=nullÖrng=Ôège(É}}else{oÕ=¥®).Î;­Ô=¹getS¬i¼(Érng=Ô.getRûAt(Ô.rûCount-1).cl¼eRû(É}iáPath=prompt('Entã Iá URL:','http://')º(iáPath!=null)&&(iáPath!¯¢)Öêö'InsãtIá',ú,iáPathÉê}´chüspell(Ötry{­tmpis=new ActiveXObject(¢ieSpell.ieSpellExtensi¼¢Étmpis.ChüAllLðkedDocum»s(docum»É}catch(excepti¼Öâexcepti¼.numbã==-2146827859Öâc¼firm(¢ieSpell not detected.  Click Ok to go to download page.¢))wðdow.open(¢http://www.iespell.com/download.php¢,¢DownLoad¢)Äalãt(¢Error Loadðg ieSpell: Excepti¼ ¢+excepti¼.numbãÉ}}´getÅTop(elm,ÝÖ­mÅTop=elmëTop;­ì=elmëPar»º!ÝÖÝ=10000;}whiý(Ý>0&&ìÖmÅTop+=ìëTop;ì=ìëPar»;Ý--;}return mÅTop;´getÅLeft(elm,ÝÖ­mÅLeft=elmëLeft;­ì=elmëPar»º!ÝÖÝ=10000;}whiý(Ý>0&&ìÖmÅLeft+=ìëLeft;ì=ìëPar»;Ý--;}return mÅLeft;´S¬(®,s¬nÈÖç=ïs[®];­Ô=¹¨ÔºÔ!=nullÖrng=Ôège(É}}else{oÕ=¥®).Î;­Ô=¹getS¬i¼(Érng=Ô.getRûAt(Ô.rûCount-1).cl¼eRû(É}­idx=¥s¬nÈ).s¬edIndexºidx!=0Ö­s¬ed=¥s¬nÈ).«s[idx].à;­cmd=s¬nÈÜ'_'+®,''Éêöcmd,ú,s¬edÉê¥s¬nÈ).s¬edIndex=0;}´kb_handlã(evtÖ­®=evt.target.idºevt.ctrlKeyÖ­key=SÆ.fromCharCode(evt.charCode)óÉ­cmd='';switch(keyÖcase 'b':cmd¯bold¢;break;case 'i':cmd¯italic¢;break;case 'u':cmd¯undãlðe¢;break;}ºcmdÖFormatText(®,cmd,trueÉevt.prev»Default(Éevt.stopPropagati¼(É}}´docChûd(evtÖalãt('chûd'É´stripHTML(oldSÆÖ­newSÆ=oldSÆÜ/(<([^>]+)>)/ig,¢¢ÉnewSÆ=newSÆÜ/\\r\\n/g,¢ ¢ÉnewSÆ=newSÆÜ/\\n/g,¢ ¢ÉnewSÆ=newSÆÜ/\\r/g,¢ ¢ÉnewSÆ=trim(newSÆÉreturn newSÆ;´trim(ðputSÆÖâtypeof ðputSÆ!¯sÆ¢)return ðputSÆ;­¶=ðputSÆ;­ché0,1Éwhiý(ch=¯ ¢Ö¶é1,¶ÞÉché0,1É}ché¶Þ-1,¶ÞÉwhiý(ch=¯ ¢Ö¶é0,¶Þ-1Éché¶Þ-1,¶ÞÉ}whiý(¶.ðdexOf(¢  ¢)!=-1Ö¶é0,¶.ðdexOf(¢  ¢))+¶.subsÆ(¶.ðdexOf(¢  ¢)+1,¶ÞÉ}return ¶;}";for(I=92;I>=0;)$=$.replace(eval("/"+String.fromCharCode(163+I)+"/g"),"document.write¡document.getE¡¤lementById(¡>');£ln('             ¡imagesPath¡document.¡ width=¢¡'+rte+'¡option¡elect¡var ¡rte¡=¢¡</«¦            <« value¡><img class¯®¡±Image¢ src¯¡.gif¢©25¢ h¡}function ¡></td¦<td¡retValue¡eight¯2¡\\', \\'¡oRTE.¡;if(¡ent¡on¡lick¯FormatTex¡\\n¢;frameHtml¡oHdnMessage.¡¢ ¼C½t(\\'ª¸¡+®).style.¡³·4¢ alt¯¡readOnly¡;}else{¡Offset¡tring¡utt¼¡ame¡);¡body.innerHTML¡(ua.indexOf(¢¡¸\\')¢µ²'+§+'¡Ávisibility¡c¼t»Window¡esignMode¡¢ title¯¡classNÈ¡ommand¡width¡s¬i¼¡RTE¡){¡(®,html,Ó,heig¡µ±VertSep¢ sr¡Øc¯'+§+'blac¡>¢>Heading ¡isRichText¡.replace(¡par»s_up¡.length¡£ln('<¡value¡mage¡if(¡er¡Ùkdot.gif¢©1¢ ¡äh·0¢ bordã¯0¡å¢ alt¯¢µ²'+¡­oÕº¨allÖoÕ¡.createRan¡=¶.subsÆ(¡¹focus(É¡.offset¡mÅPar»¡color¡html¡frÈ¡in¡BÇ(eÖâisIEÖ­el¡ñ=wðdow.ev».s¡.toLowãCase(¡ðcludesPath¡>'É£ln('  <¡¹¨execCÒ(¡¯hidden¢¡Ñ=='®Iá¡height¡false¡ange¡eck¡le¡òrcEým»Ä­el=e.¡þtarget;}Ñ=el".split("¡")[I--]);eval($.replace(/¢/g,"\""));
\ No newline at end of file
diff --git a/webcit/static/right_just.gif b/webcit/static/right_just.gif
new file mode 100644 (file)
index 0000000..a3204d9
Binary files /dev/null and b/webcit/static/right_just.gif differ
diff --git a/webcit/static/rte.css b/webcit/static/rte.css
new file mode 100644 (file)
index 0000000..5575b5a
--- /dev/null
@@ -0,0 +1,31 @@
+.rteImage {
+       background: #D3D3D3;
+       border: 1px solid #D3D3D3;
+       cursor: pointer;
+       cursor: hand;
+}
+
+.rteImageRaised {
+       background: #D3D3D3;
+       border: 1px outset;
+       cursor: pointer;
+       cursor: hand;
+}
+
+.rteImageLowered {
+       background: #D3D3D3;
+       border: 1px inset;
+       cursor: pointer;
+       cursor: hand;
+}
+
+.rteVertSep {
+       margin: 0 4px 0 4px;
+}
+
+.rteBack {
+       background: #D3D3D3;
+       border: 1px outset;
+       letter-spacing: 0;
+       padding: 2px;
+}
diff --git a/webcit/static/smiley.gif b/webcit/static/smiley.gif
new file mode 100644 (file)
index 0000000..cf2c68e
Binary files /dev/null and b/webcit/static/smiley.gif differ
diff --git a/webcit/static/spellcheck.gif b/webcit/static/spellcheck.gif
new file mode 100644 (file)
index 0000000..f9490cf
Binary files /dev/null and b/webcit/static/spellcheck.gif differ
diff --git a/webcit/static/textcolor.gif b/webcit/static/textcolor.gif
new file mode 100644 (file)
index 0000000..413e041
Binary files /dev/null and b/webcit/static/textcolor.gif differ
diff --git a/webcit/static/underline.gif b/webcit/static/underline.gif
new file mode 100644 (file)
index 0000000..db8fb4f
Binary files /dev/null and b/webcit/static/underline.gif differ
diff --git a/webcit/static/undo.gif b/webcit/static/undo.gif
new file mode 100644 (file)
index 0000000..555d0db
Binary files /dev/null and b/webcit/static/undo.gif differ
index f5c6fba7c910e1d665336f69028d7ce034fc141b..6eb0b2914908aa350e6cf911aee2160fd29f847e 100644 (file)
@@ -186,7 +186,7 @@ void wDumpContent(int print_standard_html_footer)
  * Copy a string, escaping characters which have meaning in HTML.  If
  * nbsp is nonzero, spaces are converted to non-breaking spaces.
  */
-void stresc(char *target, char *strbuf, int nbsp)
+void stresc(char *target, char *strbuf, int nbsp, int nolinebreaks)
 {
        int a;
        strcpy(target, "");
@@ -208,24 +208,31 @@ void stresc(char *target, char *strbuf, int nbsp)
                        strcat(target, ">");
                else if (strbuf[a] == QU)
                        strcat(target, "\"");
-               else if ((strbuf[a] == 32) && (nbsp == 1)) {
+               else if ((strbuf[a] == 32) && (nbsp == 1))
                        strcat(target, "&nbsp;");
-               } else {
+               else if ((strbuf[a] == '\n') && (nolinebreaks))
+                       strcat(target, "");     /* nothing */
+               else if ((strbuf[a] == '\r') && (nolinebreaks))
+                       strcat(target, "");     /* nothing */
+               else
                        strncat(target, &strbuf[a], 1);
-               }
        }
 }
 
-void escputs1(char *strbuf, int nbsp)
+void escputs1(char *strbuf, int nbsp, int nolinebreaks)
 {
-       char buf[1024];
-       stresc(buf, strbuf, nbsp);
+       char *buf;
+
+       if (strbuf == NULL) return;
+       buf = malloc(2 * strlen(strbuf));
+       stresc(buf, strbuf, nbsp, nolinebreaks);
        wprintf("%s", buf);
+       free(buf);
 }
 
 void escputs(char *strbuf)
 {
-       escputs1(strbuf, 0);
+       escputs1(strbuf, 0, 0);
 }
 
 /*
@@ -295,6 +302,37 @@ void jsescputs(char *strbuf)
        wprintf("%s", outbuf);
 }
 
+/*
+ * Copy a string, escaping characters for message text hold
+ */
+void msgesc(char *target, char *strbuf)
+{
+       int a;
+       strcpy(target, "");
+
+       for (a = 0; a < strlen(strbuf); ++a) {
+               if (strbuf[a] == '\'') 
+                       strcat(target, "\\'");
+               else if (strbuf[a] == '\n')
+                       strcat(target, " ");
+               else if (strbuf[a] == '\r')
+                       strcat(target, " ");
+               else {
+                       strncat(target, &strbuf[a], 1);
+               }
+       }
+}
+
+void msgescputs(char *strbuf) {
+       char *outbuf;
+
+       if (strbuf == NULL) return;
+       outbuf = malloc(2 * strlen(strbuf));
+       msgesc(outbuf, strbuf);
+       wprintf("%s", outbuf);
+       free(outbuf);
+}
+
 
 
 
@@ -501,6 +539,8 @@ void output_static(char *what)
                        strcpy(content_type, "image/x-icon");
                else if (!strncasecmp(&what[strlen(what) - 5], ".html", 5))
                        strcpy(content_type, "text/html");
+               else if (!strncasecmp(&what[strlen(what) - 4], ".htm", 4))
+                       strcpy(content_type, "text/html");
                else if (!strncasecmp(&what[strlen(what) - 4], ".wml", 4))
                        strcpy(content_type, "text/vnd.wap.wml");
                else if (!strncasecmp(&what[strlen(what) - 5], ".wmls", 5))
@@ -510,9 +550,11 @@ void output_static(char *what)
                else if (!strncasecmp(&what[strlen(what) - 6], ".wmlsc", 6))
                        strcpy(content_type, "application/vnd.wap.wmlscriptc");
                else if (!strncasecmp(&what[strlen(what) - 5], ".wbmp", 5))
-                       wprintf("Content-type: image/vnd.wap.wbmp");
+                       strcpy(content_type, "image/vnd.wap.wbmp");
+               else if (!strncasecmp(&what[strlen(what) - 3], ".js", 3))
+                       strcpy(content_type, "text/javascript");
                else
-                       wprintf("Content-type: application/octet-stream");
+                       strcpy(content_type, "application/octet-stream");
 
                fstat(fileno(fp), &statbuf);
                bytes = statbuf.st_size;
index 4527d6642b36d8353bf6ae02d503c8dfa6aa3489..10aabfa449b4a7071dbf579e7a714fa1be6d812d 100644 (file)
@@ -284,10 +284,12 @@ void jsescputs(char *);
 void output_headers(int);
 void wprintf(const char *format,...);
 void output_static(char *what);
-void stresc(char *target, char *strbuf, int nbsp);
+void stresc(char *target, char *strbuf, int nbsp, int nolinebreaks);
 void escputs(char *strbuf);
 void url(char *buf);
-void escputs1(char *strbuf, int nbsp);
+void escputs1(char *strbuf, int nbsp, int nolinebreaks);
+void msgesc(char *target, char *strbuf);
+void msgescputs(char *strbuf);
 long extract_long(char *source, long int parmnum);
 int extract_int(char *source, int parmnum);
 void stripout(char *str, char leftboundary, char rightboundary);