-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
113 lines (104 loc) · 4.71 KB
/
index.html
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="style.css">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"></script>
</head>
<body>
<div id="main">
<div id="container">
<div style="padding: 80px;"></div>
<div style="padding: 10px;">
<label for="inp" id="label">
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" fill="currentColor" class="bi bi-upload" viewBox="0 0 16 16">
<path d="M.5 9.9a.5.5 0 0 1 .5.5v2.5a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-2.5a.5.5 0 0 1 1 0v2.5a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2v-2.5a.5.5 0 0 1 .5-.5z"/>
<path d="M7.646 1.146a.5.5 0 0 1 .708 0l3 3a.5.5 0 0 1-.708.708L8.5 2.707V11.5a.5.5 0 0 1-1 0V2.707L5.354 4.854a.5.5 0 1 1-.708-.708l3-3z"/>
</svg>
<span class="drop-title">Choose a file</span>
<input type="file" id="inp">
</label>
</div>
<div id="footer">
<button id ="btn" class="button-54" role="button">Get link</button>
</div>
<div class="form-input" id="join-id"></div>
</div>
<h1 id="text">We're developer team and we're going to make file sharing easy for you</h1>
<div id="scroll-div1">
<h1>DEVDROP</h1>
<h1>DEVDROP</h1>
<h1>DEVDROP</h1>
</div>
<div id="scroll-div2">
<h1>DEVDROP</h1>
<h1>DEVDROP</h1>
<h1>DEVDROP</h1>
</div>
<div id="scroll-div3">
<h1>DEVDROP</h1>
<h1>DEVDROP</h1>
<h1>DEVDROP</h1>
<h1>DEVDROP</h1>
</div>
</div>
<script type="module">
import { initializeApp } from "https://www.gstatic.com/firebasejs/9.22.1/firebase-app.js";
import { getStorage, ref, uploadBytes, getDownloadURL } from "https://www.gstatic.com/firebasejs/9.22.1/firebase-storage.js";
const firebaseConfig = {
apiKey: "AIzaSyB0gEhq2Xr5lho4fi-bWMT263MjBB8AK5k",
authDomain: "node-devdrop.firebaseapp.com",
databaseURL: "https://node-devdrop-default-rtdb.firebaseio.com",
projectId: "node-devdrop",
storageBucket: "node-devdrop.appspot.com",
messagingSenderId: "581815676440",
appId: "1:581815676440:web:f0f922cac6bea891155d6d"
};
const app = initializeApp(firebaseConfig);
const storage = getStorage(app);
var myElement = document.getElementById('join-id');
document.getElementById("btn").addEventListener('click',function() {
myElement.style.display = 'none';
//Upload File
var file = document.getElementById("inp").files[0]
var x = document.getElementById("inp");
if (x.value == "") {
alert("No file selected!");
return;
}
else{
document.querySelector("#btn").innerHTML = `
<span class="spinner-border spinner-border-sm"></span> Get link
`;
const storage = getStorage();
const storageRef = ref(storage, 'images/'+file.name);
uploadBytes(storageRef, file).then((snapshot) =>
{
console.log('File Uploaded');
var filename = 'images/'+file.name;
console.log(filename);
//Download File
getDownloadURL(ref(storage,'images/'+file.name))
.then((url) => {
console.log(filename);
document.querySelector("#btn").innerHTML = `
Get link
`;
document.querySelector("#join-id").innerHTML = `
<a href="${url}" target="_blank"><button id ="btn" class="button-54" role="button">Download</button></a>
`;
myElement.style.display = 'block';
})
.catch((error) => {
console.log(errorMessage);
});
});
}
});
</script>
</body>
</html>