-
Notifications
You must be signed in to change notification settings - Fork 0
/
send.js
55 lines (41 loc) · 1.69 KB
/
send.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
function openFile() {
let input = document.createElement('input');
input.type = 'file';
input.onchange = () => {
const file = input.files[0];
const reader = new FileReader();
reader.onloadend = () => {
const string = `${reader.result}name://${file.name}`;
success(string);
}
reader.readAsDataURL(file);
}
input.click();
}
function success(string) {
document.getElementById("open-card").classList.remove("card-flat-bottom");
document.getElementById("open-card").classList.add("card-success-flat-bottom");
document.getElementById("open-button").classList.add("button-success");
document.getElementById("open-button").inert = "true";
document.getElementById("open-icon").innerText = "check";
document.getElementById("open-text").innerText = "File opened";
document.getElementById("copy-card").classList.remove("card-subtle-flat-top");
document.getElementById("copy-card").classList.add("card-flat-top");
document.getElementById("copy-button").classList.remove("button-subtle");
document.getElementById("copy-button").removeAttribute("inert");
document.getElementById("copy-button").onclick = () => {
copy(string);
}
}
function copy(string) {
navigator.clipboard.writeText(string);
document.getElementById("copy-card").classList.remove("card-flat-top");
document.getElementById("copy-card").classList.add("card-success-flat-top");
document.getElementById("copy-button").classList.add("button-success");
document.getElementById("copy-button").inert = "true";
document.getElementById("copy-icon").innerText = "check";
document.getElementById("copy-text").innerText = "Text copied";
setTimeout(() => {
location.href = ".";
}, 500);
}