From ebfe66bb89499f3dc8b55822be9b4d7ca898d62b Mon Sep 17 00:00:00 2001 From: Patrick Mueller Date: Fri, 8 Oct 2021 06:57:05 +0200 Subject: [PATCH] #1: Adding ability to copy link by clicking it --- scripts.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/scripts.js b/scripts.js index e5450b6..ee3f628 100644 --- a/scripts.js +++ b/scripts.js @@ -4,8 +4,26 @@ $(document).ready(function () { $('#submitBtn').click(function () { generateLink(); }); + + $('#full-link').click(function () { + let element = $('#full-link'); + let text = element.text() + copyToClipboard(text); + element.text('Copied!'); + setTimeout(function () { + element.text(text); + }, 2000); + }); }); +function copyToClipboard(text) { + var $temp = $(""); + $("body").append($temp); + $temp.val(text).select(); + document.execCommand("copy"); + $temp.remove(); +} + function generateLink() { let selectedCourseFromPicker = $('#coursename').val().toString();