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:
commit
0d0f210c6a
2 changed files with 17 additions and 14 deletions
|
@ -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":
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue