This commit is contained in:
@@ -45,14 +45,13 @@ class TlaController extends Controller
|
|||||||
public function check_tla(Request $request, ?string $language = 'en')
|
public function check_tla(Request $request, ?string $language = 'en')
|
||||||
{
|
{
|
||||||
$request->validate([
|
$request->validate([
|
||||||
'guess' => 'required',
|
'guess' => 'required|array|size:3',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$guess = $request->all()['guess'];
|
|
||||||
|
|
||||||
$tla = explode(' ', Tla::GetCurrentTla($language)->abbreviation);
|
$tla = explode(' ', Tla::GetCurrentTla($language)->abbreviation);
|
||||||
|
|
||||||
$guess_array = explode(' ', $guess);
|
$guess_array = $request->all()['guess'];
|
||||||
|
|
||||||
$proposal = [];
|
$proposal = [];
|
||||||
|
|
||||||
for ($i = 0; $i < 3; $i++) {
|
for ($i = 0; $i < 3; $i++) {
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="gw-div" :class="{ 'default': correctness==0, 'cw-cp': correctness==4, 'cw-ip': correctness==3, 'cf-cp': correctness==2, 'cf-ip': correctness==1 }">
|
<Transition appear>
|
||||||
<slot></slot>
|
<div v-if="true" class="gw-div" :class="{ 'less': correctness==-3, 'more': correctness==-2, 'default': correctness==0, 'cw-cp': correctness==4, 'cw-ip': correctness==3, 'cf-cp': correctness==2, 'cf-ip': correctness==1 }">
|
||||||
</div>
|
<slot></slot>
|
||||||
|
</div>
|
||||||
|
</Transition>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { Transition } from 'vue';
|
||||||
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
@@ -17,6 +21,10 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
.v-enter-active {
|
||||||
|
transition: opacity 0.5s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
.gw-div::first-letter {
|
.gw-div::first-letter {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
@@ -30,7 +38,13 @@
|
|||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
.default {
|
.default {
|
||||||
background-color: red;
|
background-color: rgb(79, 79, 79);
|
||||||
|
}
|
||||||
|
.more {
|
||||||
|
background-color: rgb(255, 0, 0);
|
||||||
|
}
|
||||||
|
.less {
|
||||||
|
background-color: rgb(129, 112, 0);
|
||||||
}
|
}
|
||||||
.cw-cp {
|
.cw-cp {
|
||||||
background-color: rgb(0, 122, 2);
|
background-color: rgb(0, 122, 2);
|
||||||
|
|||||||
@@ -25,17 +25,21 @@
|
|||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
onSubmit() {
|
onSubmit() {
|
||||||
axios
|
|
||||||
.post("/api/check_tla/en", {
|
if (this.words.length == 3) {
|
||||||
guess: this.guess,
|
console.log(this.words)
|
||||||
})
|
axios
|
||||||
.then((response) => {
|
.post("/api/check_tla/en", {
|
||||||
console.log(response.data);
|
guess: this.words,
|
||||||
this.guesses = response.data.guesses;
|
})
|
||||||
})
|
.then((response) => {
|
||||||
|
console.log(response.data);
|
||||||
|
this.guesses = response.data.guesses;
|
||||||
|
})
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onkeyup() {
|
onkeyup() {
|
||||||
this.words = this.guess.trim().split(" ");
|
this.words = this.guess.trim().split(/\W+/);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -64,13 +68,13 @@
|
|||||||
|
|
||||||
<div class="flex-container">
|
<div class="flex-container">
|
||||||
<template v-for="word in words">
|
<template v-for="word in words">
|
||||||
<GuessWord :correctness="-1">
|
<GuessWord :correctness="words.length == 3 ? -1 : (words.length > 3 ? -2 : -3)">
|
||||||
{{ word }}
|
{{ word }}
|
||||||
</GuessWord>
|
</GuessWord>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
<form @submit="onSubmit" onsubmit="return false">
|
<form @submit="onSubmit" onsubmit="return false">
|
||||||
<input type="text" @keyup="onkeyup" v-model="guess">
|
<input type="text" @keyup="onkeyup()" v-model="guess">
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
Reference in New Issue
Block a user