-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
34 lines (26 loc) · 862 Bytes
/
script.js
File metadata and controls
34 lines (26 loc) · 862 Bytes
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
let title = document.querySelector("#title");
let url = document.querySelector("#url");
let tag = document.querySelector("#tag");
let result = document.querySelector(".result_text");
let submit_btn = document.querySelector("#submit");
let copy_btn = document.querySelector(".copy_btn");
function generate(title, url, tag){
let final_string = `<title>${title}</title> <meta name="theme-color" content="${url}"> <meta name="description" content="${tag}">`;
result.value = final_string;
}
function copy(){
result.select();
document.execCommand("copy");
}
submit_btn.addEventListener("click", () => {
generate(title.value, url.value, tag.value);
title.value = "";
url.value = "";
tag.value = "";
});
copy_btn.addEventListener("click", () => {
copy();
})
window.addEventListener("unload", () => {
result.value = "";
})