Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SVG chess set graphics. Making Garbochess resolution aware and offline installable. #24

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@

* Substantial Garbochess-JS parts are BSD 3-Clause licensed
* Thirdparty code of JQuery and JQuery-UI follow the MIT license
* corresponding license texts can be reproduced from Thirdparty directory

---

Copyright (c) 2011 Gary Linscott
All rights reserved.

Expand All @@ -21,4 +28,4 @@ NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
16 changes: 14 additions & 2 deletions README → README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
<img alt="Garbochess icon" width="64" src="oliver/img/icons/garbochess128.png" /> Garbochess-JS
=============

* <em>Start an online</em> <b>Garbochess-JS</b> <em>session on</em> http://omerkel.github.io/Garbochess-JS/oliver
* <em>Android APK available for install</em> <img align="top" width="32" src="oliver/res/android.gif" /> https://github.com/OMerkel/Garbochess-JS/releases/tag/release_6.0.1
* requires minimum Android 4.4.2 (API-19)
* <em>runs in various browsers on</em>
* <em>desktop systems like BSDs, Linux, Win, MacOS and</em>
* <em>mobile platforms like Android, FirefoxOS, iOS.</em>

<b>Keywords</b> <em>Chess, Schach, Ajedrez, Computer Chess, ECMA script, <a href="http://www.w3.org/TR/workers/">Web workers</a>, CC0: <a href="http://www.w3.org/Graphics/SVG/">Scalable Vector Graphics (SVG)</a> chess set, Safari Apple-mobile-web-app support</em>

Thanks
------
- Stockfish authors
Expand Down Expand Up @@ -55,7 +67,7 @@ Version 6.0
- Bonuses for knight attacking pieces (+20)
- Bonus for bishop pins (+40)

TODO:
-----
TODO
----
- Only extend checks with SEE > 0?
- Single reply to check should be marked as dangerous.
93 changes: 34 additions & 59 deletions chess.html
Original file line number Diff line number Diff line change
@@ -1,66 +1,41 @@
<!-- saved from url=(0014)about:internet -->
<html>
<head>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta charset="UTF-8" />
<title>GarboChess Javascript</title>
<script type="text/javascript" src="js/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.24.custom.min.js"></script>
<script type="text/javascript" src="thirdparty/jquery-2.2.4.js"></script>
<script type="text/javascript" src="thirdparty/jquery-ui-1.11.4/jquery-ui.js"></script>
<script type="text/javascript" src="js/garbochess.js"></script>
<script type="text/javascript" src="js/boardui.js"></script>
<script type="text/javascript">
$(document).ready(function () {
g_timeout = 1000;
UINewGame();
});
<script type="text/javascript" src="js/boardui.js"></script>
<script type="text/javascript">
$(document).ready(function () {
g_timeout = 3000;
UINewGame();
});
</script>
<style type="text/css">
#FenTextBox {
width: 400px;
}
#TimePerMove {
width: 50px;
}
.no-highlight {
-webkit-tap-highlight-color: rgba(0,0,0,0);
}
.sprite-bishop_black{ background-position: 0 0; width: 45px; height: 45px; }
.sprite-bishop_white{ background-position: 0 -95px; width: 45px; height: 45px; }
.sprite-king_black{ background-position: 0 -190px; width: 45px; height: 45px; }
.sprite-king_white{ background-position: 0 -285px; width: 45px; height: 45px; }
.sprite-knight_black{ background-position: 0 -380px; width: 45px; height: 45px; }
.sprite-knight_white{ background-position: 0 -475px; width: 45px; height: 45px; }
.sprite-pawn_black{ background-position: 0 -570px; width: 45px; height: 45px; }
.sprite-pawn_white{ background-position: 0 -665px; width: 45px; height: 45px; }
.sprite-queen_black{ background-position: 0 -760px; width: 45px; height: 45px; }
.sprite-queen_white{ background-position: 0 -855px; width: 45px; height: 45px; }
.sprite-rook_black{ background-position: 0 -950px; width: 45px; height: 45px; }
.sprite-rook_white{ background-position: 0 -1045px; width: 45px; height: 45px; }
</style>
</head>
<body>
<link rel='stylesheet' type='text/css' href='css/chess.css' />
</head>
<body>
<div align="center">
<div>
<a href="javascript:UINewGame()">New game</a>
<select onchange="javascript:UIChangeStartPlayer()">
<option value="white">White</option>
<option value="black">Black</option>
</select>
Time per move: <input id="TimePerMove" value="3000" onchange="javascript:UIChangeTimePerMove()" />ms
<a href="javascript:UIUndoMove()">Undo</a>
</div>
<div style="margin-top:5px;">
<div id='board'></div>
<span id='output'></span><br/>
<textarea cols='50' rows='6' id='PgnTextBox'></textarea><br/>
<div>
<a href="javascript:UINewGame()">New game</a>
<select onchange="javascript:UIChangeStartPlayer()">
<option value="white">White</option>
<option value="black">Black</option>
</select>
Time per move: <input id="TimePerMove" value="3000" onchange="javascript:UIChangeTimePerMove()" />ms
<a href="javascript:UIUndoMove()">Undo</a>
</div>
<div style="margin-top:5px;">
<div id='board'></div>
<span id='output'></span><br/>
<textarea cols='50' rows='6' id='PgnTextBox'></textarea><br/>
<div>
<a id='AnalysisToggleLink' href="javascript:UIAnalyzeToggle()">Analysis: Off</a>
<a id='AnalysisToggleLink' href="javascript:UIAnalyzeToggle()">Analysis: Off</a>
</div>
FEN: <input id='FenTextBox' onchange="javascript:UIChangeFEN()"/>
</div>
<div>
<h2>About</h2>
<p>It started as a feasibility project to see how Javascript could do in Chess, then languished until Chrome came along.</p>
<a href="..\projects.html">Back to Projects</a>
</div>
</div>
</body>
</html>
</div>
</div>
</body>
</html>
23 changes: 23 additions & 0 deletions css/chess.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.disable-select {
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}

#FenTextBox {
width: 300px;
}

#TimePerMove {
width: 50px;
}

a {
text-decoration:none;
color:#000;
}

.no-highlight {
-webkit-tap-highlight-color: rgba(0,0,0,0);
}
6 changes: 4 additions & 2 deletions debug.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<!-- saved from url=(0014)about:internet -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta charset="UTF-8" />
<title>Test harness</title>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.7.2.custom.min.js"></script>
<script type="text/javascript" src="thirdparty/jquery-2.2.4.js"></script>
<script type="text/javascript" src="thirdparty/jquery-ui-1.11.4/jquery-ui.js"></script>
<script type="text/javascript" src="js/garbochess.js"></script>
<script type="text/javascript" src="tests/openings.js"></script>
<script type="text/javascript" src="tests/perft-positions.js"></script>
Expand Down
49 changes: 32 additions & 17 deletions js/boardui.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ var g_changingFen = false;
var g_analyzing = false;

var g_uiBoard;
var g_cellSize = 45;
var g_cellSize = 36,
g_minCellSize = g_cellSize;

function UINewGame() {
moveNumber = 1;
Expand Down Expand Up @@ -237,15 +238,16 @@ function RedrawPieces() {
pieceName += (piece & 0x8) ? "white" : "black";
}

var img = document.createElement("img");
img.width = g_cellSize;
img.height = g_cellSize;
img.style.margin = "0px";
img.style.padding = "0px";
var divimg = document.createElement("div");
divimg.style.maxWidth = g_cellSize + "px";
divimg.style.maxHeight = g_cellSize + "px";
if (pieceName != null) {
var img = document.createElement("div");
$(img).addClass('sprite-' + pieceName);
img.style.backgroundImage = "url('img/sprites.png')";
img.width = g_cellSize;
img.height = g_cellSize;
var divimg = document.createElement("div");
divimg.appendChild(img);

img.src = "img/" + pieceName + ".png"
$(divimg).draggable({ start: function (e, ui) {
if (g_selectedPiece === null) {
g_selectedPiece = this;
Expand Down Expand Up @@ -274,22 +276,22 @@ function RedrawPieces() {
g_selectedPiece = null;
}
});

$(td).empty().append(divimg);
} else {
$(td).empty();
img.src = "img/blank.gif"
}
divimg.appendChild(img);
$(td).empty().append(divimg);
}
}
}

function RedrawBoard() {
var div = $("#board")[0];

var table = document.createElement("table");
table.cellPadding = "0px";
table.cellSpacing = "0px";
$(table).addClass('no-highlight');
$(table).addClass('disable-select');

var tbody = document.createElement("tbody");

Expand Down Expand Up @@ -383,9 +385,22 @@ function RedrawBoard() {
RedrawPieces();

$(div).empty();
div.appendChild(table);
if ( typeof div !== 'undefined' ) {
div.appendChild(table);
g_changingFen = true;
document.getElementById("FenTextBox").value = GetFen();
g_changingFen = false;
}
}

g_changingFen = true;
document.getElementById("FenTextBox").value = GetFen();
g_changingFen = false;
function ResizeBoard() {
var innerWidth = window.innerWidth,
innerHeight = window.innerHeight;
g_cellSize = innerHeight > innerWidth ? innerWidth * 9 / 80 :
innerHeight * 9 / 90;
g_cellSize = g_cellSize < g_minCellSize ? g_minCellSize : g_cellSize;
RedrawBoard();
}

$(window).on('resize', ResizeBoard);
$(window).resize();
2 changes: 0 additions & 2 deletions js/jquery-1.8.2.min.js

This file was deleted.

Loading