The Markup
[sourcecode language=”html”]
<acidjs-xticatactoe x="Martin" o="James"></acidjs-xticatactoe>
<acidjs-xticatactoe debug="true" size="large"></acidjs-xticatactoe>
<acidjs-xticatactoe size="small"></acidjs-xticatactoe>
<acidjs-xticatactoe debug="true">
<code hidden>
{
"yourTurn": "du bist dran!",
"startNewGame": "Neues Spiel starten",
"start": "Start!",
"playerXName": "Spieler X Name",
"playerOName": "Spieler O Name",
"choosePlayerXName": "Wählen Sie Name für Spieler X",
"choosePlayerOName": "Wählen Sie Name für Spieler O",
"youWin": "Sie gewinnen!",
"draw": "Unentschieden :("
}
</code>
</acidjs-xticatactoe>
[/sourcecode]
HTML Attributes
Apart from the standard HTML attributes (style
, class
, id
, etc.), the tag also supports the following component-specific attributes:
x
– Optional name for the “x” player. Default: "Tic"
.o
– Optional name for the “o” player. Default: "Tac"
.debug
– Optional. If set to true
, the component will output console messages. Default Default: "false"
.size
– Optional size of the board. Default: "medium"
. Other possible values are "small"
and "large"
.JavaScript API
All standard JavaScript methods are supported, plus the component-specific:
init()
– Initialize the game.restart()
– Restart the game (an alias of the init()
method).destroy()
– Destroy the game and remove the board.Events
The component publishes the following custom events, returning event and game-specific data. The distribution, which could be downloaded from this link contains these event bindings, so you can use your browser’s console to see what data is returned upon firing those events.
ttt:ready
– Fired when game is ready to play.ttt:win
– Fired when game is a win.ttt:draw
– Fired when game is a draw.ttt:playing
– Fired upon user action.Enjoy the weekend! If you share the same interest towards HTML5 Web Components as I do these days, make sure you read my relevant blog posts and further endeavors on my HTML5, CSS3 and JavaScript Experiments and Insight website.
© 2006 - 2023 Martin Ivanov