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

Merge pull request #754 from ThibaultNocchi/copy_url_firefox_fix

Clipboard API & fallback method to copy stream URL
This commit is contained in:
Anthony Lavado 2020-02-09 03:07:24 -05:00 committed by GitHub
commit 0d0f210c6a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 14 deletions

View file

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