chess.wasm: add chessboard
@ -25,7 +25,7 @@ if (WHISPER_WASM_SINGLE_FILE)
|
|||||||
TARGET ${TARGET} POST_BUILD
|
TARGET ${TARGET} POST_BUILD
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy
|
COMMAND ${CMAKE_COMMAND} -E copy
|
||||||
${CMAKE_BINARY_DIR}/bin/libchess.js
|
${CMAKE_BINARY_DIR}/bin/libchess.js
|
||||||
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/chess.wasm/chess.js
|
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/chess.wasm/js/chess.js
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@ -40,6 +40,16 @@ set_target_properties(${TARGET} PROPERTIES LINK_FLAGS " \
|
|||||||
${EXTRA_FLAGS} \
|
${EXTRA_FLAGS} \
|
||||||
")
|
")
|
||||||
|
|
||||||
|
|
||||||
|
add_custom_command(
|
||||||
|
TARGET ${TARGET} POST_BUILD
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/chessboardjs-1.0.0
|
||||||
|
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/chess.wasm/
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/jquery-3.7.1.min.js
|
||||||
|
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/chess.wasm/js/
|
||||||
|
)
|
||||||
#
|
#
|
||||||
# chess.wasm
|
# chess.wasm
|
||||||
#
|
#
|
||||||
@ -47,4 +57,4 @@ set_target_properties(${TARGET} PROPERTIES LINK_FLAGS " \
|
|||||||
set(TARGET chess.wasm)
|
set(TARGET chess.wasm)
|
||||||
|
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/index-tmpl.html ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TARGET}/index.html @ONLY)
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/index-tmpl.html ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TARGET}/index.html @ONLY)
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../helpers.js ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TARGET}/helpers.js @ONLY)
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../helpers.js ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TARGET}/js/helpers.js @ONLY)
|
||||||
|
32
examples/chess.wasm/chessboardjs-1.0.0/CHANGELOG.md
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
# chessboard.js Change Log
|
||||||
|
|
||||||
|
All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
|
## [1.0.0] - 2019-06-11
|
||||||
|
- Orientation methods now return current orientation. [Issue #64]
|
||||||
|
- Drop support for IE8
|
||||||
|
- Do not check for `window.JSON` (Error #1004)
|
||||||
|
- Rename `ChessBoard` to `Chessboard` (`ChessBoard` is still supported, however)
|
||||||
|
- id query selectors are now supported as the first argument to `Chessboard()`
|
||||||
|
- Remove Error #1002
|
||||||
|
- Format code according to [StandardJS]
|
||||||
|
- Bump minimum jQuery version to 1.8.3
|
||||||
|
- Throttle piece drag functions
|
||||||
|
|
||||||
|
## [0.3.0] - 2013-08-10
|
||||||
|
- Added `appearSpeed` animation config property
|
||||||
|
- Added `onSnapbackEnd` event
|
||||||
|
- Added `onMoveEnd` event
|
||||||
|
|
||||||
|
## [0.2.0] - 2013-08-05
|
||||||
|
- Added `onMouseoverSquare` and `onMouseoutSquare` events
|
||||||
|
- Added `onSnapEnd` event
|
||||||
|
- Added square code as CSS class on the squares
|
||||||
|
- Added [chess.js] integration examples
|
||||||
|
|
||||||
|
## [0.1.0] - 2013-05-21
|
||||||
|
- Initial release
|
||||||
|
|
||||||
|
[chess.js]:https://github.com/jhlywa/chess.js
|
||||||
|
[Issue #64]:https://github.com/oakmac/chessboardjs/issues/64
|
||||||
|
[StandardJS]:https://standardjs.com/
|
20
examples/chess.wasm/chessboardjs-1.0.0/LICENSE.md
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
Copyright 2019 Chris Oakman
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of this software and associated documentation files (the
|
||||||
|
"Software"), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
82
examples/chess.wasm/chessboardjs-1.0.0/README.md
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
# chessboard.js
|
||||||
|
|
||||||
|
chessboard.js is a JavaScript chessboard component. It depends on [jQuery].
|
||||||
|
|
||||||
|
Please see [chessboardjs.com] for documentation and examples.
|
||||||
|
|
||||||
|
## What is chessboard.js?
|
||||||
|
|
||||||
|
chessboard.js is a JavaScript chessboard component with a flexible "just a
|
||||||
|
board" API that
|
||||||
|
|
||||||
|
chessboard.js is a standalone JavaScript Chess Board. It is designed to be "just
|
||||||
|
a board" and expose a powerful API so that it can be used in different ways.
|
||||||
|
Here's a non-exhaustive list of things you can do with chessboard.js:
|
||||||
|
|
||||||
|
- Use chessboard.js to show game positions alongside your expert commentary.
|
||||||
|
- Use chessboard.js to have a tactics website where users have to guess the best
|
||||||
|
move.
|
||||||
|
- Integrate chessboard.js and [chess.js] with a PGN database and allow people to
|
||||||
|
search and playback games (see [Example 5000])
|
||||||
|
- Build a chess server and have users play their games out using the
|
||||||
|
chessboard.js board.
|
||||||
|
|
||||||
|
chessboard.js is flexible enough to handle any of these situations with relative
|
||||||
|
ease.
|
||||||
|
|
||||||
|
## What can chessboard.js **not** do?
|
||||||
|
|
||||||
|
The scope of chessboard.js is limited to "just a board." This is intentional and
|
||||||
|
makes chessboard.js flexible for handling a multitude of chess-related problems.
|
||||||
|
|
||||||
|
This is a common source of confusion for new users. [remove?]
|
||||||
|
|
||||||
|
Specifically, chessboard.js does not understand anything about how the game of
|
||||||
|
chess is played: how a knight moves, who's turn is it, is White in check?, etc.
|
||||||
|
|
||||||
|
Fortunately, the powerful [chess.js] library deals with exactly this sort of
|
||||||
|
problem domain and plays nicely with chessboard.js's flexible API. Some examples
|
||||||
|
of chessboard.js combined with chess.js: 5000, 5001, 5002
|
||||||
|
|
||||||
|
Please see the powerful [chess.js] library for an API to deal with these sorts
|
||||||
|
of questions.
|
||||||
|
|
||||||
|
|
||||||
|
This logic is distinct from the logic of the board. Please see the powerful
|
||||||
|
[chess.js] library for this aspect of your application.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Here is a list of things that chessboard.js is **not**:
|
||||||
|
|
||||||
|
- A chess engine
|
||||||
|
- A legal move validator
|
||||||
|
- A PGN parser
|
||||||
|
|
||||||
|
chessboard.js is designed to work well with any of those things, but the idea
|
||||||
|
behind chessboard.js is that the logic that controls the board should be
|
||||||
|
independent of those other problems.
|
||||||
|
|
||||||
|
## Docs and Examples
|
||||||
|
|
||||||
|
- Docs - <http://chessboardjs.com/docs>
|
||||||
|
- Examples - <http://chessboardjs.com/examples>
|
||||||
|
|
||||||
|
## Developer Tools
|
||||||
|
|
||||||
|
```sh
|
||||||
|
# create a build in the build/ directory
|
||||||
|
npm run build
|
||||||
|
|
||||||
|
# re-build the website
|
||||||
|
npm run website
|
||||||
|
```
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
[MIT License](LICENSE.md)
|
||||||
|
|
||||||
|
[jQuery]:https://jquery.com/
|
||||||
|
[chessboardjs.com]:http://chessboardjs.com
|
||||||
|
[chess.js]:https://github.com/jhlywa/chess.js
|
||||||
|
[Example 5000]:http://chessboardjs.com/examples#5000
|
@ -0,0 +1,54 @@
|
|||||||
|
/*! chessboard.js v1.0.0 | (c) 2019 Chris Oakman | MIT License chessboardjs.com/license */
|
||||||
|
|
||||||
|
.clearfix-7da63 {
|
||||||
|
clear: both;
|
||||||
|
}
|
||||||
|
|
||||||
|
.board-b72b1 {
|
||||||
|
border: 2px solid #404040;
|
||||||
|
box-sizing: content-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.square-55d63 {
|
||||||
|
float: left;
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
/* disable any native browser highlighting */
|
||||||
|
-webkit-touch-callout: none;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
-khtml-user-select: none;
|
||||||
|
-moz-user-select: none;
|
||||||
|
-ms-user-select: none;
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.white-1e1d7 {
|
||||||
|
background-color: #f0d9b5;
|
||||||
|
color: #b58863;
|
||||||
|
}
|
||||||
|
|
||||||
|
.black-3c85d {
|
||||||
|
background-color: #b58863;
|
||||||
|
color: #f0d9b5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.highlight1-32417, .highlight2-9c5d2 {
|
||||||
|
box-shadow: inset 0 0 3px 3px yellow;
|
||||||
|
}
|
||||||
|
|
||||||
|
.notation-322f9 {
|
||||||
|
cursor: default;
|
||||||
|
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
|
||||||
|
font-size: 14px;
|
||||||
|
position: absolute;
|
||||||
|
}
|
||||||
|
|
||||||
|
.alpha-d2270 {
|
||||||
|
bottom: 1px;
|
||||||
|
right: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.numeric-fc462 {
|
||||||
|
top: 2px;
|
||||||
|
left: 2px;
|
||||||
|
}
|
2
examples/chess.wasm/chessboardjs-1.0.0/css/chessboard-1.0.0.min.css
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
/*! chessboard.js v1.0.0 | (c) 2019 Chris Oakman | MIT License chessboardjs.com/license */
|
||||||
|
.clearfix-7da63{clear:both}.board-b72b1{border:2px solid #404040;box-sizing:content-box}.square-55d63{float:left;position:relative;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.white-1e1d7{background-color:#f0d9b5;color:#b58863}.black-3c85d{background-color:#b58863;color:#f0d9b5}.highlight1-32417,.highlight2-9c5d2{box-shadow:inset 0 0 3px 3px #ff0}.notation-322f9{cursor:default;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:14px;position:absolute}.alpha-d2270{bottom:1px;right:3px}.numeric-fc462{top:2px;left:2px}
|
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 2.9 KiB |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 777 B |
After Width: | Height: | Size: 2.6 KiB |
After Width: | Height: | Size: 748 B |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 2.8 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 1.1 KiB |
1817
examples/chess.wasm/chessboardjs-1.0.0/js/chessboard-1.0.0.js
Normal file
2
examples/chess.wasm/chessboardjs-1.0.0/js/chessboard-1.0.0.min.js
vendored
Normal file
29
examples/chess.wasm/chessboardjs-1.0.0/package.json
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
"author": "Chris Oakman <chris@oakmac.com> (http://chrisoakman.com/)",
|
||||||
|
"name": "@chrisoakman/chessboardjs",
|
||||||
|
"description": "JavaScript chessboard widget",
|
||||||
|
"homepage": "https://chessboardjs.com",
|
||||||
|
"license": "MIT",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git://github.com/oakmac/chessboardjs.git"
|
||||||
|
},
|
||||||
|
"files": ["dist/"],
|
||||||
|
"dependencies": {
|
||||||
|
"jquery": ">=3.4.1"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"csso": "3.5.1",
|
||||||
|
"fs-plus": "3.1.1",
|
||||||
|
"kidif": "1.1.0",
|
||||||
|
"mustache": "2.3.0",
|
||||||
|
"standard": "10.0.2",
|
||||||
|
"uglify-js": "3.6.0"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"build": "standard lib/chessboard.js && node scripts/build.js",
|
||||||
|
"standard": "standard --fix lib/*.js website/js/*.js",
|
||||||
|
"website": "node scripts/website.js"
|
||||||
|
}
|
||||||
|
}
|
@ -24,6 +24,7 @@
|
|||||||
overflow-x: scroll;
|
overflow-x: scroll;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
<link rel="stylesheet" href="css/chessboard-1.0.0.min.css" integrity="sha384-q94+BZtLrkL1/ohfjR8c6L+A6qzNH9R2hBLwyoAfu3i/WCvQjzL2RQJ3uNHDISdU" crossorigin="anonymous">
|
||||||
</head>
|
</head>
|
||||||
<body onload="loadWhisper()">
|
<body onload="loadWhisper()">
|
||||||
<div id="main-container">
|
<div id="main-container">
|
||||||
@ -71,6 +72,14 @@
|
|||||||
<pre id="state-transcribed">[The recognized voice commands will be displayed here]</pre>
|
<pre id="state-transcribed">[The recognized voice commands will be displayed here]</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<br><br>
|
||||||
|
<div id="myBoard" style="width: 400px"></div>
|
||||||
|
<script src="js/jquery-3.7.1.min.js"></script>
|
||||||
|
<script src="js/chessboard-1.0.0.min.js"></script>
|
||||||
|
<script>
|
||||||
|
var board = Chessboard('myBoard', 'start')
|
||||||
|
</script>
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
Debug output:
|
Debug output:
|
||||||
@ -101,7 +110,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script type="text/javascript" src="helpers.js"></script>
|
<script type="text/javascript" src="js/helpers.js"></script>
|
||||||
<script type='text/javascript'>
|
<script type='text/javascript'>
|
||||||
// web audio context
|
// web audio context
|
||||||
var context = null;
|
var context = null;
|
||||||
@ -363,6 +372,20 @@
|
|||||||
var transcribed = Module.get_transcribed();
|
var transcribed = Module.get_transcribed();
|
||||||
|
|
||||||
if (transcribed != null && transcribed.length > 1) {
|
if (transcribed != null && transcribed.length > 1) {
|
||||||
|
const map = {
|
||||||
|
queen: 'wQ',
|
||||||
|
king: 'wK',
|
||||||
|
bishop: 'wB',
|
||||||
|
rook: 'wR',
|
||||||
|
knight: 'wN',
|
||||||
|
pawn: 'wP'
|
||||||
|
};
|
||||||
|
let [piece, _, pos] = transcribed.split(' ')
|
||||||
|
pos = pos.replace(',', '').replace('.', '')
|
||||||
|
|
||||||
|
board.position({[pos]: map[piece]})
|
||||||
|
|
||||||
|
|
||||||
transcribedAll += transcribed + '<br>';
|
transcribedAll += transcribed + '<br>';
|
||||||
nLines++;
|
nLines++;
|
||||||
|
|
||||||
@ -386,6 +409,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
<script type="text/javascript" src="chess.js"></script>
|
<script type="text/javascript" src="js/chess.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|