forked from assembler-institute/filesystem-explorer
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdyScript.js
More file actions
111 lines (89 loc) · 3.61 KB
/
Copy pathdyScript.js
File metadata and controls
111 lines (89 loc) · 3.61 KB
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
const exampleModal = document.getElementById('exampleModal')
exampleModal.addEventListener('show.bs.modal', event => {
// Button that triggered the modal
const button = event.relatedTarget
// Extract info from data-bs-* attributes
const recipient = button.getAttribute('data-bs-url')
const name = button.getAttribute('data-bs-name')
const ctime = button.getAttribute('data-bs-ctime')
const mtime = button.getAttribute('data-bs-mtime')
const dataExtension = button.getAttribute('data-bs-extension')
const size = button.getAttribute('data-bs-size')
// If necessary, you could initiate an AJAX request here
// and then do the updating in a callback.
//
// Update the modal's content.
const modalTitle = exampleModal.querySelector('.modal-title')
const modalBodyInput = exampleModal.querySelector('.modal-body')
const modalBodyClose = exampleModal.querySelector('.modal-footer-close')
const modalTitleInfo = exampleModal.querySelector('.modal-title-info')
const modalTitleInfoName = exampleModal.querySelector('.modal-title-name')
const modalTitleInfoCtime = exampleModal.querySelector('.modal-title-ctime')
const modalTitleInfoMtime = exampleModal.querySelector('.modal-title-mtime')
const modalTitleInfoExtension = exampleModal.querySelector('.modal-title-extension')
const modalTitleInfoSize = exampleModal.querySelector('.modal-title-size')
var x = document.getElementById("myAudio");
function pauseAudio() {
x.pause();
}
extension = recipient.split('.').pop();
modalTitle.textContent = `Preview and Information about ${name}`
modalTitleInfo.textContent = `Info about ${name}`
modalTitleInfoName.textContent = name
modalTitleInfoCtime.textContent = ctime
modalTitleInfoMtime.textContent = mtime
modalTitleInfoExtension.textContent = dataExtension
modalTitleInfoSize.textContent = size
switch (extension) {
case "webp":
case "png":
case "jpg":
case "jpeg":
case "jfif":
case "pjpeg":
case "pjp":
case "avif":
case "apng":
modalBodyInput.innerHTML = `<img src="${recipient}" width="100%"></img>`;
break;
case "webm":
case "mpg":
case "mp2":
case "mpeg":
case "mpe":
case "mpv":
case "mp4":
case "m4p":
case "m4v":
case "avi":
case "wmv":
case "mov":
case "qt":
case "flv":
case "swf":
case "avchd":
modalBodyInput.innerHTML = `<video src="${recipient}" width="100%" autoplay></video>`;
break;
case "wav":
case "aiff":
case "mp3":
case "aac":
case "flac":
case "alac":
modalBodyInput.innerHTML = `<audio id='myAudio' controls src="${recipient}"></audio>`;
modalBodyClose.innerHTML = `<button onclick="pauseAudio()" type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>`;
break;
case "pdf":
modalBodyInput.innerHTML = `<embed src="${recipient}" width="100%" height="800px"/>`;
break;
case "zip":
modalBodyInput.innerHTML = `<a href='${recipient}'><img src="assets/zip.png" alt="Zip Icon" width="100%" height="500"></img></a>`;
break;
case "txt":
modalBodyInput.innerHTML = `<a href='${recipient}'><img src="assets/txt.png" alt="Text Icon" width="100%" height="500"></img></a>`;
break;
default:
modalBodyInput.innerHTML = recipient
break;
}
})