js/copy-input.js
function copy(el, text) {
    var result, lastText;

    if (text) {
        lastText = el.value;
        el.value = text;
    } else {
        text = el.value;
    }

    el.value = multiLineTrim(text);

    try {
        el.select();
        result = document.execCommand('copy');
    } catch (err) {
        result = false;
    } finally {
        if (lastText !== undefined) {
            el.value = lastText;
        }
        el.blur();
    }
    return result;
}
function copy(el, text) {
    var result, lastText;

    if (text) {
        lastText = el.value;
        el.value = text;
    } else {
        text = el.value;
    }

    el.value = multiLineTrim(text);

    try {
        el.select();
        result = document.execCommand('copy');
    } catch (err) {
        result = false;
    } finally {
        if (lastText !== undefined) {
            el.value = lastText;
        }
        el.blur();
    }
    return result;
}
function copy ( el , text ) { var result , lastText ; if ( text ) { lastText = el . value ; el . value = text ; } else { text = el . value ; } el . value = multiLineTrim ( text ) ; try { el . select ( ) ; result = document . execCommand ( 'copy' ) ; } catch ( err ) { result = false ; } finally { if ( lastText !== undefined ) { el . value = lastText ; } el . blur ( ) ; } return result ; }
1. Trim the text in the given input element
2. select it
3. copy it to the clipboard
4. deselect it
5. return it
@param {HTMLElement|HTMLTextAreaElement} el
@param {string} [text=el.value] - Text to copy.
@returns {undefined|string} Trimmed text in element or undefined if unable to copy.
1 . Trim the text in the given input element 2 . select it 3 . copy it to the clipboard 4 . deselect it 5 . return it