-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.html
585 lines (476 loc) · 15.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
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta charset="utf-8" />
<!--[if IE]><![endif]-->
<title>HTML Scrabble</title>
<meta name="DC.title" content="HTML Scrabble" />
<meta name="description"
content="A simple Scrabble clone made with HTML, CSS, JavaScript, and some server-side code to handle multiplayer games." />
<meta name="DC.subject"
content="A simple Scrabble clone made with HTML, CSS, JavaScript, and some server-side code to handle multiplayer games." />
<meta name="author" content="Daniel Weck" />
<meta name="DC.creator" content="Daniel Weck" />
<meta name="Copyright" content="Open Source code, LGPL license" />
<meta name="Copyright" content="SCRABBLE[tm] is a registered trademark. All intellectual property rights in and to the game are owned in the U.S.A and Canada by Hasbro Inc., and throughout the rest of the world by J.W. Spear & Sons Limited of Maidenhead, Berkshire, England, a subsidiary of Mattel Inc. This web page and associated experiments are not associated with any of the owners." />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<!-- link rel="stylesheet" href="css/main.css" media="all" / -->
<style type="text/css" media="all">
@import "css/main.css";
</style>
<script type="text/javascript" src="javascript/jquery-1.4.3.min.js"></script>
<!-- script type="text/javascript" src="javascript/jquery.event.drag-2.0.js"></script>
<script type="text/javascript" src="javascript/jquery.event.drop-2.0.js"></script -->
<!-- script type="text/javascript" src="javascript/jquery.animate-enhanced.min.js"></script -->
<script src="javascript/jquery.blockUI.js" type="text/javascript"></script>
<script src="javascript/jquery-css-transform.js" type="text/javascript"></script>
<script src="javascript/jquery-animate-css-rotate-scale.js" type="text/javascript"></script>
<script src="javascript/rotate3Di.js" type="text/javascript"></script>
<script type="text/javascript" src="javascript/jquery-ui-1.8.7.custom.min.js"></script>
<!-- script type="text/javascript" src="javascript/dictionary_English.js"></script -->
<!--
var re = /(,[a-z]+)\+/g;
var re0 = /(,[a-z])([a-z]*)0/g;
var re1 = /(,[a-z]{2})([a-z]*)1/g;
var re2 = /(,[a-z]{3})([a-z]*)2/g;
var re3 = /(,[a-z]{4})([a-z]*)3/g;
var re4 = /(,[a-z]{5})([a-z]*)4/g;
var re5 = /(,[a-z]{6})([a-z]*)5/g;
var re6 = /(,[a-z]{7})([a-z]*)6/g;
var re7 = /(,[a-z]{8})([a-z]*)7/g;
var re8 = /(,[a-z]{9})([a-z]*)8/g;
var re9 = /(,[a-z]{10})([a-z]*)9/g;
function checkDictionary(theWord)
{
theWord = theWord.toLowerCase();
if (theWord.length == 2)
{
return (D2.indexOf(theWord) != -1);
}
first3 = theWord.replace(/^(...).*/, "$1");
if (typeof(D[first3]) == "undefined")
{
return false;
}
var theEntry = D[first3];
if (!theEntry.match(/,$/))
{
// We've not looked at this entry before - uncompress it, etc.
theEntry = theEntry.replace(/W/g, "le");
theEntry = theEntry.replace(/K/g, "al");
theEntry = theEntry.replace(/F/g, "man");
theEntry = theEntry.replace(/U/g, "ous");
theEntry = theEntry.replace(/M/g, "ment");
theEntry = theEntry.replace(/B/g, "able");
theEntry = theEntry.replace(/C/g, "ic");
theEntry = theEntry.replace(/X/g, "on");
theEntry = theEntry.replace(/Q/g, "ng");
theEntry = theEntry.replace(/R/g, "ier");
theEntry = theEntry.replace(/S/g, "st");
theEntry = theEntry.replace(/Y/g, "ly");
theEntry = theEntry.replace(/J/g, "ally");
theEntry = theEntry.replace(/E/g, "es");
theEntry = theEntry.replace(/L/g, "less");
theEntry = theEntry.replace(/Z/g, "ies");
theEntry = theEntry.replace(/P/g, "tic");
theEntry = theEntry.replace(/I/g, "iti");
theEntry = theEntry.replace(/V/g, "tion");
theEntry = theEntry.replace(/H/g, "zation");
theEntry = theEntry.replace(/A/g, "abiliti");
theEntry = theEntry.replace(/O/g, "ologi");
theEntry = theEntry.replace(/T/g, "est");
theEntry = theEntry.replace(/D/g, "ed");
theEntry = theEntry.replace(/N/g, "ness");
theEntry = theEntry.replace(/G/g, "ing");
theEntry = "," + theEntry + ",";
// May have prefixes on prefixes, so need to repeat the replace.
var more = true;
while (more)
{
var theLength = theEntry.length;
theEntry = theEntry.replace(re, "$1$1");
theEntry = theEntry.replace(re0, "$1$2$1");
theEntry = theEntry.replace(re1, "$1$2$1");
theEntry = theEntry.replace(re2, "$1$2$1");
theEntry = theEntry.replace(re3, "$1$2$1");
theEntry = theEntry.replace(re4, "$1$2$1");
theEntry = theEntry.replace(re5, "$1$2$1");
theEntry = theEntry.replace(re6, "$1$2$1");
theEntry = theEntry.replace(re7, "$1$2$1");
theEntry = theEntry.replace(re8, "$1$2$1");
theEntry = theEntry.replace(re9, "$1$2$1");
more = (theLength != theEntry.length);
}
if (theEntry.match(/[0-@+]/))
{
alert("decompression oops!");
}
D[first3] = theEntry;
}
rest = theWord.replace(/^...?/, "");
return (D[first3].indexOf("," + rest + ",") != -1);
}
-->
<script type="text/javascript" src="javascript/BinFileReader.js"></script>
<script>var _sf_startpt=(new Date()).getTime()</script>
<script type="text/javascript" src="javascript/main.js"></script>
<!-- script type="text/javascript" src="scripts/dictionary.js"></script -->
<script type="text/javascript">
var game = 0;
var board = 0;
var rack = 0;
var boardUI = 0;
function playAction_resetTilesOnRack()
{
boardUI.SetCurrentlySelectedSquareUpdateTargets(0);
//boardUI.CurrentlySelectedSquare = 0;
rack.TakeTilesBack();
}
function playAction_submitWords()
{}
function playAction_drawNewTiles()
{
boardUI.SetCurrentlySelectedSquareUpdateTargets(0);
//boardUI.CurrentlySelectedSquare = 0;
/*
rack.EmptyTiles();
rack.ReplenishRandomTiles();
*/
rack.GenerateRandomTiles();
//TODO: pass turn
}
function playAction_passTurn()
{
if (!confirm("Are you sure you want to pass your turn ?"))
{
return;
}
//TODO: pass
}
function resetTextField()
{
$("#text_field").val("");
}
function findAnagrams()
{
var text = $("#text_field").val();
var anagrams = game.Dictionary.FindAnagrams(text);
if (anagrams.length == 1)
{
alert("Error: the characters [" + anagrams[0] + "] do not return any anagrams from the \"" + game.Language + "\" dictionary.");
}
else
{
//alert("Success: the characters [" + anagrams[0] + "] return " + (anagrams.length-1) + " anagrams from the \"" + game.Language + "\" dictionary.");
$('#anagrams').html('<p><input type="button" value="Clear Anagrams" onclick="$(\'#anagrams\').html(\'\');"></input></p>');
/*
for (var i = 1; i < anagrams.length; i++)
{
$('#anagrams').append('<p>' + anagrams[i] + '</p>');
}
*/
var wordsByLength = [];
for (var i = 0; i < game.Dictionary.MaxWordLength; i++)
{
wordsByLength.push([]);
}
for (var i = 1; i < anagrams.length; i++)
{
var word = anagrams[i];
wordsByLength[word.length].push(word);
}
var charInput = anagrams[0];
var table = "<table>";
for (var i = game.Dictionary.MaxWordLength - 1; i >= 2 ; i--)
{
var words = wordsByLength[i];
if (words.length <= 0) continue;
table += "<tr>";
if (charInput.length == i)
{
table += "<th>[" + i + "]</th>";
}
else
{
table += "<th>" + i + "</th>";
}
table += "<td>";
for (var j = 0; j < words.length; j++)
{
var word = words[j];
table += word;
if (j < (words.length - 1))
{
table += " - ";
}
}
table += "</td>";
table += "<tr>";
}
table += "</table>";
$('#anagrams').append(table);
}
}
function checkWord()
{
var text = $("#text_field").val();
var ok = game.Dictionary.CheckWord(text);
if (ok)
{
alert("Success: [" + text + "] is in the \"" + game.Language + "\" dictionary.");
}
else
{
alert("Error: [" + text + "] is not in the \"" + game.Language + "\" dictionary.");
}
}
function verifyBoard()
{
boardUI.CleanupErrorLayer();
var valid = board.CheckDictionary();
if (!valid)
{
Scrabble.UI.Html.prototype.OnUnblockUIFunction = function() { boardUI.CleanupErrorLayer(); };
$.blockUI({
message: "<p>Invalid words or tile placement !</p><input type=\"submit\" value=\"Return\" onclick=\"boardUI.UnblockUIFunction();\"></input>",
focusInput: true,
bindEvents: true,
constrainTabKey: true,
fadeIn: 0,
fadeOut: 0,
showOverlay: true,
centerY: true,
css: { position: "absolute", padding: "1em", backgroundColor: "black", color: "white", width: "100%", left: 0, top: $("#rack").offset().top, border: "none", textAlign: "center" },
overlayCSS: { backgroundColor: '#FFFFFF', opacity: 0.2 },
onBlock: function()
{
//console.log("modal activated");
}
});
$('.blockOverlay').attr('title','Click to return to the game');
$('.blockOverlay').click(
boardUI.UnblockUIFunction
);
}
else
{
setTimeout(function()
{
boardUI.CleanupErrorLayer();
}, 1000);
}
//if (!valid) alert("Some words are invalid !");
//else alert("All words are valid !");
}
function emptyBoardAndRack()
{
boardUI.SetCurrentlySelectedSquareUpdateTargets(0);
//boardUI.CurrentlySelectedSquare = 0;
board.EmptyTiles();
rack.EmptyTiles();
}
function replenishRack()
{
boardUI.SetCurrentlySelectedSquareUpdateTargets(0);
//boardUI.CurrentlySelectedSquare = 0;
rack.ReplenishRandomTiles();
}
function placeRandomTiles_Rack()
{
boardUI.SetCurrentlySelectedSquareUpdateTargets(0);
//boardUI.CurrentlySelectedSquare = 0;
rack.GenerateRandomTiles();
}
function placeRandomTiles_Board()
{
boardUI.SetCurrentlySelectedSquareUpdateTargets(0);
//boardUI.CurrentlySelectedSquare = 0;
board.GenerateRandomTiles();
}
function setLanguage(lang)
{
game.SetLanguage(lang);
}
function placeTileSet()
{
boardUI.SetCurrentlySelectedSquareUpdateTargets(0);
//boardUI.CurrentlySelectedSquare = 0;
board.GenerateTilesLetterDistribution();
//rack.GenerateRandomTiles();
}
function init() {
// quit if this function has already been called
if (arguments.callee.done) return;
// flag this function so we don't do the same thing twice
arguments.callee.done = true;
boardUI = new window.Scrabble.UI.Html(); // must be instantiated first (to listen to Core events)
board = new window.Scrabble.Core.Board();
rack = new window.Scrabble.Core.Rack();
game = new window.Scrabble.Core.Game(board, rack);
/*
if (false)
{
board.GenerateRandomTiles();
}
else
{
board.GenerateTilesLetterDistribution();
}
*/
//rack.GenerateRandomTiles();
$(document).ready(function(){
/*
$(this).animate({left: "+=200px", width:320 }, 1500, function() {
$(this).animate({left: "-=200px", width:280 }, 1500, function() {
});
});
*/
//$("#board").fadeOut();
// table.fadeIn("fast");
// table.animate({rotate: '+=45deg'});
var obj = $("#title");
//obj.effect("pulsate", { times:2 }, 500);
//obj.css({opacity: 0.5});
//obj.scale(0.5);
//obj.animate({opacity: 1}, 500);
//obj.show("clip", {}, 500);
//obj.effect("transfer", { to: $("#title") }, 1000);
//obj.effect("bounce", { times: 3, direction: "right" }, 500);
obj.rotate3Di(360, 1000,
{
sideChange: function(front) {
if (front) {
//
} else {
// obj.animate({scale: 1}, 500);
}
}
,
complete: function() {
//
}
}
);
/*
$('.drag')
.drag("start",function( ev, dd ){
return $( this ).clone()
.css("opacity", .75 )
.appendTo(this.parentNode );
})
.drag(function( ev, dd ){
$( dd.proxy ).css({
top: dd.offsetY,
left: dd.offsetX
},{ relative:true });
})
.drag("end",function( ev, dd ){
$( dd.proxy ).animate({
top: dd.originalY,
left: dd.originalX
}, 420 );
$( dd.proxy ).remove();
});
$('.drop')
.drop("start",function(){
$( this ).addClass("dropActive");
})
.drop(function( ev, dd ){
$( this ).toggleClass("dropped");
})
.drop("end",function(){
$( this ).removeClass("dropActive");
});
*/
});
};
/* for Mozilla */
if (document.addEventListener) {
document.addEventListener("DOMContentLoaded", init, false);
}
/* for Internet Explorer */
/*@cc_on @*/
/*@if (@_win32)
document.write("<script defer src=ie_onload.js><"+"/script>");
/*@end @*/
/* for other browsers */
window.onload = init;
</script>
<!--[if IE]>
<style type="text/css" media="all">
div.surroundShade table,
div.bottomShade table
{
zoom: 1;
filter: progid:DXImageTransform.Microsoft.Shadow(color='#333333', Direction=135, Strength=3);
}
</style>
<![endif]-->
<!--[if lt IE 7]>
<style type="text/css" media="all">
.cie654 {display: block}
</style>
<![endif]-->
<!--[if !lt IE 7]>
<style type="text/css" media="all">
.cie7 {display: block}
</style>
<![endif]-->
<!--[if IE 8]>
<style type="text/css" media="all">
.cie8 {display: block}
</style>
<![endif]-->
<!--[if !IE]>--> <style type="text/css" media="all">.cnotie {display: block}</style> <!--<![endif]-->
</head>
<body id="body">
<audio id="audio0" src="audio/20258__Koops__Page_Turn_24.wav" preload="auto" type="audio/wav"></audio>
<audio id="audio1" src="audio/1257__Anton__hit_on_wood.wav" preload="auto" type="audio/wav"></audio>
<audio id="audio2" src="audio/1258__Anton__hit_on_wood2.wav" preload="auto" type="audio/wav"></audio>
<audio id="audio3" src="audio/37161__volivieri__soccer_stomp_01.wav" preload="auto" type="audio/wav"></audio>
<audio id="audio4" src="audio/54405__KorgMS2000B__Button_Click.wav" preload="auto" type="audio/wav"></audio>
<audio id="audio5" src="audio/32435__HardPCM__Wood012.wav" preload="auto" type="audio/wav"></audio>
<div id="title">
<span>ELBBARCS</span>
</div>
<div style="background-color: black; padding: 1em;">
<p>
Language:
<span id="language">
</span>
<input type="submit" onclick="setLanguage('French');" value="French"></input>
<input type="submit" onclick="setLanguage('English');" value="English"></input>
</p>
<p>
<input id="text_field" type="text" onmousedown="resetTextField();" value="[type word here]" size="15" style="width: 25em"></input>
<input type="submit" onclick="checkWord();" value="Check dictionary"></input>
<input type="submit" onclick="findAnagrams();" value="Find anagrams"></input>
</p>
<div id="anagrams" class="tableDivWrap"></div>
</div>
<p>
<input type="submit" onclick="emptyBoardAndRack();" value="Empty board and rack"></input>
</p>
<p>
<input type="submit" onclick="replenishRack();" value="Replenish rack"></input>
<input type="submit" onclick="placeRandomTiles_Rack();" value="Randomize rack"></input>
</p>
<p>
<input type="submit" onclick="placeRandomTiles_Board();" value="Randomize board"></input>
<input type="submit" onclick="placeTileSet();" value="Display entire tile set"></input>
</p>
<div id="rack" class="tableDivWrap bottomShade"></div>
<!-- p>
<input type="submit" onclick="playAction_resetTilesOnRack();" value="Take tiles back"></input>
<input type="submit" onclick="playAction_submitWords();" value="Submit word(s)"></input>
<input type="submit" onclick="playAction_drawNewTiles();" value="Draw new tiles (pass turn)"></input>
<input type="submit" onclick="playAction_passTurn();" value="Pass turn"></input>
</p -->
<p>
<input type="submit" onclick="verifyBoard();" value="Verify board"></input>
</p>
<div id="board" class="tableDivWrap surroundShade"></div>
<div id="letters" class="tableDivWrap" style="display:none;"></div>
</body>
</html>