Skip to content

Commit

Permalink
learning happened, rewritten to Ecmascript 6
Browse files Browse the repository at this point in the history
  • Loading branch information
laat committed Mar 20, 2014
1 parent 0d0b825 commit 4b0073c
Show file tree
Hide file tree
Showing 15 changed files with 1,098 additions and 321 deletions.
8 changes: 5 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# This file is for unifying the coding style for different editors and IDEs
# editorconfig.org

root = true

[*]
indent_style = space
indent_size = 4
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
0.0.3 / 2014-03-20
==================
* Rewrite to Ecmascript 6, because learning.
* fixed an issue with reversing position
* resetBoard renamed to clearBoard
* applyFen removed in favour of setter

0.0.2 / 2014-03-06
==================
Expand Down
15 changes: 0 additions & 15 deletions Gruntfile.js

This file was deleted.

55 changes: 22 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ A web component for displaying chess positions.
1. Import Web Components' polyfill:

```html
<script src="//cdnjs.cloudflare.com/ajax/libs/polymer/0.1.4/platform.js"></script>
<script src="/bower_components/polymer-platform/platform.js"></script>
```

1. Traceur Runtime: (Ecmascript 6)

```html
<script src="/bower_components/traceur-runtime/traceur-runtime.js"></script>
```

2. Import Custom Element:
Expand All @@ -28,35 +34,12 @@ A web component for displaying chess positions.
<chess-board>rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1</chess-board>
```

## Setup

In order to run it locally you'll need a basic server setup.

1. Install [NodeJS](http://nodejs.org/download/).
2. Install [GruntJS](http://gruntjs.com/):

```sh
$ [sudo] npm install -g grunt-cli
```

3. Install local dependencies:

```sh
$ npm install
```

4. Run a local server and open `http://localhost:8000`.

```sh
$ grunt connect
```

## Options

Attribute | Description
--- | ---
`unicode` | Display chess pices with unicode characters.
`framed` | Display file and rank arround the chessboard
`frame` | Display file and rank arround the chessboard
`reverse` | Display the chessboard with black pieces at the bottom.

## Methods
Expand Down Expand Up @@ -99,17 +82,26 @@ q // ♛ black queen
k // ♚ black king
```

### resetBoard()
### clearBoard()

```js
var board = new ChessBoard();
board.resetBoard();
board.clearBoard();
```

### applyFEN()
### setting board position
```js
var board = new ChessBoard();
board.applyFEN("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR");
board.fen = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR";
```

### getting board position
```js
var board = new ChessBoard();
board.fen = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR";
board.move("a2", "a3");

var currentFen = board.fen;
```

## Contributing
Expand All @@ -129,7 +121,4 @@ For detailed changelog, check [Releases](https://github.com/laat/chess-board/rel
[MIT License](http://opensource.org/licenses/MIT)

### Notes / Rambeling

Wanting to learn how Web Components work, I started out creating this component with only the platform polyfill from [polymer](http://polymer-project.org). However, after a while I have come to realize that I really want to use a framework like [polymer](http://polymer-project.org) or [x-tags](http://x-tags.org) because they seem to add an useful abstraction on top of the web standard.

It has been a very fun, which has obviously lead to quite a bit of over engineering. I hope to be able to add a few more features in the future, like context menu, drag and drop, and another component that uses this one for viewing PGN games.
Web Components are FUN! I hope to be able to add a few more features in the future, like context menu, drag and drop, and animation.
18 changes: 15 additions & 3 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
{
"name": "chess-board",
"version": "0.0.2",
"version": "0.0.3",
"homepage": "https://github.com/laat/chess-board",
"authors": [
"Sigurd Fosseng <[email protected]>"
],
"description": "A Web Component for displaying chess positions",
"main": "src/chess-board.html",
"license": "MIT",
"main": "dist/chess-board.html",
"keywords": [
"web-components",
"es6",
"chess"
],
"license": "MIT"
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"dependencies": {
"polymer-platform": "~0.2.1",
"traceur-runtime": "~0.0.24"
}
}
Loading

0 comments on commit 4b0073c

Please sign in to comment.