From 34acbe9ceed35b04d9faffc427b5bd309b59c296 Mon Sep 17 00:00:00 2001 From: loki Date: Tue, 17 Jun 2003 19:01:09 +0000 Subject: [PATCH] new smack web client browser side git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@1964 b35dd754-fafc-0310-a699-88a17e54d16e --- apps/webchat/source/web/account_creation.jsp | 116 +++++++++ apps/webchat/source/web/chat-form.html | 96 -------- apps/webchat/source/web/chat-hiddenform.jsp | 25 +- apps/webchat/source/web/chat-launcher.jsp | 49 ++-- apps/webchat/source/web/chat-main.html | 66 ------ apps/webchat/source/web/chat.jsp | 34 --- apps/webchat/source/web/common.js | 182 ++++++++++++++ apps/webchat/source/web/data.jsp | 26 -- apps/webchat/source/web/form.html | 18 -- apps/webchat/source/web/frame_master.jsp | 33 +++ apps/webchat/source/web/iframe.html | 56 ----- apps/webchat/source/web/index.jsp | 222 +++++++++++------- apps/webchat/source/web/input_frame.jsp | 75 ++++++ apps/webchat/source/web/logo.html | 13 - apps/webchat/source/web/menu.html | 32 --- .../webchat/source/web/participants_frame.jsp | 46 ++++ apps/webchat/source/web/style.css | 9 - apps/webchat/source/web/style_sheet.jsp | 132 +++++++++++ apps/webchat/source/web/transcript_frame.html | 13 + 19 files changed, 777 insertions(+), 466 deletions(-) create mode 100644 apps/webchat/source/web/account_creation.jsp delete mode 100644 apps/webchat/source/web/chat-form.html delete mode 100644 apps/webchat/source/web/chat-main.html delete mode 100644 apps/webchat/source/web/chat.jsp create mode 100644 apps/webchat/source/web/common.js delete mode 100644 apps/webchat/source/web/data.jsp delete mode 100644 apps/webchat/source/web/form.html create mode 100644 apps/webchat/source/web/frame_master.jsp delete mode 100644 apps/webchat/source/web/iframe.html create mode 100644 apps/webchat/source/web/input_frame.jsp delete mode 100644 apps/webchat/source/web/logo.html delete mode 100644 apps/webchat/source/web/menu.html create mode 100644 apps/webchat/source/web/participants_frame.jsp delete mode 100644 apps/webchat/source/web/style.css create mode 100644 apps/webchat/source/web/style_sheet.jsp create mode 100644 apps/webchat/source/web/transcript_frame.html diff --git a/apps/webchat/source/web/account_creation.jsp b/apps/webchat/source/web/account_creation.jsp new file mode 100644 index 000000000..b30e1f503 --- /dev/null +++ b/apps/webchat/source/web/account_creation.jsp @@ -0,0 +1,116 @@ +<%-- + - + - +--%> + +<%@ page import="java.util.*" %> + +<% // Get error map as a request attribute: + Map errors = (Map)request.getAttribute("messenger.servlet.errors"); + if (errors == null) { errors = new HashMap(); } +%> + + + + + + Create an account + + + + + + + + + + +
+ + + + + + + + + + + + + +
+

Jive Account Creation

+ + <% if (errors.get("general") != null) { %> +

+ + Error creating account. <%= errors.get("general") %> + +

+
+ <% } %> +
+
+ + + + + + + + + + + + + + + +
Desired username: + + <% if (errors.get("empty_username") != null) { %> +
+ Please enter a username. +
+ <% } %> +
Desired password: + + <% if (errors.get("empty_password") != null) { %> +
+ Please enter a password. +
+ <% } %> + <% if (errors.get("mismatch_password") != null) { %> +
+ Your passwords did not match. +
+ <% } %> +
Retype your password: + + <% if (errors.get("empty_password_two") != null) { %> +
+ You must retype your password. +
+ <% } %> +
+
+
+ + +
+
Click here to return to the login page. +
+
+ + + + diff --git a/apps/webchat/source/web/chat-form.html b/apps/webchat/source/web/chat-form.html deleted file mode 100644 index 67601cc68..000000000 --- a/apps/webchat/source/web/chat-form.html +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - Chat Session - - - - - - - - - - - - - - - - - - -
- - -
- -
-
-   -   -   - -   -   -   -
- - - - - diff --git a/apps/webchat/source/web/chat-hiddenform.jsp b/apps/webchat/source/web/chat-hiddenform.jsp index 41005ab8b..c29c3d0a4 100644 --- a/apps/webchat/source/web/chat-hiddenform.jsp +++ b/apps/webchat/source/web/chat-hiddenform.jsp @@ -1,18 +1,19 @@ - - - Chat Form - + + + Chat Form - + + -
- - -
+ +
+ + +
+ - - - \ No newline at end of file + diff --git a/apps/webchat/source/web/chat-launcher.jsp b/apps/webchat/source/web/chat-launcher.jsp index 54231f5e3..fba6cceb2 100644 --- a/apps/webchat/source/web/chat-launcher.jsp +++ b/apps/webchat/source/web/chat-launcher.jsp @@ -1,34 +1,39 @@ - - - Chat Session - - - + + - + Web Chat Session + -

+ + -Other options: + - +

Chat Session Options

- + Your chat session should have already started. If for some reason it did + not, click this link + to start your chat session. +

+ + Other options: + + + + diff --git a/apps/webchat/source/web/chat-main.html b/apps/webchat/source/web/chat-main.html deleted file mode 100644 index 56ac27f03..000000000 --- a/apps/webchat/source/web/chat-main.html +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - Chat Session - - - - - - - - - - - - - - - - - - - -
- -
- - - -
- - - - - diff --git a/apps/webchat/source/web/chat.jsp b/apps/webchat/source/web/chat.jsp deleted file mode 100644 index 726a58437..000000000 --- a/apps/webchat/source/web/chat.jsp +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - Chat Session - - - - - - - - - - - - - - \ No newline at end of file diff --git a/apps/webchat/source/web/common.js b/apps/webchat/source/web/common.js new file mode 100644 index 000000000..ace272e48 --- /dev/null +++ b/apps/webchat/source/web/common.js @@ -0,0 +1,182 @@ +function addChatText (someText, isAnnouncement) { + var yakDiv = window.parent.frames['yak'].document.getElementById('ytext'); + var children = yakDiv.childNodes.length; + var appendFailed = false; + var spanElement = document.createElement("span"); + + if (! isAnnouncement) { + spanElement.setAttribute("class", "chat_text"); + } else { + spanElement.setAttribute("class", "chat_announcement"); + } + // it's easier to dump the possibily html-containing text into the innerHTML + // of the span element than deciphering and building sub-elements. + spanElement.innerHTML = someText; + + try { + // various versions of IE crash out on this, and safari + yakDiv.appendChild(spanElement); + } catch (exception) { + appendFailed = true; + } + + if (! appendFailed) { + // really make sure the browser appended + appendFailed = (children == yakDiv.childNodes.length); + } + + if (appendFailed) { + // try this, the only way left + var inn = yakDiv.innerHTML; + + inn += "" : "chat_text\">"); + inn += someText + "
"; + + yakDiv.innerHTML = inn; + } else { + yakDiv.appendChild(document.createElement("br")); + } + + scrollYakToEnd(); +} + +function addUserName (userName) { + var yakDiv = window.parent.frames['yak'].document.getElementById('ytext'); + var children = yakDiv.childNodes.length; + var appendFailed = false; + var spanElement = document.createElement("span"); + var userIsClientOwner = false; + var announcement = false; + + if (userName == "") { + announcement = true; + + spanElement.setAttribute("class", "chat_announcement"); + + userName = "room announcement"; + } else if (userName == nickname) { + userIsClientOwner = true; + + spanElement.setAttribute("class", "chat_owner"); + } else { + spanElement.setAttribute("class", "chat_participant"); + } + + try { + spanElement.appendChild(document.createTextNode(userName + ": ")); + + // various versions of IE crash out on this, and safari + yakDiv.appendChild(spanElement); + } catch (exception) { + appendFailed = true; + } + + if (! appendFailed) { + // really make sure the browser appended + appendFailed = (children == yakDiv.childNodes.length); + } + + if (appendFailed) { + // try this, the only way left + var inn = yakDiv.innerHTML + + inn += "" + userName + ": "; + + yakDiv.innerHTML = inn; + } +} + +function scrollYakToEnd () { + var endDiv = window.parent.frames['yak'].document.getElementById('enddiv'); + + window.parent.frames['yak'].window.scrollTo(0, endDiv.offsetTop); +} + +function userJoined (username) { + var parentDIV = window.parent.frames['participants'].document.getElementById('par__list'); + var children = parentDIV.childNodes.length; + var appendFailed = false; + var divElement = document.createElement("div"); + + divElement.setAttribute("id", username); + + try { + divElement.appendChild(document.createTextNode(username)); + divElement.appendChild(document.createElement("br")); + + parentDIV.appendChild(divElement); + } catch (exception) { + appendFailed = true; + } + + if (! appendFailed) { + // really make sure the browser appended + appendFailed = (children == parentDIV.childNodes.length); + } + + if (appendFailed) { + // try this, the only way left + var inn = parentDIV.innerHTML; + + inn += "
· " + username + "
"; + + parentDIV.innerHTML = inn; + } +} + +function userDeparted (username) { + var partDoc = window.parent.frames['participants'].document; + var parentDIV = partDoc.getElementById('par__list'); + var userDIV = partDoc.getElementById(username); + var children = parentDIV.childNodes.length; + var removeFailed = false; + + // MAY RETURN THIS BLOCK + if (userDIV == null) { + return; + } + + try { + parentDIV.removeChild(userDIV); + } catch (exception) { + removeFailed = true; + } + + if (! removeFailed) { + // really make sure the browser appended + removeFailed = (children == parentDIV.childNodes.length); + } + + if (removeFailed) { + // try this, the only way left + var inn = parentDIV.innerHTML; + var openingTag = "
"; + var index = inn.toLowerCase().indexOf(openingTag); + var patchedHTML = inn.substring(0, index); + var secondIndex = openingTag.length + username.length + 13; + + patchedHTML += inn.substring(secondIndex, (inn.length)); + + parentDIV.innerHTML = inn; + } +} + +function writeDate () { + var msg = "This frame loaded at: "; + var now = new Date(); + + msg += now + "

"; + + document.write(msg); +} diff --git a/apps/webchat/source/web/data.jsp b/apps/webchat/source/web/data.jsp deleted file mode 100644 index 333aa4bb3..000000000 --- a/apps/webchat/source/web/data.jsp +++ /dev/null @@ -1,26 +0,0 @@ -<%-- - - - - ---%> - -<% // get the username of the current user - String nickname = (String)session.getAttribute("messenger.servlet.nickname"); - if (nickname == null) { - nickname = ""; - } -%> - - - - - - Chat Data - - - - - - diff --git a/apps/webchat/source/web/form.html b/apps/webchat/source/web/form.html deleted file mode 100644 index 77f13f6cf..000000000 --- a/apps/webchat/source/web/form.html +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - Chat Form - - - - -
- - -
- - - - \ No newline at end of file diff --git a/apps/webchat/source/web/frame_master.jsp b/apps/webchat/source/web/frame_master.jsp new file mode 100644 index 000000000..a96b88f4c --- /dev/null +++ b/apps/webchat/source/web/frame_master.jsp @@ -0,0 +1,33 @@ + + + <%= request.getSession().getAttribute("messenger.servlet.room") %> + - Jive Web Chat Client + + + + + + + + + + + + + + + + diff --git a/apps/webchat/source/web/iframe.html b/apps/webchat/source/web/iframe.html deleted file mode 100644 index 209c2966b..000000000 --- a/apps/webchat/source/web/iframe.html +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - Chat Session - - - - - - - - -  - - - - - \ No newline at end of file diff --git a/apps/webchat/source/web/index.jsp b/apps/webchat/source/web/index.jsp index dee0e1787..617b63b77 100644 --- a/apps/webchat/source/web/index.jsp +++ b/apps/webchat/source/web/index.jsp @@ -7,100 +7,158 @@ <% // Get error map as a request attribute: Map errors = (Map)request.getAttribute("messenger.servlet.errors"); + boolean allowAnonymous = true; + boolean allowAccountCreate = true; + boolean allowLogin = true; + String param = null; if (errors == null) { errors = new HashMap(); } + param = application.getInitParameter("allowAnonymous"); + if ((param != null) && (param.equalsIgnoreCase("false"))) { + allowAnonymous = false; + } + param = application.getInitParameter("allowAccountCreation"); + if ((param != null) && (param.equalsIgnoreCase("false"))) { + allowAccountCreate = false; + } + param = application.getInitParameter("allowLogin"); + if ((param != null) && (param.equalsIgnoreCase("false"))) { + allowLogin = false; + } %> - - Chat - - - + + Jive Web Chat Client Login + + -<% if (errors.get("general") != null) { %> + + -

- Error logging in. Make sure your username and password is correct. -

+ -<% } %> + + + + +
+ + + + + + + + + + + <% if (allowAccountCreate) { %> + + + + <% } %> +
+

Welcome to the Jive Web Chat Client - Please Login

+ <% if (errors.get("general") != null) { %> +

+ Error logging in. Make sure your username and + password are correct. <%= errors.get("general") %> +

+ <% } %> +
+
+ - - + + <% if (allowLogin) { %> + + + + + + + + + <% } %> + + + + + + + + +
Username: + + <% if (errors.get("username") != null) { %> +
+ Please enter a valid username. +
+ <% } %> +
Password: + + <% if (errors.get("password") != null) { %> +
+ Please enter a valid password. +
+ <% } %> +
Nickname: + + <% if (errors.get("nickname") != null) { %> +
+ Please enter a nickname. +
+ <% } %> +
Room: + + <% if (errors.get("room") != null) { %> +
+ Please enter a valid room. +
+ <% } %> +
+
+
+ <% if (allowLogin) { %> + + <% } %> + <% if (allowAnonymous) { %> + + <% } %> + +
+
Don't have an account and would like to create one? + Click here. +
+
- - - - - - - - - - - - - - - - - -
Username: - - <% if (errors.get("username") != null) { %> - -
- Please enter a valid username. -
- - <% } %> -
Password: - - <% if (errors.get("password") != null) { %> - -
- Please enter a valid password. -
- - <% } %> -
Nickname: - - <% if (errors.get("nickname") != null) { %> - -
- Please enter a valid nickname. -
- - <% } %> -
Room: - - <% if (errors.get("room") != null) { %> - -
- Please enter a valid room. -
- - <% } %> -
+ -
- - - - - - - + diff --git a/apps/webchat/source/web/input_frame.jsp b/apps/webchat/source/web/input_frame.jsp new file mode 100644 index 000000000..352863160 --- /dev/null +++ b/apps/webchat/source/web/input_frame.jsp @@ -0,0 +1,75 @@ +<%@ page import="javax.servlet.*" %> + +<% // Get error map as a request attribute: + String logoFilename = application.getInitParameter("logoFilename"); + if (logoFilename == null) { + logoFilename = "images/logo.gif"; + } +%> + + + + + + + + + + + +
+
+ +
+ +
+
+ + + + + diff --git a/apps/webchat/source/web/logo.html b/apps/webchat/source/web/logo.html deleted file mode 100644 index 936da4a71..000000000 --- a/apps/webchat/source/web/logo.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - Chat Logo - - - - - - - - diff --git a/apps/webchat/source/web/menu.html b/apps/webchat/source/web/menu.html deleted file mode 100644 index 95db08dd6..000000000 --- a/apps/webchat/source/web/menu.html +++ /dev/null @@ -1,32 +0,0 @@ - - - - - Chat Menu - - - - - - - - - - -
-   - - - End Chat (Log Off) - -
- - - diff --git a/apps/webchat/source/web/participants_frame.jsp b/apps/webchat/source/web/participants_frame.jsp new file mode 100644 index 000000000..a2369de83 --- /dev/null +++ b/apps/webchat/source/web/participants_frame.jsp @@ -0,0 +1,46 @@ + + + + + + + + + + + +
In the room:
+
+
+ +
+ +
+ +
+ + + + Logout + + + diff --git a/apps/webchat/source/web/style.css b/apps/webchat/source/web/style.css deleted file mode 100644 index 0d47f4f28..000000000 --- a/apps/webchat/source/web/style.css +++ /dev/null @@ -1,9 +0,0 @@ -BODY, TD, TH { - font-family : tahoma; font-size : 0.8em; -} -H3 { - font-size : 1.2em; -} -.error-text { - color : red; -} \ No newline at end of file diff --git a/apps/webchat/source/web/style_sheet.jsp b/apps/webchat/source/web/style_sheet.jsp new file mode 100644 index 000000000..381dceeef --- /dev/null +++ b/apps/webchat/source/web/style_sheet.jsp @@ -0,0 +1,132 @@ +<% // Set the content type of the this page to be CSS + String contentType = "text/css"; + String chatAnnouncementColor = application.getInitParameter("chat.announcement-color"); + String chatOwnerLabelColor = application.getInitParameter("chat.owner-label-color"); + String chatParticipantLabelColor = application.getInitParameter("chat.participant-label-color"); + String chatTextColor = application.getInitParameter("chat.text-color"); + String errorTextColor = application.getInitParameter("error.text-color"); + String linkColor = application.getInitParameter("link.color"); + String linkHoverColor = application.getInitParameter("link.hover-color"); + String linkVisitedColor = application.getInitParameter("link.visited-color"); + String bodyBGColor = application.getInitParameter("body.background-color"); + String bodyTextColor = application.getInitParameter("body.text-color"); + String frameDividerColor = application.getInitParameter("frame.divider-color"); + String buttonColor = application.getInitParameter("button.color"); + String buttonTextColor = application.getInitParameter("button.text-color"); + String textFieldColor = application.getInitParameter("textfield.color"); + String textFieldTextColor = application.getInitParameter("textfield.text-color"); + response.setContentType(contentType); + if (chatAnnouncementColor == null) { + chatAnnouncementColor = "#009d00"; + } + if (chatOwnerLabelColor == null) { + chatOwnerLabelColor = "#aa0000"; + } + if (chatParticipantLabelColor == null) { + chatParticipantLabelColor = "#0000aa"; + } + if (chatTextColor == null) { + chatTextColor = "#434343"; + } + if (errorTextColor == null) { + errorTextColor = "#ff0000"; + } + if (linkColor == null) { + linkColor = "#045d30"; + } + if (linkHoverColor == null) { + linkHoverColor = "#350000"; + } + if (linkVisitedColor == null) { + linkVisitedColor = "#3b3757"; + } + if (bodyBGColor == null) { + bodyBGColor = "#ffffff"; + } + if (bodyTextColor == null) { + bodyTextColor = "#362f2d"; + } + if (frameDividerColor == null) { + frameDividerColor = "#83272b"; + } + if (buttonColor == null) { + buttonColor = "#d6dfdf"; + } + if (buttonTextColor == null) { + buttonTextColor = "#333333"; + } + if (textFieldColor == null) { + textFieldColor = "#f7f7fb"; + } + if (textFieldTextColor == null) { + textFieldTextColor = "#333333"; + } +%> + +BODY, TD, TH { font-family : Tahoma, Arial, Verdana, sans serif; font-size: 13px; } + +H3 { font-size : 1.2em; } + +.error-text { color : <%= errorTextColor %>; } + + +/* default unvisited, visited and hover link presentation */ +A:link { background: transparent; color: <%= linkColor %>; + text-decoration: none; } +A:visited { background: transparent; color: <%= linkVisitedColor %>; + text-decoration: none; } +A:hover { background: transparent; color: <%= linkHoverColor %>; + text-decoration: underline; } + +/** + * site wide BODY style rule; the scrollbar stuff only works in IE for windows, + * but doesn't seem to hurt on other browsers.. + */ +BODY.deffr { background-color: <%= bodyBGColor %>; color: <%= bodyTextColor %>; + scrollbar-face-color: <%= bodyBGColor %>; + scrollbar-shadow-color: <%= bodyTextColor %>; + scrollbar-highlight-color: <%= bodyBGColor %>; + scrollbar-darkshadow-color: <%= bodyBGColor %>; + scrollbar-track-color: <%= bodyBGColor %>; + scrollbar-arrow-color: <%= bodyTextColor %>; } + + +FRAME.bordered_left { border-left: 3px solid <%= frameDividerColor %>; } + + +IMG.logo { position: absolute; bottom: 12px; left: 10px; } + +IMG.logout { vertical-align: middle; } + + +INPUT.submit { background-color: <%= buttonColor %>; color: <%= buttonTextColor %>; + font-size: 12px; font-family: Arial, Verdana, sans serif; + border-style: ridge; margin: 1px 5px 1px 5px; } + +INPUT.submit_right { background-color: <%= buttonColor %>; color: <%= buttonTextColor %>; + font-size: 12px; font-family: Arial, Verdana, sans serif; + border-style: ridge; margin: 1px 5px 1px 5px; + position: absolute; right: 10px; } + +INPUT.text { background-color: <%= textFieldColor %>; color: <%= textFieldTextColor %>; + font: normal 12px Arial, Verdana, sans serif; height: 20px; width: 271px; + border-style: groove; margin-left: 10px; } + + +SPAN.chat_text { font: normal 11px Arial, Verdana, sans serif; + color: <%= chatTextColor %>; } + +SPAN.chat_announcement { font: italic 11px Arial, Verdana, sans serif; + color: <%= chatAnnouncementColor %>; } + +SPAN.chat_owner { font: bold 11px Arial, Verdana, sans serif; + color: <%= chatOwnerLabelColor %>; } + +SPAN.chat_participant { font: bold 11px Arial, Verdana, sans serif; + color: <%= chatParticipantLabelColor %>; } + +SPAN.logout { position: absolute; bottom: 12px; right: 15px; } + + +TEXTAREA { color: <%= textFieldTextColor %>; font: normal 12px Arial, Verdana, sans serif; + width: 500px; height: 130px; } diff --git a/apps/webchat/source/web/transcript_frame.html b/apps/webchat/source/web/transcript_frame.html new file mode 100644 index 000000000..a4cc1faf5 --- /dev/null +++ b/apps/webchat/source/web/transcript_frame.html @@ -0,0 +1,13 @@ + + + + + + + + + +

+ + +