clipcopy.js - jscancer - Javascript crap (relatively small)
 (HTM) git clone git://git.codemadness.org/jscancer
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
       clipcopy.js (764B)
       ---
            1 // clipboard(text, [el])
            2 // (if allowed, try to) copy text to clipboard.
            3 // specifying el tries to insert the textarea before the element, this
            4 // prevents the page from scrolling in some cases.
            5 function clipcopy(text, el) {
            6         var textarea = document.createElement("textarea");
            7         textarea.value = text;
            8         if (el == null)
            9                 document.body.appendChild(textarea);
           10         else
           11                 el.parentNode.insertBefore(textarea, el);
           12         textarea.focus();
           13         textarea.select();
           14         try {
           15                 document.execCommand("copy");
           16         } catch (err) {
           17         }
           18         if (el == null)
           19                 document.body.removeChild(textarea);
           20         else
           21                 el.parentNode.removeChild(textarea);
           22 }
           23 
           24 // copy the data-value from the specified element to the clipboard.
           25 function clipcopy_datavalue(el) {
           26         clipcopy(el.getAttribute("data-value") || "", el);
           27