8 Commits

4 changed files with 56 additions and 30 deletions

View File

@@ -89,7 +89,7 @@ Environment="DICTIONARY_LIST=/srv/www_data/alfagok.example.com/dictionary.txt"
Environment="STATIC_DIR=/srv/www/alfagok.example.com/alfagok/src/alfagok/static"
Environment="TEMPLATE_DIR=/srv/www/alfagok.example.com/alfagok/src/alfagok/templates"
ExecStart=/srv/www/alfagok.example.com/venv/bin/gunicorn -c /srv/www/_webconfig/sites/alfagok.diginaut.net/gunicorn_alfagok_conf.py alfagok.main:app
ExecStart=/srv/www/alfagok.example.com/venv/bin/gunicorn -c /srv/www/_webconfig/sites/alfagok.example.com/gunicorn_alfagok_conf.py alfagok.main:app
[Install]
WantedBy=multi-user.target

View File

@@ -7,6 +7,8 @@ body {
padding: 2rem 1rem;
}
[x-cloak] { display: none !important; }
a.title {
color: #FF9800;
font-weight: bold;
@@ -23,12 +25,16 @@ a.title {
float: right;
}
#container center {
padding-top: 2rem;
}
.instructions {
padding: 2rem 0 0 0;
}
.guessesbefore {
padding-top: 2rem;
.guessesheading {
color: #CCC;;
}
input[type="text"] {
@@ -61,3 +67,12 @@ input[type="text"], button, .error {
padding: .5rem;
font-size: 1.5rem;
}
.win {
background-color: rgb(42 73 54);
padding: 1rem;
}
.results {
background-color: #333;
}

View File

@@ -16,6 +16,10 @@ document.addEventListener('alpine:init', () => {
guessError: '',
resultGameID: '',
resultGuesses: '',
resultTimeTaken: '',
async getGameID() {
/* Get the game number from the backend */
this.loading = true;
@@ -30,7 +34,6 @@ document.addEventListener('alpine:init', () => {
},
async doGuess() {
/* Check guess against server */
this.guessError = null;
this.guessValue = this.guessValue.toLowerCase();
@@ -46,11 +49,12 @@ document.addEventListener('alpine:init', () => {
}
this.nrGuesses++;
if (this.startTime === '') {
if (this.startTime === null) {
console.log('Setting startTime to now');
this.startTime = now();
this.startTime = new Date();
}
/* Check guess against server */
this.loading = true;
let response = await fetch('/api/guess/' + this.guessValue);
@@ -69,14 +73,19 @@ document.addEventListener('alpine:init', () => {
if (result.hint && result.hint === 'after') {
this.guessesBefore.push(this.guessValue);
this.guessesBefore.sort();
this.guessValue = '';
}
if (result.hint && result.hint === 'before') {
this.guessesAfter.push(this.guessValue);
this.guessesAfter.sort();
this.guessValue = '';
}
if (result.hint && result.hint === 'it') {
console.log('gevonden!');
this.winTime = now();
this.winTime = new Date();
this.resultGameID = '🧩 Puzzel #' + this.gameID;
this.resultGuesses = '🤔 '+ this.nrGuesses + ' gokken';
this.resultTimeTaken = '⏱️ ' + getFormattedTime(this.winTime - this.startTime);
}
}
}),
@@ -111,7 +120,7 @@ function getFormattedTime(milliseconds) {
const formattedTime = [];
if (hours) {
formattedTime.push(`${hours}h`);
formattedTime.push(`${hours}u`);
}
if (minutes) {
formattedTime.push(`${minutes}m`);

View File

@@ -20,42 +20,44 @@
<center>
<p class="guessesheading" x-cloak x-show="$store.alfagok.guessesBefore.length">Het woord van de dag komt <em>na</em>:</p>
<ul class="guessesbefore">
<template x-for="item in $store.alfagok.guessesBefore" :key="item">
<li x-text="item"></li>
</template>
</ul>
<input type="text" autocomplete="new-password" autocorrect="off" x-model="$store.alfagok.guessValue" @keyup.enter="$store.alfagok.doGuess()">
<div x-show="!$store.alfagok.winTime">
<input type="text" autocomplete="new-password" autocorrect="off" x-model="$store.alfagok.guessValue" @keyup.enter="$store.alfagok.doGuess()">
{# <p x-cloak>Je huidige gok is: <span x-text="$store.alfagok.guessValue"></span></p>#}
<button @click="$store.alfagok.doGuess()">Doe een gok</button>
<p class="error" x-show="$store.alfagok.guessError" x-text="$store.alfagok.guessError"></p>
<button @click="$store.alfagok.doGuess()">Doe een gok</button>
<p class="error" x-cloak x-show="$store.alfagok.guessError" x-text="$store.alfagok.guessError"></p>
</div>
<div x-cloak x-show="$store.alfagok.winTime" class="win">
<h3><b>Je hebt hem! 🎉</b></h3>
<p>Het woord van vandaag was <b x-text="$store.alfagok.guessValue"></b>.</p>
<div id="stats">
<div id="results">
<p><b x-text="$store.alfagok.resultGameID"></b></p>
<p x-text="$store.alfagok.resultGuesses"></p>
<p x-text="$store.alfagok.resultTimeTaken"></p>
<p>🔗 <span style="color:var(--blue)">alfagok.diginaut.net</span></p>
</div>
</div>
<div id="copyresults"></div>
<button class="copy" data-clipboard-target="#results">
Tik om te kopi&euml;ren en te delen ❤️
</button>
</div>
<p class="guessesheading" x-cloak x-show="$store.alfagok.guessesAfter.length">Het woord van de dag komt <em>voor</em>:</p>
<ul class="guessesafter">
<template x-for="item in $store.alfagok.guessesAfter" :key="item">
<li x-text="item"></li>
</template>
</ul>
<div>
<div x-show="$store.alfagok.winTime" class="win">
<h3><b>Je hebt hem! 🎉</b></h3>
<p>Het woord van vandaag was <b x-text="$store.alfagok.guessValue"></b>.</p>
<div id="stats">
<div id="results">
<p><b x-data="{ message: '🧩 Puzzel #' + $store.alfagok.gameID }" x-text="message"></b></p>
<p x-data="{ message: '🤔 '+ $store.alfagok.nrGuesses + ' gokken' }" x-text="message"></p>
<p x-data="{ message: '⏱️ ' + getFormattedTime($store.alfagok.winTime - $store.alfagok.startTime) }" x-text="message"></p>
<p>🔗 <span style="color:var(--blue)">alfagok.diginaut.net</span></p>
</div>
</div>
<div id="copyresults"></div>
<button class="copy" data-clipboard-target="#results">
Tik om te kopi&euml;ren en te delen ❤️
</button>
</div>
</div>
</center>
</div>