upgrade and re-hack jQuery, removing more support

more-scalatags
Thibault Duplessis 2019-04-14 21:30:44 +07:00
parent 8e1248dbc1
commit d691209f4e
7 changed files with 40 additions and 42 deletions

File diff suppressed because one or more lines are too long

View File

@ -22,8 +22,7 @@ export default function(element: HTMLElement, ctrl: AnalyseCtrl) {
if (!li.AnalyseNVUI) {
li.pubsub.on('analysis.comp.toggle', (v: boolean) => {
setTimeout(function() {
if (v) $menu.find('a.computer-analysis').mousedown();
else $menu.find('a:eq(1)').mousedown();
(v ? $menu.find('a.computer-analysis') : $menu.find('a:eq(1)')).trigger('mousedown');
}, 50);
});
li.pubsub.on('analysis.change', (fen: Fen, _, mainlinePly: Ply | false) => {

View File

@ -404,10 +404,10 @@ module.exports = function(cfg, element) {
$form.find('div.level').each(function() {
var $infos = $(this).find('.ai_info > div');
$(this).find('label').mouseenter(function() {
$(this).find('label').on('mouseenter', function() {
$infos.hide().filter('.' + $(this).attr('for')).show();
});
$(this).find('#config_level').mouseleave(function() {
$(this).find('#config_level').on('mouseleave', function() {
var level = $(this).find('input:checked').val();
$infos.hide().filter('.sf_level_' + level).show();
}).trigger('mouseout');

View File

@ -11,7 +11,7 @@ export function hooks(ctrl: LobbyController): Hooks {
return bind('click', e => {
const id = (e.target as HTMLElement).getAttribute('data-id') ||
((e.target as HTMLElement).parentNode as HTMLElement).getAttribute('data-id');
if (id === 'custom') $('.config_hook').mousedown();
if (id === 'custom') $('.config_hook').trigger('mousedown');
else if (id) ctrl.clickPool(id);
}, ctrl.redraw);
}

View File

@ -1,32 +0,0 @@
module.exports = function(send) {
var currentId = 1; // increment with each ackable message sent
var messages = [];
function resend() {
var resendCutoff = Date.now() - 2500;
messages.forEach(function(m) {
if (m.at < resendCutoff) send(m.t, m.d);
});
}
setInterval(resend, 1000);
return {
resend: resend,
register: function(t, d) {
d.a = currentId++;
messages.push({
t: t,
d: d,
at: Date.now()
});
},
gotAck: function(id) {
messages = messages.filter(function(m) {
return m.d.a !== id;
});
}
};
}

View File

@ -168,7 +168,7 @@
if (opts.focus) $input.focus();
if (opts.onSelect) $input.on('typeahead:select', function(ev, sel) {
opts.onSelect(sel);
}).keypress(function(e) {
}).on('keypress', function(e) {
if (e.which == 10 || e.which == 13) opts.onSelect($(this).val());
});
});
@ -499,7 +499,7 @@
if ($oc[0]) $oc[0].click();
else {
$input = $(':focus');
if ($input.length) $input.blur();
if ($input.length) $input.trigger('blur');
}
return false;
});

View File

@ -1,4 +1,35 @@
var makeAckable = require('./ackable');
function makeAckable(send) {
var currentId = 1; // increment with each ackable message sent
var messages = [];
function resend() {
var resendCutoff = Date.now() - 2500;
messages.forEach(function(m) {
if (m.at < resendCutoff) send(m.t, m.d);
});
}
setInterval(resend, 1000);
return {
resend: resend,
register: function(t, d) {
d.a = currentId++;
messages.push({
t: t,
d: d,
at: Date.now()
});
},
gotAck: function(id) {
messages = messages.filter(function(m) {
return m.d.a !== id;
});
}
};
}
// versioned events, acks, retries, resync
lichess.StrongSocket = function(url, version, settings) {