Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT] - switch languages #94

Open
alekseystepanov92 opened this issue Sep 13, 2024 · 1 comment
Open

[FEAT] - switch languages #94

alekseystepanov92 opened this issue Sep 13, 2024 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@alekseystepanov92
Copy link

Hi. Is there a solution to switch languages ​​within a single keyboard object?
Have a nice day!

@alekseystepanov92 alekseystepanov92 added the enhancement New feature or request label Sep 13, 2024
@alekseystepanov92
Copy link
Author

Solved it with the help of an "keysEnterCallback"
////////////////////////////////////////////////////////////////////////
//START switch Language по event kioskboard-key-enter
////////////////////////////////////////////////////////////////////////
var k = a.document.querySelector(".kioskboard-key-enter");
k && va(k, function (a) {
//switchLanguage()//
a.preventDefault(), b.focus()
!0 === A.keysEnterCanClose && ta(), "function" == typeof A.keysEnterCallback && A.keysEnterCallback();
var language
if (k.textContent == 'RU') { k.innerHTML = "EN"; language = russianKeyboard } else { k.innerHTML = "RU"; language = englishKeyboard }
var row_dynamic = document.getElementsByClassName('kioskboard-row-dynamic')
// dynamic keys group: begin
for (var i = 0; i < language.length; i++) {
var eachObj = language[i];
var rowKeysContent = '';
for (var key5 in eachObj) {
if (Object.prototype.hasOwnProperty.call(eachObj, key5)) {
var index5 = key5;
var value5 = eachObj[key5];
var eachKey5 = '' + value5.toString() + '';
rowKeysContent += eachKey5;
}}
// add current row
row_dynamic[i].innerHTML = rowKeysContent
}
// update listener (key's)
const keys = document.querySelectorAll('.kioskboard-key');
function spansClick(a) {
a.preventDefault();
var c = 1 * (b.getAttribute("maxlength") || ""),
d = 1 * (b.getAttribute("max") || ""),
e = (b.value || "").length || 0;
if (0 < c && e >= c) return !1;
if (0 < d && e >= d) return !1;
b.focus();
var f = a.currentTarget.dataset.value || "";
f = G ? f.toLocaleUpperCase(z) : f.toLocaleLowerCase(z);
for (var g = f.split(""), h = 0; h < g.length; h++) m = b.selectionStart || (b.value || "").length, n.splice(m, 0, g[h]), b.value = n.join(""), "number" !== b.type && b.setSelectionRange(m + 1, m + 1), b.dispatchEvent(ua)
}
// addEventListener --> click (key)
keys.forEach((span) => {
span.addEventListener('click', spansClick);
});
})
////////////////////////////////////////////////////////////////////////
//END switch Language по event kioskboard-key-enter
////////////////////////////////////////////////////////////////////////

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants