improve board editor
parent
e40f930ab4
commit
553acd367a
|
@ -7,9 +7,9 @@ object Editor extends LilaController with BaseGame {
|
|||
|
||||
private def env = Env.importer
|
||||
|
||||
def index = Open { implicit ctx ⇒
|
||||
def index(fen: String) = Open { implicit ctx ⇒
|
||||
makeListMenu map { listMenu ⇒
|
||||
Ok(html.game.editor(listMenu))
|
||||
Ok(html.game.editor(listMenu, fen.trim.some.filter(_.nonEmpty)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
@(listMenu: lila.game.ListMenu)(implicit ctx: Context)
|
||||
@(listMenu: lila.game.ListMenu, fen: Option[String])(implicit ctx: Context)
|
||||
|
||||
@moreCss = {
|
||||
@cssVendorTag("chessboard/css/chessboard-0.1.0.css")
|
||||
|
@ -24,13 +24,13 @@ moreCss = moreCss) {
|
|||
</p>
|
||||
<p>
|
||||
<a class="button flip">@trans.flipBoard()</a>
|
||||
<a class="button fen_link save" href="@routes.Editor.index()?fen=#">@trans.savePosition()</a>
|
||||
<a class="button save" data-domain="@netBaseUrl">@trans.savePosition()</a>
|
||||
</p>
|
||||
<p>
|
||||
<a class="fen_link button big" href="@routes.Lobby.home()?fen=#ai">@trans.playWithTheMachine()</a>
|
||||
<a class="fen_link button big" href="@routes.Lobby.home()?fen=#friend">@trans.playWithAFriend()</a>
|
||||
</p>
|
||||
</div>
|
||||
<div id="chessboard"></div>
|
||||
<div id="chessboard" data-fen="@fen"></div>
|
||||
</div>
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
<a class="@active.active("import")" href="@routes.Importer.importGame()">
|
||||
@trans.importGame()
|
||||
</a>
|
||||
<a class="@active.active("edit")" href="@routes.Editor.index()">
|
||||
<a class="@active.active("edit")" href="@routes.Editor.index("")">
|
||||
@trans.boardEditor()
|
||||
</a>
|
||||
<a class="@active.active("all")" href="@routes.Game.all()">
|
||||
|
|
|
@ -177,7 +177,8 @@ GET /paste controllers.Importer.importGame
|
|||
POST /paste controllers.Importer.sendGame
|
||||
|
||||
# Edit
|
||||
GET /edit controllers.Editor.index
|
||||
GET /editor controllers.Editor.index(fen: String = "")
|
||||
GET /editor/*fen controllers.Editor.index(fen: String)
|
||||
|
||||
# Monitor
|
||||
GET /monitor controllers.Monitor.index
|
||||
|
|
|
@ -12,9 +12,9 @@ $(function() {
|
|||
}
|
||||
|
||||
var board = new ChessBoard('chessboard', {
|
||||
position: $('#chessboard').data('fen') || 'start',
|
||||
draggable: true,
|
||||
dropOffBoard: 'trash',
|
||||
position: 'start',
|
||||
sparePieces: true,
|
||||
pieceTheme: '/assets/vendor/chessboard/img/chesspieces/wikipedia/{piece}.png',
|
||||
onChange: function(oldPos, newPos) {
|
||||
|
@ -26,5 +26,9 @@ $(function() {
|
|||
$wrap.find('a.start').on('click', board.start);
|
||||
$wrap.find('a.clear').on('click', board.clear);
|
||||
$wrap.find('a.flip').on('click', board.flip);
|
||||
$wrap.find('a.save').on('click', function() {
|
||||
alert('Permalink: ' + $(this).data('domain') + '/edit/' + fen);
|
||||
return false;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
position: relative;
|
||||
}
|
||||
#chessboard {
|
||||
margin-top: 20px;
|
||||
width: 392px;
|
||||
}
|
||||
#chessboard_side {
|
||||
|
|
Loading…
Reference in New Issue