-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo-dashboard.html
239 lines (216 loc) · 10.1 KB
/
demo-dashboard.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>Geniverse Dashboard</title>
<script src="lib/jquery-1.4.2.min.js" type="text/javascript"></script>
<script src="/chat/comet.js" type="text/javascript"></script>
<script src="/chat/geniversechat.js" type="text/javascript"></script>
<script src="lib/geniverse-chat-service.js" type="text/javascript"></script>
<script src="lib/geniverse-view-service.js" type="text/javascript"></script>
<script type="text/javascript">
var allChannels = ["Smaug", "Norbert"];
$(function(){
$('#left').find('h3').html(allChannels[0]);
$('#right').find('h3').html(allChannels[1]);
});
GenView.init(function(){
GenChatService.setUsername("Admin");
startChannel = GenChatService.initChat();
setupClientLists = function(channel, list){
this._channel = channel;
this._list = list;
var self = this;
GenChatService.subscribeToUserList(this._channel, function(message){
var clients = [].concat(message);
var out = "";
for (var i = 0; i < clients.length; i++) {
out += "<li>" + clients[i] + "</li>";
}
$('#'+self._list).html(out);
});
}
new setupClientLists(allChannels[0], "left-clientList");
new setupClientLists(allChannels[1], "right-clientList");
setupChatListener = function(channel, list){
this._channel = channel;
this._list = list;
var self = this;
GenChatService.subscribe(this._channel, function(message){
var messageString = '<b>' + message.user + ':</b> '+message.message;
if (message.messageObject != null && message.messageObject.image != null)
messageString = '<div><img style="float: left; margin: 5px;" src="'+message.messageObject.image+'" width="55" height="55">' + messageString + '</div>';
$('#'+self._list).append('<li style="overflow: auto;">' + messageString + '</li>');
$('#streamContainer').animate({ scrollTop: this._stream.height() }, 1000);
dragonString = (message.messageObject != null && message.messageObject != undefined) ? message.messageObject.dragon.characteristics.array : "";
$('#log').append(self._channel + "|"+message.user+"|"+message.message+"|"+dragonString+"<br>");
});
}
new setupChatListener(allChannels[0], "left-stream")
new setupChatListener(allChannels[1], "right-stream")
setupChatSender = function(channel, messageArea, button){
var self = this;
self._channel = GenChatService.validate(channel);
self._messageArea = $('#'+messageArea);
self.submit = function(){
msg = self._messageArea.val();
if (msg.search(/Goal:[ ]*/i) > -1){
var array = msg.split(/Goal:[ ]*/i)
var goal = array[array.length-1];
var command = new GenChatService.Command();
command.newGoal = goal;
GenChatService.postAdminCommand(self._channel, command) // doesn't do anything yet
message = "New goal: "+goal;
message = {user: "Admin", message: message, admin: true};
GenChatService.post(self._channel, message);
} else if (msg.search(/Alleles:[ ]*/i) > -1){
var array = msg.split(/Alleles:[ ]*/i)
var alleles = array[array.length-1];
alleles = alleles.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
var command = new GenChatService.Command();
command.newAlleles = alleles;
GenChatService.postAdminCommand(self._channel, command) // doesn't do anything yet
} else if (msg.search(/Clear:[ ]*/i) > -1){
var command = new GenChatService.Command();
command.clearAllDragons = true;
GenChatService.postAdminCommand(self._channel, command) // doesn't do anything yet
} else {
message = {user: "Admin", message: msg, admin: true};
GenChatService.post(self._channel, message);
}
self._messageArea.val('');
}
$('#'+button).click(function(){
self.submit();
});
self._messageArea.keypress(function (e) {
if (e.keyCode != 13)
return;
e.preventDefault();
self.submit();
});
}
new setupChatSender(allChannels[0], 'left-message', 'left-submit');
new setupChatSender(allChannels[1], 'right-message', 'right-submit');
});
$(function(){
$('#merge').click(function(){
// tell all users in channel[1] to switch to channel[0]
var command = new GenChatService.Command();
command.unsubscribe.push(allChannels[1]);
command.subscribe.push(allChannels[0]);
GenChatService.postAdminCommand(allChannels[1], command);
});
freezeScreens = function(channel, freeze){
var command = new GenChatService.Command();
command.freeze = freeze;
command.unfreeze = !freeze;
GenChatService.postAdminCommand(channel, command);
}
$('#left-unfreeze').hide();
$('#right-unfreeze').hide();
$('#left-freeze').click(function(){
freezeScreens(allChannels[0], true);
$('#left-freeze').hide();
$('#left-unfreeze').show();
});
$('#right-freeze').click(function(){
freezeScreens(allChannels[1], true);
$('#right-freeze').hide();
$('#right-unfreeze').show();
});
$('#left-unfreeze').click(function(){
freezeScreens(allChannels[0], false);
$('#left-freeze').show();
$('#left-unfreeze').hide();
});
$('#right-unfreeze').click(function(){
freezeScreens(allChannels[1], false);
$('#right-freeze').show();
$('#right-unfreeze').hide();
});
});
</script>
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen">
</head>
<body style="background-color: #BDC5F2;">
<div class="container">
<h1><em>Geniverse</em> | <em>dashboard</em></h1>
<div id="app">
<div id="left" style="float: left; clear: left; height: 320;">
<h3></h3>
<table>
<tr>
<td>
<div style="width: 250; height:320; border:1px solid #9dba4f; margin-left: auto; margin-right: auto; overflow: auto; margin-bottom: 10px">
<ul id="left-stream">
</ul>
</div>
<label for="message">Post a message</label><br/>
<textarea name="message" id="left-message" rows="3" style="width: 250;"></textarea><br/>
<button idd="left-submit">Chat</button>
</td>
<td>
<label>Members</label>
<div style="width: 150; height:310; border:1px solid #9dba4f; overflow: auto;">
<ul id="left-clientList">
</ul>
</div>
</td>
</tr>
<tr>
<td>
<button id="left-freeze">Lock screens</button>
<button id="left-unfreeze">Unlock screens</button>
</td>
</tr>
</table>
</div>
<div id="right" style="float: right; clear: right height: 320;">
<h3></h3>
<table>
<tr>
<td>
<div style="width: 250; height:320; border:1px solid #9dba4f; margin-left: auto; margin-right: auto; overflow: auto; margin-bottom: 10px">
<ul id="right-stream">
</ul>
</div>
<label for="message">Post a message</label><br/>
<textarea name="message" id="right-message" rows="3" style="width: 250;"></textarea><br/>
<button idd="right-submit">Chat</button>
</td>
<td>
<label>Members</label>
<div style="width: 150; height:310; border:1px solid #9dba4f; overflow: auto;">
<ul id="right-clientList">
</ul>
</div>
</td>
</tr>
<tr>
<td>
<button id="right-freeze">Lock screens</button>
<button id="right-unfreeze">Unlock screens</button>
</td>
</tr>
</table>
</div>
</div>
<div id="controls" style="clear: right;">
<button id="merge">Merge rooms</button><br>
</div>
<div style="text-align: left;">
<p style="background-color: #DEE1FC; padding: 3px;">
(Future functionality)<br>
To change the goal in any room, type a chat starting with "Goal: ___".<br>
<span style="position: relative; left: 30px">E.g.: "<span style="font-family:monospace;">Goal: Create a dragon with wings</span>"</span><br>
To change the base allele string in any room, type a chat starting with "Alleles: ___".<br>
<span style="position: relative; left: 30px">E.g.: "<span style="font-family:monospace;">Alleles: a:h,b:h</span>"</span>
</p>
Log:
<div id="log" style="clear: right; height: 200; width: 500; overflow: auto; background-color: #FFFFFF;">
</div>
</div>
</div>
</body>
</html>