From 32a741b147ba13a16dc76d819265b2d9294a28a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kasper=20Rynning-T=C3=B8nnesen?= Date: Mon, 22 Oct 2018 14:33:54 +0200 Subject: [PATCH] Updated panel some --- server/public/assets/css/style.css | 6 +- server/public/assets/js/listeners.js | 106 +++++------------- .../public/partials/channel/panel.handlebars | 7 +- 3 files changed, 35 insertions(+), 84 deletions(-) diff --git a/server/public/assets/css/style.css b/server/public/assets/css/style.css index 42df5db0..ab77793e 100755 --- a/server/public/assets/css/style.css +++ b/server/public/assets/css/style.css @@ -386,7 +386,7 @@ li.disabled span { color: white !important; } -.import-spotify-auth, .import-youtube, .export-spotify-auth, .export-youtube, .exported-playlist, .import-zoff, .import-soundcloud{ +.import-spotify-auth, .import-youtube, .export-spotify-auth, .export-youtube, .exported-playlist, .import-zoff, .import-soundcloud, .export-soundcloud{ color:white !important; height:40px !important; line-height: 40px !important; @@ -394,11 +394,11 @@ li.disabled span { width: 76%; } -.import-soundcloud, .import-soundcloud:active, .import-soundcloud:visited { +.import-soundcloud, .import-soundcloud:active, .import-soundcloud:visited, .export-soundcloud:visited { background: #f96200; } -.import-soundcloud:hover { +.import-soundcloud:hover, .export-soundcloud:hover { background: #f97f30; } diff --git a/server/public/assets/js/listeners.js b/server/public/assets/js/listeners.js index 9ae38eed..19752ccd 100755 --- a/server/public/assets/js/listeners.js +++ b/server/public/assets/js/listeners.js @@ -952,6 +952,29 @@ function addDynamicListeners() { } }); + addListener("click", ".export-soundcloud", function(event) { + this.preventDefault(); + var nonce = Helper.randomString(29); + Helper.removeClass("#playlist_loader_export", "hide"); + Helper.addClass(".soundcloud_export_button", "hide"); + window.callback = function(data) { + access_token_data_soundcloud = data; + if(access_token_data_soundcloud.state == nonce){ + soundcloud_authenticated = true; + Helper.removeClass("#playlist_loader_export", "hide"); + Helper.addClass(".soundcloud_export_button", "hide"); + } else { + access_token_data_soundcloud = {}; + console.error("States doesn't match"); + Helper.addClass("#playlist_loader_export", "hide"); + Helper.removeClass(".soundcloud_export_button", "hide"); + } + soundcloud_window.close(); + window.callback = ""; + }; + soundcloud_window = window.open("/api/oauth#soundcloud=true&nonce=" + nonce, "", "width=600, height=600"); + }) + addListener("click", ".export-spotify-auth", function(event){ this.preventDefault(); var nonce = Helper.randomString(29); @@ -1019,7 +1042,7 @@ function addDynamicListeners() { document.querySelector("#import_soundcloud").focus(); }); - addListener("submit", "#listImportSoundCloud", function(event) { + /*addListener("submit", "#listImportSoundCloud", function(event) { this.preventDefault(); Helper.removeClass(".playlist_loader_soundcloud", "hide"); Helper.addClass("#listImportSoundCloud", "hide"); @@ -1085,87 +1108,10 @@ function addDynamicListeners() { console.log(data); Helper.addClass(".playlist_loader_soundcloud", "hide"); Helper.removeClass("#listImportSoundCloud", "hide"); - if(data.status == 404) { - var nonce = Helper.randomString(29); - window.callback = function(data) { - access_token_data_soundcloud = data; - console.log(access_token_data_soundcloud, nonce); - if(access_token_data_soundcloud.state == nonce){ - soundcloud_authenticated = true; - Helper.ajax({ - type: "POST", - headers: { - "Content-Type": "application/json" - }, - url: "https://api.soundcloud.com/resolve/?url=" + document.querySelector("#import_soundcloud").value + "&limit=1&client_id=" + api_key.soundcloud + "&oauth_token=" + access_token_data_soundcloud.code + "&format=json&_status_code_map[200]=200", - success: function(data){ - try { - var jsonData = JSON.parse(data); - var tracks = jsonData.tracks; - document.querySelector("#import_soundcloud").value = ""; - var addList = []; - for(var i = 0; i < tracks.length; i++) { - var song = tracks[i]; - var title=song.title; - if(title.indexOf(song.user.username) == -1) { - title = song.user.username + " - " + title; - } - if(!song.streamable) { - var not_added_song = document.createElement("div"); - not_added_song.innerHTML = not_import_html; - - not_added_song.querySelector(".extra-add-text").innerText = title; - not_added_song.querySelector(".extra-add-text").setAttribute("title", title); - not_added_song.querySelector(".extra-button-search").setAttribute("data-text", title); - document.querySelector(".not-imported-container").insertAdjacentHTML("beforeend", not_added_song.innerHTML); - Helper.removeClass(".not-imported", "hide"); - continue; - } - var duration=Math.floor(song.duration / 1000); - //var secs=Search.durationToSeconds(duration); - var secs = duration; - if(longsongs == undefined) longsongs = true; - if((longsongs != undefined && !longsongs) || secs<720){ - - var id=song.id; - //duration = duration.replace("PT","").replace("H","h ").replace("M","m ").replace("S","s"); - var thumb=song.artwork_url; - //var thumb = null; - if(thumb == null) thumb = song.waveform_url; - - var songElement = {id: song.id, title: title, duration: secs, source: "soundcloud", thumbnail: thumb}; - - addList.push(songElement); - } - } - if(addList.length > 0) { - socket.emit("addPlaylist", {channel: chan.toLowerCase(), songs: addList}); - } - Helper.addClass(".playlist_loader_soundcloud", "hide"); - Helper.removeClass("#listImportSoundCloud", "hide"); - //{id: song.id, title: enc_title, duration: duration, source: "youtube", thumbnail: "https://img.youtube.com/vi/" + song.id + "/mqdefault.jpg"} - } catch(e) { - console.error(e); - Helper.addClass(".playlist_loader_soundcloud", "hide"); - Helper.removeClass("#listImportSoundCloud", "hide"); - } - }, - error: function(e) { - console.error(e); - } - }); - } else { - access_token_data_soundcloud = {}; - console.error("States doesn't match"); - } - soundcloud_window.close(); - window.callback = ""; - }; - soundcloud_window = window.open("/api/oauth#soundcloud=true&nonce=" + nonce, "", "width=600, height=600"); - } + toast("If the list is private, you have to add the secret code at the end"); } }); - }); + });*/ addListener("submit", "#listImportSpotify", function(event){ this.preventDefault(); diff --git a/server/public/partials/channel/panel.handlebars b/server/public/partials/channel/panel.handlebars index 054a8a20..b25330d2 100755 --- a/server/public/partials/channel/panel.handlebars +++ b/server/public/partials/channel/panel.handlebars @@ -203,7 +203,7 @@
playlist_add -

Private lists won't work with imports yet, due to our API-key being limited at the time being. Sorry for any inconvinience.

+

If you want to add a private list, remember to add the secret token at the end!

@@ -266,6 +266,11 @@
+
  • +
    +

    Exporting to SoundCloud is in the works.

    +
    +