@רפאל מפני הכרת הטוב ל @רפאל אעלה למרות המלצתו 'המחנכת' של ר' @yossiz שעזר לי לקצר את הקוד שלי, בשבעים שורות..
let evtext;
export function input41_keyPress(event) {
let key = event.key;
if (key === "Enter" || key === "Tab") {
$w('#input41').blur()
$w('#text168').hide()
const hipus = String($w('#input41').value);
filters(hipus)
let einglish = "qwertyuiopasdfghjklzxcvvbnmQWERTYUIOPASDFGHJKLZXCVBNM,.;",
tw = $w('#input41').value
let cnisa = einglish.indexOf(tw.charAt(0))
if (cnisa !== -1) {
evtext = converter.convert(tw)
$w('#text167').show()
$w('#text167').text = " האם נתכונת לחפש? " + evtext
}
}
}
function filters(hipus) {
const velur = hipus.split(' ').reverse().join(' ');
console.log(velur);
wixData.query("magar").eq("phon", hipus).find().then((res) => {
if (res.length === 1) {
let id = res.items[0]
wixWindow.openLightbox("רכישת כרטיסים", { id })
}
})
const types = ['phon', 'hir', 'ctovet', 'sem', 'tz', 'mishpaha', 'semmale'];
let filter2 = wixData.filter();
const type = $w('#input13').value;
if (type in types) {
filter2 = filter2.contains(type, hipus);
}
if (type === 'semmale' || type === 'all') {
filter2 = filter2.or(
wixData.filter().contains("semmale", velur));
}
if (type === 'all') {
for (const type of types) {
filter2 = filter2.or(wixData.filter().contains(type, hipus));
}
}
$w("#dataset1").setFilter(filter2).then(()=>{
let count = $w("#dataset1").getTotalCount(); // 23\
console.log(count);
if (count===0) {
$w('#text168').show()
}
})
.catch((err) => {
console.log(err);
});
}
class LayoutConvertor {
convert(str) {
return str.replace(/./g, x => this.#lookup.get(x) ?? this.#lookup.get(x.toLowerCase()) ?? x)
}
#lookup = new Map([
["q", "/"],
["w", "'"],
["e", "ק"],
["r", "ר"],
["t", "א"],
["y", "ט"],
["u", "ו"],
["i", "ן"],
["o", "ם"],
["p", "פ"],
["[", "]"],
["{", "}"],
["]", "["],
["}", "{"],
["\\", "\\"],
["|", "|"],
["a", "ש"],
["s", "ד"],
["d", "ג"],
["f", "כ"],
["g", "ע"],
["h", "י"],
["j", "ח"],
["k", "ל"],
["l", "ך"],
[";", "ף"],
[":", ":"],
["'", ","],
["\"", "\""],
["z", "ז"],
["x", "ס"],
["c", "ב"],
["v", "ה"],
["b", "נ"],
["n", "מ"],
["m", "צ"],
[",", "ת"],
["<", ">"],
[".", "ץ"],
[">", "<"],
["/", "."],
["?", "?"]
]);
}
const converter = new LayoutConvertor()
export function text167_click(event) {
$w('#input41').blur()
const hipus = evtext;
$w('#input41').value = evtext
filters(hipus)
$w('#text167').hide()
// This function was added from the Properties & Events panel. To learn more, visit http://wix.to/UcBnC-4
// Add your code for this event here:
}