-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
41 lines (34 loc) · 1.47 KB
/
script.js
File metadata and controls
41 lines (34 loc) · 1.47 KB
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
31
32
33
34
35
36
37
38
39
40
41
let html_input = document.querySelector("#html-section textarea");
let css_input = document.querySelector("#css-section textarea");
let js_input = document.querySelector("#js-section textarea");
let save = document.querySelector("#save");
let output = document.querySelector("#output");
save.addEventListener("click",() => {
output.contentDocument.body.innerHTML = html_input.value;
output.contentDocument.head.innerHTML = `<style>${css_input.value}</style>`;
const script = document.createElement("script");
script.textContent = js_input.value;
output.contentDocument.body.appendChild(script);
})
let full = document.querySelector("#full-screen");
let output_container = document.querySelector(".output-container");
full.addEventListener("click" , () => {
output_container.classList.toggle("output-full-screen");
if( output_container.classList.contains("output-full-screen")){
full.style.transform = "rotate(180deg)";
}else{
full.style.transform = "rotate(0deg)";
}
})
let copy = document.querySelectorAll(".copy");
copy.forEach((e) => {
e.addEventListener("click" , () => {
if(e.classList.contains("copy1")){
navigator.clipboard.writeText(html_input.value);
}else if(e.classList.contains("copy2")){
navigator.clipboard.writeText(css_input.value);
}else if(e.classList.contains("copy3")){
navigator.clipboard.writeText(js_input.value);
}
})
})