-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathenterOnCustom.js
More file actions
26 lines (25 loc) · 861 Bytes
/
enterOnCustom.js
File metadata and controls
26 lines (25 loc) · 861 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
onPage('GamesList', function fixEnter() {
let toast = fn.infoToast({
text: 'You can now press enter on the Create Game window.',
onClose: () => {
toast = null;
}
}, 'underscript.notice.customGame', '1');
$('#state1 button:contains(Create)').on('mouseup.script', () => {
// Wait for the dialog to show up...
$(window).one('shown.bs.modal', (e) => {
const input = $('.bootstrap-dialog-message input');
if (!input.length) return; // This is just to prevent errors... though this is an error in itself
$(input[0]).focus();
input.on('keydown.script', (e) => {
if (e.which === 13) {
if (toast) {
toast.close();
}
e.preventDefault();
$('.bootstrap-dialog-footer-buttons button:first').trigger('click');
}
});
});
});
});