diff --git a/app/views/challenge/theirs.scala.html b/app/views/challenge/theirs.scala.html
index 7c1b72e51d..b5706d866f 100644
--- a/app/views/challenge/theirs.scala.html
+++ b/app/views/challenge/theirs.scala.html
@@ -15,19 +15,42 @@ moreJs = js(c, json, false)) {
@explanation(c)
@c.initialFen.map { fen =>
- @views.html.game.miniBoard(fen, color = c.chessColor.name)
+ @views.html.game.miniBoard(fen, color = (!(c.chessColor)).name)
}
+
+ @c.status match {
+ case Status.Created | Status.Offline => {
@if(!c.mode.rated || ctx.isAuth) {
@if(c.mode.rated && c.unlimited) {
@trans.bewareTheGameIsRatedButHasNoClock()
}
-
} else {
This game is rated
You must log in to join it.
}
+ }
+ case Status.Declined => {
+
+ }
+ case Status.Accepted => {
+
+ }
+ case Status.Canceled => {
+
+ }
+ }
}
diff --git a/public/javascripts/challenge.js b/public/javascripts/challenge.js
index 32b3f371d6..7f8969182c 100644
--- a/public/javascripts/challenge.js
+++ b/public/javascripts/challenge.js
@@ -1,7 +1,7 @@
lichess = lichess || {};
lichess.startChallenge = function(element, opts) {
- console.log(opts);
var challenge = opts.data.challenge;
+ var accepting;
if (!opts.owner && lichess.openInMobileApp(challenge.id)) return;
lichess.socket = new lichess.StrongSocket(
opts.socketUrl,
@@ -19,7 +19,8 @@ lichess.startChallenge = function(element, opts) {
url: opts.xhrUrl,
success(html) {
$('.lichess_overboard').replaceWith($(html).find('.lichess_overboard'));
- $('#challenge_redirect').each(function() {
+ init();
+ if (!accepting) $('#challenge_redirect').each(function() {
location.href = $(this).attr('href');
});
}
@@ -28,6 +29,14 @@ lichess.startChallenge = function(element, opts) {
}
});
+ var init = function() {
+ $('.lichess_overboard').find('form.accept').submit(function() {
+ accepting = true;
+ $(this).html('');
+ });
+ };
+ init();
+
var pingNow = function() {
if (document.getElementById('ping_challenge')) {
lichess.socket.send('ping');
@@ -36,10 +45,10 @@ lichess.startChallenge = function(element, opts) {
};
pingNow();
- Chessground(element.querySelector('.lichess_board'), {
+ var ground = Chessground(element.querySelector('.lichess_board'), {
viewOnly: true,
fen: challenge.initialFen,
- orientation: challenge.color,
+ orientation: (opts.owner ^ challenge.color === 'black') ? 'white' : 'black',
coordinates: false,
disableContextMenu: true
});