Somewhat better copy-link for soundcloud, still needs work

This commit is contained in:
Kasper Rynning-Tønnesen
2018-09-28 13:09:13 +02:00
parent 1ad6272331
commit 3053e61985
2 changed files with 7 additions and 1 deletions

View File

@@ -355,6 +355,7 @@ function contextListener(that, event) {
if(parent.id.indexOf("suggested-") > -1) suggested = true;
document.getElementsByClassName("context-menu-root")[0].setAttribute("data-suggested", suggested);
document.getElementsByClassName("context-menu-root")[0].setAttribute("data-id", parent.getAttribute("id").replace("suggested-", ""));
document.getElementsByClassName("context-menu-root")[0].setAttribute("data-source", parent.getAttribute("data-video-source"));
Helper.removeClass("#context-menu-overlay", "hide");
var left = event.pageX - document.querySelector(".context-menu-root").offsetWidth / 2;
var top = event.pageY;

View File

@@ -602,7 +602,11 @@ function addDynamicListeners() {
var id = parent.getAttribute("data-id");
if(id != "") {
Helper.css(".copy_video_id", "display", "block");
Helper.setHtml(".copy_video_id", "https://www.youtube.com/watch?v=" + id);
if(parent.getAttribute("data-source") == "soundcloud") {
Helper.setHtml(".copy_video_id", "https://api.soundcloud.com/tracks/" + id + "?client_id=" + api_key.soundcloud);
} else if(parent.getAttribute("data-source") == "youtube") {
Helper.setHtml(".copy_video_id", "https://www.youtube.com/watch?v=" + id);
}
var copyTextarea = document.querySelector('.copy_video_id');
copyTextarea.select();
var successful = document.execCommand('copy');
@@ -613,6 +617,7 @@ function addDynamicListeners() {
}
Helper.css(".copy_video_id", "display", "none");
}
Helper.addClass(".context-menu-root", "hide");
Helper.addClass("#context-menu-overlay", "hide");
document.getElementsByClassName("context-menu-root")[0].setAttribute("data-id", "");