http://git-wip-us.apache.org/repos/asf/activemq/blob/3f32507f/activemq-web-demo/src/main/webapp/js/amq_prototype_adapter.js
----------------------------------------------------------------------
diff --git a/activemq-web-demo/src/main/webapp/js/amq_prototype_adapter.js 
b/activemq-web-demo/src/main/webapp/js/amq_prototype_adapter.js
index 5f4f1c9..0e1b5d3 100755
--- a/activemq-web-demo/src/main/webapp/js/amq_prototype_adapter.js
+++ b/activemq-web-demo/src/main/webapp/js/amq_prototype_adapter.js
@@ -1,84 +1,84 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// AMQ Ajax Adapter for Prototype
-// This class provides an adapter interface for the prototype library to 
perform
-// some of the library-dependent tasks...namely logging and ajax.
-
-var org = org || {};
-org.activemq = org.activemq || {};
-
-org.activemq.AmqAdapter = {
-
-       init: function(options) {
-       },
-
-/**
- *  Implement this method to make an AJAX call to the AjaxServlet. An
- *  options object will accompany this class and will contain the properties
- *  that describe the details of the AJAX call. The options object will
- *  have the following properties:
- *
- *  - method:  'get' or 'post'
- *  - data:    query data to accompany the post or get.
- *  - success: A callback function that is invoked upon successful
- *             completion of the AJAX call. The parameter is:
- *             - data: The result of the AJAX call. In the case of XML
- *                     data should resolve to a Document element.
- *  - error:   A callback when some type of error occurs. The callback
- *             function's parameters should be:
- *             - xhr:    The XmlHttpRequest object.
- *             - status: A text string of the status.
- *             - ex:     The exception that caused the error.
- *  - headers: An object containing additional headers for the ajax request.
- */
-       ajax: function(uri, options) {
-               request = {
-                       onSuccess: options.success ? function(xhr, header) {
-                               if (options.success) {
-                                       var ct = 
xhr.getResponseHeader("content-type");
-                                       var xml = ct && ct.indexOf("xml") >= 0;
-                                       var data = xml ? xhr.responseXML : 
xhr.responseText;
-                                       options.success(data);
-                               }
-                       } : function() {},
-                       onFailure: options.error || function() {
-                       },
-                       onException: options.error || function() {
-                       }
-               }
-               
-               if( options.headers ) {
-                       request.requestHeaders = options.headers;
-               }
-               
-               if (options.method == 'post') {
-                       request.postBody = options.data;
-               } else {
-                       request.parameters = options.data;
-                       request.method = 'get';
-               }
-               
-               new Ajax.Request( uri, request );
-       },
-
-       log: function(message, exception) {
-               if (typeof console != 'undefined' && console.log) 
console.log(message);
-       }
-
-};
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// AMQ Ajax Adapter for Prototype
+// This class provides an adapter interface for the prototype library to 
perform
+// some of the library-dependent tasks...namely logging and ajax.
+
+var org = org || {};
+org.activemq = org.activemq || {};
+
+org.activemq.AmqAdapter = {
+
+       init: function(options) {
+       },
+
+/**
+ *  Implement this method to make an AJAX call to the AjaxServlet. An
+ *  options object will accompany this class and will contain the properties
+ *  that describe the details of the AJAX call. The options object will
+ *  have the following properties:
+ *
+ *  - method:  'get' or 'post'
+ *  - data:    query data to accompany the post or get.
+ *  - success: A callback function that is invoked upon successful
+ *             completion of the AJAX call. The parameter is:
+ *             - data: The result of the AJAX call. In the case of XML
+ *                     data should resolve to a Document element.
+ *  - error:   A callback when some type of error occurs. The callback
+ *             function's parameters should be:
+ *             - xhr:    The XmlHttpRequest object.
+ *             - status: A text string of the status.
+ *             - ex:     The exception that caused the error.
+ *  - headers: An object containing additional headers for the ajax request.
+ */
+       ajax: function(uri, options) {
+               request = {
+                       onSuccess: options.success ? function(xhr, header) {
+                               if (options.success) {
+                                       var ct = 
xhr.getResponseHeader("content-type");
+                                       var xml = ct && ct.indexOf("xml") >= 0;
+                                       var data = xml ? xhr.responseXML : 
xhr.responseText;
+                                       options.success(data);
+                               }
+                       } : function() {},
+                       onFailure: options.error || function() {
+                       },
+                       onException: options.error || function() {
+                       }
+               }
+               
+               if( options.headers ) {
+                       request.requestHeaders = options.headers;
+               }
+               
+               if (options.method == 'post') {
+                       request.postBody = options.data;
+               } else {
+                       request.parameters = options.data;
+                       request.method = 'get';
+               }
+               
+               new Ajax.Request( uri, request );
+       },
+
+       log: function(message, exception) {
+               if (typeof console != 'undefined' && console.log) 
console.log(message);
+       }
+
+};

http://git-wip-us.apache.org/repos/asf/activemq/blob/3f32507f/activemq-web-demo/src/main/webapp/js/chat.js
----------------------------------------------------------------------
diff --git a/activemq-web-demo/src/main/webapp/js/chat.js 
b/activemq-web-demo/src/main/webapp/js/chat.js
index ed6d8aa..f616add 100755
--- a/activemq-web-demo/src/main/webapp/js/chat.js
+++ b/activemq-web-demo/src/main/webapp/js/chat.js
@@ -1,209 +1,209 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the 'License'); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an 'AS IS' BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-var amq = org.activemq.Amq;
-
-org.activemq.Chat = function() {
-       var last = '';
-
-       var user = null;
-
-       var chatTopic = 'topic://CHAT.DEMO';
-
-       var chat, join, joined, phrase, members, username = null;
-
-       var chatHandler = function(message) {
-               var type = message.getAttribute('type');
-               var from = message.getAttribute('from');
-
-               switch (type) {
-                       // Incoming chat message
-                       case 'chat' : {
-                               var text = message.childNodes[0].data;
-
-                               if (from == last) from = '...';
-                               else {
-                                       last = from;
-                                       from += ':';
-                               }
-
-                               chat.innerHTML += '<span class=\'from\'>' + 
from + '&nbsp;</span><span class=\'text\'>' + text + '</span><br/>';
-                               break;
-                       }
-
-                       // Incoming ping request, add the person's name to your 
list.
-                       case 'ping' : {
-                               members.innerHTML += '<span class="member">' + 
from + '</span><br/>';
-                               break;
-                       }
-
-                       // someone new joined the chatroom, clear your list and
-                       // broadcast your name to all users.
-                       case 'join' : {
-                               members.innerHTML = '';
-                               if (user != null)
-                                       amq.sendMessage(chatTopic, '<message 
type="ping" from="' + user + '"/>');
-                               chat.innerHTML += '<span class="alert"><span 
class="from">' + from + '&nbsp;</span><span class="text">has joined the 
room!</span></span><br/>';
-                               break;
-                       }
-
-                       // Screw you guys, I'm going home...
-                       // When I (and everyone else) receive a leave message, 
we broadcast
-                       // our own names in a ping in order to update 
everyone's list.
-                       // todo: Make this more efficient by simply removing 
the person's name from the list.
-                       case 'leave': {
-                               members.innerHTML = '';
-                               chat.innerHTML += '<span class="alert"><span 
class="from">' + from + '&nbsp;</span><span class="text">has left the 
room!</span></span><br/>';
-
-                               // If we are the one that is leaving...
-                               if (from == user) {
-                               // switch the input form
-                                       join.className = '';
-                                       joined.className = 'hidden';
-                                       username.focus();
-
-                                       user = null;
-                                       amq.removeListener('chat', chatTopic);
-                               }
-                               if (user != null)
-                                       amq.sendMessage(chatTopic, '<message 
type="ping" from="' + user + '"/>');
-                               break;
-                       }
-               }
-
-               chat.scrollTop = chat.scrollHeight - chat.clientHeight;
-       };
-
-       var getKeyCode = function (ev) {
-               var keyc;
-               if (window.event) keyc = window.event.keyCode;
-               else keyc = ev.keyCode;
-               return keyc;
-       };
-
-       var addEvent = function(obj, type, fn) {
-               if (obj.addEventListener)
-                       obj.addEventListener(type, fn, false);
-               else if (obj.attachEvent) {
-                       obj["e"+type+fn] = fn;
-                       obj[type+fn] = function() { obj["e"+type+fn]( 
window.event ); }
-                       obj.attachEvent( "on"+type, obj[type+fn] );
-               }
-       };
-
-       var initEventHandlers = function() {
-               addEvent(username, 'keyup', function(ev) {
-                       var keyc = getKeyCode(ev);
-                       if (keyc == 13 || keyc == 10) {
-                               org.activemq.Chat.join();
-                               return false;
-                       }
-                       return true;
-               });
-
-               addEvent(document.getElementById('joinB'), 'click', function() {
-                       org.activemq.Chat.join();
-                       return true;
-               });
-
-               addEvent(phrase, 'keyup', function(ev) {
-                       var keyc = getKeyCode(ev);
-
-                       if (keyc == 13 || keyc == 10) {
-                               var text = phrase.value;
-                               phrase.value = '';
-                               org.activemq.Chat.chat(text);
-                               return false;
-                       }
-                       return true;
-               });
-
-               addEvent(document.getElementById('sendB'), 'click', function() {
-                       var text = phrase.value;
-                       phrase.value = '';
-                       org.activemq.Chat.chat(text);
-               });
-
-               addEvent(document.getElementById('leaveB'), 'click', function() 
{
-                       org.activemq.Chat.leave();
-                       return false;
-               });
-       };
-
-       return {
-               join: function() {
-                       var name = username.value;
-                       if (name == null || name.length == 0) {
-                               alert('Please enter a username!');
-                       } else {
-                               user = name;
-
-                               amq.addListener('chat', chatTopic, chatHandler);
-                               join.className = 'hidden';
-                               joined.className = '';
-                               phrase.focus();
-
-                               amq.sendMessage(chatTopic, '<message 
type="join" from="' + user + '"/>');
-                       }
-               },
-
-               leave: function() {
-                       amq.sendMessage(chatTopic, '<message type="leave" 
from="' + user + '"/>');
-               },
-
-               chat: function(text) {
-                       if (text != null && text.length > 0) {
-                               // TODO more encoding?
-                               text = text.replace('<', '&lt;');
-                               text = text.replace('>', '&gt;');
-
-                               amq.sendMessage(chatTopic, '<message 
type="chat" from="' + user + '">' + text + '</message>');
-                       }
-               },
-
-               init: function() {
-                       join = document.getElementById('join');
-                       joined = document.getElementById('joined');
-                       chat = document.getElementById('chat');
-                       members = document.getElementById('members');
-                       username = document.getElementById('username');
-                       phrase = document.getElementById('phrase');
-
-                       if (join.className == 'hidden' && joined.className == 
'hidden') {
-                               join.className = '';
-                               joined.className = 'hidden';
-                               username.focus();
-                       }
-
-                       initEventHandlers();
-               }
-       }
-}();
-
-
-
-
-
-
-
-
-
-
-
-
-
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the 'License'); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an 'AS IS' BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var amq = org.activemq.Amq;
+
+org.activemq.Chat = function() {
+       var last = '';
+
+       var user = null;
+
+       var chatTopic = 'topic://CHAT.DEMO';
+
+       var chat, join, joined, phrase, members, username = null;
+
+       var chatHandler = function(message) {
+               var type = message.getAttribute('type');
+               var from = message.getAttribute('from');
+
+               switch (type) {
+                       // Incoming chat message
+                       case 'chat' : {
+                               var text = message.childNodes[0].data;
+
+                               if (from == last) from = '...';
+                               else {
+                                       last = from;
+                                       from += ':';
+                               }
+
+                               chat.innerHTML += '<span class=\'from\'>' + 
from + '&nbsp;</span><span class=\'text\'>' + text + '</span><br/>';
+                               break;
+                       }
+
+                       // Incoming ping request, add the person's name to your 
list.
+                       case 'ping' : {
+                               members.innerHTML += '<span class="member">' + 
from + '</span><br/>';
+                               break;
+                       }
+
+                       // someone new joined the chatroom, clear your list and
+                       // broadcast your name to all users.
+                       case 'join' : {
+                               members.innerHTML = '';
+                               if (user != null)
+                                       amq.sendMessage(chatTopic, '<message 
type="ping" from="' + user + '"/>');
+                               chat.innerHTML += '<span class="alert"><span 
class="from">' + from + '&nbsp;</span><span class="text">has joined the 
room!</span></span><br/>';
+                               break;
+                       }
+
+                       // Screw you guys, I'm going home...
+                       // When I (and everyone else) receive a leave message, 
we broadcast
+                       // our own names in a ping in order to update 
everyone's list.
+                       // todo: Make this more efficient by simply removing 
the person's name from the list.
+                       case 'leave': {
+                               members.innerHTML = '';
+                               chat.innerHTML += '<span class="alert"><span 
class="from">' + from + '&nbsp;</span><span class="text">has left the 
room!</span></span><br/>';
+
+                               // If we are the one that is leaving...
+                               if (from == user) {
+                               // switch the input form
+                                       join.className = '';
+                                       joined.className = 'hidden';
+                                       username.focus();
+
+                                       user = null;
+                                       amq.removeListener('chat', chatTopic);
+                               }
+                               if (user != null)
+                                       amq.sendMessage(chatTopic, '<message 
type="ping" from="' + user + '"/>');
+                               break;
+                       }
+               }
+
+               chat.scrollTop = chat.scrollHeight - chat.clientHeight;
+       };
+
+       var getKeyCode = function (ev) {
+               var keyc;
+               if (window.event) keyc = window.event.keyCode;
+               else keyc = ev.keyCode;
+               return keyc;
+       };
+
+       var addEvent = function(obj, type, fn) {
+               if (obj.addEventListener)
+                       obj.addEventListener(type, fn, false);
+               else if (obj.attachEvent) {
+                       obj["e"+type+fn] = fn;
+                       obj[type+fn] = function() { obj["e"+type+fn]( 
window.event ); }
+                       obj.attachEvent( "on"+type, obj[type+fn] );
+               }
+       };
+
+       var initEventHandlers = function() {
+               addEvent(username, 'keyup', function(ev) {
+                       var keyc = getKeyCode(ev);
+                       if (keyc == 13 || keyc == 10) {
+                               org.activemq.Chat.join();
+                               return false;
+                       }
+                       return true;
+               });
+
+               addEvent(document.getElementById('joinB'), 'click', function() {
+                       org.activemq.Chat.join();
+                       return true;
+               });
+
+               addEvent(phrase, 'keyup', function(ev) {
+                       var keyc = getKeyCode(ev);
+
+                       if (keyc == 13 || keyc == 10) {
+                               var text = phrase.value;
+                               phrase.value = '';
+                               org.activemq.Chat.chat(text);
+                               return false;
+                       }
+                       return true;
+               });
+
+               addEvent(document.getElementById('sendB'), 'click', function() {
+                       var text = phrase.value;
+                       phrase.value = '';
+                       org.activemq.Chat.chat(text);
+               });
+
+               addEvent(document.getElementById('leaveB'), 'click', function() 
{
+                       org.activemq.Chat.leave();
+                       return false;
+               });
+       };
+
+       return {
+               join: function() {
+                       var name = username.value;
+                       if (name == null || name.length == 0) {
+                               alert('Please enter a username!');
+                       } else {
+                               user = name;
+
+                               amq.addListener('chat', chatTopic, chatHandler);
+                               join.className = 'hidden';
+                               joined.className = '';
+                               phrase.focus();
+
+                               amq.sendMessage(chatTopic, '<message 
type="join" from="' + user + '"/>');
+                       }
+               },
+
+               leave: function() {
+                       amq.sendMessage(chatTopic, '<message type="leave" 
from="' + user + '"/>');
+               },
+
+               chat: function(text) {
+                       if (text != null && text.length > 0) {
+                               // TODO more encoding?
+                               text = text.replace('<', '&lt;');
+                               text = text.replace('>', '&gt;');
+
+                               amq.sendMessage(chatTopic, '<message 
type="chat" from="' + user + '">' + text + '</message>');
+                       }
+               },
+
+               init: function() {
+                       join = document.getElementById('join');
+                       joined = document.getElementById('joined');
+                       chat = document.getElementById('chat');
+                       members = document.getElementById('members');
+                       username = document.getElementById('username');
+                       phrase = document.getElementById('phrase');
+
+                       if (join.className == 'hidden' && joined.className == 
'hidden') {
+                               join.className = '';
+                               joined.className = 'hidden';
+                               username.focus();
+                       }
+
+                       initEventHandlers();
+               }
+       }
+}();
+
+
+
+
+
+
+
+
+
+
+
+
+

Reply via email to