From 331a05b080afbba1a5e4fc155dd2b5aac4a16189 Mon Sep 17 00:00:00 2001 From: Daniel Seifert Date: Thu, 24 Nov 2022 09:36:39 +0100 Subject: [PATCH] handle delete keys in OTP input form --- .../views/admin/tpl/d3totplogin.tpl | 23 +++++++++++-------- src/Application/views/tpl/d3totplogin.tpl | 21 +++++++++-------- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/src/Application/views/admin/tpl/d3totplogin.tpl b/src/Application/views/admin/tpl/d3totplogin.tpl index d2b1768..6dd26e1 100644 --- a/src/Application/views/admin/tpl/d3totplogin.tpl +++ b/src/Application/views/admin/tpl/d3totplogin.tpl @@ -34,24 +34,27 @@
- + - + - + - + - + - +
[{capture name="d3js"}] - function clickEvent(next){ - const digits = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']; - if(digits.includes(event.key)){ + function clickEvent(previous, next){ + const digitKeys = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']; + const deleteKeys = ['Backspace', 'Delete']; + if(next && digitKeys.includes(event.key)){ document.getElementById(next).focus(); + } else if(previous && deleteKeys.includes(event.key)){ + document.getElementById(previous).focus(); } } document.addEventListener("paste", function(e) { @@ -71,7 +74,7 @@
[{oxstyle include=$oViewConf->getModuleUrl('d3totp', 'out/admin/src/css/d3totplogin.css')}] diff --git a/src/Application/views/tpl/d3totplogin.tpl b/src/Application/views/tpl/d3totplogin.tpl index 816687b..c6ec44d 100644 --- a/src/Application/views/tpl/d3totplogin.tpl +++ b/src/Application/views/tpl/d3totplogin.tpl @@ -25,24 +25,27 @@
- + - + - + - + - + - +
[{capture name="d3js"}] - function clickEvent(next){ - const digits = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']; - if(digits.includes(event.key)){ + function clickEvent(previous, next){ + const digitKeys = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']; + const deleteKeys = ['Backspace', 'Delete']; + if(next && digitKeys.includes(event.key)){ document.getElementById(next).focus(); + } else if(previous && deleteKeys.includes(event.key)){ + document.getElementById(previous).focus(); } } document.addEventListener("paste", function(e) {