clean up code in ZapHome and ZapDisplay (#19 and #20)

This commit is contained in:
Fabian de Boer 2026-07-20 01:14:00 +02:00
commit 3edb156749
5 changed files with 24 additions and 21 deletions

View file

@ -85,3 +85,9 @@
{"timestamp":"2026-07-19T21:49:54.312195218+02:00","action":"edit","task_id":21,"detail":"Consolidate duplicated screen-size constants"} {"timestamp":"2026-07-19T21:49:54.312195218+02:00","action":"edit","task_id":21,"detail":"Consolidate duplicated screen-size constants"}
{"timestamp":"2026-07-19T21:49:54.312297605+02:00","action":"claim","task_id":21,"detail":"rain-raven"} {"timestamp":"2026-07-19T21:49:54.312297605+02:00","action":"claim","task_id":21,"detail":"rain-raven"}
{"timestamp":"2026-07-19T21:49:54.334491216+02:00","action":"move","task_id":21,"detail":"todo -\u003e done"} {"timestamp":"2026-07-19T21:49:54.334491216+02:00","action":"move","task_id":21,"detail":"todo -\u003e done"}
{"timestamp":"2026-07-19T22:54:27.983080764+02:00","action":"edit","task_id":20,"detail":"Consistent template rendering pattern across all handlers"}
{"timestamp":"2026-07-19T22:54:27.98319541+02:00","action":"claim","task_id":20,"detail":"rain-raven"}
{"timestamp":"2026-07-19T22:54:28.007952955+02:00","action":"move","task_id":20,"detail":"todo -\u003e done"}
{"timestamp":"2026-07-20T01:09:23.947300407+02:00","action":"edit","task_id":19,"detail":"Single source of truth for word count + cleanup handleWords"}
{"timestamp":"2026-07-20T01:09:23.947430566+02:00","action":"claim","task_id":19,"detail":"rain-raven"}
{"timestamp":"2026-07-20T01:09:23.97076796+02:00","action":"move","task_id":19,"detail":"todo -\u003e done"}

View file

@ -1,12 +1,16 @@
--- ---
id: 19 id: 19
title: Single source of truth for word count + cleanup handleWords title: Single source of truth for word count + cleanup handleWords
status: todo status: done
priority: low priority: low
created: 2026-07-17T03:58:05.365933671+02:00 created: 2026-07-17T03:58:05.365933671+02:00
updated: 2026-07-17T03:58:05.365933671+02:00 updated: 2026-07-20T01:09:23.968637294+02:00
started: 2026-07-20T01:09:23.970603129+02:00
completed: 2026-07-20T01:09:23.970603129+02:00
tags: tags:
- cleanup - cleanup
claimed_by: rain-raven
claimed_at: 2026-07-20T01:09:23.968637294+02:00
class: standard class: standard
--- ---

View file

@ -1,12 +1,16 @@
--- ---
id: 20 id: 20
title: Consistent template rendering pattern across all handlers title: Consistent template rendering pattern across all handlers
status: todo status: done
priority: low priority: low
created: 2026-07-17T03:58:11.987251314+02:00 created: 2026-07-17T03:58:11.987251314+02:00
updated: 2026-07-17T03:58:11.987251314+02:00 updated: 2026-07-19T22:54:28.006158702+02:00
started: 2026-07-19T22:54:28.007766996+02:00
completed: 2026-07-19T22:54:28.007766996+02:00
tags: tags:
- cleanup - cleanup
claimed_by: rain-raven
claimed_at: 2026-07-19T22:54:28.006158702+02:00
class: standard class: standard
--- ---

View file

@ -80,15 +80,11 @@ class ZAPDisplay implements ZAPHandler {
*/ */
private function handleWords() { private function handleWords() {
$words = array(); $words = array();
$ix = 1; for ($i = 1; $i <= MAX_WORDS; $i++) {
$postix = sprintf("%02d", $ix); $key = 'word' . sprintf("%02d", $i);
$wd = 'word' . $postix; if (!empty($_POST[$key])) {
$words[] = $_POST[$key];
while(!empty($_POST[$wd])) { }
array_push($words, $_POST[$wd]);
$ix++;
$postfix = sprintf("%02d", $ix);
$wd = 'word' . $postfix;
} }
return $words; return $words;
} }

View file

@ -8,11 +8,6 @@ class ZAPHome implements ZAPHandler {
*/ */
private $template = 'index'; private $template = 'index';
/**
* ZAP version
*/
private $ver;
/** /**
* Parsable content * Parsable content
*/ */
@ -22,10 +17,8 @@ class ZAPHome implements ZAPHandler {
* Constructor * Constructor
*/ */
public function __construct() { public function __construct() {
$this->ver = ZAP_VERSION;
extract(get_object_vars($this));
ob_start(); ob_start();
$ver = ZAP_VERSION;
include getZAPTemplate($this->template); include getZAPTemplate($this->template);
$this->tpl .= ob_get_clean(); $this->tpl .= ob_get_clean();
} }