Completed
Push — master ( bda088...431d08 )
by Sander
01:09
created

js/lib/copyText.js   A

Complexity

Total Complexity 1
Complexity/F 1

Size

Lines of Code 10
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 0
c 1
b 0
f 0
nc 1
dl 0
loc 10
rs 10
wmc 1
mnd 0
bc 1
fnc 1
bpm 1
cpm 1
noi 0
1
function copyText(text) {
2
    var txtToCopy = document.createElement('input');
3
    txtToCopy.style.left = '-300px';
4
    txtToCopy.style.position = 'absolute';
5
    txtToCopy.value = text;
6
    document.body.appendChild(txtToCopy);
7
    txtToCopy.select();
8
    document.execCommand('copy');
9
    txtToCopy.parentNode.removeChild(txtToCopy);
10
}