-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFile_Viewer.js
More file actions
67 lines (34 loc) · 1.34 KB
/
File_Viewer.js
File metadata and controls
67 lines (34 loc) · 1.34 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
function open_file_viewer(file_path) {
let extension = file_path.split('.').pop().toLowerCase();
if (["pdf", "doc", "docx"].includes(extension)) {
open_app("file-viewer-app", "FILE VIEWER", `
<div class="file-viewer-body">
<iframe src="${file_path}"></iframe>
</div>
`);
} else if (["jpg", "jpeg", "png", "gif", "bmp"].includes(extension)) {
open_app("file-viewer-app", "FILE VIEWER", `
<div class="file-viewer-body">
<img src="${file_path}" alt="File">
</div>
`);
} else if (["mp4", "webm", "ogg"].includes(extension)) {
open_app("file-viewer-app", "FILE VIEWER", `
<div class="file-viewer-body">
<video controls src="${file_path}" type="video/${extension}"></video>
</div>
`);
} else if (["mp3", "wav", "ogg"].includes(extension)) {
open_app("file-viewer-app", "FILE VIEWER", `
<div class="file-viewer-body">
<audio controls src="${file_path}" type="audio/${extension}"></audio>
</div>
`);
} else {
open_app("file-viewer-app", "FILE VIEWER", `
<div class="file-viewer-body">
<p>Cannot Preview This File Type.</p>
</div>
`);
}
};