-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
253 lines (238 loc) · 8.85 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
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<title>ImJoy elFinder</title>
<style>
.spinner {
border: 16px solid #f3f3f3;
border-top: 16px solid #3498db;
border-radius: 50%;
width: 60px;
height: 60px;
animation: spin 2s linear infinite;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
</style>
<!-- elfinder 1.x connector API support (OPTIONAL) -->
<script src="./elFinderSupportBrowserFS.js"></script>
<!-- Require JS (REQUIRED) -->
<!-- Rename "main.default.js" to "main.js" and edit it if you need configure elFInder options or any things -->
<script data-main="./main.default.js"
src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js"></script>
<script>
define('elFinderConfig', {
// elFinder options (REQUIRED)
// Documentation for client options:
// https://github.com/Studio-42/elFinder/wiki/Client-configuration-options
defaultOpts: {
url: '/fs/connector', // or connector.maximal.php : connector URL (REQUIRED)
height: '100%',
// transport : new elFinderSupportBrowserFs(),
theme: 'default',
themes: {
'dark-slim': 'https://johnfort.github.io/elFinder.themes/dark-slim/manifest.json',
'material': 'https://nao-pon.github.io/elfinder-theme-manifests/material-default.json',
'material-gray': 'https://nao-pon.github.io/elfinder-theme-manifests/material-gray.json',
'material-light': 'https://nao-pon.github.io/elfinder-theme-manifests/material-light.json',
'win10': 'https://nao-pon.github.io/elfinder-theme-manifests/win10.json'
},
commandsOptions: {
edit: {
extraOptions: {
// set API key to enable Creative Cloud image editor
// see https://console.adobe.io/
creativeCloudApiKey: '',
// browsing manager URL for CKEditor, TinyMCE
// uses self location with the empty value
managerUrl: ''
}
},
quicklook: {
width: 750,
height: 450,
// to enable CAD-Files and 3D-Models preview with sharecad.org
sharecadMimes: ['image/vnd.dwg', 'image/vnd.dxf', 'model/vnd.dwf', 'application/vnd.hp-hpgl', 'application/plt', 'application/step', 'model/iges', 'application/vnd.ms-pki.stl', 'application/sat', 'image/cgm', 'application/x-msmetafile'],
// to enable preview with Google Docs Viewer
googleDocsMimes: ['application/pdf', 'image/tiff', 'application/vnd.ms-office', 'application/msword', 'application/vnd.ms-word', 'application/vnd.ms-excel', 'application/vnd.ms-powerpoint', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/vnd.openxmlformats-officedocument.presentationml.presentation', 'application/postscript', 'application/rtf'],
// to enable preview with Microsoft Office Online Viewer
// these MIME types override "googleDocsMimes"
officeOnlineMimes: ['application/vnd.ms-office', 'application/msword', 'application/vnd.ms-word', 'application/vnd.ms-excel', 'application/vnd.ms-powerpoint', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/vnd.openxmlformats-officedocument.presentationml.presentation', 'application/vnd.oasis.opendocument.text', 'application/vnd.oasis.opendocument.spreadsheet', 'application/vnd.oasis.opendocument.presentation']
}
},
// bootCalback calls at before elFinder boot up
bootCallback: function (fm, extraObj) {
/* any bind functions etc. */
fm.bind('init', function () {
require(['imjoyLoader'], function (imjoyLoader) {
function mount(host) {
return new Promise((resolve, reject) => {
fm.request({
data: {
cmd: 'netmount',
protocol: 's3',
host,
},
preventFail: true,
notify: { type: 'netmount', cnt: 1, hideCnt: true }
}).done(function (data) {
var pdir;
if (data.added && data.added.length) {
if (data.added[0].phash) {
if (pdir = fm.file(data.added[0].phash)) {
if (!pdir.dirs) {
pdir.dirs = 1;
fm.change({ changed: [pdir] });
}
}
}
fm.one('netmountdone', function () {
fm.exec('open', data.added[0].hash);
fm.one('opendone', function () {
data.toast && fm.toast(data.toast);
});
});
}
resolve();
})
.fail(reject)
})
}
// inside iframe
if (window.self !== window.top) {
const rootNode = fm.getUI().get(0)
fm.toggleFullscreen(rootNode)
loadImJoyRPC({
version: "0.5.13"
}).then(async (imjoyRPC) => {
const api = await imjoyRPC.setupRPC({
name: 'ImJoy elFinder',
description: 'A web file browser for ImJoy',
type: 'rpc-window',
version: '{{ IMJOY_ELFINDER_VERSION }}',
defaults: {
as_dialog: true
},
})
function setup() {
window.imjoy = {
api
}
api.log('elFinder plugin initialized.')
}
async function close() {
await api.close()
}
async function show() {
await api.show()
}
async function hide() {
await api.hide()
}
function getSelections(config) {
return new Promise((resolve) => {
const buttonStyle = "font-size: 0.65rem; background: #448aff;color: white;margin-right: 10px;margin-top: -4px;margin-left: -8px;width: 40px;"
// Check if buttons already exist
let ok_button = $('#ok-button');
let cancel_button = $('#cancel-button');
if (!ok_button.length || !cancel_button.length) {
ok_button = $(`<button id="ok-button" style="${buttonStyle}" class="dialog-btn ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only elfinder-btncnt-2 elfinder-tabstop">OK</button>`)
cancel_button = $(`<button id="cancel-button" style="${buttonStyle}" class="dialog-btn ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only elfinder-btncnt-2 elfinder-tabstop">Cancel</button>`)
const button_set = $('<div class="ui-dialog-buttonset"></div>')
button_set.append(ok_button).append(cancel_button)
button_set.insertAfter(fm.getUI('statusbar').children('.elfinder-stat-size'));
}
ok_button.on('click', () => {
const selected = fm.selectedFiles()
resolve(selected);
if(config === undefined || !config.close_on_select) api.close()
})
ok_button.hide()
fm.select(() => {
ok_button.show()
})
cancel_button.on('click', () => {
resolve([])
if(config === undefined || !config.close_on_select) api.close()
})
// adjust the window size
window.dispatchEvent(new Event('resize'))
api.on("close", () => {
resolve([])
})
})
}
function run() {
}
api.export({
setup,
run,
close,
hide,
mount,
getSelections
});
})
}
else {
setupImJoyApp();
// get the a list of query `mount` values and mount them
const query = new URLSearchParams(window.location.search);
const mounts = query.getAll('mount')
for (const host of mounts) {
mount(host).catch(console.error);
}
}
})
});
// for example set document.title dynamically.
var title = document.title;
fm.bind('open', function () {
var path = '',
cwd = fm.cwd();
if (cwd) {
path = fm.path(cwd.hash) || null;
}
document.title = path ? path + ':' + title : title;
}).bind('destroy', function () {
document.title = title;
});
}
},
managers: {
// 'DOM Element ID': { /* elFinder options of this DOM Element */ }
'elfinder': {}
}
});
</script>
<style>
.imjoy-dialog-control {
height: 20px !important;
width: 13px !important;
}
div.elfinder {
width: calc(100vw - 2px) !important;
height: calc(100vh - 2px) !important;
}
</style>
</head>
<body>
<div id="spinner" class="spinner"></div>
<!-- Element where elFinder will be created (REQUIRED) -->
<div id="elfinder"></div>
<!-- <div id="window-manager" style="position:absolute;"></div> -->
</body>
</html>