add feature word_typed_listener_allowed_only_for_empty_customerf

This commit is contained in:
Schneider Roland
2023-03-24 17:08:51 +01:00
parent beb3c3944e
commit 89fe6a37c1
4 changed files with 35 additions and 17 deletions

View File

@@ -4,7 +4,7 @@ var seq = '';
var socket;
$(document).ready(
function(){
$("input[name='number']").on('focus', function (e) {
$(this)
.one('mouseup', function () {
@@ -13,7 +13,7 @@ $(document).ready(
})
.select();
});
addDocumentKeypressedListener();
}
);
@@ -23,9 +23,9 @@ function addDocumentKeypressedListener(){
$( document ).keypress(function( event ) {
var tag = event.target.tagName.toLowerCase();
if ( tag != 'input' && tag != 'textarea' && tag != 'select') {
resetSequenceIfToMuchTimePassedOrEnterWasPressed(event);
if ( event.which == 13 ) {
enterPressed = 1;
if ( seq ){
@@ -35,19 +35,27 @@ function addDocumentKeypressedListener(){
appendCharToSeq(event);
}
}
});
});
$( document ).on( "wordtyped", function( event, data ) {
var word;
word = data.word;
if ( word && word.length > 0){
location.href= reception_card_url +'&number=' + word;
var redirectAllowed = true;
if ( isWordTypedListenerAllowedOnlyForEmptyCustomer ){
if ( location.href !== reception_card_url ){
redirectAllowed = false;
console.info("disalbling customer redirect. reason: isWordTypedListenerAllowedOnlyForEmptyCustomer = true")
}
}
if ( redirectAllowed){
location.href= reception_card_url +'&number=' + word;
}
}
});
function resetSequenceIfToMuchTimePassedOrEnterWasPressed(){
var prevDate, timePassed;
prevDate= keyDate;
@@ -58,7 +66,7 @@ function addDocumentKeypressedListener(){
enterPressed = 0;
}
}
function appendCharToSeq(event){
var code,s;
code = event.which;
@@ -68,7 +76,7 @@ function addDocumentKeypressedListener(){
seq += s;
}
}
}