JS code tweaks
parent
e942741f5b
commit
9cc1ff10aa
|
@ -2,7 +2,7 @@ $(function() {
|
|||
const $form = $('#signup_form');
|
||||
const $exists = $form.find('.username-exists');
|
||||
|
||||
const usernameCheck = lichess.debounce(function() {
|
||||
const usernameCheck = lichess.debounce(() => {
|
||||
const name = $username.val();
|
||||
if (name.length >= 3) $.ajax({
|
||||
method: 'GET',
|
||||
|
@ -11,27 +11,27 @@ $(function() {
|
|||
term: name,
|
||||
exists: 1
|
||||
},
|
||||
success: function(res) {
|
||||
success(res) {
|
||||
$exists.toggle(res);
|
||||
}
|
||||
});
|
||||
}, 300);
|
||||
|
||||
$username = $form.find('input[name="username"]')
|
||||
.on('change keyup paste', function() {
|
||||
.on('change keyup paste', () => {
|
||||
$exists.hide();
|
||||
usernameCheck();
|
||||
});
|
||||
|
||||
$form.on('submit', function() {
|
||||
$form.on('submit', () =>
|
||||
$form.find('button.submit')
|
||||
.attr('disabled', true)
|
||||
.removeAttr('data-icon')
|
||||
.addClass('frameless')
|
||||
.html(lichess.spinnerHtml);
|
||||
.html(lichess.spinnerHtml)
|
||||
);
|
||||
});
|
||||
});
|
||||
window.signupSubmit = function(token) {
|
||||
window.signupSubmit = () => {
|
||||
const form = document.getElementById('signup_form');
|
||||
if (form.reportValidity()) form.submit();
|
||||
}
|
||||
|
|
|
@ -129,7 +129,7 @@
|
|||
}, {
|
||||
hint: true,
|
||||
highlight: false,
|
||||
source: function(query, _, runAsync) {
|
||||
source(query, _, runAsync) {
|
||||
query = query.trim();
|
||||
if (!query.match(/^[a-z0-9][\w-]{2,29}$/i)) return;
|
||||
else if (cache[query]) setTimeout(() => runAsync(cache[query]), 50);
|
||||
|
@ -164,8 +164,8 @@
|
|||
templates: {
|
||||
empty: '<div class="empty">No player found</div>',
|
||||
pending: lichess.spinnerHtml,
|
||||
suggestion: function(o) {
|
||||
var tag = opts.tag || 'a';
|
||||
suggestion(o) {
|
||||
const tag = opts.tag || 'a';
|
||||
return '<' + tag + ' class="ulpt user-link' + (o.online ? ' online' : '') + '" ' + (tag === 'a' ? '' : 'data-') + 'href="/@/' + o.name + '">' +
|
||||
'<i class="line' + (o.patron ? ' patron' : '') + '"></i>' + (o.title ? '<span class="utitle">' + o.title + '</span> ' : '') + o.name +
|
||||
'</' + tag + '>';
|
||||
|
|
Loading…
Reference in New Issue