-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
408 lines (370 loc) · 11.8 KB
/
index.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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
<!DOCTYPE html>
<meta charset="utf-8" />
<meta name="description" content="Multi User Dungeon based upon AberMUD" />
<meta name="keywords" content="MUD, MUSH, Game, AberMUD, Multi User Dungeon, fantasy, ANSI graphics, RPG, Role Playing Game, Python, GPL, Aberystwyth, Wales" />
<style>
@charset "UTF-8";
:root {
--main-background-color: black;
--title-text-color: lightgrey;
--main-text-color: white;
--chess-text-color: white;
--inputbox-color: #111;
--button-text-color: yellow;
--main-font-size: 20px;
--chess-font-size: 30px;
--input-font-size: 28px;
--title-font-size: 40px;
--button-font-size: 30px;
--image-font-size: 1vw;
--text-padding: 32px;
}
@font-face {
font-family: 'Catwalzhari';
font-style: normal;
font-weight: normal;
font-display: block;
src: url('./fonts/Catwalzhari.ttf') format('truetype');
}
@font-face {
font-family: 'Octavius';
font-style: normal;
font-weight: normal;
font-display: block;
src: url('./fonts/Octavius.woff2') format('woff2');
}
body, html {
font-family: 'Octavius';
font-size: var(--main-font-size);
background-color: var(--main-background-color);
color: var(--main-text-color);
}
blockquote {
color: orange;
}
#roomtitle {
font-family: 'Catwalzhari';
font-size: var(--title-font-size);
color: var(--title-text-color);
float: left;
}
#roomimage {
font-family: monospace;
font-size: var(--image-font-size);
}
#roomdescription {
font-family: 'Octavius';
font-size: var(--main-font-size);
padding: var(--text-padding) var(--text-padding);
color: var(--main-text-color);
line-height: 200%;
}
#initialText {
font-family: 'Octavius';
font-size: var(--main-font-size);
padding: var(--text-padding) var(--text-padding);
color: var(--main-text-color);
line-height: 200%;
}
textarea {
font-family: 'Octavius';
font-size: var(--input-font-size);
width: 92%;
background-color: var(--inputbox-color);
color: var(--main-text-color);
padding: 16px 16px;
border: 0;
margin-left: 3%;
}
input[type=button] {
font-family: 'Catwalzhari';
font-size: var(--button-font-size);
background-color: var(--inputbox-color);
color: var(--button-text-color);
float: right;
margin: 3% 3%;
}
#maintable {
width: 100%;
background-color: var(--main-background-color);
}
#cards img {
width: 90%;
}
#chess {
width: 80%;
padding: 0;
border: 0;
cellspacing: 0;
cellpadding: 0;
}
#chess img {
width: 100%;
}
.textentrycol {
width: 50%;
}
.parent {
position: relative;
top: 0;
left: 0;
padding: 0 0;
margin: 0 0;
width: 100%;
height: 100%;
display: block;
}
table,
td,
th {
border-color: transparent;
padding: 0;
cellspacing: 0;
cellpadding: 0;
}
td img {vertical-align: bottom;}
.coord {
font-family: 'Octavius';
font-size: var(--chess-font-size);
color: var(--chess-text-color);
text-align: center;
padding: 20px 20px;
}
.board {
position: relative;
top: 0;
left: 0;
}
.boardpiece {
position: absolute;
top: 0%;
left: 0%;
}
.morrisboard {
position: relative;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
</style>
<title>AberMUSH</title>
<script src="ansi_up.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
var ansi_up = new AnsiUp;
function initial_layout()
{
document.myform.inputtext.value = ""
// buttons not initially visible
document.myform.connectButton.style.visibility = "visible";
document.myform.connectButton.disabled = false;
document.myform.disconnectButton.style.visibility = "hidden";
document.myform.disconnectButton.disabled = true;
document.myform.clearButton.style.visibility = "hidden";
// hide input box
document.myform.inputtext.style.visibility = "hidden";
var inputbox = document.getElementById("inputtext");
inputbox.focus();
}
function init()
{
initial_layout();
var inputbox = document.getElementById("inputtext");
inputbox.addEventListener("keydown", function (e) {
if (e.keyCode === 13) { // "Enter"
doSend( document.myform.inputtext.value );
}
});
}
function doConnect()
{
var cdiv = document.getElementById("roomdescription");
cdiv.innerHTML = "";
var cdiv = document.getElementById("roomimage");
cdiv.innerHTML = "";
var cdiv = document.getElementById("roomtitle");
cdiv.innerHTML = "";
websocket = new WebSocket("ws://localhost:6221/");
websocket.onopen = function(evt) { onOpen(evt) };
websocket.onclose = function(evt) { onClose(evt) };
websocket.onmessage = function(evt) { onMessage(evt) };
websocket.onerror = function(evt) { onError(evt) };
// make buttons visible
document.myform.connectButton.style.visibility = "hidden";
document.myform.disconnectButton.style.visibility = "visible";
document.myform.clearButton.style.visibility = "visible";
// make input box visible
document.myform.inputtext.style.visibility = "visible";
document.getElementById("inputtext").focus();
}
function onOpen(evt)
{
writeToScreen("connected");
document.myform.connectButton.disabled = true;
document.myform.disconnectButton.disabled = false;
}
function onClose(evt)
{
writeToScreen("disconnected");
initial_layout();
}
function onMessage(evt)
{
writeToScreen(evt.data);
}
function onError(evt)
{
writeToScreen("error: " + evt.data);
websocket.close();
document.myform.connectButton.disabled = false;
document.myform.disconnectButton.disabled = true;
}
function doSend(message)
{
writeToScreen(message);
websocket.send(message);
document.myform.inputtext.value = "";
document.getElementById("inputtext").focus();
}
function writeToScreen(message)
{
// ignore silent messages which are used to check
// that the client is still active
if (message == "\x00") return;
var clearRoomText = false;
destination = "roomdescription";
if (message.includes("****TITLE****")) {
clearAll()
destination = "roomtitle";
message = message.replace("****TITLE****", "");
message = message.replace("You arrive at ", "");
message = message.replace("You row to ", "");
}
if (message.includes("****DISCONNECT****")) {
message = message.replace("****DISCONNECT****", "");
initial_layout();
}
if (message.includes("****CLEAR****")) {
message = message.replace("****CLEAR****", "");
clearRoomText = true;
var cdiv = document.getElementById(destination);
cdiv.innerHTML = "";
}
if (message.includes("****IMAGE****")) {
destination = "roomimage";
message = message.replace("****IMAGE****", "");
clearRoomText = true;
var cdiv = document.getElementById("roomdescription");
cdiv.innerHTML = "";
}
var cdiv = document.getElementById(destination);
if (destination == "roomtitle" || destination == "roomimage") {
cdiv.innerHTML = "";
}
if (destination != "roomtitle") {
if (message.includes('<img class=')) {
// playing card or chess images
msgStr = message;
}
else {
// split the message into lines
var lines = message.split('\n');
msgStr = "";
var maxLines = lines.length;
if (destination == "roomimage") {
if (maxLines > 40) maxLines = 40;
}
for (var i = 0; i < maxLines; i++) {
msgStr += ansi_up.ansi_to_html(lines[i]) + "<br>";
}
}
}
else {
msgStr = ansi_up.ansi_to_html(message.replace('\n', ''));
}
if (destination == "roomdescription") {
while (msgStr.includes("<br><br><br>")) {
msgStr = msgStr.replace("<br><br><br>", "<br><br>");
}
}
cdiv.innerHTML += msgStr;
document.getElementById("inputtext").focus();
window.scrollTo(0,document.body.scrollHeight);
}
window.addEventListener("load", init, false);
if(typeof(String.prototype.trim) === "undefined")
{
String.prototype.trim = function()
{
return String(this).replace(/^\s+|\s+$/g, '');
};
}
function clearAll() {
var cdiv = document.getElementById("roomdescription");
cdiv.innerHTML = "";
var cdiv = document.getElementById("roomimage");
cdiv.innerHTML = "";
var cdiv = document.getElementById("roomtitle");
cdiv.innerHTML = "";
}
function clearText() {
var cdiv = document.getElementById("roomdescription");
cdiv.innerHTML = "";
}
function doDisconnect() {
websocket.close();
initial_layout();
}
</script>
<div id="output"></div>
<form name="myform">
<table id="maintable">
<tr>
<td class="textentrycol">
<table id="texttable">
<tr>
<td>
<div id="roomtitle" name="roomtitle" contenteditable="true">
A B E R M U S H
</div>
<br>
<input type="button" name="connectButton" value="Connect" onClick="doConnect();">
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td>
<div id="roomdescription" name="roomdescription" contenteditable="true">
<blockquote>"Once a year the dragon emerged from its cave. The people of the valleys could hear its thundering roar as it awakened from its long slumber."</blockquote>
<center><img src="index.jpg" style="width:100%" /></center>
<p>AberMUSH is a text based role playing game with UTF-8 ANSI graphics, set in the AberMUD 5 universe. Explore, battle and adventure in a fantasy version of medieval Wales. Experience DnD style combat, gambling disputes, excessive ale consumption and puzzling mysteries in the once magnificent but now fallen city of Tranoch, with dynamic scenery, tides, wildlife and weather effects.</p>
<p>There are additional games within the MUSH, such as cards and chess.</p>
<p>Source code: https://gitlab.com/bashrc2/AberMUSH</p>
</div>
</td>
</tr>
<tr>
<td>
<textarea name="inputtext" id="inputtext" autofocus></textarea>
<br>
<input type="button" name="clearButton" value="Clear" onClick="clearText();">
<input type="button" name="disconnectButton" value="Disconnect" onClick="doDisconnect();">
</td>
</tr>
</table>
</td>
<td class="textentrycol">
<div id="roomimage" name="roomimage" contenteditable="true">
<div id="initialText" name="initialText">
<p>Somewhere in the mysterious past of Wales, among mountains and icy ravines, the city of Tranoch is a haven for adventurers.</p>
</div>
<center><img src="index2.jpg" style="width:70%" /></center>
</div>
</td>
</tr>
</table>
</form>
</html>