commit f29deb646c5e1ec2af37294cb11c4d76981d8d20 parent 19e562d4fe7518d1b175b96db4ee4271ae061d2b Author: JayVii <jayvii[AT]posteo[DOT]de> Date: Sat, 20 Jul 2024 15:37:44 +0200 fix: count number of streams via js Diffstat:
M | index.php | | | 11 | +++++++++-- |
M | lib/build_html.php | | | 2 | +- |
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/index.php b/index.php @@ -64,12 +64,12 @@ $streams = array( </a> <!-- Live pseudo-button --> <a href="#streams"> - Live: <?php echo array_sum($streams["status"]); ?> + Live: <span id="num_streams">0</span> </a> </nav> </header> - <h1>Streams</h1> + <h1 id="streams">Streams</h1> <!-- Search Bar --> <form action="https://www.twitch.tv/search" method="GET" style="width:100%;"> @@ -93,4 +93,11 @@ if (!$loading_screen) { </main> </body> + + <!-- Script for counting active streams --> + <script> + var num_streams = document.querySelectorAll(".streamlisting").length; + document.querySelector("#num_streams").innerText = num_streams; + </script> + </html> diff --git a/lib/build_html.php b/lib/build_html.php @@ -10,7 +10,7 @@ for ($i = 0; $i < sizeof($streams["stream"]); $i++) { ?> -<section id="stream_<?php echo $streams["stream"][$i]; ?>"> +<section class="streamlisting" id="stream_<?php echo $streams["stream"][$i]; ?>"> <h2> <a href="https://www.twitch.tv/<?php echo $streams["stream"][$i]; ?>"> <?php echo $streams["stream"][$i] . ": " . $streams["desc"][$i]; ?>