Life is like a hamburger on our gas station - never know what you gonna get.
If you have any suggestions, comments or you spotted some error (bug, broken link, grammatical error), please drop me a note:
The viewer consists of 3 elements:
You can download them separately or in in one all in one pack.
The viewer files ca be also seen on ShogiTools pages (http://code.google.com/p/shogitools/source/browse/#svn/trunk/jsfenparser)
Making the script work on your page is fairly simple. The procedure boils down to:
First we include the script on your page, by placing the following in the <HEAD> section:
Next, we put <DIV> HTML tag where we want the board(s) to be inserted.
Important thing to remember is the id attribute. We will later use it's value to tell the script to generate the diagram for us.
Please note, that you could customize the viewer's behavior by supplying the constructor with init parameters. For clarity, I leave it for later and describe it in "Customization" section.
Now, we are almost there. The only thing to do is to "feed" the viewer with proper Shogi position. But how to do this?
Besides, JSON is quite popular data exchange format, so there could be converters (i.e. from Shogi FEN or others) easily plugged in to the viewer.
The good thing about JSON is that it's very self-descriptive format. Here is how I designed the format.
The description consists of 4 elements:
and could be expressed as JSON like this:
Side on move is simple: it can be either "black" or white".
Pieces in hand data
is an array of numbers. Each number represent the count of pieces for a
given rank. The rank is indicated by position in the array. Pieces info
is stored in a given order:
So, for a Silver and 2 Pawns in hand the data would look like this:
I am not particularly happy with the format. I don't like the fact that a human has to remember position of piece ranks in the array. The format could be therefore change in the matter.
[[Maybe better would be to have pairs rank:count?]]
Pieces on board are given by field:rank pairs. A field is described by 2 chars: column number and row char in the standard Shogi coordinate system. Leftmost column is named '9', rightmost is '1'. Uppermost row is 'a', lowermost is 'i'.
A piece symbol is "borrowed" from Shogi Ladder notation (http://www.shogi.net/ladder/shogiboard.html). The
'w' and 'b' in front of the piece symbol's abbreviations indicate white
and black respectively. When a piece is promoted, it will be given with
a preceding "+", as in "+bL" or "+wP".
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
One important thing to note. If you are using Internet Explorer 7 or 8, before including ShogiBoardViewer.js, you have to include js_fixes.js:
TBD (for now, see the example: http://shogitools.appspot.com/html/shogiview.html).
20080701 -- created the page
20080703 -- added js "patch" for IE7/8
20080917 -- fixed bugs reported by Bernhard Maerz
20081214 -- placeholder element's id is now a constructor parameter.
20090609 -- changes in ShogiBoard. Fields are direct attributes of 'pieces' field (not an array of objects anymore)