opening trainer history
parent
236b37474a
commit
4bbadd79d6
|
@ -40,6 +40,13 @@ object Opening extends LilaController {
|
|||
OptionFuOk(env.api.opening find id)(renderShow)
|
||||
}
|
||||
|
||||
def history = Auth { implicit ctx =>
|
||||
me =>
|
||||
XhrOnly {
|
||||
env userInfos me map { ui => Ok(views.html.opening.history(ui)) }
|
||||
}
|
||||
}
|
||||
|
||||
private val attemptForm = Form(mapping(
|
||||
"found" -> number,
|
||||
"failed" -> number
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
@(userInfos: lila.opening.UserInfos)(implicit ctx: Context)
|
||||
|
||||
<div class="undertable">
|
||||
<div class="undertable_top">
|
||||
<span class="title">@trans.recentlyPlayedOpenings()</span>
|
||||
</div>
|
||||
<div class="undertable_inner scroll-shadow-soft">
|
||||
<div class="content">
|
||||
<table>
|
||||
<tbody>
|
||||
@userInfos.history.map { attempt =>
|
||||
<tr>
|
||||
<td>
|
||||
<a class="user_link ulpt" href="@routes.User.show(userInfos.user.username)">
|
||||
@userInfos.user.username (@attempt.userRating) @showRatingDiff(attempt.userRatingDiff)
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
<a class="user_link" href="@routes.Opening.show(attempt.openingId)">
|
||||
@trans.openingId(attempt.openingId) (@attempt.openingRating) @showRatingDiff(attempt.openingRatingDiff)
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -315,3 +315,4 @@ findNbStrongMoves=Find %s strong moves
|
|||
thisMoveGivesYourOpponentTheAdvantage=This move gives your opponent the advantage
|
||||
openingFailed=Opening failed
|
||||
openingSolved=Opening solved
|
||||
recentlyPlayedOpenings=Recently played openings
|
||||
|
|
|
@ -73,6 +73,7 @@ GET /games/search controllers.Game.search(page: Int ?= 1)
|
|||
|
||||
# Training - Opening
|
||||
GET /training/opening controllers.Opening.home
|
||||
GET /training/opening/history controllers.Opening.history
|
||||
GET /training/opening/:id controllers.Opening.show(id: Int)
|
||||
POST /training/opening/:id controllers.Opening.attempt(id: Int)
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -168,6 +168,23 @@ function renderSide(ctrl) {
|
|||
]);
|
||||
}
|
||||
|
||||
function renderHistory(ctrl) {
|
||||
return m('div.history', {
|
||||
config: function(el, isUpdate, context) {
|
||||
var hash = ctrl.data.user.history.join('');
|
||||
if (hash == context.hash) return;
|
||||
context.hash = hash;
|
||||
$.ajax({
|
||||
url: '/training/opening/history',
|
||||
cache: false,
|
||||
success: function(html) {
|
||||
el.innerHTML = html;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function progress(ctrl) {
|
||||
var steps = [];
|
||||
var figuredOut = ctrl.vm.figuredOut.slice(0);
|
||||
|
@ -227,7 +244,8 @@ module.exports = function(ctrl) {
|
|||
))
|
||||
]),
|
||||
m('div.center', [
|
||||
progress(ctrl)
|
||||
progress(ctrl),
|
||||
(ctrl.data.user && ctrl.data.user.history) ? renderHistory(ctrl) : null
|
||||
])
|
||||
]);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue