add copy-to-clipboard ability for full id

pull/42/head
Zlatin Balevsky 2020-03-19 19:19:47 +00:00
parent e542a50260
commit db91c9171d
3 changed files with 17 additions and 1 deletions

View File

@ -41,6 +41,7 @@ public class Util {
_x("Certify"),
_x("Clear Finished"),
_x("Comment"),
_x("Copy To Clipbaord"),
_x("Default settings for new feeds"),
_x("Details for {0}"),
_x("Distrusted"),

View File

@ -6,6 +6,13 @@ function rfc3986EncodeURIComponent (str) {
return encodeURIComponent(str).replace(/[!'()*]/g, escape);
}
function copyToClipboard(id) {
var copyText = document.getElementById(id)
copyText.select()
copyText.setSelectionRange(0,99999) // because W3Schools says so
document.execCommand("copy")
}
/**
*
* Base64 encode / decode

View File

@ -17,6 +17,13 @@ Core core = (Core) application.getAttribute("core");
<html>
<head>
<%@include file="css.jsi"%>
<script src="js/util.js?<%=version%>" type="text/javascript"></script>
<script>
function copyFullId() {
copyToClipboard("full-id")
alert("Full Id Copied To Clipboard")
}
</script>
</head>
<body onload="initConnectionsCount();">
<%@include file="header.jsi"%>
@ -27,7 +34,8 @@ Core core = (Core) application.getAttribute("core");
<section class="main foldermain">
<p><%=Util._t("Your short MuWire id is {0}", core.getMe().getHumanReadableName())%></p>
<p><%=Util._t("Your full MuWire id is")%></p>
<p><pre class="fullId"><%=core.getMe().toBase64()%></pre></p>
<p><textarea class="fullId" id="full-id" readOnly="true"><%=core.getMe().toBase64()%></textarea></p>
<p><a href='#' onclick="window.copyFullId();return false;"><%=Util._t("Copy To Clipboard")%></a></p>
</section>
</body>
</html>