remove common.js

This commit is contained in:
Thibault Duplessis 2014-12-27 12:02:37 +01:00
parent b7d0726914
commit 7db6ca0249
5 changed files with 52 additions and 31 deletions

View file

@ -276,7 +276,6 @@ chessground: Boolean = true)(body: Html)(implicit ctx: Context)
@jsTag("deps.min.js")
@momentjsTag
@powertipTag
@jsTagCompiled("common.js")
@jsTagCompiled("socket.js")
@jsTagCompiled("big.js")
@moreJs

View file

@ -20,9 +20,8 @@
@gameFenNoCtx(g, g.firstPlayer.color, tv = true, blank = true)
@game.vstext(g)(none)
</div>
<script src="http://code.jquery.com/jquery-2.1.0.min.js"></script>
<script src="http://code.jquery.com/jquery-2.1.3.min.js"></script>
@jsTag("vendor/chessground.min.js")
@jsTagCompiled("common.js")
@jsTagCompiled("tv.js")
@base.ga()
</body>

View file

@ -221,6 +221,30 @@ var storage = {
location.reload();
};
lichess.parseFen = function($elem) {
if (!$elem || !$elem.jquery) {
$elem = $('.parse_fen');
}
$elem.each(function() {
var $this = $(this).removeClass('parse_fen');
var lm = $this.data('lastmove');
var lastMove = lm ? [lm[0] + lm[1], lm[2] + lm[3]] : [];
var color = $this.data('color');
var ground = $this.data('chessground');
var playable = $this.data('playable');
var config = {
coordinates: false,
viewOnly: !playable,
minimalDom: !playable,
fen: $this.data('fen'),
lastMove: lm ? [lm[0] + lm[1], lm[2] + lm[3]] : null
};
if (color) config.orientation = color;
if (ground) ground.set(config);
else $this.data('chessground', Chessground($this[0], config));
});
}
$(function() {
// small layout
@ -1147,8 +1171,8 @@ var storage = {
/////////////////
$(function() {
parseFen();
$('body').on('lichess.content_loaded', parseFen);
lichess.parseFen();
$('body').on('lichess.content_loaded', lichess.parseFen);
var socketOpened = false;
@ -1204,7 +1228,7 @@ var storage = {
$captcha.toggleClass('failure', data != 1);
if (data == 1) $board.data('chessground').stop();
else setTimeout(function() {
parseFen($board);
lichess.parseFen($board);
$board.data('chessground').set({
turnColor: color,
movable: {

View file

@ -1,23 +0,0 @@
function parseFen($elem) {
if (!$elem || !$elem.jquery) {
$elem = $('.parse_fen');
}
$elem.each(function() {
var $this = $(this).removeClass('parse_fen');
var lm = $this.data('lastmove');
var lastMove = lm ? [lm[0] + lm[1], lm[2] + lm[3]] : [];
var color = $this.data('color');
var ground = $this.data('chessground');
var playable = $this.data('playable');
var config = {
coordinates: false,
viewOnly: !playable,
minimalDom: !playable,
fen: $this.data('fen'),
lastMove: lm ? [lm[0] + lm[1], lm[2] + lm[3]] : null
};
if (color) config.orientation = color;
if (ground) ground.set(config);
else $this.data('chessground', Chessground($this[0], config));
});
}

View file

@ -1,3 +1,26 @@
function parseFen($elem) {
if (!$elem || !$elem.jquery) {
$elem = $('.parse_fen');
}
$elem.each(function() {
var $this = $(this).removeClass('parse_fen');
var lm = $this.data('lastmove');
var lastMove = lm ? [lm[0] + lm[1], lm[2] + lm[3]] : [];
var color = $this.data('color');
var ground = $this.data('chessground');
var playable = $this.data('playable');
var config = {
coordinates: false,
viewOnly: !playable,
minimalDom: !playable,
fen: $this.data('fen'),
lastMove: lm ? [lm[0] + lm[1], lm[2] + lm[3]] : null
};
if (color) config.orientation = color;
if (ground) ground.set(config);
else $this.data('chessground', Chessground($this[0], config));
});
}
$(function() {
var $featured = $('#featured_game');
var board = function() {
@ -13,8 +36,7 @@ $(function() {
if (data.t == "featured") {
$('#featured_game').html(data.d.html);
parseFen(board());
}
else if (data.t == "fen") {
} else if (data.t == "fen") {
parseFen(board().data("fen", data.d.fen).data("lastmove", data.d.lm));
}
}, false);