-
Notifications
You must be signed in to change notification settings - Fork 0
/
send.html
197 lines (183 loc) · 6.47 KB
/
send.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
<!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" />
<link rel="apple-touch-icon" sizes="180x180" href="v/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="v/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="v/favicon-16x16.png">
<link rel="manifest" href="v/site.webmanifest">
<link
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC"
crossorigin="anonymous"
/>
<script
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM"
crossorigin="anonymous"
></script>
<!-- Firebase CDN -->
<script src="https://www.gstatic.com/firebasejs/8.8.0/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.8.0/firebase-database.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.8.0/firebase-storage.js"></script>
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<title>MVJ NOTICE UPLOAD PORTAL</title>
</head>
<body>
<center><i><b><h1><u>Notice Upload Portal</u></h1></b></i></center>
<div class="container mb-5">
<h3 class="mt-5">Upload the File</h3>
<div class="row g-3 mt-2 border">
<div class="col-md-3">
<label for="id" class="form-label">MAIN CONTENT</label>
<input
class="form-control"
type="text"
required
placeholder="Content"
id="content"
/>
</div>
<div class="col-md-3">
<label for="id" class="form-label">HEADER CONTENT</label>
<input
class="form-control"
type="text"
required
placeholder="Header"
id="head-sec"
/>
</div>
<div class="col-md-3">
<label for="id" class="form-label">NOTICE REFERENCE</label>
<input
class="form-control"
type="text"
required
placeholder="Notice Ref"
id="notice-ref"
/>
</div>
<div class="col-md-3">
<label for="id" class="form-label">Time</label>
<input
class="form-control"
type="date"
required
placeholder="Time"
id="time"
/>
</div>
<div class="col-md-3">
<label for="id" class="form-label">VALIDITY</label>
<input
class="form-control"
type="text"
required
placeholder="Validity"
id="validity"
/>
</div>
<div class="col-md-3">
<label for="file" class="form-label">IMAGE FILE</label>
<div class="input-group mb-3">
<input type="file" class="form-control" required id="file" />
</div>
</div>
<div class="col-md-3">
<label for="file" class="form-label">Notice Number</label>
<div class="input-group mb-3">
<!-- <input type="" class="form-control" required id="file" /> -->
<select name="not" id="fil" class="form-select" >
<option value="notice-1" >NOTICE-1</option>
<option value="notice-2">NOTICE-2</option>
<option value="notice-3">NOTICE-3</option>
</select>
</div>
</div>
</div>
<br />
<button type="submit" onclick="update()" class="btn btn-primary" id="submit">
<div id="loading" style="display: none">
<span
class="spinner-border spinner-border-sm"
role="status"
aria-hidden="true"
></span>
Loading...
</div>
<span id="uploadSpan">Upload</span>
</button>
<script >
const firebaseConfig = {
apiKey: "AIzaSyDYK-pacTGL3Q2ugGW12XhplpCBkrSob-A",
authDomain: "webdemo-572d9.firebaseapp.com",
databaseURL: "https://webdemo-572d9-default-rtdb.firebaseio.com",
projectId: "webdemo-572d9",
storageBucket: "webdemo-572d9.appspot.com",
messagingSenderId: "692981044266",
appId: "1:692981044266:web:ebdb142027ab2a4de35f53"
};
var value;
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
var database=" ";
function update(){
var select = document.getElementById('fil');
value = select.options[select.selectedIndex].value;
console.log(value);
database = firebase.database().ref("Data/"+value+"/");
console.log(database);
}
const file = document.getElementById("file");
const content = document.getElementById("content");
const headsec = document.getElementById("head-sec");
const noticeref = document.getElementById("notice-ref");
const time = document.getElementById("time");
const validity = document.getElementById("validity");
const btn = document.getElementById("submit");
const loading = document.getElementById("loading");
btn.addEventListener("click", () => {
const storage = firebase.storage().ref(value+".jpg");
const idName = "hh";
const floc = file.files[0];
file.value = "";
const metadata = {
contentType: file.jpg,
};
var task = storage.put(floc, metadata);
task.on(
"state_changed",
(snapshot) => {
loading.style.display = "block";
uploadSpan.style.display = "none";
console.log("Uploading...");
},
(err) => {
console.log(err);
},
() => {
loading.style.display = "none";
uploadSpan.style.display = "block";
task.snapshot.ref.getDownloadURL().then((url) => {
database.set({
content: content.value,
head_sec: headsec.value,
notice_ref: noticeref.value,
time: time.value,
validity: validity.value,
url : url
});
});
console.log("Complete");
// alert("Uploaded");
}
);
});
</script>
</body>
</html>