From 2b4c670ec3d52a6e69dec99dc593e318bcd108aa Mon Sep 17 00:00:00 2001 From: Davis Mosenkovs Date: Mon, 15 Jun 2015 00:25:04 +0300 Subject: [PATCH] Added ability to save Queue as local Playlist --- README.rst | 1 + mopidy_musicbox_webclient/static/index.html | 3 ++- .../static/js/controls.js | 25 +++++++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index d078789..4a45093 100644 --- a/README.rst +++ b/README.rst @@ -59,6 +59,7 @@ v2.0.1 (UNRELEASED) - Support for Mopidy-Grooveshark. - Fixed slow to start playing from a large tracklist of browsed tracks. - Added link to `Alarm Clock `_ (if present). +- Added ability to save Queue as local Playlist. v2.0.0 (26-3-2015) ------------------ diff --git a/mopidy_musicbox_webclient/static/index.html b/mopidy_musicbox_webclient/static/index.html index 80cd301..2310738 100644 --- a/mopidy_musicbox_webclient/static/index.html +++ b/mopidy_musicbox_webclient/static/index.html @@ -334,7 +334,8 @@
- Clear

Play Queue

+ Clear + Save

Play Queue

    diff --git a/mopidy_musicbox_webclient/static/js/controls.js b/mopidy_musicbox_webclient/static/js/controls.js index 74b3d46..ef60a74 100644 --- a/mopidy_musicbox_webclient/static/js/controls.js +++ b/mopidy_musicbox_webclient/static/js/controls.js @@ -227,6 +227,31 @@ function clearQueue() { return false; } +function saveQueue() { + mopidy.tracklist.getTracks().then(function(tracks) { + if (tracks.length > 0) { + var plname = window.prompt("Playlist name:", ""); + if (plname != null && plname.trim() != "") { + plname = plname.trim(); + mopidy.playlists.filter({"name": plname}).then(function(existing) { + var exists = false; + for (var i = 0; i < existing.length; i++) { + exists = exists || existing[i].uri.indexOf("m3u:") == 0 || existing[i].uri.indexOf("local:") == 0; + } + if (!exists || window.confirm("Overwrite existing playlist \"" + plname + "\"?")) { + mopidy.playlists.create(plname, "local").then(function(playlist) { + playlist.tracks = tracks; + mopidy.playlists.save(playlist).then(); + getPlaylists(); + }); + } + }); + } + } + }); + return false; +} + /********************** * Buttons */