lichess.pubsub.emit has only one argument list
parent
5e85162820
commit
77a2463b11
|
@ -19,7 +19,7 @@ object home {
|
|||
moreJs = embedJsUnsafe(s"""$$(function() {
|
||||
lichess.StrongSocket.defaults.params.flag = 'simul';
|
||||
lichess.pubsub.on('socket.in.reload', () => {
|
||||
$$('.simul-list__content').load('${routes.Simul.homeReload()}', lichess.pubsub.emit('content_loaded'));
|
||||
$$('.simul-list__content').load('${routes.Simul.homeReload()}', () => lichess.pubsub.emit('content_loaded'));
|
||||
});
|
||||
});"""),
|
||||
title = trans.simultaneousExhibitions.txt(),
|
||||
|
|
|
@ -90,7 +90,7 @@ lichess.advantageChart = function(data, trans, el) {
|
|||
click: function(event) {
|
||||
if (event.point) {
|
||||
event.point.select();
|
||||
lichess.pubsub.emit('analysis.chart.click')(event.point.x);
|
||||
lichess.pubsub.emit('analysis.chart.click', event.point.x);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -146,7 +146,7 @@ lichess.advantageChart = function(data, trans, el) {
|
|||
}]
|
||||
}
|
||||
});
|
||||
lichess.pubsub.emit('analysis.change.trigger')();
|
||||
lichess.pubsub.emit('analysis.change.trigger');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -106,7 +106,7 @@ lichess.movetimeChart = function(data, trans) {
|
|||
click: function(event) {
|
||||
if (event.point) {
|
||||
event.point.select();
|
||||
lichess.pubsub.emit('analysis.chart.click')(event.point.x);
|
||||
lichess.pubsub.emit('analysis.chart.click', event.point.x);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -144,7 +144,7 @@ lichess.movetimeChart = function(data, trans) {
|
|||
}
|
||||
});
|
||||
});
|
||||
lichess.pubsub.emit('analysis.change.trigger')();
|
||||
lichess.pubsub.emit('analysis.change.trigger');
|
||||
};
|
||||
lichess.movetimeChart.render();
|
||||
});
|
||||
|
|
|
@ -77,7 +77,7 @@ $(function() {
|
|||
}
|
||||
}, function() {
|
||||
$("#infscr-loading").remove();
|
||||
lichess.pubsub.emit('content_loaded')();
|
||||
lichess.pubsub.emit('content_loaded');
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ type PubsubCallback = (...data: any[]) => void;
|
|||
interface Pubsub {
|
||||
on(msg: string, f: PubsubCallback): void;
|
||||
off(msg: string, f: PubsubCallback): void;
|
||||
emit(msg: string): (...args: any[]) => void;
|
||||
emit(msg: string, ...args: any[]): void;
|
||||
}
|
||||
|
||||
interface LichessStorageHelper {
|
||||
|
|
|
@ -312,7 +312,7 @@ export default class AnalyseCtrl {
|
|||
};
|
||||
|
||||
private onChange: () => void = throttle(300, () => {
|
||||
li.pubsub.emit('analysis.change')(this.node.fen, this.path, this.onMainline ? this.node.ply : false);
|
||||
li.pubsub.emit('analysis.change', this.node.fen, this.path, this.onMainline ? this.node.ply : false);
|
||||
});
|
||||
|
||||
private updateHref: () => void = li.debounce(() => {
|
||||
|
@ -358,7 +358,7 @@ export default class AnalyseCtrl {
|
|||
if (this.study) this.study.onJump();
|
||||
}
|
||||
if (this.music) this.music.jump(this.node);
|
||||
li.pubsub.emit('ply')(this.node.ply);
|
||||
li.pubsub.emit('ply', this.node.ply);
|
||||
}
|
||||
|
||||
userJump = (path: Tree.Path): void => {
|
||||
|
@ -726,7 +726,7 @@ export default class AnalyseCtrl {
|
|||
this.showComputer(value);
|
||||
if (!value && this.practice) this.togglePractice();
|
||||
this.onToggleComputer();
|
||||
li.pubsub.emit('analysis.comp.toggle')(value);
|
||||
li.pubsub.emit('analysis.comp.toggle', value);
|
||||
}
|
||||
|
||||
mergeAnalysisData(data: ServerEvalData): void {
|
||||
|
@ -738,7 +738,7 @@ export default class AnalyseCtrl {
|
|||
if (data.division) this.data.game.division = data.division;
|
||||
if (this.retro) this.retro.onMergeAnalysisData();
|
||||
if (this.study) this.study.serverEval.onMergeAnalysisData();
|
||||
li.pubsub.emit('analysis.server.progress')(this.data);
|
||||
li.pubsub.emit('analysis.server.progress', this.data);
|
||||
this.redraw();
|
||||
}
|
||||
|
||||
|
|
|
@ -115,7 +115,7 @@ export function view(ctrl: StudyCtrl): VNode {
|
|||
});
|
||||
vnode.data!.li = {};
|
||||
update(vnode);
|
||||
window.lichess.pubsub.emit('chat.resize')();
|
||||
window.lichess.pubsub.emit('chat.resize');
|
||||
},
|
||||
postpatch(old, vnode) {
|
||||
vnode.data!.li = old.data!.li;
|
||||
|
|
|
@ -143,8 +143,8 @@ export default function(data: StudyData, ctrl: AnalyseCtrl, tagTypes: TagTypes,
|
|||
const canContribute = members.canContribute();
|
||||
// unwrite if member lost privileges
|
||||
vm.mode.write = vm.mode.write && canContribute;
|
||||
li.pubsub.emit('chat.writeable')(data.features.chat);
|
||||
li.pubsub.emit('chat.permissions')({local: canContribute});
|
||||
li.pubsub.emit('chat.writeable', data.features.chat);
|
||||
li.pubsub.emit('chat.permissions', {local: canContribute});
|
||||
const computer: boolean = !isGamebookPlay() && !!(data.chapter.features.computer || data.chapter.practice);
|
||||
if (!computer) ctrl.getCeval().enabled(false);
|
||||
ctrl.getCeval().allowed(computer);
|
||||
|
|
|
@ -231,8 +231,8 @@ export function view(ctrl: StudyCtrl): VNode {
|
|||
return h('div.study__members', {
|
||||
hook: {
|
||||
insert: _ => {
|
||||
window.lichess.pubsub.emit('content_loaded')();
|
||||
window.lichess.pubsub.emit('chat.resize')();
|
||||
window.lichess.pubsub.emit('content_loaded');
|
||||
window.lichess.pubsub.emit('chat.resize');
|
||||
}
|
||||
}
|
||||
}, [
|
||||
|
|
|
@ -38,7 +38,7 @@ export default function(opts: ChatOpts, redraw: Redraw): Ctrl {
|
|||
alert('Max length: 140 chars. ' + text.length + ' chars used.');
|
||||
return;
|
||||
}
|
||||
li.pubsub.emit('socket.send')('talk', text);
|
||||
li.pubsub.emit('socket.send', 'talk', text);
|
||||
};
|
||||
|
||||
const onTimeout = function(username: string) {
|
||||
|
@ -84,7 +84,6 @@ export default function(opts: ChatOpts, redraw: Redraw): Ctrl {
|
|||
moderation = canMod() ? moderationCtrl({
|
||||
reasons: opts.timeoutReasons || ([{key: 'other', name: 'Inappropriate behavior'}]),
|
||||
permissions: opts.permissions,
|
||||
send: li.pubsub.emit('socket.send'),
|
||||
redraw
|
||||
}) : undefined;
|
||||
if (canMod()) opts.loadCss('chat.mod');
|
||||
|
@ -116,7 +115,7 @@ export default function(opts: ChatOpts, redraw: Redraw): Ctrl {
|
|||
subs.forEach(([eventName, callback]) => li.pubsub.off(eventName, callback));
|
||||
};
|
||||
|
||||
const emitEnabled = () => li.pubsub.emit('chat.enabled')(vm.enabled);
|
||||
const emitEnabled = () => li.pubsub.emit('chat.enabled', vm.enabled);
|
||||
emitEnabled();
|
||||
|
||||
return {
|
||||
|
|
|
@ -32,7 +32,7 @@ export default function(ctrl: Ctrl): Array<VNode | undefined> {
|
|||
hook: {
|
||||
insert(vnode) {
|
||||
const $el = $(vnode.elm as HTMLElement).on('click', 'a.jump', (e: Event) => {
|
||||
window.lichess.pubsub.emit('jump')((e.target as HTMLElement).getAttribute('data-ply'));
|
||||
window.lichess.pubsub.emit('jump', (e.target as HTMLElement).getAttribute('data-ply'));
|
||||
});
|
||||
if (m) $el.on('click', '.mod', (e: Event) => {
|
||||
m.open(((e.target as HTMLElement).getAttribute('data-username') as string).split(' ')[0]);
|
||||
|
|
|
@ -96,7 +96,6 @@ export interface NoteCtrl {
|
|||
export interface ModerationOpts {
|
||||
reasons: ModerationReason[]
|
||||
permissions: Permissions
|
||||
send(typ: string, data: any): void
|
||||
redraw: Redraw
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ export function moderationCtrl(opts: ModerationOpts): ModerationCtrl {
|
|||
open,
|
||||
close,
|
||||
timeout(reason: ModerationReason) {
|
||||
data && opts.send('timeout', {
|
||||
data && window.lichess.pubsub.emit('socket.send', 'timeout', {
|
||||
userId: data.id,
|
||||
reason: reason.key
|
||||
});
|
||||
|
@ -119,7 +119,7 @@ export function moderationView(ctrl?: ModerationCtrl): VNode[] | undefined {
|
|||
h('strong', 'Timeout history'),
|
||||
h('table', h('tbody.slist', {
|
||||
hook: {
|
||||
insert: () => window.lichess.pubsub.emit('content_loaded')()
|
||||
insert: () => window.lichess.pubsub.emit('content_loaded')
|
||||
}
|
||||
}, data.history.map(function(e) {
|
||||
return h('tr', [
|
||||
|
|
|
@ -85,7 +85,7 @@ export default function(ctrl: DasherCtrl): VNode {
|
|||
'data-icon': 'K',
|
||||
title: 'Keyboard: z'
|
||||
},
|
||||
hook: bind('click', window.lichess.pubsub.emit('zen'))
|
||||
hook: bind('click', () => window.lichess.pubsub.emit('zen'))
|
||||
}, noarg('zenMode'))
|
||||
]) : null;
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ export function ctrl(trans: Trans, redraw: Redraw): PingCtrl {
|
|||
|
||||
const hub = window.lichess.pubsub;
|
||||
|
||||
hub.emit('socket.send')('moveLat', true);
|
||||
hub.emit('socket.send', 'moveLat', true);
|
||||
hub.on('socket.lag', lag => {
|
||||
data.ping = Math.round(lag);
|
||||
redraw();
|
||||
|
|
|
@ -36,7 +36,7 @@ export function ctrl(raw: string[], trans: Trans, redraw: Redraw, close: Close):
|
|||
api,
|
||||
set(k: Key) {
|
||||
api.speech(k == 'speech');
|
||||
window.lichess.pubsub.emit('speech.enabled')(api.speech());
|
||||
window.lichess.pubsub.emit('speech.enabled', api.speech());
|
||||
if (api.speech()) api.say('Speech synthesis ready');
|
||||
else {
|
||||
api.changeSet(k);
|
||||
|
|
|
@ -55,7 +55,7 @@ module.exports = function(cfg, element) {
|
|||
url: $("#timeline").data('href'),
|
||||
success: function(html) {
|
||||
$('#timeline').html(html);
|
||||
lichess.pubsub.emit('content_loaded')();
|
||||
lichess.pubsub.emit('content_loaded');
|
||||
}
|
||||
});
|
||||
},
|
||||
|
@ -65,7 +65,7 @@ module.exports = function(cfg, element) {
|
|||
},
|
||||
featured: function(o) {
|
||||
$('.lobby__tv').html(o.html);
|
||||
lichess.pubsub.emit('content_loaded')();
|
||||
lichess.pubsub.emit('content_loaded');
|
||||
},
|
||||
redirect: function(e) {
|
||||
lobby.leavePool();
|
||||
|
@ -74,11 +74,11 @@ module.exports = function(cfg, element) {
|
|||
},
|
||||
tournaments: function(data) {
|
||||
$("#enterable_tournaments").html(data);
|
||||
lichess.pubsub.emit('content_loaded')();
|
||||
lichess.pubsub.emit('content_loaded');
|
||||
},
|
||||
simuls: function(data) {
|
||||
$("#enterable_simuls").html(data).parent().toggle($('#enterable_simuls tr').length > 0);
|
||||
lichess.pubsub.emit('content_loaded')();
|
||||
lichess.pubsub.emit('content_loaded');
|
||||
},
|
||||
fen: function(e) {
|
||||
lichess.StrongSocket.defaults.events.fen(e);
|
||||
|
@ -376,7 +376,7 @@ module.exports = function(cfg, element) {
|
|||
$(this).attr('href', $(this).attr('href').replace(/editor\/.+$/, "editor/" + fen));
|
||||
});
|
||||
$submits.removeClass('nope');
|
||||
lichess.pubsub.emit('content_loaded')();
|
||||
lichess.pubsub.emit('content_loaded');
|
||||
},
|
||||
error: function() {
|
||||
$fenInput.addClass("failure");
|
||||
|
@ -426,7 +426,7 @@ module.exports = function(cfg, element) {
|
|||
prepareForm($.modal(html, 'game-setup', () => {
|
||||
$startButtons.find('.active').removeClass('active');
|
||||
}));
|
||||
lichess.pubsub.emit('content_loaded')();
|
||||
lichess.pubsub.emit('content_loaded');
|
||||
},
|
||||
error: function(res) {
|
||||
if (res.status == 400) alert(res.responseText);
|
||||
|
|
|
@ -52,7 +52,7 @@ function clickHook(f: () => void) {
|
|||
};
|
||||
}
|
||||
|
||||
const contentLoaded = window.lichess.pubsub.emit('content_loaded');
|
||||
const contentLoaded = () => window.lichess.pubsub.emit('content_loaded');
|
||||
|
||||
function recentNotifications(d: NotifyData, scrolling: boolean): VNode {
|
||||
return h('div', {
|
||||
|
|
|
@ -365,7 +365,7 @@ export default function(opts, redraw: () => void): Controller {
|
|||
promotion.cancel();
|
||||
vm.justPlayed = undefined;
|
||||
vm.autoScrollRequested = true;
|
||||
window.lichess.pubsub.emit('ply')(vm.node.ply);
|
||||
window.lichess.pubsub.emit('ply', vm.node.ply);
|
||||
};
|
||||
|
||||
function userJump(path) {
|
||||
|
|
|
@ -32,7 +32,7 @@ export default function(opts: RoundOpts): void {
|
|||
const $html = $(html), $meta = $html.find('.game__meta');
|
||||
$meta.length && $('.game__meta').replaceWith($meta);
|
||||
$('.crosstable').replaceWith($html.find('.crosstable'));
|
||||
li.pubsub.emit('content_loaded')();
|
||||
li.pubsub.emit('content_loaded');
|
||||
}
|
||||
});
|
||||
},
|
||||
|
@ -87,6 +87,6 @@ export default function(opts: RoundOpts): void {
|
|||
});
|
||||
if (location.pathname.lastIndexOf('/round-next/', 0) === 0)
|
||||
history.replaceState(null, '', '/' + data.game.id);
|
||||
$('#zentog').click(li.pubsub.emit('zen'));
|
||||
$('#zentog').click(() => li.pubsub.emit('zen'));
|
||||
li.storage.make('reload-round-tabs').listen(li.reload);
|
||||
}
|
||||
|
|
|
@ -232,7 +232,7 @@ export default class RoundController {
|
|||
}
|
||||
this.autoScroll();
|
||||
if (this.keyboardMove) this.keyboardMove.update(s);
|
||||
li.pubsub.emit('ply')(ply);
|
||||
li.pubsub.emit('ply', ply);
|
||||
return true;
|
||||
};
|
||||
|
||||
|
@ -399,7 +399,7 @@ export default class RoundController {
|
|||
});
|
||||
if (o.check) sound.check();
|
||||
blur.onMove();
|
||||
li.pubsub.emit('ply')(this.ply);
|
||||
li.pubsub.emit('ply', this.ply);
|
||||
}
|
||||
d.game.threefold = !!o.threefold;
|
||||
const step = {
|
||||
|
|
|
@ -32,5 +32,5 @@ export function init(ctrl: RoundController) {
|
|||
ctrl.redraw();
|
||||
}));
|
||||
k.bind('f', preventing(ctrl.flipNow));
|
||||
k.bind('z', preventing(window.lichess.pubsub.emit('zen')));
|
||||
k.bind('z', preventing(() => window.lichess.pubsub.emit('zen')));
|
||||
}
|
||||
|
|
|
@ -282,5 +282,5 @@ export function watcherFollowUp(ctrl: RoundController): VNode | null {
|
|||
}
|
||||
|
||||
const onSuggestionHook: Hooks = util.onInsert(
|
||||
el => window.lichess.pubsub.emit('round.suggestion')(el.textContent)
|
||||
el => window.lichess.pubsub.emit('round.suggestion', el.textContent)
|
||||
);
|
||||
|
|
|
@ -168,7 +168,7 @@
|
|||
}
|
||||
}
|
||||
}).on('typeahead:render', function() {
|
||||
lichess.pubsub.emit('content_loaded')();
|
||||
lichess.pubsub.emit('content_loaded');
|
||||
});
|
||||
if (opts.focus) $input.focus();
|
||||
if (opts.onSelect) $input.on('typeahead:select', function(ev, sel) {
|
||||
|
@ -449,7 +449,7 @@
|
|||
}
|
||||
}, function() {
|
||||
$("#infscr-loading").remove();
|
||||
lichess.pubsub.emit('content_loaded')();
|
||||
lichess.pubsub.emit('content_loaded');
|
||||
var ids = [];
|
||||
$(el).find('.paginated[data-dedup]').each(function() {
|
||||
var id = $(this).data('dedup');
|
||||
|
@ -470,7 +470,7 @@
|
|||
var $p = $(this).parent();
|
||||
$p.toggleClass('shown');
|
||||
$p.siblings('.shown').removeClass('shown');
|
||||
lichess.pubsub.emit('top.toggle.' + $(this).attr('id'))();
|
||||
lichess.pubsub.emit('top.toggle.' + $(this).attr('id'));
|
||||
setTimeout(function() {
|
||||
var handler = function(e) {
|
||||
if ($.contains($p[0], e.target)) return;
|
||||
|
@ -641,7 +641,7 @@
|
|||
};
|
||||
|
||||
var publish = function() {
|
||||
lichess.pubsub.emit('sound_set')(soundSet);
|
||||
lichess.pubsub.emit('sound_set', soundSet);
|
||||
};
|
||||
setTimeout(publish, 500);
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ lichess.StrongSocket = function(url, version, settings) {
|
|||
onSuccess();
|
||||
$('body').removeClass('offline').addClass('online').addClass(nbConnects > 1 ? 'reconnected' : '');
|
||||
pingNow();
|
||||
lichess.pubsub.emit('socket.open')();
|
||||
lichess.pubsub.emit('socket.open');
|
||||
ackable.resend();
|
||||
};
|
||||
ws.onmessage = function(e) {
|
||||
|
@ -167,7 +167,7 @@ lichess.StrongSocket = function(url, version, settings) {
|
|||
var mix = pongCount > 4 ? 0.1 : 1 / pongCount;
|
||||
averageLag += mix * (currentLag - averageLag);
|
||||
|
||||
lichess.pubsub.emit('socket.lag')(averageLag);
|
||||
lichess.pubsub.emit('socket.lag', averageLag);
|
||||
};
|
||||
|
||||
var handle = function(m) {
|
||||
|
@ -190,7 +190,7 @@ lichess.StrongSocket = function(url, version, settings) {
|
|||
ackable.gotAck(m.d);
|
||||
break;
|
||||
default:
|
||||
lichess.pubsub.emit('socket.in.' + m.t)(m.d);
|
||||
lichess.pubsub.emit('socket.in.' + m.t, m.d);
|
||||
var processed = settings.receive && settings.receive(m.t, m.d);
|
||||
if (!processed && settings.events[m.t]) settings.events[m.t](m.d || null, m);
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ $(function() {
|
|||
$('.angle-content .infinitescroll').infinitescroll('destroy');
|
||||
$.get(path).then(function(html) {
|
||||
$content.html(html);
|
||||
lichess.pubsub.emit('content_loaded')();
|
||||
lichess.pubsub.emit('content_loaded');
|
||||
history.replaceState({}, '', path);
|
||||
lichess.loadInfiniteScroll('.angle-content .infinitescroll');
|
||||
});
|
||||
|
|
|
@ -27,22 +27,22 @@ lichess.isCol1 = (() => {
|
|||
{
|
||||
const buildStorage = (storage) => {
|
||||
const api = {
|
||||
get: (k) => storage.getItem(k),
|
||||
get: k => storage.getItem(k),
|
||||
set: (k, v) => storage.setItem(k, v),
|
||||
remove: (k) => storage.removeItem(k),
|
||||
make: (k) => ({
|
||||
remove: k => storage.removeItem(k),
|
||||
make: k => ({
|
||||
get: () => api.get(k),
|
||||
set: (v) => api.set(k, v),
|
||||
set: v => api.set(k, v),
|
||||
remove: () => api.remove(k),
|
||||
listen: (f) => window.addEventListener('storage', e => {
|
||||
listen: f => window.addEventListener('storage', e => {
|
||||
if (e.key === k &&
|
||||
e.storageArea === storage &&
|
||||
e.newValue !== null) f(e);
|
||||
})
|
||||
}),
|
||||
makeBoolean: (k) => ({
|
||||
makeBoolean: k => ({
|
||||
get: () => api.get(k) == 1,
|
||||
set: (v) => api.set(k, v ? 1 : 0),
|
||||
set: v => api.set(k, v ? 1 : 0),
|
||||
toggle: () => api.set(k, api.get(k) == 1 ? 0 : 1)
|
||||
})
|
||||
};
|
||||
|
@ -95,7 +95,7 @@ lichess.powertip = (() => {
|
|||
url: url + '/mini',
|
||||
success: function(html) {
|
||||
$('#' + id).html(html);
|
||||
lichess.pubsub.emit('content_loaded')();
|
||||
lichess.pubsub.emit('content_loaded');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
@ -300,12 +300,11 @@ lichess.pubsub = (function() {
|
|||
}
|
||||
}
|
||||
},
|
||||
emit(name) {
|
||||
return () => {
|
||||
if (!subs[name]) return;
|
||||
const args = Array.prototype.slice.call(arguments, 0);
|
||||
for (let i in subs[name]) subs[name][i].apply(null, args);
|
||||
}
|
||||
emit(name /*, args... */) {
|
||||
if (!subs[name]) return;
|
||||
const args = Array.prototype.slice.call(arguments, 1);
|
||||
console.log(args, name);
|
||||
for (let i in subs[name]) subs[name][i].apply(null, args);
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
|
|
@ -39,7 +39,7 @@ if (location.search.startsWith('?mod')) $toggle.click();
|
|||
|
||||
function userMod($zone) {
|
||||
|
||||
lichess.pubsub.emit('content_loaded')();
|
||||
lichess.pubsub.emit('content_loaded');
|
||||
|
||||
$('#mz_menu .mz_plan').toggleClass('disabled', !$('#mz_plan').length);
|
||||
|
||||
|
|
Loading…
Reference in New Issue