Add a button to copy the "use statement"
This commit is contained in:
parent
f35e587db4
commit
828179d687
8 changed files with 58 additions and 14 deletions
|
@ -3061,3 +3061,28 @@ function hideThemeButtonState() {
|
|||
window.onhashchange = onHashChange;
|
||||
setupSearchLoader();
|
||||
}());
|
||||
|
||||
function copy_path(but) {
|
||||
var parent = but.parentElement;
|
||||
var path = [];
|
||||
|
||||
onEach(parent.childNodes, function(child) {
|
||||
if (child.tagName === 'A') {
|
||||
path.push(child.textContent);
|
||||
}
|
||||
});
|
||||
|
||||
var el = document.createElement('textarea');
|
||||
el.value = 'use ' + path.join('::') + ';';
|
||||
el.setAttribute('readonly', '');
|
||||
// To not make it appear on the screen.
|
||||
el.style.position = 'absolute';
|
||||
el.style.left = '-9999px';
|
||||
|
||||
document.body.appendChild(el);
|
||||
el.select();
|
||||
document.execCommand('copy');
|
||||
document.body.removeChild(el);
|
||||
|
||||
but.textContent = '✓';
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue