Merge pull request #751 from ThibaultNocchi/copy_url_firefox_fix

Checks if stream URL is successfully copied and displays an appropriate toast
This commit is contained in:
dkanada 2020-01-31 22:36:19 +09:00 committed by GitHub
commit 9f105c477e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View File

@ -351,14 +351,15 @@ define(["apphost", "globalize", "connectionManager", "itemHelper", "appRouter",
document.body.appendChild(textArea); document.body.appendChild(textArea);
textArea.focus(); textArea.focus();
textArea.select(); textArea.select();
try { if (document.execCommand("copy")) {
document.execCommand("copy");
require(["toast"], function (toast) { require(["toast"], function (toast) {
toast(globalize.translate("CopyStreamURLSuccess")); toast(globalize.translate("CopyStreamURLSuccess"));
}); });
} catch (err) { } else {
console.error("Failed to copy to clipboard"); console.error("Failed to copy to clipboard");
require(["toast"], function (toast) {
toast(globalize.translate("CopyStreamURLError"));
});
} }
document.body.removeChild(textArea); document.body.removeChild(textArea);

View File

@ -161,6 +161,7 @@
"Continuing": "Continuing", "Continuing": "Continuing",
"CopyStreamURL": "Copy Stream URL", "CopyStreamURL": "Copy Stream URL",
"CopyStreamURLSuccess": "URL copied successfully.", "CopyStreamURLSuccess": "URL copied successfully.",
"CopyStreamURLError": "There was an error copying the URL.",
"CriticRating": "Critic rating", "CriticRating": "Critic rating",
"CustomDlnaProfilesHelp": "Create a custom profile to target a new device or override a system profile.", "CustomDlnaProfilesHelp": "Create a custom profile to target a new device or override a system profile.",
"DateAdded": "Date added", "DateAdded": "Date added",