pub / tw2html

Checks online status of streams on twitch.tv and lets you watch them
git clone https://src.jayvii.de/pub/tw2html.git
Home | Log | Files | Exports | Refs | README | RSS

build_html.php (1451B)


      1 <!-- SPDX-License-Identifier: AGPL-3.0-or-later
      2      SPDX-FileCopyrightText: 2024 JayVii <jayvii[AT]posteo[DOT]de>
      3 -->
      4 
      5 <?php
      6 
      7 // Build "article" section if stream is online
      8 for ($i = 0; $i < sizeof($streams["stream"]); $i++) {
      9     if ($streams["status"][$i] > 0) {
     10 
     11 ?>
     12 
     13 <section class="streamlisting" id="stream_<?php echo $streams["stream"][$i]; ?>">
     14     <h2>
     15         <a href="https://www.twitch.tv/<?php echo $streams["stream"][$i]; ?>">
     16             <?php echo $streams["stream"][$i] . ": " . $streams["desc"][$i]; ?>
     17         </a>
     18     </h2>
     19     <a
     20         href="#stream_<?php echo $streams["stream"][$i]; ?>"
     21         onclick="toggle_player('<?php echo $streams["stream"][$i]; ?>');"
     22     >
     23         <img
     24             class="preview"
     25             id="img-<?php echo $streams["stream"][$i]; ?>"
     26             src="https://static-cdn.jtvnw.net/previews-ttv/live_user_<?php echo $streams["stream"][$i]; ?>-1280x720.jpg"
     27             loading="lazy"
     28         >
     29     </a>
     30     <details class="button">
     31         <summary onclick="toggle_chat('<?php echo $streams["stream"][$i]; ?>');">
     32             Chat
     33         </summary>
     34         <div class="chatwrapper">
     35             <div id="chat-placeholder-<?php echo $streams["stream"][$i]; ?>">
     36             </div>
     37         </div>
     38     </details>
     39 </section>
     40 
     41 <?php
     42 
     43     }
     44 }
     45 
     46 // Color of save button
     47 if (implode(",", $streams["stream"]) == $_COOKIE["streams"]) {
     48     $save_col = "#006164";
     49 } else {
     50     $save_col = "#db4325";
     51 }
     52 
     53 ?>