operator.html 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <html>
  2. <head>
  3. <title>Cometd chat / Operator Page</title>
  4. <script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug:true, parseOnLoad:false"></script>
  5. <script type="text/javascript" src="room.js"></script>
  6. <script type="text/javascript">
  7. dojo.require("dijit.layout.TabContainer");
  8. dojo.require("dijit.layout.ContentPane");
  9. dojo.require("dojo.parser");
  10. var control = {
  11. _chats: {},
  12. _getAlert: function(e){
  13. console.log(e);
  14. if (!this._chats[(e.data.user)] && (operator != e.data.user)){
  15. dojox.cometd.subscribe("/chat/demo/"+e.data.joined,this,"_privateChat");
  16. var tabNode = document.createElement('div');
  17. tabNode.id = "chatWith" + e.data.user;
  18. var chatNode = document.createElement('div');
  19. chatNode.id = e.data.user + "Widget";
  20. tabNode.appendChild(chatNode);
  21. var newTab = new dijit.layout.ContentPane({
  22. title: e.data.user,
  23. closable: true
  24. },tabNode);
  25. dijit.byId('tabView').addChild(newTab);
  26. var chat = new dijit.demos.chat.Room({
  27. roomId: e.data.joined,
  28. registeredAs: operator
  29. },chatNode);
  30. chat.startup();
  31. this._chats[(e.data.user)]=true;
  32. }
  33. },
  34. _privateChat: function(e){
  35. var thisChat = dijit.byId(e.data.user+"Widget") || false;
  36. if (thisChat) { /* thisChat._chat(e); */}
  37. }
  38. };
  39. dojo.addOnLoad(function(){
  40. dojo.parser.parse(dojo.body());
  41. dojox.cometd.init("http://comet.sitepen.com:9000/cometd");
  42. dojox.cometd.subscribe("/chat/demo",control,"_getAlert");
  43. });
  44. var operator;
  45. function registerOperator(){
  46. operator = dojo.byId('opName').value;
  47. dojo.byId('login').style.display = "none";
  48. dojo.byId('status').innerHTML = "You are: <b>"+operator+"</b>";
  49. }
  50. </script>
  51. <style type="text/css">
  52. @import "chat.css";
  53. @import "../../tests/css/dijitTests.css";
  54. @import "../../themes/tundra/tundra.css";
  55. #status { position:absolute; top:5px; right:25px; }
  56. </style>
  57. </head>
  58. <body class="tundra">
  59. <h1 class="testTitle">Tech Support Operator Page:</h1>
  60. <div id="tabView" dojoType="dijit.layout.TabContainer" style="width:100%; height:75%; ">
  61. <div dojoType="dijit.layout.ContentPane" title="Home" style="padding:8px;" >
  62. <h3>Welcome Operator</h3>
  63. <p>It is your job to respond to incoming Support Requests. Sit here, and watch the screen.</p>
  64. <p id="login">Please Login as an operator:
  65. <br><br>
  66. Name: <input type="text" name="username" id="opName" value="" /> <input type="submit" value="login" onclick="registerOperator()"/>
  67. </p>
  68. </div><!-- home tab -->
  69. </div><!-- tabContainer -->
  70. <div id="status"></div>
  71. </body>
  72. </html>