From e901dee7b1cc9b123846dc8e5cca55778c37523a Mon Sep 17 00:00:00 2001 From: Thibault Duplessis Date: Wed, 24 Jul 2013 15:53:04 +0200 Subject: [PATCH] allow casual hook elo range --- app/views/setup/clock.scala.html | 2 +- app/views/setup/hook.scala.html | 30 +++++++++++++----------- conf/messages | 2 +- modules/i18n/src/main/I18nKeys.scala | 4 ++-- modules/i18n/src/main/JsDump.scala | 2 ++ modules/setup/src/main/FormFactory.scala | 2 +- modules/setup/src/main/HookConfig.scala | 10 ++++---- public/javascripts/big.js | 10 ++++---- public/stylesheets/common.css | 3 +-- todo | 1 - 10 files changed, 36 insertions(+), 30 deletions(-) diff --git a/app/views/setup/clock.scala.html b/app/views/setup/clock.scala.html index 5586280fe8..cf994122ca 100644 --- a/app/views/setup/clock.scala.html +++ b/app/views/setup/clock.scala.html @@ -4,7 +4,7 @@
- + @setup.checkbox(form("clock"))
diff --git a/app/views/setup/hook.scala.html b/app/views/setup/hook.scala.html index 75b38f8144..6b14fbde24 100644 --- a/app/views/setup/hook.scala.html +++ b/app/views/setup/hook.scala.html @@ -12,22 +12,24 @@
@setup.radios(form("mode"), translatedModeChoices)
-
- @trans.eloRange(): ? - ? -
- @setup.input( - form("eloRange"), - Symbol("type") -> "hidden", - Symbol("data-min") -> EloRange.min, - Symbol("data-max") -> EloRange.max) +
+ @if(ctx.isAuth) { +
+ + @setup.checkbox(form("membersOnly")) +
+ } +
+ @trans.eloRange(): ? - ? +
+ @setup.input( + form("eloRange"), + Symbol("type") -> "hidden", + Symbol("data-min") -> EloRange.min, + Symbol("data-max") -> EloRange.max) +
-@if(ctx.isAuth) { -
- - @setup.checkbox(form("allowAnon")) -
-} } } diff --git a/conf/messages b/conf/messages index 10146b6be1..ea0c4c7307 100644 --- a/conf/messages +++ b/conf/messages @@ -239,7 +239,7 @@ createdBy=Created by waitingForNbPlayers=Waiting for %s players tournamentIsStarting=Tournament is starting nbMinutesPerSidePlusNbSecondsPerMove=%s minutes/side + %s seconds/move -anonymousCanJoin=Anonymous can join +membersOnly=Members only boardEditor=Board editor startPosition=Start position clearBoard=Clear board diff --git a/modules/i18n/src/main/I18nKeys.scala b/modules/i18n/src/main/I18nKeys.scala index 659ff3c1a6..ca1fc48367 100644 --- a/modules/i18n/src/main/I18nKeys.scala +++ b/modules/i18n/src/main/I18nKeys.scala @@ -263,11 +263,11 @@ final class I18nKeys(translator: Translator) { val waitingForNbPlayers = new Key("waitingForNbPlayers") val tournamentIsStarting = new Key("tournamentIsStarting") val nbMinutesPerSidePlusNbSecondsPerMove = new Key("nbMinutesPerSidePlusNbSecondsPerMove") - val anonymousCanJoin = new Key("anonymousCanJoin") + val membersOnly = new Key("membersOnly") 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, startPosition, clearBoard, 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, membersOnly, boardEditor, startPosition, clearBoard, savePosition) } diff --git a/modules/i18n/src/main/JsDump.scala b/modules/i18n/src/main/JsDump.scala index ea8144cf4b..b1556cac67 100644 --- a/modules/i18n/src/main/JsDump.scala +++ b/modules/i18n/src/main/JsDump.scala @@ -46,6 +46,8 @@ private[i18n] case class JsDump( keys.addToChrome, keys.createANewTournament, keys.join, + keys.joinTheGame, + keys.cancel, keys.withdraw, keys.tournamentIsStarting) diff --git a/modules/setup/src/main/FormFactory.scala b/modules/setup/src/main/FormFactory.scala index 455644a2cc..11ff59262f 100644 --- a/modules/setup/src/main/FormFactory.scala +++ b/modules/setup/src/main/FormFactory.scala @@ -80,7 +80,7 @@ private[setup] final class FormFactory { "time" -> time, "increment" -> increment, "mode" -> mode(ctx.isAuth), - "allowAnon" -> boolean, + "membersOnly" -> boolean, "eloRange" -> eloRange, "color" -> nonEmptyText.verifying(Color.names contains _) )(HookConfig.<<)(_.>>) diff --git a/modules/setup/src/main/HookConfig.scala b/modules/setup/src/main/HookConfig.scala index 84af4292c2..01e621df94 100644 --- a/modules/setup/src/main/HookConfig.scala +++ b/modules/setup/src/main/HookConfig.scala @@ -16,7 +16,8 @@ case class HookConfig( color: Color, eloRange: EloRange) extends HumanConfig { - def >> = (variant.id, clock, time, increment, mode.id.some, allowAnon, eloRange.toString.some, color.name).some + // allowAnons -> membersOnly + def >> = (variant.id, clock, time, increment, mode.id.some, !allowAnon, eloRange.toString.some, color.name).some def hook(uid: String, user: Option[User], sid: Option[String]) = Hook.make( uid = uid, @@ -43,16 +44,17 @@ case class HookConfig( object HookConfig extends BaseHumanConfig { - def <<(v: Int, k: Boolean, t: Int, i: Int, m: Option[Int], a: Boolean, e: Option[String], c: String) = { + def <<(v: Int, k: Boolean, t: Int, i: Int, m: Option[Int], membersOnly: Boolean, e: Option[String], c: String) = { val realMode = m.fold(Mode.default)(Mode.orDefault) + val useEloRange = realMode.rated || membersOnly new HookConfig( variant = Variant(v) err "Invalid game variant " + v, clock = k, time = t, increment = i, mode = realMode, - allowAnon = a, - eloRange = e.filter(_ ⇒ realMode.rated).fold(EloRange.default)(EloRange.orDefault), + allowAnon = !membersOnly, // membersOnly + eloRange = e.filter(_ ⇒ useEloRange).fold(EloRange.default)(EloRange.orDefault), color = Color(c) err "Invalid color " + c) } diff --git a/public/javascripts/big.js b/public/javascripts/big.js index 1ab2cf79db..c2fc4e3aae 100644 --- a/public/javascripts/big.js +++ b/public/javascripts/big.js @@ -1864,13 +1864,14 @@ var storage = { } }); var $eloRangeConfig = $this.parent(); - $modeChoices.on('change', function() { + $modeChoices.add($form.find('.members_only input')).on('change', function() { var rated = $rated.prop('checked'); - $eloRangeConfig.toggle(rated); + var membersOnly = $form.find('.members_only input').prop('checked'); + $eloRangeConfig.toggle(rated || membersOnly); if (isHook && rated && !$clockCheckbox.prop('checked')) { $clockCheckbox.click(); } - $form.find('.allow_anon_config').toggle(!rated); + $form.find('.members_only').toggle(!rated); $.centerOverboard(); }).trigger('change'); }); @@ -2275,7 +2276,8 @@ var storage = { } function renderTr(hook) { - return '' + _.map([ + var title = (hook.action == "join") ? $.trans('Join the game') : $.trans('cancel'); + return '' + _.map([ ['', ''], [hook.username, hook.elo ? '' + hook.username + '' : 'Anonymous'], [hook.elo || 0, hook.elo || ''], diff --git a/public/stylesheets/common.css b/public/stylesheets/common.css index e4c26bfc26..dd27fd4515 100644 --- a/public/stylesheets/common.css +++ b/public/stylesheets/common.css @@ -1358,8 +1358,7 @@ div.game_config .time_choice, div.game_config .increment_choice, div.game_config div.game_config .time_choice span { font-weight: bold; } -div.game_config .allow_anon_config label, -div.game_config .clock_config label { +div.game_config label.pointer { cursor: pointer; } div.game_config button.submit { diff --git a/todo b/todo index 1cab5d2d72..12cee06597 100644 --- a/todo +++ b/todo @@ -59,4 +59,3 @@ embedded games links http://2ls.ru/chessonline/ filter ranges http://en.lichess.org/forum/lichess-feedback/my-proposed-changes-with-filter-window#1 hooks resync (chrome does not remove them all) casual games elo range -change own hook color