jellyfish-web/src/controllers/user/quickConnect/index.js

24 lines
763 B
JavaScript
Raw Normal View History

import { authorize } from './helper';
2020-10-18 18:58:09 +01:00
import globalize from '../../../scripts/globalize';
import toast from '../../../components/toast/toast';
2020-07-26 23:57:28 -05:00
export default function (view) {
view.addEventListener('viewshow', function () {
2020-09-16 04:20:00 +09:00
const codeElement = view.querySelector('#txtQuickConnectCode');
2020-07-26 23:57:28 -05:00
view.querySelector('.quickConnectSettingsContainer').addEventListener('submit', (e) => {
e.preventDefault();
2020-07-26 23:57:28 -05:00
if (!codeElement.validity.valid) {
toast(globalize.translate('QuickConnectInvalidCode'));
return;
}
// Remove spaces from code
const normalizedCode = codeElement.value.replace(/\s/g, '');
authorize(normalizedCode);
});
2020-07-26 23:57:28 -05:00
});
}