dev #14384 Правка ошибок отображения WPA КофеЛайк: fix sms enter code on ios
This commit is contained in:
parent
7b5200d9f8
commit
26b2e8eb13
@ -9,15 +9,19 @@ export class FocusNextInputDirective {
|
|||||||
constructor(private renderer: Renderer2) { }
|
constructor(private renderer: Renderer2) { }
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.eventEmitter.subscribe(elementId => {
|
// TODO: don't need to listen all events
|
||||||
try {
|
this.eventEmitter.subscribe(elementId => {
|
||||||
this.renderer.selectRootElement(elementId).focus();
|
try {
|
||||||
this.renderer.selectRootElement(elementId).click();
|
const element = this.renderer.selectRootElement(elementId)
|
||||||
} catch (ex) {
|
setTimeout(() => {
|
||||||
(document.activeElement as HTMLElement).blur();
|
element.focus();
|
||||||
// If the element doesn't exist or if the element disappears when this called then no need to do anything
|
element.click();
|
||||||
}
|
}, 0);
|
||||||
});
|
} catch (ex) {
|
||||||
|
(document.activeElement as HTMLElement).blur();
|
||||||
|
// If the element doesn't exist or if the element disappears when this called then no need to do anything
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,3 @@
|
|||||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
||||||
// @ts-nocheck
|
|
||||||
import {
|
import {
|
||||||
AfterViewInit,
|
AfterViewInit,
|
||||||
Component,
|
Component,
|
||||||
@ -43,47 +41,17 @@ export class LoginComponent implements OnInit, AfterViewInit {
|
|||||||
private jsonRpcService: JsonrpcService
|
private jsonRpcService: JsonrpcService
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {}
|
||||||
if ('OTPCredential' in window) {
|
|
||||||
console.log('have otp credential');
|
|
||||||
window.addEventListener('DOMContentLoaded', e => {
|
|
||||||
const form = document.querySelector('.code-form');
|
|
||||||
const ac = new AbortController();
|
|
||||||
if (form) {
|
|
||||||
form.addEventListener('submit', e => {
|
|
||||||
ac.abort();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
navigator.credentials.get({
|
|
||||||
otp: { transport:['sms'] },
|
|
||||||
signal: ac.signal
|
|
||||||
}).then(otp => {
|
|
||||||
console.log(otp)
|
|
||||||
const input1 = document.getById("field");
|
|
||||||
const input2 = document.getById("field1");
|
|
||||||
const input3 = document.getById("field2");
|
|
||||||
const input4 = document.getById("field3");
|
|
||||||
input1.value = otp.code[0];
|
|
||||||
input2.value = otp.code[1];
|
|
||||||
input3.value = otp.code[2];
|
|
||||||
input4.value = otp.code[3];
|
|
||||||
if (form) form.submit();
|
|
||||||
}).catch(err => {
|
|
||||||
console.log(err);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ngAfterViewInit() {
|
ngAfterViewInit() {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.inputFocusEmitter.emit(`#${this.inputIds[0]}`);
|
this.inputFocusEmitter.emit(`#${this.inputIds[0]}`);
|
||||||
}, 1000);
|
}, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
public inputFocusEmitter = new EventEmitter<string>();
|
public inputFocusEmitter = new EventEmitter<string>();
|
||||||
|
|
||||||
@HostListener('window:keyup', ['$event'])
|
@HostListener('window:keydown', ['$event'])
|
||||||
HandlKeyEvents(event: any) {
|
HandlKeyEvents(event: any) {
|
||||||
if (!event.target.classList.contains('field')) return;
|
if (!event.target.classList.contains('field')) return;
|
||||||
const key = event.key.toLocaleLowerCase();
|
const key = event.key.toLocaleLowerCase();
|
||||||
@ -100,12 +68,11 @@ export class LoginComponent implements OnInit, AfterViewInit {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
elementId = event.target.id;
|
elementId = event.target.id;
|
||||||
const index = this.inputIds.indexOf(elementId);
|
const index = this.inputIds.indexOf(elementId);
|
||||||
const nextInputIndex = index + 1;
|
const nextInputIndex = index + 1;
|
||||||
if (event.target.value.length > 1) {
|
event.target.value = event.key;
|
||||||
event.target.value = event.target.value.slice(-1);
|
|
||||||
}
|
|
||||||
if (nextInputIndex > 0 && nextInputIndex <= this.inputIds.length) {
|
if (nextInputIndex > 0 && nextInputIndex <= this.inputIds.length) {
|
||||||
this.inputFocusEmitter.emit(`#${this.inputIds[nextInputIndex]}`);
|
this.inputFocusEmitter.emit(`#${this.inputIds[nextInputIndex]}`);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user