diff --git a/js/home.js b/js/home.js index caf52ffc..5513c774 100644 --- a/js/home.js +++ b/js/home.js @@ -2,7 +2,7 @@ // Zookeeper Online // // @author Jim Mason -// @copyright Copyright (C) 1997-2023 Jim Mason +// @copyright Copyright (C) 1997-2024 Jim Mason // @link https://zookeeper.ibinx.com/ // @license GPL-3.0 // @@ -220,7 +220,7 @@ $().ready(function(){ accept: 'application/json; charset=utf-8', url: url }).done(function (response) { - $("#time").empty().append(response.times).selectmenu('refresh'); + $("#time").empty().append(response).selectmenu('refresh'); var time = $("#time").val(); populateCards(true, time == 'now' ? null : (date + " " + time)); }); diff --git a/ui/Home.php b/ui/Home.php index 6a069d51..89232a77 100644 --- a/ui/Home.php +++ b/ui/Home.php @@ -3,7 +3,7 @@ * Zookeeper Online * * @author Jim Mason - * @copyright Copyright (C) 1997-2022 Jim Mason + * @copyright Copyright (C) 1997-2024 Jim Mason * @link https://zookeeper.ibinx.com/ * @license GPL-3.0 * @@ -47,46 +47,44 @@ public function recentSpins() { } protected function makeDatePicker() { + $result = []; + $now = new \DateTime(); - $result = ""; - $now->modify("-1 days"); - $result .= ""; - for($i=0; $i<5; $i++) { + $result[] = clone $now; + + for($i=0; $i<6; $i++) { $now->modify("-1 days"); - $result .= ""; + $result[] = clone $now; } - return $result; + $this->addVar("dates", $result); } protected function makeTimePicker($date=null) { + $result = []; + $now = new \DateTime(); if(!$date || $now->format("Y-m-d") == $date) { // today - $result = ""; $hour = (int)$now->format("H"); + $result[] = -1; } else { - $result = ""; $hour = 23; + $result[] = $hour; } do { if($hour % 3) continue; - $h = sprintf("%02d", $hour); - $ampm = $h >= 12?"pm":"am"; - $hx = $h > 12?$hour-12:$hour; - $dh = $h == 12?"noon":($hx.$ampm); - $result .= ""; + $result[] = $hour; } while(--$hour > 0); - return $result; + $this->addVar("times", $result); } public function getTimes() { - $retVal = []; - $retVal['times'] = $this->makeTimePicker($_REQUEST["date"] ?? null); - echo json_encode($retVal); + $this->setTemplate('onnow.html'); + $this->makeTimePicker($_REQUEST["date"] ?? null); + echo json_encode($this->render('time')); } public function emitHome() { @@ -102,8 +100,8 @@ public function emitHome() { private function emitRecentlyPlayed() { $this->addVar('discogs', true); - $this->addVar('datepicker', $this->makeDatePicker()); - $this->addVar('timepicker', $this->makeTimePicker()); + $this->makeDatePicker(); + $this->makeTimePicker(); } private function emitTopPlays($numweeks=1, $limit=10) { diff --git a/ui/templates/default/onnow.html b/ui/templates/default/onnow.html index f3dbb6a4..7835766d 100644 --- a/ui/templates/default/onnow.html +++ b/ui/templates/default/onnow.html @@ -36,8 +36,28 @@

Recently Played on {{ app.station }}

- - + +