copy hash to clipboard functionality in file tree

pull/42/head
Zlatin Balevsky 2020-03-21 11:41:44 +00:00
parent e9eafe9380
commit 3a340e40c8
4 changed files with 21 additions and 4 deletions

View File

@ -504,7 +504,7 @@ li.fileTree {
z-index:1;
background: white;
padding-left: 20px;
width: max-content;
}
.dropdown-content a {
@ -516,4 +516,11 @@ li.fileTree {
.dropdown-content a:hover {background-color: #ddd;}
/* Show the dropdown menu on hover */
.dropdown:hover .dropdown-content {display: block;}
.dropdown:hover .dropdown-content {display: block;}
textarea.copypaste {
opacity: 0;
position: absolute;
z-index: -9999;
pointer-events: none;
}

View File

@ -41,6 +41,7 @@ public class Util {
_x("Certify"),
_x("Clear Finished"),
_x("Comment"),
_x("Copy hash to clipboard"),
_x("Copy To Clipbaord"),
_x("Default settings for new feeds"),
_x("Details for {0}"),
@ -66,6 +67,7 @@ public class Util {
_x("Feed"),
_x("File"),
_x("Files"),
_x("Hash copied to clipboard"),
_x("Hashing"),
_x("Hide Certificates"),
_x("Hide Comment"),

View File

@ -46,10 +46,13 @@ class Node {
published = ""
}
var infoHashTextArea = "<textarea class='copypaste' readOnly='true' id='" + this.infoHash + "'>" + this.infoHash + "</textarea>"
var copyInfoHashLink = new Link(_t("Copy hash to clipboard"), "copyAndAlert", [this.infoHash, _t("Hash copied to clipboard")])
var nameLink = "<a href='/MuWire/DownloadedContent/" + this.infoHash + "'>" + this.path + "</a>"
var html = "<li class='fileTree'>" + nameLink
var html = "<li class='fileTree'>" + nameLink + infoHashTextArea
html += "<div class='right'>" + certified + " " + published + " <div class='dropdown'>" + actionsLink + "<div class='dropdown-content'>"
html += unshareLink + commentLink + certifyLink + publish.render()
html += copyInfoHashLink.render() + unshareLink + commentLink + certifyLink + publish.render()
html += "</div></div></div>"
html += "<div class='centercomment' id='comment-" + this.nodeId + "'></div>"
html += "</li>"

View File

@ -13,6 +13,11 @@ function copyToClipboard(id) {
document.execCommand("copy")
}
function copyAndAlert(id, msg) {
copyToClipboard(id)
alert(msg)
}
/**
*
* Base64 encode / decode