Populate original file name

Signed-off-by: Joe Ma <rikkaneko23@gmail.com>
This commit is contained in:
Joe Ma 2022-10-15 15:12:16 +08:00
parent 4408b4027b
commit 5cef3755b3
No known key found for this signature in database
GPG key ID: 7A0ECF5F5EDC587F

View file

@ -61,7 +61,7 @@
<label for="title_input">Title: </label> <label for="title_input">Title: </label>
</td> </td>
<td> <td>
<input id="title_input" type="text" name="title" spellcheck="false"> <input id="title_input" type="text" name="title" spellcheck="false" style="width: 20em">
</td> </td>
</tr> </tr>
<tr> <tr>
@ -69,7 +69,7 @@
<label for="pass_input">Password: </label> <label for="pass_input">Password: </label>
</td> </td>
<td> <td>
<input id="pass_input" type="password" name="pass"> <input id="pass_input" type="password" name="pass" style="width: 20em">
<input id="show_pass_button" type="checkbox"> <input id="show_pass_button" type="checkbox">
<label for="show_pass_button">Show</label> <label for="show_pass_button">Show</label>
</td> </td>
@ -96,7 +96,6 @@
<input id="sumbit_form_button" type="submit" value="Sumbit" style="font-size: 14px"> (<span <input id="sumbit_form_button" type="submit" value="Sumbit" style="font-size: 14px"> (<span
id="file_stats">0 bytes</span>) id="file_stats">0 bytes</span>)
</div> </div>
</div>
</form> </form>
<script> <script>
@ -107,6 +106,7 @@
function update_file_status() { function update_file_status() {
const status = document.getElementById('file_stats'); const status = document.getElementById('file_stats');
const title = document.getElementById('title_input');
if (this.files[0] === undefined) { if (this.files[0] === undefined) {
status.textContent = '0 bytes'; status.textContent = '0 bytes';
return; return;
@ -117,6 +117,7 @@
for (let i = 0, approx = bytes / 1024; approx > 1; approx /= 1024, i++) { for (let i = 0, approx = bytes / 1024; approx > 1; approx /= 1024, i++) {
size = approx.toFixed(3) + ' ' + units[i]; size = approx.toFixed(3) + ' ' + units[i];
} }
title.value = this.files[0]?.name || '';
status.textContent = `${this.files[0]?.type || 'application/octet-stream'}, ${size}`; status.textContent = `${this.files[0]?.type || 'application/octet-stream'}, ${size}`;
} }