Compare commits
18
Commits
853498e9ac
...
dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ee9a1f2e13 | ||
|
|
dada5855ab | ||
|
|
890bb53ef6 | ||
|
|
2bce3f9a71 | ||
|
|
5613a95063 | ||
|
|
cc892fdebf | ||
|
|
c1fcb34ee5 | ||
|
|
836c83b473 | ||
|
|
5d5250287d | ||
|
|
865ac153b2 | ||
|
|
a79363b4da | ||
|
|
cab6a3e7f1 | ||
|
|
0395c01cdf | ||
|
|
0a605fce7c | ||
|
|
9af75a0781 | ||
|
|
6ac21fc4ca | ||
|
|
eca1bf138c | ||
|
|
73b0f6527a |
@@ -7,7 +7,7 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
IMAGE_NAME: tladle
|
IMAGE_NAME: tladle
|
||||||
REGISTRY_NAME: gitea.sc0tt.org
|
REGISTRY_NAME: gitea.sc0tt.org
|
||||||
GIT_TAG: 1.2.1
|
GIT_TAG: 2.0
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources\TlaSuggestions\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Resources\TlaSuggestions\TlaSuggestionResource;
|
||||||
|
use Filament\Actions\CreateAction;
|
||||||
|
use Filament\Resources\Pages\ManageRecords;
|
||||||
|
|
||||||
|
class ManageTlaSuggestions extends ManageRecords
|
||||||
|
{
|
||||||
|
protected static string $resource = TlaSuggestionResource::class;
|
||||||
|
|
||||||
|
protected function getHeaderActions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
CreateAction::make(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,96 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources\TlaSuggestions;
|
||||||
|
|
||||||
|
use App\Filament\Resources\TlaSuggestions\Pages\ManageTlaSuggestions;
|
||||||
|
use App\Models\TlaSuggestion;
|
||||||
|
use BackedEnum;
|
||||||
|
use Filament\Actions\BulkActionGroup;
|
||||||
|
use Filament\Actions\DeleteAction;
|
||||||
|
use Filament\Actions\DeleteBulkAction;
|
||||||
|
use Filament\Actions\EditAction;
|
||||||
|
use Filament\Forms\Components\Select;
|
||||||
|
use Filament\Forms\Components\TextInput;
|
||||||
|
use Filament\Forms\Components\Textarea;
|
||||||
|
use Filament\Resources\Resource;
|
||||||
|
use Filament\Schemas\Schema;
|
||||||
|
use Filament\Support\Icons\Heroicon;
|
||||||
|
use Filament\Tables\Columns\TextColumn;
|
||||||
|
use Filament\Tables\Table;
|
||||||
|
use Filament\Actions\Action;
|
||||||
|
|
||||||
|
class TlaSuggestionResource extends Resource
|
||||||
|
{
|
||||||
|
protected static ?string $model = TlaSuggestion::class;
|
||||||
|
|
||||||
|
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedRectangleStack;
|
||||||
|
|
||||||
|
protected static ?string $recordTitleAttribute = 'Suggestions';
|
||||||
|
|
||||||
|
public static function form(Schema $schema): Schema
|
||||||
|
{
|
||||||
|
return $schema
|
||||||
|
->components([
|
||||||
|
TextInput::make('acronym')
|
||||||
|
->required(),
|
||||||
|
TextInput::make('hint')
|
||||||
|
->default(null),
|
||||||
|
Select::make('language')
|
||||||
|
->options(['hu' => 'Hu', 'en' => 'En'])
|
||||||
|
->required(),
|
||||||
|
Textarea::make('context')
|
||||||
|
->default(null)
|
||||||
|
->columnSpanFull(),
|
||||||
|
TextInput::make('submitter')
|
||||||
|
->default(null),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function table(Table $table): Table
|
||||||
|
{
|
||||||
|
return $table
|
||||||
|
->recordTitleAttribute('Suggestions')
|
||||||
|
->columns([
|
||||||
|
TextColumn::make('acronym')
|
||||||
|
->searchable(),
|
||||||
|
TextColumn::make('hint')
|
||||||
|
->searchable(),
|
||||||
|
TextColumn::make('language')
|
||||||
|
->badge(),
|
||||||
|
TextColumn::make('submitter')
|
||||||
|
->searchable(),
|
||||||
|
TextColumn::make('created_at')
|
||||||
|
->dateTime()
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
TextColumn::make('updated_at')
|
||||||
|
->dateTime()
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
])
|
||||||
|
->filters([
|
||||||
|
//
|
||||||
|
])
|
||||||
|
->recordActions([
|
||||||
|
EditAction::make(),
|
||||||
|
DeleteAction::make(),
|
||||||
|
Action::make('Approve')
|
||||||
|
->action(fn (TlaSuggestion $record) => TlaSuggestion::ApproveTla($record))
|
||||||
|
->requiresConfirmation()
|
||||||
|
->modalHeading('Approve TLA')
|
||||||
|
->modalDescription('Are you sure you want to approve this TLA?')
|
||||||
|
])
|
||||||
|
->toolbarActions([
|
||||||
|
BulkActionGroup::make([
|
||||||
|
DeleteBulkAction::make(),
|
||||||
|
]),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getPages(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'index' => ManageTlaSuggestions::route('/'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -31,7 +31,7 @@ class TlasTable
|
|||||||
->dateTime()
|
->dateTime()
|
||||||
->sortable()
|
->sortable()
|
||||||
->toggleable(isToggledHiddenByDefault: true),
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
])
|
])->defaultSort('used', direction: 'asc')
|
||||||
->filters([
|
->filters([
|
||||||
//
|
//
|
||||||
])
|
])
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ class TlaResource extends Resource
|
|||||||
|
|
||||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedRectangleStack;
|
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedRectangleStack;
|
||||||
|
|
||||||
protected static ?string $recordTitleAttribute = 'tla';
|
protected static ?string $recordTitleAttribute = 'Tla';
|
||||||
|
|
||||||
public static function form(Schema $schema): Schema
|
public static function form(Schema $schema): Schema
|
||||||
{
|
{
|
||||||
@@ -42,13 +42,23 @@ class TlaResource extends Resource
|
|||||||
Textarea::make('context')
|
Textarea::make('context')
|
||||||
->default(null)
|
->default(null)
|
||||||
->columnSpanFull(),
|
->columnSpanFull(),
|
||||||
|
TextInput::make('submitter')
|
||||||
|
->default(null),
|
||||||
|
TextInput::make('likes')
|
||||||
|
->required()
|
||||||
|
->numeric()
|
||||||
|
->default(0),
|
||||||
|
TextInput::make('dislikes')
|
||||||
|
->required()
|
||||||
|
->numeric()
|
||||||
|
->default(0),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function table(Table $table): Table
|
public static function table(Table $table): Table
|
||||||
{
|
{
|
||||||
return $table
|
return $table
|
||||||
->recordTitleAttribute('tla')
|
->recordTitleAttribute('Tla')
|
||||||
->columns([
|
->columns([
|
||||||
TextColumn::make('acronym')
|
TextColumn::make('acronym')
|
||||||
->searchable(),
|
->searchable(),
|
||||||
@@ -59,6 +69,14 @@ class TlaResource extends Resource
|
|||||||
TextColumn::make('used')
|
TextColumn::make('used')
|
||||||
->date()
|
->date()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
|
TextColumn::make('submitter')
|
||||||
|
->searchable(),
|
||||||
|
TextColumn::make('likes')
|
||||||
|
->numeric()
|
||||||
|
->sortable(),
|
||||||
|
TextColumn::make('dislikes')
|
||||||
|
->numeric()
|
||||||
|
->sortable(),
|
||||||
TextColumn::make('created_at')
|
TextColumn::make('created_at')
|
||||||
->dateTime()
|
->dateTime()
|
||||||
->sortable()
|
->sortable()
|
||||||
@@ -80,6 +98,7 @@ class TlaResource extends Resource
|
|||||||
DeleteBulkAction::make(),
|
DeleteBulkAction::make(),
|
||||||
]),
|
]),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getPages(): array
|
public static function getPages(): array
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ class TlaController extends Controller
|
|||||||
$session->forget('tla-'.$language);
|
$session->forget('tla-'.$language);
|
||||||
$session->forget('correct-'.$language);
|
$session->forget('correct-'.$language);
|
||||||
$session->forget('review-'.$language);
|
$session->forget('review-'.$language);
|
||||||
|
$session->put('tla-array-'.$language, ['', '', '']);
|
||||||
$session->put('date-'.$language, date('Y-m-d'));
|
$session->put('date-'.$language, date('Y-m-d'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -27,6 +28,9 @@ class TlaController extends Controller
|
|||||||
if ( !in_array($language, $allowedLanguages) ) $language = 'en';
|
if ( !in_array($language, $allowedLanguages) ) $language = 'en';
|
||||||
|
|
||||||
$tla = Tla::GetCurrentTla($language);
|
$tla = Tla::GetCurrentTla($language);
|
||||||
|
|
||||||
|
if ($tla == NULL) return response()->json([ 'no_tla' => true ]);
|
||||||
|
|
||||||
$this->session_flush($request, $language);
|
$this->session_flush($request, $language);
|
||||||
|
|
||||||
$session = $request->session();
|
$session = $request->session();
|
||||||
@@ -37,7 +41,9 @@ class TlaController extends Controller
|
|||||||
'date' => $session->get('date-'.$language),
|
'date' => $session->get('date-'.$language),
|
||||||
'tla' => $session->get('tla-'.$language) == $tla->acronym ? $tla->acronym : NULL,
|
'tla' => $session->get('tla-'.$language) == $tla->acronym ? $tla->acronym : NULL,
|
||||||
'context' => $session->get('tla-'.$language) == $tla->acronym ? $tla->context : NULL,
|
'context' => $session->get('tla-'.$language) == $tla->acronym ? $tla->context : NULL,
|
||||||
|
'submitter' => $tla->submitter,
|
||||||
'correct' => $session->get('correct-'.$language),
|
'correct' => $session->get('correct-'.$language),
|
||||||
|
'tla_array' => $session->get('tla-array-'.$language),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,6 +101,14 @@ class TlaController extends Controller
|
|||||||
if ($score == 12) $session->put('correct-'.$language, true);
|
if ($score == 12) $session->put('correct-'.$language, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$tla_array = $session->get('tla-array-'.$language);
|
||||||
|
|
||||||
|
for ($i = 0; $i < 3; $i++) {
|
||||||
|
if ($tla_array[$i] == "" && $guess_array[$i + 3] == 2) $tla_array[$i] = $tla[$i];
|
||||||
|
}
|
||||||
|
|
||||||
|
$session->put('tla-array-'.$language, $tla_array);
|
||||||
|
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'guesses' => $guesses,
|
'guesses' => $guesses,
|
||||||
'date' => $session->get('date'),
|
'date' => $session->get('date'),
|
||||||
@@ -102,6 +116,7 @@ class TlaController extends Controller
|
|||||||
'context' => $session->get('tla-'.$language) == $tla_object->acronym ? $tla_object->context : NULL,
|
'context' => $session->get('tla-'.$language) == $tla_object->acronym ? $tla_object->context : NULL,
|
||||||
'score' => $score,
|
'score' => $score,
|
||||||
'correct' => $session->get('correct-'.$language),
|
'correct' => $session->get('correct-'.$language),
|
||||||
|
'tla_array' => $tla_array,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-2
@@ -11,9 +11,9 @@ class Tla extends Model
|
|||||||
|
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
protected $fillable = ['acronym', 'hint', 'language', 'used', 'context', 'likes', 'dislikes'];
|
protected $fillable = ['acronym', 'hint', 'language', 'used', 'context', 'submitter', 'likes', 'dislikes'];
|
||||||
|
|
||||||
public static function GetCurrentTla( string $language ) : Tla {
|
public static function GetCurrentTla( string $language ) {
|
||||||
$tla = Tla::where('used', date("Y-m-d"))
|
$tla = Tla::where('used', date("Y-m-d"))
|
||||||
->where('language', $language)
|
->where('language', $language)
|
||||||
->first();
|
->first();
|
||||||
@@ -24,6 +24,8 @@ class Tla extends Model
|
|||||||
->inRandomOrder()
|
->inRandomOrder()
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
|
if ($tla == NULL) return NULL;
|
||||||
|
|
||||||
$tla->used = date("Y-m-d");
|
$tla->used = date("Y-m-d");
|
||||||
$tla->save();
|
$tla->save();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,18 @@
|
|||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
|
||||||
class TlaSuggestion extends Model
|
class TlaSuggestion extends Model
|
||||||
{
|
{
|
||||||
|
use HasFactory;
|
||||||
protected $table = 'tla_suggestion';
|
protected $table = 'tla_suggestion';
|
||||||
|
|
||||||
protected $fillable = ['acronym', 'hint', 'language', 'context', 'submitter'];
|
protected $fillable = ['acronym', 'hint', 'language', 'context', 'submitter'];
|
||||||
|
|
||||||
|
public static function ApproveTla(TlaSuggestion $record) {
|
||||||
|
$tla = new Tla($record->toArray());
|
||||||
|
$record->delete();
|
||||||
|
$tla->save();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,10 @@ return new class extends Migration
|
|||||||
public function up(): void
|
public function up(): void
|
||||||
{
|
{
|
||||||
Schema::table('tla_suggestion', function (Blueprint $table){
|
Schema::table('tla_suggestion', function (Blueprint $table){
|
||||||
$table->string('submitter')->default('Anonymus')->after('context');
|
$table->string('submitter')->nullable()->after('context');
|
||||||
|
});
|
||||||
|
Schema::table('tla', function (Blueprint $table){
|
||||||
|
$table->string('submitter')->nullable()->after('context');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,11 @@
|
|||||||
|
|
||||||
:root {
|
:root {
|
||||||
--ui-primary: rgb(255, 200, 0);
|
--ui-primary: rgb(255, 200, 0);
|
||||||
|
|
||||||
|
--correct-guess: rgb(0, 126, 2);
|
||||||
|
--partial-correct-guess: rgb(37, 43, 154);
|
||||||
|
--incorrect-guess: rgb(79, 79, 79);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.main {
|
.main {
|
||||||
|
|||||||
@@ -1,20 +1,39 @@
|
|||||||
<template>
|
<template>
|
||||||
<Transition appear>
|
<button v-if="true"
|
||||||
<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 }">
|
@click="onclick"
|
||||||
|
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
|
||||||
|
}">
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
</div>
|
</button>
|
||||||
</Transition>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Transition } from 'vue';
|
|
||||||
export default {
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
modal_open: false,
|
||||||
|
}
|
||||||
|
},
|
||||||
props: {
|
props: {
|
||||||
correctness: {
|
correctness: {
|
||||||
type: Number,
|
type: Number,
|
||||||
default: 0,
|
default: 0,
|
||||||
},
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
onclick () {
|
||||||
|
if (this.correctness == 2) this.$emit('pressed_wordle');
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -22,8 +41,6 @@ import { Transition } from 'vue';
|
|||||||
.v-enter-active {
|
.v-enter-active {
|
||||||
transition: opacity 0.5s ease;
|
transition: opacity 0.5s ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.gw-div::first-letter {
|
.gw-div::first-letter {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
@@ -35,8 +52,11 @@ import { Transition } from 'vue';
|
|||||||
background-color: grey;
|
background-color: grey;
|
||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
|
.gw-button {
|
||||||
|
}
|
||||||
|
|
||||||
.default {
|
.default {
|
||||||
background-color: rgb(79, 79, 79);
|
background-color: var(--incorrect-guess)
|
||||||
}
|
}
|
||||||
.more {
|
.more {
|
||||||
background-color: rgb(255, 0, 0);
|
background-color: rgb(255, 0, 0);
|
||||||
@@ -45,13 +65,20 @@ import { Transition } from 'vue';
|
|||||||
background-color: rgb(129, 112, 0);
|
background-color: rgb(129, 112, 0);
|
||||||
}
|
}
|
||||||
.cw-cp {
|
.cw-cp {
|
||||||
background-color: rgb(0, 126, 2);
|
background-color: var(--correct-guess)
|
||||||
}
|
}
|
||||||
.cw-ip {
|
.cw-ip {
|
||||||
background-color: rgb(98, 175, 99);
|
background-color: rgb(98, 175, 99);
|
||||||
}
|
}
|
||||||
.cf-cp {
|
.cf-cp {
|
||||||
background-color: rgb(37, 43, 154);
|
background-color: var(--partial-correct-guess);
|
||||||
|
border: solid white;
|
||||||
|
}
|
||||||
|
.cf-cp.hover {
|
||||||
|
background-color: #4CAF50; /* Green */
|
||||||
|
}
|
||||||
|
.cf-cp.focus {
|
||||||
|
background-color: red;
|
||||||
}
|
}
|
||||||
.cf-ip {
|
.cf-ip {
|
||||||
background-color: rgb(106, 108, 160);
|
background-color: rgb(106, 108, 160);
|
||||||
|
|||||||
@@ -35,8 +35,10 @@
|
|||||||
<GuessWord :correctness="4">Acronym</GuessWord>
|
<GuessWord :correctness="4">Acronym</GuessWord>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
If you manage to figure out a letter in its correct position you unlock a mini wordle for that specific word. Press the word if it has a white outline to launch it!
|
||||||
|
|
||||||
If you have any feedback, <a style="text-decoration: underline;" href="mailto:peter@sc0tt.org">
|
If you have any feedback, <a style="text-decoration: underline;" href="mailto:peter@sc0tt.org">
|
||||||
let me know in an email</a>, or create a <a style="text-decoration: underline;" href='https://gitea.sc0tt.org/Belupeti/TLA/pulls'>pull request</a>
|
let me know in an email</a>, or create an <a style="text-decoration: underline;" href='https://gitea.sc0tt.org/Belupeti/TLA/pulls'>issue</a>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
</UModal>
|
</UModal>
|
||||||
|
|||||||
@@ -0,0 +1,91 @@
|
|||||||
|
<template>
|
||||||
|
<Modal v-model:open="open">
|
||||||
|
|
||||||
|
<h1>Wordle for word {{ index }}</h1>
|
||||||
|
<br>
|
||||||
|
<div class="flex-container-a gap-1.5">
|
||||||
|
<template v-for="i in max_guesses">
|
||||||
|
<WordleRow v-if="guesses.length > i" :guess="guesses[i]" :length="correct.length" :correct="correct"/>
|
||||||
|
|
||||||
|
<UForm @submit="onsubmit" v-if="guesses.length == i">
|
||||||
|
<UPinInput v-if="guesses[guesses.length-1].toString().replace(/\,/gi, '') != correct" default class="mb-2" autofocus v-model="guess" color="neutral" :length="correct.length" size="md" :correct="correct" />
|
||||||
|
|
||||||
|
<WordleRow v-else :length="correct.length"/>
|
||||||
|
|
||||||
|
<UButton type="submit" style="display: none;">
|
||||||
|
Submit
|
||||||
|
</UButton>
|
||||||
|
</UForm>
|
||||||
|
|
||||||
|
<WordleRow v-if="guesses.length < i" :length="correct.length"/>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template v-if="guesses[guesses.length-1].toString().replace(/\,/gi, '') == correct">
|
||||||
|
You guessed word #{{ index }}! It was '{{ correct }}'
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<UButton @click="onsubmit" class="m-3" v-if="guesses[guesses.length-1].toString().replace(/\,/gi, '') != correct">
|
||||||
|
Submit
|
||||||
|
</UButton>
|
||||||
|
</Modal>
|
||||||
|
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import Modal from './Modal.vue';
|
||||||
|
import WordleRow from './WordleRow.vue';
|
||||||
|
</script>
|
||||||
|
<script lang="ts">
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
max_guesses: 10,
|
||||||
|
open: true,
|
||||||
|
guess: '',
|
||||||
|
guesses: [''],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
correct: {
|
||||||
|
type: String,
|
||||||
|
default: 'nagyonhosszezugyselesz'
|
||||||
|
},
|
||||||
|
index: {
|
||||||
|
type: Number,
|
||||||
|
default: 0,
|
||||||
|
},
|
||||||
|
date: {
|
||||||
|
type: String,
|
||||||
|
default: '1970-01-01',
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
if (localStorage.date) {
|
||||||
|
if (localStorage.date === this.date) this.guesses = JSON.parse(localStorage.getItem('guesses-' + this.index) || '[""]'); console.log(this.guesses);
|
||||||
|
} else localStorage.date = this.date;
|
||||||
|
|
||||||
|
this.max_guesses = this.correct.length > 5 ? this.correct.length : 6
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
onsubmit () {
|
||||||
|
if (this.guess.length == this.correct.length) {
|
||||||
|
this.guesses.push(this.guess);
|
||||||
|
this.guess = '';
|
||||||
|
|
||||||
|
localStorage.setItem('guesses-' + this.index, JSON.stringify(this.guesses));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.flex-container-a {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="flex-container gap-1.5">
|
||||||
|
<div v-for="i in length" class="border border-default wr-div" :class="{'correct' : getCorrectness[i-1]==2, 'wrong-place' : getCorrectness[i-1]==1, 'incorrect' : getCorrectness[i-1]==0}" >
|
||||||
|
{{ guess[i-1] }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
}
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
correct: {
|
||||||
|
type: String,
|
||||||
|
default: 'testword',
|
||||||
|
},
|
||||||
|
guess: {
|
||||||
|
type: String,
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
|
index: Number,
|
||||||
|
empty: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
length: Number,
|
||||||
|
},
|
||||||
|
|
||||||
|
computed: {
|
||||||
|
getCorrectness() : number[] {
|
||||||
|
let correctness_alt = [];
|
||||||
|
let correctness = [];
|
||||||
|
for (let i = 0; i < this.guess.length; i++) {
|
||||||
|
if (this.guess[i] == this.correct[i]) {
|
||||||
|
correctness.push(2);
|
||||||
|
} else correctness.push(0);
|
||||||
|
}
|
||||||
|
correctness_alt = correctness.slice();
|
||||||
|
|
||||||
|
for (let i = 0; i < this.guess.length; i++) {
|
||||||
|
for (let j = 0; j < this.correct.length; j++) {
|
||||||
|
if (this.guess[i] == this.correct[j] && correctness[i] == 0 && correctness_alt[j] == 0) {
|
||||||
|
correctness[i] = 1;
|
||||||
|
correctness_alt[j] = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return correctness;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.wr-div {
|
||||||
|
justify-content: center;
|
||||||
|
border-radius: 6px;
|
||||||
|
width: 32px;
|
||||||
|
height: 32px;
|
||||||
|
line-height: 32px;
|
||||||
|
background-color: transparent;
|
||||||
|
text-transform: uppercase;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
.correct {
|
||||||
|
background-color: rgb(0, 126, 2);
|
||||||
|
}
|
||||||
|
.incorrect {
|
||||||
|
background-color: var(--incorrect-guess);
|
||||||
|
}
|
||||||
|
.wrong-place {
|
||||||
|
background-color: var(--partial-correct-guess);
|
||||||
|
}
|
||||||
|
.empty {
|
||||||
|
background-color: var(--incorrect-guess);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
import GuessWord from '../components/GuessWord.vue';
|
import GuessWord from '../components/GuessWord.vue';
|
||||||
import Modal from '../components/Modal.vue';
|
import Modal from '../components/Modal.vue';
|
||||||
import Review from '../components/Review.vue';
|
import Review from '../components/Review.vue';
|
||||||
|
import Wordle from '../components/Wordle.vue';
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
@@ -10,15 +11,22 @@
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
hint: ' ',
|
hint: ' ',
|
||||||
guesses: [' '],
|
guesses: [''],
|
||||||
words: [' '],
|
words: [''],
|
||||||
|
correct_words: [''],
|
||||||
guess: '',
|
guess: '',
|
||||||
tla: '',
|
tla: '',
|
||||||
context: '',
|
context: '',
|
||||||
|
submitter: '',
|
||||||
|
date: '',
|
||||||
victory: false,
|
victory: false,
|
||||||
loss: false,
|
loss: false,
|
||||||
maxGuesses: 10,
|
maxGuesses: 10,
|
||||||
correct: false,
|
correct: false,
|
||||||
|
no_tla: false,
|
||||||
|
wordle_open: [false, false, false],
|
||||||
|
wordle_dontshow: false,
|
||||||
|
wordle_hint: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -26,12 +34,22 @@
|
|||||||
axios
|
axios
|
||||||
.get('/api/fetch_tla/en')
|
.get('/api/fetch_tla/en')
|
||||||
.then(response => {
|
.then(response => {
|
||||||
|
if (response.data.no_tla) this.no_tla = true;
|
||||||
|
else {
|
||||||
this.hint = response.data.hint;
|
this.hint = response.data.hint;
|
||||||
|
this.submitter = response.data.submitter;
|
||||||
this.guesses = response.data.guesses;
|
this.guesses = response.data.guesses;
|
||||||
this.tla = response.data.tla;
|
this.tla = response.data.tla;
|
||||||
this.context = response.data.context;
|
this.context = response.data.context;
|
||||||
this.correct = response.data.correct;
|
this.correct = response.data.correct;
|
||||||
|
this.correct_words = response.data.tla_array;
|
||||||
|
this.date = response.data.date;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (localStorage.wordle_dontshow) {
|
||||||
|
this.wordle_dontshow = localStorage.wordle_dontshow;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
@@ -46,6 +64,7 @@
|
|||||||
this.guesses = response.data.guesses;
|
this.guesses = response.data.guesses;
|
||||||
this.guess = '';
|
this.guess = '';
|
||||||
this.words = [];
|
this.words = [];
|
||||||
|
this.correct_words = response.data.tla_array;
|
||||||
|
|
||||||
let current_guess = response.data.guesses[response.data.guesses.length-1]
|
let current_guess = response.data.guesses[response.data.guesses.length-1]
|
||||||
if (Number(current_guess[3]) + Number(current_guess[4]) + Number(current_guess[5]) == 12) {
|
if (Number(current_guess[3]) + Number(current_guess[4]) + Number(current_guess[5]) == 12) {
|
||||||
@@ -65,6 +84,10 @@
|
|||||||
},
|
},
|
||||||
onkeyup() {
|
onkeyup() {
|
||||||
this.words = this.guess.trim().split(/\s+/);
|
this.words = this.guess.trim().split(/\s+/);
|
||||||
|
},
|
||||||
|
wordle_disable() {
|
||||||
|
this.wordle_dontshow = true;
|
||||||
|
localStorage.wordle_dontshow = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -82,20 +105,18 @@
|
|||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template v-for="guess in guesses">
|
<template v-for="guess in guesses" v-if="guesses.length>0">
|
||||||
<div class="flex-container">
|
<div class="flex-container">
|
||||||
<template v-for="i in 3">
|
<template v-for="i in 3">
|
||||||
<GuessWord :correctness="Number(guess[i+2])">
|
<GuessWord @pressed_wordle="wordle_open[i-1] = true" :correctness="Number(guess[i+2])" :index="i-1">
|
||||||
{{ guess[i-1] }}
|
{{ guess[i-1] }}
|
||||||
</GuessWord>
|
</GuessWord>
|
||||||
|
<Wordle v-model:open="wordle_open[i-1]" :correct="correct_words[i-1]" :index="i" :date="date"/>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<template v-if="guesses.length < maxGuesses && !correct && !no_tla">
|
||||||
<template #footer>
|
|
||||||
|
|
||||||
<template v-if="guesses.length < maxGuesses && !correct">
|
|
||||||
<div class="flex-container" v-if="guess.length > 0">
|
<div class="flex-container" v-if="guess.length > 0">
|
||||||
<template v-for="word in words">
|
<template v-for="word in words">
|
||||||
<GuessWord :correctness="words.length == 3 ? -1 : (words.length > 3 ? -2 : -3)">
|
<GuessWord :correctness="words.length == 3 ? -1 : (words.length > 3 ? -2 : -3)">
|
||||||
@@ -113,6 +134,10 @@
|
|||||||
</UButton>
|
</UButton>
|
||||||
</UForm>
|
</UForm>
|
||||||
</template>
|
</template>
|
||||||
|
<template v-if="no_tla">
|
||||||
|
<h2>No TLA for today, please shoot me an email to <a style="text-decoration: underline;" href="mailto:peter@sc0tt.org">
|
||||||
|
peter@sc0tt.org</a></h2>
|
||||||
|
</template>
|
||||||
<template v-if="!correct && guesses.length >= maxGuesses">
|
<template v-if="!correct && guesses.length >= maxGuesses">
|
||||||
You ran out of guesses. Todays TLA was <b>{{ tla }}</b>
|
You ran out of guesses. Todays TLA was <b>{{ tla }}</b>
|
||||||
<Review/>
|
<Review/>
|
||||||
@@ -121,10 +146,16 @@
|
|||||||
You completed todays TLAdle! Todays TLA was <b>{{ tla }}</b>
|
You completed todays TLAdle! Todays TLA was <b>{{ tla }}</b>
|
||||||
<Review/>
|
<Review/>
|
||||||
</template>
|
</template>
|
||||||
<h3>Guesses left: {{ maxGuesses - guesses.length }}</h3>
|
<h3 v-if="!no_tla">Guesses left: {{ maxGuesses - guesses.length }}</h3>
|
||||||
|
|
||||||
</template>
|
|
||||||
</UCard>
|
</UCard>
|
||||||
|
<br>
|
||||||
|
<template v-if="submitter != null">
|
||||||
|
Todays TLA was submitted by <b>{{ submitter }}</b>
|
||||||
|
<br><br>
|
||||||
|
</template>
|
||||||
|
<UButton to="/suggestion" color="neutral" variant="subtle">
|
||||||
|
Suggest a TLA!
|
||||||
|
</UButton>
|
||||||
|
|
||||||
<Modal v-model:open="victory">
|
<Modal v-model:open="victory">
|
||||||
<h1>Congratulations!</h1>
|
<h1>Congratulations!</h1>
|
||||||
@@ -139,6 +170,27 @@
|
|||||||
{{ context }}
|
{{ context }}
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
<UForm @submit="wordle_disable" v-if="!wordle_dontshow">
|
||||||
|
<UAlert
|
||||||
|
title="Press the word if the starting letter is correct to launch a mini wordle!"
|
||||||
|
color="success"
|
||||||
|
style="text-align: left; margin-top: 10px;"
|
||||||
|
variant="subtle"
|
||||||
|
orientation="horizontal"
|
||||||
|
:actions="[
|
||||||
|
{
|
||||||
|
label: 'Don\'t show again',
|
||||||
|
color: 'warning',
|
||||||
|
type: 'submit',
|
||||||
|
variant: 'subtle'
|
||||||
|
}
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</UForm>
|
||||||
|
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import Modal from '../components/Modal.vue';
|
||||||
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<h1>TLA suggestion form</h1>
|
<h1>TLA suggestion form</h1>
|
||||||
<UCard class="w-140 align-center">
|
<br>
|
||||||
|
<UCard class="align-center">
|
||||||
|
|
||||||
<UForm @submit="onSubmit" class="space-y-4" action="/api/suggestion" method="post">
|
<UForm @submit="onSubmit" class="space-y-4" action="/api/suggestion" method="post">
|
||||||
<UFormField class="form-field" label="Acronym" required>
|
<UFormField class="form-field" label="Acronym" required>
|
||||||
@@ -31,6 +36,9 @@
|
|||||||
If you wish, you can submit adnother TLA by exiting this alert. <br><br>
|
If you wish, you can submit adnother TLA by exiting this alert. <br><br>
|
||||||
<UButton to="/">Main page</UButton>
|
<UButton to="/">Main page</UButton>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
<Modal v-model:open="missing_fields">
|
||||||
|
<b>Please fill out all required fields (marked with *)</b>
|
||||||
|
</Modal>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -45,7 +53,6 @@
|
|||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@@ -56,13 +63,16 @@ import axios from 'axios';
|
|||||||
language: '',
|
language: '',
|
||||||
submitter: '',
|
submitter: '',
|
||||||
},
|
},
|
||||||
|
missing_fields: false,
|
||||||
submited: false,
|
submited: false,
|
||||||
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
onSubmit() {
|
onSubmit() {
|
||||||
axios.post('/api/suggestion/en', this.form);
|
axios.post('/api/suggestion/en', this.form).then( response => {
|
||||||
|
if (response.status == 200)
|
||||||
|
{
|
||||||
this.form.acronym = '';
|
this.form.acronym = '';
|
||||||
this.form.hint = '';
|
this.form.hint = '';
|
||||||
this.form.context = '';
|
this.form.context = '';
|
||||||
@@ -70,6 +80,8 @@ import axios from 'axios';
|
|||||||
this.form.language = 'en';
|
this.form.language = 'en';
|
||||||
this.submited = true;
|
this.submited = true;
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -2,6 +2,6 @@
|
|||||||
|
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
Route::any('{all}',function(){
|
Route::get('{all}',function(){
|
||||||
return view('vue');
|
return view('vue');
|
||||||
})->where(['all' => '.*'])->name("vue");
|
})->where(['all' => '.*'])->name("vue");
|
||||||
|
|||||||
Reference in New Issue
Block a user