Skip to content

Commit

Permalink
Add 'copy url' button
Browse files Browse the repository at this point in the history
Signed-off-by: Nikolai Rozanov <nickolay.rozanov@gmail.com>
  • Loading branch information
nrozanov committed Apr 5, 2024
1 parent 1b43c3e commit 042c703
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions flexmeasures/ui/templates/crud/asset.html
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,36 @@ <h3>All child assets for {{ asset.name }}</h3>
</table>
</div>
</div>
<div class="row">
<div class="copy-url" title="Click to copy URL to clipboard">
<script>
function copyUrl() {
if (!window.getSelection) {
alert('Please copy the URL from the location bar.');
return;
}
const dummy = document.createElement('p');
dummy.textContent = window.location.href;
document.body.appendChild(dummy);

const range = document.createRange();
range.setStartBefore(dummy);
range.setEndAfter(dummy);

const selection = window.getSelection();
// First clear, in case the user already selected some other text
selection.removeAllRanges();
selection.addRange(range);

document.execCommand('copy');
document.body.removeChild(dummy);
}
</script>
<a href="#" onclick="copyUrl()">
<i class="fa fa-link"></i>
</a>
</div>
</div>
<div class="col-sm-2">
<div class="replay-container">
<div id="replay" title="Press 'p' to play/pause/resume or 's' to stop." class="stopped"></div>
Expand Down

0 comments on commit 042c703

Please sign in to comment.