Sha256: acc05fd7b3a1dcce20d3928d5c3e412f608ac58dd4b92b43754b19169b6254b7
Contents?: true
Size: 1.17 KB
Versions: 1
Compression:
Stored size: 1.17 KB
Contents
(function() { window.onload = function() { const elems = document.getElementsByClassName('highlight') let tempDiv = document.createElement('div') Array.prototype.forEach.call(elems, function(elem) { // sample code without caption tempDiv.innerHTML = elem.innerHTML const caption = tempDiv.getElementsByClassName("caption")[0] if (caption) tempDiv.removeChild(caption) // textarea for preserving the copy text const copyText = document.createElement('textarea') copyText.setAttribute('class', 'highlight__copy-text') copyText.innerHTML = tempDiv.textContent.replace(/^\n+/, "").replace(/\n{2,}$/, "\n") elem.appendChild(copyText) // COPY button const btn = document.createElement('div') btn.setAttribute('class', 'highlight__copy-button') // btn.textContent = "COPY" elem.insertBefore(btn, elem.firstChild) btn.onclick = function(){ copyText.select() document.execCommand("copy") btn.classList.add("copied") window.setTimeout(function() { btn.classList.remove("copied") }, 1000) } } ) } })()
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bitclust-core-1.2.4 | theme/default/script.js |