-
Notifications
You must be signed in to change notification settings - Fork 231
Add copy-to-clipboard element for upload/download lists. #1099
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: next
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -431,3 +431,9 @@ div#statusbar div.separator { | |
| } | ||
|
|
||
|
|
||
|
|
||
| .copy-to-clipboard-element:active { | ||
| color: red; | ||
| font-weight: bold; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| // @license magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt GPL-v3-or-Later | ||
| function addCopyKeyFieldToFinishedTransfers() { | ||
| if (navigator && navigator.clipboard) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Window There really is no need to check for that property to exist 😃 |
||
| var matching = document.getElementsByClassName("finished_key_link"); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we make this copy-to-clipboard functionality agnostic of the context in which it is used? One could search for |
||
| for (var matchingElement of matching) { | ||
| var key = matchingElement.dataset.key; | ||
| if (key) { | ||
| var toClipboard = document.createElement("span"); | ||
| toClipboard.textContent = " ⎘"; | ||
|
Comment on lines
+8
to
+9
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Best to not use whitespace characters for positioning. A better approach would be to set a
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As for the character (⎘), this is not something that I would immediately recognize. The emoji glyph for clipboard (📋) might be more visually recognizable (depending on OS support). What's your take?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The character ⎘ is the only one that’s universally supported. I don’t actually see 📋 on my system (copied it as empty block).
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mmh. In that case we might be better off rendering an SVG, as the character may be too font-dependent. That could be something like this (quick sketch based on distant memories of similar functionality): <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" style="height: 1em; width: 1em; margin-inline-start: .5ex; vertical-align: middle;">
<path stroke="currentColor" stroke-width="2" d="M 2 16 v -12 a 2 2 0 0 1 2 -2 h 12 M 9 7 h 10 a 2 2 0 0 1 2 2 v 10 a 2 2 0 0 1 -2 2 h -10 a 2 2 0 0 1 -2 -2 v -10 a 2 2 0 0 1 2 -2" fill="none"></path>
</svg> |
||
| toClipboard.classList.add("copy-to-clipboard-element"); | ||
| toClipboard.setAttribute("title", "Copy to Clipboard"); | ||
| toClipboard.onclick=() => navigator.clipboard.writeText(key); | ||
| matchingElement.parentElement.appendChild(toClipboard); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This could directly use |
||
| } | ||
| } | ||
| } | ||
| } | ||
| document.addEventListener("DOMContentLoaded", addCopyKeyFieldToFinishedTransfers); | ||
| // @license-end | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this duplication necessary? If all is well .. all themes include
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some themes don’t include color.css, because that actually causes latency of displaying toadlets to increase (despite being a local service, our static file serving is pretty slow). |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -59,3 +59,9 @@ | |
| /* | ||
| * Statusbar | ||
| */ | ||
|
|
||
| .copy-to-clipboard-element:active { | ||
| color: red; | ||
| font-weight: bold; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Loading it here causes the script to be included more than once when there are multiple tables on the page (like when there are both completed and running downloads), rendering duplicate buttons for each key.
(if we cannot prevent the script from loading twice for some reason, the script should guard for this condition)