Implement episode switching
This commit is contained in:
parent
00468be4e9
commit
0278b6b040
2 changed files with 51 additions and 10 deletions
31
index.php
31
index.php
|
@ -43,20 +43,31 @@
|
||||||
<hr class="ms-2 me-2">
|
<hr class="ms-2 me-2">
|
||||||
<!-- Episodes -->
|
<!-- Episodes -->
|
||||||
<div>
|
<div>
|
||||||
<h3><?= $podcast->episodes[0]->title; ?></h3>
|
<select class="form-select form-select-lg mb-3" name="" id="episode-selection" autocomplete="off">
|
||||||
<div><?= $podcast->episodes[0]->pubDate; ?></div>
|
<option value="0" selected><?= $podcast->episodes[0]->title; ?></option>
|
||||||
<div><?= $podcast->episodes[0]->desc ?></div>
|
<?php foreach ($podcast->episodes as $key => $ep) {
|
||||||
<audio controls=true <?= $podcast->episodes[0]->audioData; ?>></audio>
|
if ($key != 0) {
|
||||||
|
echo "<option value={$key}>Episode {$key} - {$podcast->episodes[$key]->title}</option>";
|
||||||
|
};
|
||||||
|
} ?>
|
||||||
|
</select>
|
||||||
|
<div class="dPubDate"><?= $podcast->episodes[0]->pubDate; ?></div>
|
||||||
|
<div class="dDesc"><?= $podcast->episodes[0]->desc ?></div>
|
||||||
|
<audio controls class="dAudio">
|
||||||
|
<source <?= $podcast->episodes[0]->audioData; ?>>
|
||||||
|
</audio>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script type="text/javascript" src="tools/script.js"></script>
|
<script type="text/javascript" src="tools/script.js"></script>
|
||||||
<div>
|
<div class="epData" hidden>
|
||||||
<?php foreach ($podcast->episodes as $key => $ep) {
|
<?php foreach ($podcast->episodes as $key => $ep) {
|
||||||
echo "<div class=\"ep{$key}\" hidden>
|
echo "<div class=\"ep{$key}\">
|
||||||
<h3>{$ep->title}</h3>
|
<div class=\"ep{$key}-title\">{$ep->title}</div>
|
||||||
<div>{$ep->pubDate}</div>
|
<div class=\"ep{$key}-pubDate\">{$ep->pubDate}</div>
|
||||||
<div>{$ep->desc}</div>
|
<div class=\"ep{$key}-desc\">{$ep->desc}</div>
|
||||||
<audio controls=true {$ep->audioData}></audio>
|
<audio class=\"ep{$key}-audio\">
|
||||||
|
<source {$ep->audioData}>
|
||||||
|
</audio>
|
||||||
</div>";
|
</div>";
|
||||||
} ?>
|
} ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,9 +1,39 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
function getPubDate(epNum) {
|
||||||
|
const epData = document.getElementsByClassName("ep"+epNum+"-pubDate")
|
||||||
|
return epData[0].innerHTML;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getDesc(epNum) {
|
||||||
|
const epData = document.getElementsByClassName("ep"+epNum+"-desc")
|
||||||
|
return epData[0].innerHTML;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getAudioSource(epNum) {
|
||||||
|
const epData = document.getElementsByClassName("ep"+epNum+"-audio")
|
||||||
|
return epData[0].innerHTML;
|
||||||
|
}
|
||||||
|
|
||||||
window.addEventListener("DOMContentLoaded", function () {
|
window.addEventListener("DOMContentLoaded", function () {
|
||||||
console.log(
|
console.log(
|
||||||
"Hewo, c'est renarde 🦊, la créatrice de ce site.\nSi tu veux trouver le code source du site c'est par ici -> "
|
"Hewo, c'est renarde 🦊, la créatrice de ce site.\nSi tu veux trouver le code source du site c'est par ici -> "
|
||||||
+ 'https://forgejo.la-taniere-solidaire.gay/Renarde/site-web-le-plus-beau-des-voyages'
|
+ 'https://forgejo.la-taniere-solidaire.gay/Renarde/site-web-le-plus-beau-des-voyages'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const epSelect = document.getElementById("episode-selection");
|
||||||
|
const dPubDate = document.getElementsByClassName("dPubDate");
|
||||||
|
const dDesc = document.getElementsByClassName("dDesc");
|
||||||
|
const dAudio = document.getElementsByClassName("dAudio");
|
||||||
|
|
||||||
|
epSelect.addEventListener('change',function() {
|
||||||
|
dPubDate[0].innerHTML = getPubDate(epSelect.value);
|
||||||
|
dDesc[0].innerHTML = getDesc(epSelect.value);
|
||||||
|
dAudio[0].innerHTML = getAudioSource(epSelect.value);
|
||||||
|
dAudio[0].load()
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue