-
Notifications
You must be signed in to change notification settings - Fork 1
/
site.js
30 lines (26 loc) · 926 Bytes
/
site.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
function copy(id){
var href = document.getElementById("href" + id.toString());
var contentDiv = document.getElementById("clip" + id.toString());
var clipContent = "";
if(href) {
clipContent = href.innerHTML;
} else if(contentDiv) {
clipContent = contentDiv.innerHTML;
}
if(clipContent) {
copyHack(clipContent);
var backgroundColor = document.body.style.backgroundColor;
document.body.style.backgroundColor = '#ccffcc';
setTimeout(function () {document.body.style.backgroundColor = backgroundColor}, 200);
}
}
function copyHack(value){ //such a hack!!
var copyTextarea = document.createElement("textarea");
copyTextarea.style.position = "fixed";
copyTextarea.style.opacity = "0";
copyTextarea.textContent = value;
document.body.appendChild(copyTextarea);
copyTextarea.select();
document.execCommand("copy");
document.body.removeChild(copyTextarea);
}