play JS router is slow, use it only for complex routes
parent
5df54748e0
commit
0181e28870
|
@ -4,16 +4,16 @@
|
|||
@helper.javascriptRouter("puzzleRoutes")(
|
||||
routes.javascript.Puzzle.attempt,
|
||||
routes.javascript.Puzzle.show,
|
||||
routes.javascript.Puzzle.history,
|
||||
routes.javascript.Puzzle.difficulty,
|
||||
routes.javascript.Puzzle.home,
|
||||
routes.javascript.Puzzle.newPuzzle,
|
||||
/* routes.javascript.Puzzle.history, */
|
||||
/* routes.javascript.Puzzle.difficulty, */
|
||||
/* routes.javascript.Puzzle.home, */
|
||||
/* routes.javascript.Puzzle.newPuzzle, */
|
||||
routes.javascript.Puzzle.load,
|
||||
routes.javascript.Puzzle.vote,
|
||||
routes.javascript.Coordinate.home,
|
||||
/* routes.javascript.Coordinate.home, */
|
||||
routes.javascript.Editor.load,
|
||||
routes.javascript.Round.watcher,
|
||||
routes.javascript.Auth.signup
|
||||
/* routes.javascript.Auth.signup */
|
||||
)(ctx.req)
|
||||
@embedJs {
|
||||
LichessPuzzle(
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
@()(implicit ctx: Context)
|
||||
@helper.javascriptRouter("roundRoutes")(
|
||||
routes.javascript.Lobby.home,
|
||||
routes.javascript.Auth.signup,
|
||||
routes.javascript.User.show,
|
||||
routes.javascript.Tournament.show,
|
||||
/* routes.javascript.Lobby.home */,
|
||||
/* routes.javascript.Auth.signup */,
|
||||
/* routes.javascript.User.show */,
|
||||
/* routes.javascript.Tournament.show */,
|
||||
routes.javascript.Round.watcher,
|
||||
routes.javascript.Round.playerText,
|
||||
routes.javascript.Round.watcherText,
|
||||
routes.javascript.Round.sideWatcher,
|
||||
routes.javascript.Round.continue,
|
||||
routes.javascript.Tv.index,
|
||||
routes.javascript.Tv.side,
|
||||
routes.javascript.Editor.game)(ctx.req)
|
||||
/* routes.javascript.Tv.index */,
|
||||
routes.javascript.Tv.side
|
||||
/* routes.javascript.Editor.game */
|
||||
)(ctx.req)
|
||||
|
|
|
@ -221,7 +221,7 @@ function buttons(ctrl) {
|
|||
}, m('span[data-icon=B]')),
|
||||
m('a.button.hint--bottom', {
|
||||
'data-hint': ctrl.trans('boardEditor'),
|
||||
href: ctrl.router.Editor.game(ctrl.data.game.id).url + '?fen=' + ctrl.vm.situation.fen
|
||||
href: ctrl.data.game.id + '/edit?fen=' + ctrl.vm.situation.fen
|
||||
}, m('span[data-icon=m]')),
|
||||
m('a.button.hint--bottom', {
|
||||
'data-hint': ctrl.trans('continueFromHere'),
|
||||
|
|
|
@ -25,7 +25,7 @@ module.exports = function(ctrl, player, klass) {
|
|||
el.classList.add('ulpt');
|
||||
},
|
||||
class: 'user_link ' + (player.user.online ? 'online is-green' : 'offline') + (klass ? ' ' + klass : ''),
|
||||
href: ctrl.router.User.show(player.user.username).url,
|
||||
href: '/@/' + player.user.username,
|
||||
target: game.isPlayerPlaying(ctrl.data) ? '_blank' : null,
|
||||
'data-icon': 'r',
|
||||
}, [
|
||||
|
|
|
@ -36,17 +36,17 @@ function renderTrainingBox(ctrl) {
|
|||
m('h1', ctrl.trans('training')),
|
||||
m('div.tabs.buttonset', [
|
||||
m('a.button.active', {
|
||||
href: ctrl.router.Puzzle.home().url
|
||||
href: '/training'
|
||||
}, 'Puzzle'),
|
||||
m('a.button', {
|
||||
href: ctrl.router.Coordinate.home().url
|
||||
href: '/training/coordinate'
|
||||
}, 'Coordinate')
|
||||
]),
|
||||
ctrl.data.user ? renderUserInfos(ctrl) : m('div.register', [
|
||||
m('p', ctrl.trans('toTrackYourProgress')),
|
||||
m('p.signup',
|
||||
m('a.button', {
|
||||
href: ctrl.router.Auth.signup().url
|
||||
href: '/signup',
|
||||
}, ctrl.trans('signUp'))
|
||||
),
|
||||
m('p', ctrl.trans('trainingSignupExplanation'))
|
||||
|
@ -268,7 +268,7 @@ function renderHistory(ctrl) {
|
|||
var hash = ctrl.data.user.history.join('');
|
||||
if (hash == context.hash) return;
|
||||
context.hash = hash;
|
||||
$.get(ctrl.router.Puzzle.history().url, function(html) {
|
||||
$.get('/training/history', function(html) {
|
||||
el.innerHTML = html;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ function retry(ctrl) {
|
|||
function setDifficulty(ctrl, d) {
|
||||
m.request({
|
||||
method: 'POST',
|
||||
url: ctrl.router.Puzzle.difficulty().url,
|
||||
url: '/training/difficulty',
|
||||
data: {
|
||||
difficulty: d
|
||||
},
|
||||
|
@ -56,7 +56,7 @@ function setDifficulty(ctrl, d) {
|
|||
function newPuzzle(ctrl) {
|
||||
m.request({
|
||||
method: 'GET',
|
||||
url: ctrl.router.Puzzle.newPuzzle().url,
|
||||
url: '/training/new',
|
||||
config: xhrConfig
|
||||
}).then(ctrl.reload);
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ function renderButtons(ctrl, curPly) {
|
|||
class: 'button flip hint--bottom' + (root.vm.flip ? ' active' : ''),
|
||||
'data-hint': root.trans('flipBoard'),
|
||||
};
|
||||
if (root.data.tv) flipAttrs.href = root.router.Tv.index().url + (root.data.tv.flip ? '' : '?flip=1');
|
||||
if (root.data.tv) flipAttrs.href = '/tv' + (root.data.tv.flip ? '' : '?flip=1');
|
||||
else if (root.data.player.spectator) flipAttrs.href = root.router.Round.watcher(root.data.game.id, root.data.opponent.color).url;
|
||||
else flipAttrs.onclick = root.flip;
|
||||
return m('div.buttons', [
|
||||
|
|
|
@ -124,17 +124,17 @@ module.exports = {
|
|||
newGame: function(ctrl) {
|
||||
if (!ctrl.data.offeringRematch && !ctrl.data.tournament) return m('a.lichess_new_game.button.hint--bottom', {
|
||||
'data-hint': ctrl.trans('playWithAnotherOpponent'),
|
||||
href: ctrl.router.Lobby.home().url
|
||||
href: '/',
|
||||
}, ctrl.trans('newOpponent'));
|
||||
},
|
||||
backToTournament: function(ctrl) {
|
||||
if (ctrl.data.tournament) return m('a[data-icon=G].button' + (ctrl.data.tournament.running ? '.strong.glowing' : ''), {
|
||||
href: ctrl.router.Tournament.show(ctrl.data.tournament.id).url
|
||||
href: '/tournament/' + ctrl.data.tournament.id
|
||||
}, ctrl.trans('backToTournament'));
|
||||
},
|
||||
viewTournament: function(ctrl) {
|
||||
if (ctrl.data.tournament) return m('a.button', {
|
||||
href: ctrl.router.Tournament.show(ctrl.data.tournament.id).url
|
||||
href: '/tournament/' + ctrl.data.tournament.id
|
||||
}, ctrl.trans('viewTournament'));
|
||||
},
|
||||
moretime: function(ctrl) {
|
||||
|
|
Loading…
Reference in New Issue