Skip to content

Commit

Permalink
fix diakritiky pro linux + drobnosti
Browse files Browse the repository at this point in the history
  • Loading branch information
Firu115 committed Dec 4, 2024
1 parent 225be42 commit b517a1a
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 23 deletions.
2 changes: 1 addition & 1 deletion frontend/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ async function upravitSirkuJmena() {
jmenoSpan.value.style.fontSize = `${velikost}px`
if (velikost <= 0) break
}
console.log("velikost jmena v px:", velikost)
//console.log("velikost jmena v px:", velikost)
}
function odhlasit(e: Event) {
Expand Down
29 changes: 17 additions & 12 deletions frontend/src/components/Psani.vue
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,9 @@ function klik(e: Event) {
startTimer()
if (!(e instanceof InputEvent)) return // typescript je sus, nemůžu dát do parametru rovnou InputEvent https://github.com/microsoft/TypeScript/issues/39925
if (e.inputType == "insertText") {
// kvůli linuxu ->
if (e.inputType == "insertText" || (e.inputType == "insertCompositionText" && !e.isComposing)) {
if (e.data === aktivniPismeno.value.znak) {
if (zvukyZaply.value) zvuky[Math.floor(Math.random() * 2)].play()
if (aktivniPismeno.value.spatne === 1) {
Expand Down Expand Up @@ -304,7 +305,7 @@ function restart() {
mistaPosunuti.value = [0, 0]
chybyPismenka.clear()
opravene.value = 0
input.value!.value = '' // nemusi byt
if (input.value != null) input.value.value = '' // nemusi byt asi
clearTimeout(timeoutID)
for (let i = 0; i < props.text.length; i++) {
Expand Down Expand Up @@ -397,7 +398,11 @@ function checkFocus() {
unfocused.value = document.activeElement !== input.value
}
defineExpose({ restart, aktivniPismeno, fullHideKlavesnice })
function focusInput() {
input.value?.focus()
}
defineExpose({ restart, aktivniPismeno, fullHideKlavesnice, focusInput })
</script>

<template>
Expand All @@ -420,7 +425,8 @@ defineExpose({ restart, aktivniPismeno, fullHideKlavesnice })
</div>
</div>
</div>
<span class="unfocused" :style="{ display: unfocused ? 'block' : 'none', top: route.fullPath == '/prvni-psani' ? '200px' : '235px' }"
<span class="unfocused"
:style="{ display: unfocused ? 'block' : 'none', top: (route.fullPath == '/prvni-psani' || route.fullPath.split('/')[1] == 'prace') ? '200px' : '235px' }"
@click="input?.focus()">Klikni sem nebo zmáčkni <span class="klavesa-v-textu">Mezerník</span> !</span>

<input type="text" ref="input" id="input" @input="klik">
Expand All @@ -430,24 +436,23 @@ defineExpose({ restart, aktivniPismeno, fullHideKlavesnice })
:cekame="(aktivniPismeno.id == 0 || aktivniPismeno.id == -1) && cass == 0" :full-hide="fullHideKlavesnice" />
</Transition>
<Transition>
<Tooltip zprava="Restart cvičení <span class='klavesa-v-textu-mensi'>Delete</span>" :sirka="120" :vzdalenost="85" :xOffset="385"
:yOffset="-154">
<div v-if="klavesnice != '' && props.resetBtn" id="reset-btn" @click="resetTlacitko(); animace()"
:class="{ schovat: route.fullPath == '/prvni-psani' }">
<Tooltip v-if="klavesnice != '' && props.resetBtn" zprava="Restart cvičení <span class='klavesa-v-textu-mensi'>Delete</span>"
:sirka="120" :vzdalenost="-55" :xOffset="385" :yOffset="-154">
<div id="reset-btn" @click="resetTlacitko(); animace(); input?.focus();" :class="{ schovat: route.fullPath == '/prvni-psani' }">
<img :style="{ transform: rotace }" src="../assets/icony/reset.svg" alt="Restart">
</div>
</Tooltip>
</Transition>
<Transition>
<div v-if="klavesnice != '' && props.resetBtn" id="hide-btn" @click="fullHideKlavesnice = !fullHideKlavesnice"
<div v-if="klavesnice != '' && props.resetBtn" id="hide-btn" @click="fullHideKlavesnice = !fullHideKlavesnice; input?.focus()"
:class="{ schovat: route.fullPath == '/prvni-psani' }"
:style="{ top: route.fullPath.split('/')[1] == 'lekce' ? '-140px' : '-70px' }">
<img v-if="!fullHideKlavesnice" src="../assets/icony/oko.svg" alt="Schovat" width="34">
<img v-else src="../assets/icony/okoSkrtnuty.svg" alt="Schovat" width="34">
</div>
</Transition>

<div id="zvuk-btn" @click="toggleZvuk">
<div id="zvuk-btn" @click="toggleZvuk(); input?.focus()">
<img v-if="zvukyZaply" style="margin-top: 1px;" class="zvuk-icon" src="../assets/icony/zvukOn.svg" alt="Zvuky jsou zapnuté">
<img v-else style="margin-left: 1px;" class="zvuk-icon" src="../assets/icony/zvukOff.svg" alt="Zvuky jsou vypnuté">
</div>
Expand Down Expand Up @@ -479,7 +484,7 @@ span.unfocused {
#input {
position: absolute;
opacity: 0;
opacity: 1;
cursor: default;
}
Expand Down
9 changes: 5 additions & 4 deletions frontend/src/components/PsaniMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { onMounted, ref } from "vue";
import { nastaveniJmeno, prihlasen } from "../stores";
import { saveNastaveni } from "../utils";
defineEmits(["restart", "toggle", "toggleInterpunkce"])
const emit = defineEmits(["restart", "toggle", "refocus"])
const props = defineProps({
vyberTextu: {
Expand Down Expand Up @@ -54,6 +54,7 @@ function disabledBtn(e: KeyboardEvent) {
function d(x: number) {
delka.value = x
saveNastaveni(diakritika.value, velkaPismena.value, typ.value, delka.value, klavModel.value)
emit("refocus")
}
defineExpose({ diakritika, velkaPismena, typ, delka, klavModel })
Expand All @@ -64,7 +65,7 @@ defineExpose({ diakritika, velkaPismena, typ, delka, klavModel })
<div id="psani-menu" :class="{ 'bez-stinu': props.bezStinu }">
<div v-if="!(prihlasen && !vyberTextu)" class="kontejner" style="gap: 20px;">
<input v-if="vyberTextu" v-model="typ" type="checkbox" id="toggle" class="toggle-checkbox"
@change="$emit('restart'); saveNastaveni(diakritika, velkaPismena, typ, delka, klavModel)" />
@change="emit('restart'); saveNastaveni(diakritika, velkaPismena, typ, delka, klavModel)" />
<label v-if="vyberTextu" for="toggle" class="toggle-contejner">
<div>Slova</div>
<div>Věty</div>
Expand Down Expand Up @@ -93,12 +94,12 @@ defineExpose({ diakritika, velkaPismena, typ, delka, klavModel })

<div class="kontejner">
<label for="toggle2" class="kontejner">
<input v-model="velkaPismena" @change="$emit('toggle')" type="checkbox" id="toggle2" class="radio" />
<input v-model="velkaPismena" @change="emit('toggle')" type="checkbox" id="toggle2" class="radio" />
Velká písmena
</label>

<label for="toggle3" class="kontejner">
<input v-model="diakritika" @change="$emit('toggle')" type="checkbox" id="toggle3" class="radio" />
<input v-model="diakritika" @change="emit('toggle')" type="checkbox" id="toggle3" class="radio" />
Diakritika
</label>
</div>
Expand Down
10 changes: 7 additions & 3 deletions frontend/src/views/Procvic.vue
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,10 @@ watch(a, () => {
}
})
function refocus() {
psaniRef.value.focusInput()
}
</script>

<template>
Expand All @@ -241,10 +245,10 @@ watch(a, () => {
<Vysledek v-else @restart="restart" :preklepy="preklepy" :opravenych="opravenePocet" :delkaTextu="delkaNapsanehoTextu"
:cas="menuRef == undefined ? 15 : menuRef.delka" :cislo="typ" :posledni="true" :nejcastejsiChyby="nejcastejsiChyby" />

<PsaniMenu class="psaniMenu" :class="{ hide: konec || !hideKlavecnice }" @restart="restart(); psaniRef?.restart()" @toggle="toggleDiakritikaAVelkaPismena"
:vyberTextu="false" :bez-stinu="psaniRef?.fullHideKlavesnice" ref="menuRef" />
<PsaniMenu class="psaniMenu" :class="{ hide: konec || !hideKlavecnice }" @restart="restart(); psaniRef?.restart()"
@toggle="toggleDiakritikaAVelkaPismena" @click="refocus" :vyberTextu="false" :bez-stinu="psaniRef?.fullHideKlavesnice" ref="menuRef" />

<NastaveniBtn v-if="!konec && klavesnice != ''" @klik="hideKlavecnice = !hideKlavecnice" />
<NastaveniBtn v-if="!konec && klavesnice != ''" @klik="hideKlavecnice = !hideKlavecnice; refocus(); psaniRef?.restart()" />
</template>

<style scoped>
Expand Down
9 changes: 7 additions & 2 deletions frontend/src/views/TestPsani.vue
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,11 @@ async function prodlouzit() {
nacitamNovej.value = false
})
}
function refocus() {
psaniRef.value.focusInput()
}
</script>

<template>
Expand All @@ -218,9 +223,9 @@ async function prodlouzit() {
:cas="menuRef == undefined ? 15 : menuRef.delka" :cislo="'test-psani'" :posledni="true" :nejcastejsiChyby="nejcastejsiChyby" />

<PsaniMenu class="psaniMenu" :class="{ hide: konec || !hideKlavecnice }" @restart="restart(); psaniRef.restart()"
@toggle="toggleDiakritikaAVelkaPismena" :bez-stinu="psaniRef?.fullHideKlavesnice" ref="menuRef" />
@toggle="toggleDiakritikaAVelkaPismena" @click="refocus" :bez-stinu="psaniRef?.fullHideKlavesnice" ref="menuRef" />

<NastaveniBtn v-if="!konec && klavesnice != ''" @klik="hideKlavecnice = !hideKlavecnice" />
<NastaveniBtn v-if="!konec && klavesnice != ''" @klik="hideKlavecnice = !hideKlavecnice; refocus(); psaniRef?.restart()" />
</template>

<style scoped>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/views/ucitel/ZadaniPrace.vue
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ function smazatEnterAMezery() {
function vymenitUvozovky() {
if (textovePole.value!.text.length == 0) return
puvodniText.value = textovePole.value!.text
textovePole.value!.text = textovePole.value!.text.replace(/[„“”‟❞❝"⹂]/g, '"').replace(/[‚’‘‛❛❜]/g, "'")
textovePole.value!.text = textovePole.value!.text.replace(/[„“”‟❞❝"⹂]/g, '"').replace(/[‚’‘‛❛❜]/g, "'")
}
function zrusitPosledniUpravu() {
Expand Down

0 comments on commit b517a1a

Please sign in to comment.