diff --git a/util/gh-pages/index.html b/util/gh-pages/index.html index 1171da3f4..2076d1299 100644 --- a/util/gh-pages/index.html +++ b/util/gh-pages/index.html @@ -490,6 +490,9 @@ Otherwise, have a great day =^.^=
{{lint.id}} + + 📋 +
diff --git a/util/gh-pages/script.js b/util/gh-pages/script.js index c3250afde..b095f6ef1 100644 --- a/util/gh-pages/script.js +++ b/util/gh-pages/script.js @@ -258,6 +258,27 @@ return true; } + $scope.copyToClipboard = function (lint) { + const clipboard = document.getElementById("clipboard-" + lint.id); + if (clipboard) { + let resetClipboardTimeout = null; + let resetClipboardIcon = clipboard.innerHTML; + + function resetClipboard() { + resetClipboardTimeout = null; + clipboard.innerHTML = resetClipboardIcon; + } + + navigator.clipboard.writeText("clippy::" + lint.id); + + clipboard.textContent = "✓"; + if (resetClipboardTimeout !== null) { + clearTimeout(resetClipboardTimeout); + } + resetClipboardTimeout = setTimeout(resetClipboard, 1000); + } + } + // Get data $scope.open = {}; $scope.loading = true;