Skip to content

Commit 48dfaf7

Browse files
Merge pull request #1991 from kefahwambai/kefah
added Copy button to make it easy for user to copy url link
2 parents 63e3229 + ea35192 commit 48dfaf7

2 files changed

Lines changed: 22 additions & 3 deletions

File tree

Projects/Bookmarker_App/main.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,10 @@ function fetchbookmarks() {
5555
<div class="col-9">
5656
<h5>${bookmarks[i].name}</h5>
5757
</div>
58-
<div class="col-3">
59-
<a class="btn btn-sm btn-success" href="https://${bookmarks[i].url}" target="_blank">Visit</a>
60-
<a onclick="deletebookmark(${i});" class="btn btn-danger text-light btn-sm" >Delete</a>
58+
<div class="col-3 button-container">
59+
<a class="btn btn-sm " href="https://${bookmarks[i].url}" target="_blank">Visit</a>
60+
<a onclick="copyToClipboard('${bookmarks[i].url}')" class="btn btn-sm ">Copy</a>
61+
<a onclick="deletebookmark(${i});" class="btn btn-sm" >Delete</a>
6162
</div>
6263
</div>
6364
<small>Created at : ${Date().slice(4, 15)}</small>
@@ -82,3 +83,14 @@ function validateform(sitename, siteurl) {
8283
}
8384
return true;
8485
}
86+
function copyToClipboard(url) {
87+
var input = document.createElement('input');
88+
input.style.position = 'fixed';
89+
input.style.opacity = 0;
90+
input.value = url;
91+
document.body.appendChild(input);
92+
input.select();
93+
document.execCommand('copy');
94+
document.body.removeChild(input);
95+
alert('Link Copied!');
96+
}

Projects/Bookmarker_App/style.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,14 @@ body {
6363
margin-top: 30px;
6464
background-color: #f1ecec;
6565
}
66+
.button-container {
67+
display: flex;
68+
justify-content: space-between;
69+
}
6670

71+
.button-container a:hover {
72+
color: #d74946;
73+
}
6774
@media screen and (min-width: 768px) {
6875

6976
.header,

0 commit comments

Comments
 (0)