1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Moved URL copy to Clipboard API method

This commit is contained in:
Thibault Nocchi 2020-02-01 17:26:03 +01:00
parent 254c69b2f1
commit 74530fe4d9

View file

@ -346,23 +346,16 @@ define(["apphost", "globalize", "connectionManager", "itemHelper", "appRouter",
break; break;
case "copy-stream": case "copy-stream":
var downloadHref = apiClient.getItemDownloadUrl(itemId); var downloadHref = apiClient.getItemDownloadUrl(itemId);
var textArea = document.createElement("textarea"); navigator.clipboard.writeText(downloadHref).then(function () {
textArea.value = downloadHref;
document.body.appendChild(textArea);
textArea.focus();
textArea.select();
if (document.execCommand("copy")) {
require(["toast"], function (toast) { require(["toast"], function (toast) {
toast(globalize.translate("CopyStreamURLSuccess")); toast(globalize.translate("CopyStreamURLSuccess"));
}); });
} else { }, function () {
console.error("Failed to copy to clipboard"); console.error("Failed to copy to clipboard");
require(["toast"], function (toast) { require(["toast"], function (toast) {
toast(globalize.translate("CopyStreamURLError")); toast(globalize.translate("CopyStreamURLError"));
}); });
} });
document.body.removeChild(textArea);
getResolveFunction(resolve, id)(); getResolveFunction(resolve, id)();
break; break;
case "editsubtitles": case "editsubtitles":