function makeCopyButton(idTarget,bFlipped,cchLength){ var elButton = document.createElement("span"); elButton.className = "copy-button"; if( bFlipped ) elButton.className += " copy-button-flipped"; elButton.id = "copy-" + idTarget; initCopyButton(elButton,idTarget,cchLength); return elButton; } function initCopyButtonById(idButton,idTarget,cchLength){ idButton = idButton || "copy-" + idTarget; var elButton = document.getElementById(idButton); if( elButton ) initCopyButton(elButton,idTarget,cchLength); return elButton; } function initCopyButton(elButton,idTarget,cchLength){ elButton.style.transition = ""; elButton.style.opacity = 1; if( idTarget ) elButton.setAttribute("data-copytarget",idTarget); if( cchLength ) elButton.setAttribute("data-copylength",cchLength); elButton.onclick = clickCopyButton; return elButton; } setTimeout(function(){ var aButtons = document.getElementsByClassName("copy-button"); for ( var i=0; i0 ){ text = text.slice(0,cchLength); } copyTextToClipboard(text); } setTimeout(function(id){ var elButton = document.getElementById(id); if( elButton ){ elButton.style.transition = ""; elButton.style.opacity = 1; } lockCopyText = false; }.bind(null,this.id),400); } function copyTextToClipboard(text){ if( window.clipboardData && window.clipboardData.setData ){ window.clipboardData.setData('Text',text); }else{ var x = document.createElement("textarea"); x.style.position = 'fixed'; x.value = text; document.body.appendChild(x); x.select(); try{ document.execCommand('copy'); }catch(err){ }finally{ document.body.removeChild(x); } } }