comments, forum posts: add 'Copy Link' action to '...' menu.

Add a 'Copy Link' action to forum posts and comments. This copies the
full link to the clipboard. The 'Copy ID' action copies just the DText
shortlink (comment #XXX or forum #XXX).
This commit is contained in:
evazion
2022-01-13 13:07:23 -06:00
parent 5adeedcf01
commit ba29794e89
7 changed files with 50 additions and 21 deletions

View File

@@ -118,6 +118,15 @@ Utility.splitWords = function(string) {
return words(string, /\S+/g);
}
Utility.copyToClipboard = async function(text, message = "Copied!") {
try {
await navigator.clipboard.writeText(text);
Utility.notice(message);
} catch (error) {
Utility.error("Couldn't copy to clipboard");
}
}
$.fn.selectEnd = function() {
return this.each(function() {
this.focus();