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

commit 5a6cb0872516b3245c50a82f392ab3ec39159136
parent 5103859dbcf3ef3eb5ea826d9eccd574c29e594a
Author: JayVii <jayvii[AT]posteo[DOT]de>
Date:   Mon,  1 Apr 2024 14:51:26 +0200

Add save button via cookie

Diffstat:
Mindex.php | 38++++++++++++++++++++++++++++++--------
1 file changed, 30 insertions(+), 8 deletions(-)

diff --git a/index.php b/index.php @@ -18,10 +18,13 @@ $time0 = time(); // Fetch GET and POST arguments -if (!is_null($_GET["streams"])) { +if (is_null($_POST["streams"])) { $loading_screen = true; - $channels = explode(",", $_GET["streams"]); - + if (!is_null($_GET["streams"])) { + $channels = explode(",", $_GET["streams"]); + } else { + $channels = explode(",", $_COOKIE["streams"]); + } } else { $loading_screen = false; $channels = unserialize($_POST["streams"]); @@ -131,8 +134,8 @@ if (!$loading_screen) { $menu_items = "<li><strong style='color:#fff;'>" . "<span style='color:" . $beep_color . "' class='" . $beep_class . "'>•</span>" . - "Live: " . array_sum($streams["status"]) . - "</strong></li>"; + "Live: " . array_sum($streams["status"]) . "</strong>" . + "</li>"; // Generate Content List $content = ""; @@ -283,8 +286,27 @@ if (!$loading_screen) { <ul class="container"> <?php - /* Reload Button */ + /* Reload & Save Buttons */ + if (implode(",", $streams["stream"]) == $_COOKIE["streams"]) { + $save_button_style = "display:none;"; + } else { + $save_button_style = ""; + } echo "<li>" . + // Save Button + "<a " . + "style='color:#F00;" . $save_button_style . "'". + "href=\"#\"" . + "onclick=\"document.cookie='streams=" . + implode(",", $streams["stream"]) . + "';\"" . + "title='Save' " . + "id='button-save'>" . + "&#128427;" . + "</a>" . + "</li>" . + "<li>" . + // Reoad Button "<a " . "href=\"javascript:" . "window.location='/?streams=" . @@ -292,7 +314,7 @@ if (!$loading_screen) { "';\"" . "title='Reload' " . "id='button-reload'>" . - "&#x21bb;" . + "&#8635;" . "</a>" . "</li>"; /* Other menu items */ @@ -308,6 +330,7 @@ if (!$loading_screen) { <div class="container"> <?php + echo $content; ?> @@ -360,7 +383,6 @@ if (!$loading_screen) { "<td>" . $streams["desc"][$i] . "</td>" . "</tr>"; } - ?> </tbody>