mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-10 15:14:29 +00:00
Add copy lint name button
This commit is contained in:
parent
bf2e63104d
commit
27fec01fa8
2 changed files with 24 additions and 0 deletions
|
@ -490,6 +490,9 @@ Otherwise, have a great day =^.^=
|
|||
<div class="panel-title-name">
|
||||
<span>{{lint.id}}</span>
|
||||
<a href="#{{lint.id}}" class="anchor label label-default" ng-click="open[lint.id] = true; $event.stopPropagation()">¶</a>
|
||||
<a href="" id="clipboard-{{lint.id}}" class="anchor label label-default" ng-click="copyToClipboard(lint); $event.stopPropagation()">
|
||||
📋
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="panel-title-addons">
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue