board editor wip
This commit is contained in:
parent
29d016ec77
commit
d7c9730df1
|
@ -1,11 +1,12 @@
|
|||
@(listMenu: lila.game.ListMenu)(implicit ctx: Context)
|
||||
|
||||
@moreCss = {
|
||||
@cssVendorTag("chessboardjs/css/chessboardjs-0.1.0.min.css")
|
||||
@cssVendorTag("chessboard/css/chessboard-0.1.0.css")
|
||||
@cssTag("boardEditor.css")
|
||||
}
|
||||
@moreJs = {
|
||||
@jsVendorTag("chessboard/js/chessboard-0.1.0.js")
|
||||
@jsTag("boardEditor.js")
|
||||
@jsVendorTag("chessboardjs/js/chessboardjs-0.1.0.min.js")
|
||||
}
|
||||
|
||||
@game.layout(
|
||||
|
@ -14,7 +15,22 @@ menu = game.sideMenu(listMenu, "edit").some,
|
|||
moreJs = moreJs,
|
||||
moreCss = moreCss) {
|
||||
<div id="board_editor" class="content_box">
|
||||
<h1 class="title">@trans.boardEditor</h1>
|
||||
<div id="board"></div>
|
||||
<h1 class="title">@trans.boardEditor()</h1>
|
||||
<div id="chessboard_side">
|
||||
<p class="fen_string"></p>
|
||||
<p>
|
||||
<a class="button start">@trans.startPosition()</a>
|
||||
<a class="button clear">@trans.clearBoard()</a>
|
||||
</p>
|
||||
<p>
|
||||
<a class="button flip">@trans.flipBoard()</a>
|
||||
<a class="button fen_link save" href="@routes.Editor.index()?fen=#">@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>
|
||||
}
|
||||
|
|
|
@ -241,3 +241,6 @@ tournamentIsStarting=Tournament is starting
|
|||
nbMinutesPerSidePlusNbSecondsPerMove=%s minutes/side + %s seconds/move
|
||||
anonymousCanJoin=Anonymous can join
|
||||
boardEditor=Board editor
|
||||
startPosition=Start position
|
||||
clearBoard=Clear board
|
||||
savePosition=Save position
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 8575c75138c073fe88e3ef3fe518926bf0374cbe
|
||||
Subproject commit 4b05b5482edc18ac272930699a7b3313ee3fbfe7
|
|
@ -265,6 +265,9 @@ final class I18nKeys(translator: Translator) {
|
|||
val nbMinutesPerSidePlusNbSecondsPerMove = new Key("nbMinutesPerSidePlusNbSecondsPerMove")
|
||||
val anonymousCanJoin = new Key("anonymousCanJoin")
|
||||
val boardEditor = new Key("boardEditor")
|
||||
val startPosition = new Key("startPosition")
|
||||
val clearBoard = new Key("clearBoard")
|
||||
val savePosition = new Key("savePosition")
|
||||
|
||||
def keys = List(playWithAFriend, inviteAFriendToPlayWithYou, playWithTheMachine, challengeTheArtificialIntelligence, toInviteSomeoneToPlayGiveThisUrl, gameOver, waitingForOpponent, waiting, yourTurn, aiNameLevelAiLevel, level, toggleTheChat, toggleSound, chat, resign, checkmate, stalemate, white, black, createAGame, noGameAvailableRightNowCreateOne, whiteIsVictorious, blackIsVictorious, playWithTheSameOpponentAgain, newOpponent, playWithAnotherOpponent, yourOpponentWantsToPlayANewGameWithYou, joinTheGame, whitePlays, blackPlays, theOtherPlayerHasLeftTheGameYouCanForceResignationOrWaitForHim, makeYourOpponentResign, forceResignation, talkInChat, theFirstPersonToComeOnThisUrlWillPlayWithYou, whiteCreatesTheGame, blackCreatesTheGame, whiteJoinsTheGame, blackJoinsTheGame, whiteResigned, blackResigned, whiteLeftTheGame, blackLeftTheGame, shareThisUrlToLetSpectatorsSeeTheGame, youAreViewingThisGameAsASpectator, replayAndAnalyse, computerAnalysisInProgress, theComputerAnalysisYouRequestedIsNowAvailable, theComputerAnalysisHasFailed, viewTheComputerAnalysis, requestAComputerAnalysis, blunders, mistakes, inaccuracies, viewGameStats, flipBoard, threefoldRepetition, claimADraw, offerDraw, draw, nbConnectedPlayers, talkAboutChessAndDiscussLichessFeaturesInTheForum, seeTheGamesBeingPlayedInRealTime, gamesBeingPlayedRightNow, viewAllNbGames, viewNbCheckmates, nbBookmarks, nbPopularGames, nbAnalysedGames, bookmarkedByNbPlayers, viewInFullSize, logOut, signIn, newToLichess, youNeedAnAccountToDoThat, signUp, people, games, forum, xPostedInForumY, chessPlayers, minutesPerSide, variant, timeControl, time, start, username, password, haveAnAccount, allYouNeedIsAUsernameAndAPassword, learnMoreAboutLichess, rank, gamesPlayed, nbGamesWithYou, declineInvitation, cancel, timeOut, drawOfferSent, drawOfferDeclined, drawOfferAccepted, drawOfferCanceled, yourOpponentOffersADraw, accept, decline, playingRightNow, finished, abortGame, gameAborted, standard, unlimited, mode, casual, rated, thisGameIsRated, rematch, rematchOfferSent, rematchOfferAccepted, rematchOfferCanceled, rematchOfferDeclined, cancelRematchOffer, viewRematch, play, inbox, chatRoom, spectatorRoom, composeMessage, sentMessages, noNewMessages, subject, recipient, send, incrementInSeconds, freeOnlineChess, spectators, nbWins, nbLosses, nbDraws, exportGames, color, eloRange, giveNbSeconds, whoIsOnline, allPlayers, premoveEnabledClickAnywhereToCancel, thisPlayerUsesChessComputerAssistance, opening, takeback, proposeATakeback, takebackPropositionSent, takebackPropositionDeclined, takebackPropositionAccepted, takebackPropositionCanceled, yourOpponentProposesATakeback, bookmarkThisGame, toggleBackground, search, advancedSearch, tournament, tournaments, tournamentPoints, viewTournament, freeOnlineChessGamePlayChessNowInACleanInterfaceNoRegistrationNoAdsNoPluginRequiredPlayChessWithComputerFriendsOrRandomOpponents, teams, nbMembers, allTeams, newTeam, myTeams, noTeamFound, joinTeam, quitTeam, anyoneCanJoin, aConfirmationIsRequiredToJoin, joiningPolicy, teamLeader, teamBestPlayers, teamRecentMembers, xJoinedTeamY, xCreatedTeamY, averageElo, location, settings, filterGames, reset, apply, leaderboard, pasteTheFenStringHere, pasteThePgnStringHere, fromPosition, continueFromHere, importGame, nbImportedGames, thisIsAChessCaptcha, clickOnTheBoardToMakeYourMove, notACheckmate, colorPlaysCheckmateInOne, retry, reconnecting, onlineFriends, noFriendsOnline, findFriends, favoriteOpponents, follow, following, unfollow, block, blocked, unblock, followsYou, xStartedFollowingY, nbFollowers, nbFollowing, profile, more, memberSince, lastLogin, challengeToPlay, player, list, graph, all, lessThanNbMinutes, xToYMinutes, textIsTooShort, textIsTooLong, required, addToChrome, openTournaments, duration, winner, standing, createANewTournament, join, withdraw, points, wins, losses, winStreak, createdBy, waitingForNbPlayers, tournamentIsStarting, nbMinutesPerSidePlusNbSecondsPerMove, anonymousCanJoin, boardEditor)
|
||||
def keys = List(playWithAFriend, inviteAFriendToPlayWithYou, playWithTheMachine, challengeTheArtificialIntelligence, toInviteSomeoneToPlayGiveThisUrl, gameOver, waitingForOpponent, waiting, yourTurn, aiNameLevelAiLevel, level, toggleTheChat, toggleSound, chat, resign, checkmate, stalemate, white, black, createAGame, noGameAvailableRightNowCreateOne, whiteIsVictorious, blackIsVictorious, playWithTheSameOpponentAgain, newOpponent, playWithAnotherOpponent, yourOpponentWantsToPlayANewGameWithYou, joinTheGame, whitePlays, blackPlays, theOtherPlayerHasLeftTheGameYouCanForceResignationOrWaitForHim, makeYourOpponentResign, forceResignation, talkInChat, theFirstPersonToComeOnThisUrlWillPlayWithYou, whiteCreatesTheGame, blackCreatesTheGame, whiteJoinsTheGame, blackJoinsTheGame, whiteResigned, blackResigned, whiteLeftTheGame, blackLeftTheGame, shareThisUrlToLetSpectatorsSeeTheGame, youAreViewingThisGameAsASpectator, replayAndAnalyse, computerAnalysisInProgress, theComputerAnalysisYouRequestedIsNowAvailable, theComputerAnalysisHasFailed, viewTheComputerAnalysis, requestAComputerAnalysis, blunders, mistakes, inaccuracies, viewGameStats, flipBoard, threefoldRepetition, claimADraw, offerDraw, draw, nbConnectedPlayers, talkAboutChessAndDiscussLichessFeaturesInTheForum, seeTheGamesBeingPlayedInRealTime, gamesBeingPlayedRightNow, viewAllNbGames, viewNbCheckmates, nbBookmarks, nbPopularGames, nbAnalysedGames, bookmarkedByNbPlayers, viewInFullSize, logOut, signIn, newToLichess, youNeedAnAccountToDoThat, signUp, people, games, forum, xPostedInForumY, chessPlayers, minutesPerSide, variant, timeControl, time, start, username, password, haveAnAccount, allYouNeedIsAUsernameAndAPassword, learnMoreAboutLichess, rank, gamesPlayed, nbGamesWithYou, declineInvitation, cancel, timeOut, drawOfferSent, drawOfferDeclined, drawOfferAccepted, drawOfferCanceled, yourOpponentOffersADraw, accept, decline, playingRightNow, finished, abortGame, gameAborted, standard, unlimited, mode, casual, rated, thisGameIsRated, rematch, rematchOfferSent, rematchOfferAccepted, rematchOfferCanceled, rematchOfferDeclined, cancelRematchOffer, viewRematch, play, inbox, chatRoom, spectatorRoom, composeMessage, sentMessages, noNewMessages, subject, recipient, send, incrementInSeconds, freeOnlineChess, spectators, nbWins, nbLosses, nbDraws, exportGames, color, eloRange, giveNbSeconds, whoIsOnline, allPlayers, premoveEnabledClickAnywhereToCancel, thisPlayerUsesChessComputerAssistance, opening, takeback, proposeATakeback, takebackPropositionSent, takebackPropositionDeclined, takebackPropositionAccepted, takebackPropositionCanceled, yourOpponentProposesATakeback, bookmarkThisGame, toggleBackground, search, advancedSearch, tournament, tournaments, tournamentPoints, viewTournament, freeOnlineChessGamePlayChessNowInACleanInterfaceNoRegistrationNoAdsNoPluginRequiredPlayChessWithComputerFriendsOrRandomOpponents, teams, nbMembers, allTeams, newTeam, myTeams, noTeamFound, joinTeam, quitTeam, anyoneCanJoin, aConfirmationIsRequiredToJoin, joiningPolicy, teamLeader, teamBestPlayers, teamRecentMembers, xJoinedTeamY, xCreatedTeamY, averageElo, location, settings, filterGames, reset, apply, leaderboard, pasteTheFenStringHere, pasteThePgnStringHere, fromPosition, continueFromHere, importGame, nbImportedGames, thisIsAChessCaptcha, clickOnTheBoardToMakeYourMove, notACheckmate, colorPlaysCheckmateInOne, retry, reconnecting, onlineFriends, noFriendsOnline, findFriends, favoriteOpponents, follow, following, unfollow, block, blocked, unblock, followsYou, xStartedFollowingY, nbFollowers, nbFollowing, profile, more, memberSince, lastLogin, challengeToPlay, player, list, graph, all, lessThanNbMinutes, xToYMinutes, textIsTooShort, textIsTooLong, required, addToChrome, openTournaments, duration, winner, standing, createANewTournament, join, withdraw, points, wins, losses, winStreak, createdBy, waitingForNbPlayers, tournamentIsStarting, nbMinutesPerSidePlusNbSecondsPerMove, anonymousCanJoin, boardEditor, startPosition, clearBoard, savePosition)
|
||||
}
|
||||
|
|
|
@ -1,8 +1,30 @@
|
|||
$(function() {
|
||||
var board = new ChessBoard('board', {
|
||||
$('#board_editor').each(function() {
|
||||
var $wrap = $(this);
|
||||
var fen = "";
|
||||
|
||||
function setFen(f) {
|
||||
fen = f;
|
||||
$wrap.find('.fen_string').text(fen);
|
||||
$wrap.find('a.fen_link').each(function() {
|
||||
$(this).attr('href', $(this).attr('href').replace(/fen=[^#]*#/, "fen=" + fen + '#'));
|
||||
});
|
||||
}
|
||||
|
||||
var board = new ChessBoard('chessboard', {
|
||||
draggable: true,
|
||||
dropOffBoard: 'trash',
|
||||
position: 'start',
|
||||
sparePieces: true
|
||||
sparePieces: true,
|
||||
pieceTheme: '/assets/vendor/chessboard/img/chesspieces/wikipedia/{piece}.png',
|
||||
onChange: function(oldPos, newPos) {
|
||||
setFen(ChessBoard.objToFen(newPos));
|
||||
}
|
||||
});
|
||||
setFen(board.fen());
|
||||
|
||||
$wrap.find('a.start').on('click', board.start);
|
||||
$wrap.find('a.clear').on('click', board.clear);
|
||||
$wrap.find('a.flip').on('click', board.flip);
|
||||
});
|
||||
});
|
||||
|
|
24
public/stylesheets/boardEditor.css
Normal file
24
public/stylesheets/boardEditor.css
Normal file
|
@ -0,0 +1,24 @@
|
|||
#board_editor {
|
||||
position: relative;
|
||||
}
|
||||
#chessboard {
|
||||
width: 392px;
|
||||
}
|
||||
#chessboard_side {
|
||||
position: absolute;
|
||||
left: 424px;
|
||||
top: 95px;
|
||||
width: 356px;
|
||||
}
|
||||
#board_editor p.fen_string {
|
||||
font-family: monospace;
|
||||
}
|
||||
#chessboard_side p {
|
||||
margin-bottom: 2em;
|
||||
text-align: center;
|
||||
}
|
||||
#board_editor a.button.big {
|
||||
display: block;
|
||||
text-align: center;
|
||||
margin-bottom: 1em;
|
||||
}
|
Loading…
Reference in a new issue