aad6fc0cfb65c94164efe31f628393c3f6d727f5.svn-base 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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="../../../dijit/tests/_testCommon.js"></script>
  6. <script type="text/javascript" src="room.js"></script>
  7. <script type="text/javascript">
  8. dojo.require("dijit.Dialog");
  9. dojo.require("dijit.layout.SplitContainer");
  10. dojo.require("dijit.layout.LayoutContainer");
  11. dojo.require("dijit.layout.TabContainer");
  12. dojo.require("dijit.layout.ContentPane");
  13. dojo.require("dijit.form.Button");
  14. // custom widget created for this demo:
  15. dojo.require("dojox.widget.SortList");
  16. dojo.require("dojo.parser");
  17. // not for production use?
  18. //dojox.cometd.init("http://comet.sitepen.com:9000/cometd");
  19. var control = {
  20. _chats: [],
  21. _getAlert: function(e){
  22. console.log(e);
  23. if (!this._chats[(e.data.user)] && (operator != e.data.user)){
  24. dojox.cometd.subscribe("/chat/demo/"+e.data.joined,this,"_privateChat");
  25. var tabNode = document.createElement('div');
  26. tabNode.id = "chatWith" + e.data.user;
  27. var chatNode = document.createElement('div');
  28. chatNode.id = e.data.user + "Widget";
  29. tabNode.appendChild(chatNode);
  30. var newTab = new dijit.layout.ContentPane({
  31. title: e.data.user,
  32. closable: true
  33. },tabNode);
  34. dijit.byId('tabView').addChild(newTab);
  35. var chat = new dijit.demos.chat.Room({
  36. roomId: e.data.joined,
  37. registeredAs: operator
  38. },chatNode);
  39. chat.startup();
  40. this._chats[(e.data.user)]=true;
  41. }
  42. },
  43. _privateChat: function(e){
  44. var thisChat = dijit.byId(e.data.user+"Widget") || false;
  45. if (thisChat) { thisChat._chat(e); }
  46. }
  47. };
  48. function registerOperator(){
  49. dijit.byId('loginDialog').hide();
  50. }
  51. dojo.addOnLoad(function(){
  52. dojo.parser.parse(dojo.body());
  53. // dojox.cometd.subscribe("/chat/demo/poundDojo",control,"_getAlert");
  54. var widget = dijit.byId('userList');
  55. for (var i = 0; i<50; i++){
  56. var node = document.createElement('li');
  57. node.innerHTML = i+": list item sample";
  58. widget.containerNode.appendChild(node);
  59. }
  60. widget.onSort();
  61. });
  62. </script>
  63. <style type="text/css">
  64. @import "chat.css";
  65. @import "../../tests/css/dijitTests.css";
  66. @import "../../themes/tundra/tundra.css";
  67. @import "../../../dojox/widget/SortList/SortList.css";
  68. html, body { margin:0; padding:0; height:100%; width:100%; overflow:hidden; }
  69. #status { position:absolute; top:5px; right:25px; }
  70. #mainPane { background:#fff; }
  71. </style>
  72. </head>
  73. <body>
  74. <div dojoType="dijit.layout.LayoutContainer" style="width:100%; height:100%;">
  75. <div dojoType="dijit.layout.SplitContainer" orientation="vertical" style="height:100%" layoutAlign="client" sizerWidth="7">
  76. <div dojoType="dijit.layout.SplitContainer" orientation="horizontal" sizerWidth="7" activeSizing="true" layoutAlign="top" sizeShare="80">
  77. <div id="mainPane" dojoType="dijit.layout.ContentPane" title="Home" style="padding:8px;" sizeShare="80" layoutAlign="left" style="background:#fff;">
  78. <h3>Dojo community chat demo</h3>
  79. <h2>NON-WORKING PROTOTYPE</h2>
  80. <button dojoType="dijit.form.Button">Login
  81. <script type="dojo/method" event="onClick">
  82. console.log('foo?');
  83. dijit.byId('loginDialog').show();
  84. </script>
  85. </button>
  86. </div>
  87. <div title="Users in #dojo" id="userList" dojoType="dojox.widget.SortList" sizeShare="20" sizeMin="15" layoutAlign="right"></div>
  88. </div>
  89. <div dojoType="dijit.layout.ContentPane" sizeShare="20" layoutAlign="bottom">
  90. bottom. (input area)
  91. </div>
  92. </div>
  93. </div>
  94. <div dojoType="dijit.Dialog" id="loginDialog" title="Select Username:">
  95. Name: <input type="text" name="username" id="opName" value="" />
  96. <input type="submit" value="login" onclick="registerOperator()"/>
  97. </div>
  98. </body>
  99. </html>