Skip to content

Commit

Permalink
Missing function
Browse files Browse the repository at this point in the history
  • Loading branch information
SkyEye-FAST committed Jul 12, 2024
1 parent 911f479 commit a8ae6b4
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions static/js/quiz.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,29 @@ $(document).ready(function () {

// Initialize first question
initializeQuestion();
});

$(document).ready(function () {
var currentUrl = window.location.href;
var match = currentUrl.match(/\/([^\/?#]+)[\/?#]?$/);
var lastSegment = match ? match[1] : "";
document.getElementById("last-segment").textContent = lastSegment;

$("#copy-button").click(function () {
var $copyButton = $(this);
var $lastSegment = $("#last-segment");
var lastSegmentContent = $lastSegment.text();

navigator.clipboard
.writeText(lastSegmentContent)
.then(function () {
$copyButton.text("check");
setTimeout(function () {
$copyButton.text("content_copy");
}, 1500);
})
.catch(function (err) {
console.error("Failed to copy: ", err);
});
});
});

0 comments on commit a8ae6b4

Please sign in to comment.