Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implemented copy link button #171

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added images/copy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ <h2 class="typingeffect">Season of AI | Beginner AI Learner</h2>
>
<i class="fab fa-facebook-f"></i>
</a>
<button class="copy-link-btn" id="copy-link-badge-1" data-badge-id="badge-1">
<img src="images/copy.png" alt="" id="copy-link">
</button>

</div>
</div>
</div>
Expand Down Expand Up @@ -137,7 +141,11 @@ <h2 class="typingeffect">Season of AI | Intermediate AI Learner</h2>
class="share-button facebook"
>
<i class="fab fa-facebook-f"></i>

</a>
<button class="copy-link-btn" id="copy-link-badge-2" data-badge-id="badge-2">
<img src="images/copy.png" alt="" id="copy-link">
</button>
</div>
</div>
</div>
Expand Down Expand Up @@ -183,6 +191,9 @@ <h2 class="typingeffect">Season of AI | Intermediate AI Learner</h2>
>
<i class="fab fa-facebook-f"></i>
</a>
<button class="copy-link-btn" id="copy-link-badge-3" data-badge-id="badge-3">
<img src="images/copy.png" alt="" id="copy-link">
</button>
</div>
</div>
</div>
Expand Down Expand Up @@ -228,6 +239,10 @@ <h2 class="typingeffect">Season of AI | Intermediate AI Learner</h2>
>
<i class="fab fa-facebook-f"></i>
</a>
<button class="copy-link-btn" id="copy-link-badge-4" data-badge-id="badge-4">
<img src="images/copy.png" alt="" id="copy-link">
</button>

</div>
</div>
</div>
Expand Down Expand Up @@ -273,6 +288,10 @@ <h2 class="typingeffect">Season of AI | Intermediate AI Learner</h2>
>
<i class="fab fa-facebook-f"></i>
</a>
<button class="copy-link-btn" id="copy-link-badge-5" data-badge-id="badge-5">
<img src="images/copy.png" alt="" id="copy-link">
</button>

</div>
</div>
</div>
Expand Down Expand Up @@ -319,6 +338,9 @@ <h2 class="typingeffect">Season of AI | Advance AI Learner</h2>
>
<i class="fab fa-facebook-f"></i>
</a>
<button class="copy-link-btn" id="copy-link-badge-6" data-badge-id="badge-6">
<img src="images/copy.png" alt="" id="copy-link">
</button>
</div>
</div>
</div>
Expand Down Expand Up @@ -365,5 +387,6 @@ <h2 class="typingeffect">Season of AI | Advance AI Learner</h2>

<!-- Typing effect for badge title -->
<script src="js/typing-badge-title.js"></script>
<script src="js/badge.js"></script>
</body>
</html>
28 changes: 28 additions & 0 deletions js/badge.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Function to generate unique badge URLs
function generateBadgeURL(badgeId) {
const baseUrl = "https://ai.mlsc-amity.tech/badge/";
return `${baseUrl}${badgeId}`;
}

// Function to copy badge URL to clipboard
function copyLink(badgeId) {
const badgeUrl = generateBadgeURL(badgeId);
navigator.clipboard.writeText(badgeUrl).then(() => {
alert("Badge URL copied to clipboard!");
}).catch((error) => {
console.error("Failed to copy: ", error);
});
}

// Event listener for dynamically created badge elements
document.addEventListener("DOMContentLoaded", function () {
// Loop through all copy link buttons
const copyButtons = document.querySelectorAll(".copy-link-btn");
copyButtons.forEach(button => {
const badgeId = button.dataset.badgeId; // Get the badge ID from data attribute
button.addEventListener("click", function () {
copyLink(badgeId); // Call the copyLink function with the specific badge ID
});
});
});

18 changes: 16 additions & 2 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,7 @@ nav {
.nav-links ul li {
margin-left: 20px;
}

ul li a {
ul li a {
height: 100%;
padding: 0;
display: flex;
Expand All @@ -200,6 +199,7 @@ nav {
transition: color 0.3s ease;
}


.nav-links ul li a:hover {
color: #58a6ff;
}
Expand Down Expand Up @@ -370,6 +370,19 @@ footer a {
.share-button.linkedin {
background-color: #0077b5;
}
#copy-link{
width:50px;
height:50px;
background-color:#083e77;
border:none;
position:absolute;
top:100px ;
left:400px



}


.share-button.linkedin:hover {
transform: scale(1.2);
Expand All @@ -386,6 +399,7 @@ footer a {
box-shadow: 0 4px 10px rgba(59, 89, 152, 0.5);
}


/* Icon Colors on Hover */
.share-button:hover i {
color: #fff;
Expand Down