feat: Paint kanji grid row background green on completion
This commit is contained in:
parent
1db54a9235
commit
c49e62d052
|
@ -109,10 +109,23 @@ class KanjiController extends AbstractController
|
||||||
): Response {
|
): Response {
|
||||||
$charInfo = $this->getCharInfo(force: $request->isNoCache());
|
$charInfo = $this->getCharInfo(force: $request->isNoCache());
|
||||||
|
|
||||||
|
$completedRows = [];
|
||||||
|
$completedFlag = true;
|
||||||
$chars = [];
|
$chars = [];
|
||||||
foreach (range(intval("{$start}0", 16), intval("{$end}f", 16)) as $codepoint) {
|
foreach (range(intval("{$start}0", 16), intval("{$end}f", 16)) as $codepoint) {
|
||||||
$charStr = mb_chr($codepoint, 'UTF-8');
|
$charStr = mb_chr($codepoint, 'UTF-8');
|
||||||
|
|
||||||
|
if (
|
||||||
|
!key_exists('ignored', $charInfo[$charStr] ?? ['ignored' => 0])
|
||||||
|
and !key_exists('unicode', $charInfo[$charStr] ?? [])
|
||||||
|
) {
|
||||||
|
$completedFlag = false;
|
||||||
|
}
|
||||||
|
if (($codepoint + 1) % 0x10 === 0) {
|
||||||
|
if ($completedFlag === true) $completedRows[] = dechex($codepoint - 0xf);
|
||||||
|
$completedFlag = true;
|
||||||
|
}
|
||||||
|
|
||||||
$chars[] = [
|
$chars[] = [
|
||||||
'str' => $charStr,
|
'str' => $charStr,
|
||||||
'codepoint' => dechex($codepoint),
|
'codepoint' => dechex($codepoint),
|
||||||
|
@ -122,6 +135,7 @@ class KanjiController extends AbstractController
|
||||||
|
|
||||||
return $this->render(self::tmpl('grid'), [
|
return $this->render(self::tmpl('grid'), [
|
||||||
'characters' => $chars,
|
'characters' => $chars,
|
||||||
|
'completed' => $completedRows,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,8 @@
|
||||||
.ebook { border-top: 3px solid deeppink !important; }
|
.ebook { border-top: 3px solid deeppink !important; }
|
||||||
.jimaku { border-top: 3px solid lightgray !important; }
|
.jimaku { border-top: 3px solid lightgray !important; }
|
||||||
|
|
||||||
.none, .ignored { opacity: 0.15; }
|
.none, .ignored { opacity: 0.15; }
|
||||||
|
.completed { background-color: rgba(0 255 0 / 0.05); }
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
|
@ -71,12 +72,18 @@
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="d-flex flex-wrap p-4"
|
class="pd-flex flex-column"
|
||||||
|
|
||||||
hx-target="#baseModalContent"
|
hx-target="#baseModalContent"
|
||||||
hx-swap="innerHTML"
|
hx-swap="innerHTML"
|
||||||
>
|
>
|
||||||
{% for char in characters %}
|
{% for char in characters %}
|
||||||
|
{% if char.codepoint ends with '0' %}
|
||||||
|
<div class="
|
||||||
|
d-flex p-1 ps-3 pe-3
|
||||||
|
{{ char.codepoint in completed ? 'completed' : '' }}
|
||||||
|
">
|
||||||
|
{% endif %}
|
||||||
<div style="width: calc(100% / 16);">
|
<div style="width: calc(100% / 16);">
|
||||||
<div
|
<div
|
||||||
class="
|
class="
|
||||||
|
@ -129,6 +136,9 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{% if char.codepoint ends with 'f' %}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue