-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
executable file
·142 lines (135 loc) · 5.3 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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="keywords" content="Chess, Chessboard, Javascript, Play Chess, Javascript Chess, three.js, chessboard.js, chessboard3.js">
<title>chessboard3.js</title>
<link rel="shortcut icon" href="img/favicon.ico" type="image/x-icon" />
<link type="text/css" rel="stylesheet" href="css/site.css">
<link type="text/css" rel="stylesheet" href="css/chessboard.css">
<link type="text/css" rel="stylesheet" href="css/prettyprint.css">
<script type="text/javascript" src="js/jquery-2.1.3.min.js"></script>
<script type="text/javascript" src="js/chessboard.js"></script>
<script type="text/javascript" src="js/three.min.js"></script>
<script type="text/javascript" src="js/OrbitControls.js"></script>
<script type="text/javascript" src="js/chessboard3.js"></script>
<script type="text/javascript" src="js/prettify.js"></script>
<script type="text/javascript" src="js/index.js"></script>
</head>
<body onload="prettyPrint()">
<header id="header">
<h1>chessboard3.js</h1>
<nav>
<ul>
<li><a href="play.html"><input type="button" class="blueButton" value="Play"></a></li>
</ul>
</nav>
</header>
<div class="banner">
</div>
<div class="row">
<div class="leftcol">
<h2>Simplest possible usage:</h2>
<h4>HTML</h4>
<pre class="prettyprint"><div id="board1" style="width: 600px; height: 450px"></div></pre>
<h4>JavaScript</h4>
<pre class="prettyprint">var board1 = new ChessBoard3('board1', 'start');</pre>
<p>
These two lines create a board with default settings..
</p>
</div>
<div class="rightcol">
<div id="board1" style="width: 600px; height: 450px">
<h2 class="vertical-align">LOADING...</h2>
</div>
<p>(By default, pieces are not draggable.)</p>
</div>
</div>
<div class="row">
<div class="leftcol">
<h2>Customization</h2>
<h4>HTML</h4>
<pre class="prettyprint"><div id="board2" style="width: 600px; height: 450px"></div>
<input type="button" id="startBtn" value="Start" />
<input type="button" id="clearBtn" value="Clear" />
<input type="button" id="flipBtn" value="Flip" />
<div id="FEN"></div></pre>
<h4>JavaScript</h4>
<pre class="prettyprint">
var board2 = new ChessBoard3('board2', {
draggable: true,
dropOffBoard: 'trash',
sparePieces: true
onChange: function(oldPos, newPos) {
$("#FEN").text(ChessBoard3.objToFen(newPos));
}
});
$('#startBtn').on('click', board2.start);
$('#clearBtn').on('click', board2.clear);
$('#flipBtn').on('click', board2.flip);</pre>
The second argument can also be a configuration object.
</div>
<div class="rightcol">
<div id="board2" style="width: 600px; height: 450px">
<h2 class="vertical-align">LOADING...</h2>
</div>
<input type="button" id="startBtn" value="Start"/>
<input type="button" id="clearBtn" value="Clear"/>
<input type="button" id="flipBtn" value="Flip"/>
<p id="FEN">8/8/8/8/8/8/8/8</p>
</div>
</div>
<div class="row">
<div class="leftcol">
<h2>Integrating chessboard3.js and chessboard.js</h2>
<h4>HTML</h4>
<pre class="prettyprint"><div id="outer">
<div id="inner"></div>
</div>
<input type="button" id="2D" value="2D"/>
<input type="button" id="3D" value="3D"/>
</pre>
<h4>JavaScript</h4>
<pre class="prettyprint">var sampleConfig =
position: 'start',
draggable : true,
dropOffBoard: 'snapback'
};
var board;
function setUpBoard(dimensions) {
var currentPosition = 'start';
if (board !== undefined) {
currentPosition = board.position();
board.destroy();
}
if (dimensions >= 3) {
$('#inner').css('width', '600px');
$('#inner').css('height', '450px');
$('#outer').css('padding', '');
board = new ChessBoard3('inner', sampleConfig);
} else {
$('#inner').css('width', '450px');
$('#outer').css('height', '450px');
$('#outer').css('padding', '0px 75px 0px 75px');
board = new ChessBoard('inner', sampleConfig);
}
board.position(currentPosition, false);
}
$('#2D').on('click', function() {setUpBoard(2);});
$('#3D').on('click', function() {setUpBoard(3);});
setUpBoard(2); // start with a 2D board
</pre>
</div>
<div class="rightcol">
<div id="outer">
<div id="inner"></div>
</div>
<input type="button" id="2D" value="2D"/>
<input type="button" id="3D" value="3D"/>
<p style="text-align: left">
You can easily switch between 2D and 3D boards.
</p>
</div>
</div>
</body>
</html>