Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added reverse playlist button in playlist editor #15

Merged
merged 1 commit into from
Jun 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions playlist-editor/src/components/PlaylistEditor.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import PlaylistPlusIcon from "./icons/PlaylistPlusIcon.svelte";
import PlusMultiple from "./icons/PlusMultiple.svelte";
import SaveIcon from "./icons/SaveIcon.svelte";
import ReverseIcon from "./icons/ReverseIcon.svelte";
import LoadingModal from "./LoadingModal.svelte";
import Modal from "./Modal.svelte";
import PlaylistVideo from "./PlaylistVideo.svelte";
Expand Down Expand Up @@ -128,6 +129,15 @@
modalType = ModalType.Export;
}

async function reversePlaylist() {
let reversed = new Array(videos.length);
for(let i = 0; i < videos.length; i++) {
let r = videos.length - i - 1;
reversed[i] = videos[r];
}
videos = reversed;
}

async function savePlaylist() {
const videoIds = videos.map((video) => video.videoId.toString());
playlist = { ...playlist, videos: videoIds };
Expand Down Expand Up @@ -196,6 +206,12 @@
<FloatingButton on:click={displayExport} title="Export videos"
><ClipboardMultiple /></FloatingButton
>
{#if videos.length > 1}
<FloatingButton
on:click={reversePlaylist}
title="Reverse order"><ReverseIcon /></FloatingButton
>
{/if}
<FloatingButton
on:click={savePlaylist}
title="Save the playlist"
Expand Down
4 changes: 4 additions & 0 deletions playlist-editor/src/components/icons/ReverseIcon.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<svg style="width:24px;height:24px" viewBox="0 0 24 24">
<path fill="currentColor" d="M 6.164062,0 3.0644531,4.8320311 0,9.6855465 4.0312497,9.7597654 V 23.999999 H 7.9902341 V 9.8183594 L 12,9.8632814 9.1015622,4.921875 Z" />
<path fill="currentColor" d="M 16.03125,0 V 14.240234 L 12,14.314452 l 3.064452,4.853517 3.09961,4.83203 2.937499,-4.921874 2.898438,-4.941406 -4.009765,0.04492 V 0 Z" />
</svg>
2 changes: 1 addition & 1 deletion src/editor/bundle.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/editor/main.js

Large diffs are not rendered by default.