commit 8abe76f548b95db6c8509b7142ce386950a46c96
parent 5c31444bee79dd42688ab7949d4c6fec9fe11ca5
Author: JayVii <jayvii[AT]posteo[DOT]de>
Date: Tue, 27 Oct 2026 22:45:03 +0100
feat: set section ID as video ID
Diffstat:
2 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/assets/js/yt.js b/assets/js/yt.js
@@ -1,16 +1,15 @@
-function yt2html_toggle_player(index, video) {
+function yt2html_toggle_player(video) {
- console.log("index: " + index);
console.log("video: " + video);
// get video section
- var section = document.getElementById("video_" + index);
+ var section = document.getElementById("video_" + video);
// Preview image
- var preview = section.querySelector("#preview_" + index);
+ var preview = section.querySelector("#preview_" + video);
// if player-iframe exists, remove it and unhide preview image
- var player = section.querySelectorAll("#player_" + index);
+ var player = section.querySelectorAll("#player_" + video);
if (player.length > 0) {
@@ -33,7 +32,7 @@ function yt2html_toggle_player(index, video) {
// Construct player iframe
var player = document.createElement("iframe");
- player.id = "player_" + index;
+ player.id = "player_" + video;
player.classList.add("player");
player.allowFullscreen = "true";
player.sandbox = "allow-scripts allow-same-origin allow-popups allow-popups-to-escape-sandbox";
@@ -50,10 +49,10 @@ function yt2html_toggle_player(index, video) {
section.querySelector(".player_container").prepend(player);
// Focus player
- document.getElementById("player_" + index).focus();
+ document.getElementById("player_" + video).focus();
// Scroll to player
- document.location = "#video_" + index;
+ document.location = "#video_" + video;
}
diff --git a/index.php b/index.php
@@ -314,11 +314,11 @@
foreach ($videos as $video) {
/* Stop if 500 videos are listed */
- if ($index >= 500) {
+ /*if ($index >= 500) {
break;
- }
+ }*/
?>
- <section id="video_<?php echo $index; ?>">
+ <section id="video_<?php echo $video["vid"]; ?>">
<!-- Headline: streamer name -->
<h3 style="margin-bottom:5px;">
@@ -350,7 +350,7 @@
<!-- player Container -->
<div class="player_container hidden">
- <?php $js_args = $index . ",'" . $video["vid"] . "'"; ?>
+ <?php $js_args = "'" . $video["vid"] . "'"; ?>
<button onclick="yt2html_toggle_player(<?php echo $js_args; ?>)">
Toggle Player
</button>
@@ -358,7 +358,7 @@
<!-- Preview Image -->
<div
- id="preview_<?php echo $index; ?>"
+ id="preview_<?php echo $video["vid"]; ?>"
class="preview"
>
<img