Commit 2e16deea authored by david's avatar david
Browse files

Differentiation planned_playlist and playlogs. #2

parent 059c3a2f
...@@ -93,7 +93,6 @@ ...@@ -93,7 +93,6 @@
} }
} }
/* Initialize the component */ /* Initialize the component */
function initComponent(value) { function initComponent(value) {
...@@ -124,7 +123,6 @@ ...@@ -124,7 +123,6 @@
return ""; return "";
} }
/* Checks if there's an existing, valid timeslot */ /* Checks if there's an existing, valid timeslot */
function hasValidTimeslot(value) { function hasValidTimeslot(value) {
if (value.current_timeslot != null) { if (value.current_timeslot != null) {
...@@ -138,15 +136,23 @@ ...@@ -138,15 +136,23 @@
return false; return false;
} }
/* Retrieve planned playlist items after the current one */
function getFuturePlaylistItems(value) {
let items = [];
let now = Date();
/* Checks if there is an existing valid playlist */ if ("planned_playlist" in value) {
function hasValidPlaylist(value) { if (value.planned_playlist) {
if (value.current_playlist != null) for (let i in items) {
return true; let track_start = Date.parse(i.track_start)
return false; if (track_start > now)
items.push(i);
}
}
}
return items;
} }
/* Display the title of a track */ /* Display the title of a track */
function displayTitle(track) { function displayTitle(track) {
if (track != null) { if (track != null) {
...@@ -191,7 +197,6 @@ ...@@ -191,7 +197,6 @@
return ""; return "";
} }
/* Display the name of a show */ /* Display the name of a show */
function displayShowName(timeslot, defaultText) { function displayShowName(timeslot, defaultText) {
let name = "" let name = ""
...@@ -203,7 +208,6 @@ ...@@ -203,7 +208,6 @@
return name; return name;
} }
/* Display the timeslot of a show */ /* Display the timeslot of a show */
function displayShowTimeslot(timeslot) { function displayShowTimeslot(timeslot) {
let str = ""; let str = "";
...@@ -234,7 +238,6 @@ ...@@ -234,7 +238,6 @@
} }
return "(" + str + ")"; return "(" + str + ")";
} }
/* Indicates if some fallback timeslot is playing */ /* Indicates if some fallback timeslot is playing */
function isFallbackTimeslot(value) { function isFallbackTimeslot(value) {
...@@ -624,9 +627,11 @@ ...@@ -624,9 +627,11 @@
</div> </div>
<div id="playlist"> <div id="playlist">
{#if hasValidPlaylist(value)} <!-- {#if hasValidPlaylist(value)} -->
<ol> <ol>
{#each value.current_playlist.entries as entry, index}
<!-- Render playlog currently playing -->
{#each value.current_playlogs as entry, index}
{#if isActive(entry, value.current_track)} {#if isActive(entry, value.current_track)}
<li id="current-playlist-entry" class="playlist-entry is-active" bind:this={currentTrackElement}> <li id="current-playlist-entry" class="playlist-entry is-active" bind:this={currentTrackElement}>
...@@ -639,6 +644,7 @@ ...@@ -639,6 +644,7 @@
<span class="track-time-left">{formatTime(timeLeft)}</span> <span class="track-time-left">{formatTime(timeLeft)}</span>
</li> </li>
<!-- Render playlogs before the one currently playing -->
{:else} {:else}
<li class="playlist-entry"> <li class="playlist-entry">
...@@ -655,8 +661,23 @@ ...@@ -655,8 +661,23 @@
{/if} {/if}
{/each} {/each}
<!-- Render planned playlist items which are in the future -->
{#each getFuturePlaylistItems(value) as entry, index}
<li class="playlist-entry">
<span class="track-title">{displayTitle(entry)}</span>
<span class="track-type">{displayType(entry)}</span>
{#if isFallbackEntry(value, entry)}
<span class="fallback-indicator">{fallbacktext}</span>
{/if}
{#if entry.track_duration > 0 }
<span class="track-duration">{formatTime(entry.track_duration)}</span>
{/if}
</li>
{/each}
</ol> </ol>
{:else} <!-- {:else}
{#if value.current_track} {#if value.current_track}
<div id="current-track" class="is-active"> <div id="current-track" class="is-active">
<h2> <h2>
...@@ -666,8 +687,8 @@ ...@@ -666,8 +687,8 @@
<span class="track-time-left">{formatTime(timeLeft)}</span> <span class="track-time-left">{formatTime(timeLeft)}</span>
</h2> </h2>
</div> </div>
{/if} {/if} -->
{/if} <!-- {/if} -->
</div> </div>
</div> </div>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment