From 4c631f6839d9efc8e8f4a1302c47a6b7f5d89c22 Mon Sep 17 00:00:00 2001 From: Cotes Chung <11371340+cotes2020@users.noreply.github.com> Date: Tue, 18 Feb 2020 03:04:52 +0800 Subject: [PATCH] Enhanced JS function. --- assets/js/_src/_commons/copy-link.js | 5 +++-- assets/js/dist/_commons/copy-link.min.js | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/assets/js/_src/_commons/copy-link.js b/assets/js/_src/_commons/copy-link.js index ffe3e5d..24cc8dc 100644 --- a/assets/js/_src/_commons/copy-link.js +++ b/assets/js/_src/_commons/copy-link.js @@ -6,8 +6,9 @@ * MIT License */ -function copyLink() { - var url = window.location.href; +function copyLink(url) { + if (!url || 0 === url.length) + url = window.location.href; var $temp = $(""); $("body").append($temp); diff --git a/assets/js/dist/_commons/copy-link.min.js b/assets/js/dist/_commons/copy-link.min.js index 976cb85..636dc92 100644 --- a/assets/js/dist/_commons/copy-link.min.js +++ b/assets/js/dist/_commons/copy-link.min.js @@ -1 +1 @@ -function copyLink(){var a=window.location.href;var b=$("");$("body").append(b);b.val(a).select();document.execCommand("copy");b.remove();alert("Link copied successfully!")}; \ No newline at end of file +function copyLink(a){if(!a||0===a.length){a=window.location.href}var b=$("");$("body").append(b);b.val(a).select();document.execCommand("copy");b.remove();alert("Link copied successfully!")}; \ No newline at end of file