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