commit | author | age
|
723bf7
|
1 |
/* |
U |
2 |
Dateiverwaltung - File management in your browser |
|
3 |
Copyright (C) 2017 Ulrich Hilger, http://uhilger.de |
|
4 |
|
|
5 |
This program is free software: you can redistribute it and/or modify |
|
6 |
it under the terms of the GNU Affero General Public License as |
|
7 |
published by the Free Software Foundation, either version 3 of the |
|
8 |
License, or (at your option) any later version. |
|
9 |
|
|
10 |
This program is distributed in the hope that it will be useful, |
|
11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
GNU Affero General Public License for more details. |
|
14 |
|
|
15 |
You should have received a copy of the GNU Affero General Public License |
|
16 |
along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
17 |
*/ |
|
18 |
|
a4d3b5
|
19 |
var cm; |
5dfab6
|
20 |
var pfad = ''; |
10d3d3
|
21 |
var modus = 'kacheln'; |
5ebb8e
|
22 |
var openFileName = ''; |
305573
|
23 |
var ed; |
7d8ef6
|
24 |
var openEditor; |
0c1d5b
|
25 |
var userid; |
U |
26 |
var tmo; |
be9b6d
|
27 |
var tmo2; |
7165a1
|
28 |
var cutCopySrcDir; |
U |
29 |
var cutCopyFiles; |
|
30 |
var cutCopyOperation; |
fa012b
|
31 |
var loc; |
cccd2b
|
32 |
var PERS_DIR = "Persoenlich"; |
U |
33 |
var PUB_DIR = "Oeffentlich"; |
45ad00
|
34 |
var DAV_DIR = "Austausch"; |
1f550a
|
35 |
var BASE_DIR = "$basis"; |
U |
36 |
var DATA_DIR = "$daten"; |
11536c
|
37 |
var WWW_DIR = "www"; |
e3043f
|
38 |
var compilerIssues; |
76660f
|
39 |
var fm_slideshow = false; |
c7c502
|
40 |
|
U |
41 |
function fm_init() { |
305573
|
42 |
$("#mce-editor").hide(); |
a4d3b5
|
43 |
$('.codeeditor-space').hide(); |
U |
44 |
$('.code-editor-container').hide(); |
a450f2
|
45 |
$('.sued').hide(); |
bef5c6
|
46 |
//$('.ost').attr('flex-basis', 0); |
53119f
|
47 |
$('#newTab').on('click', fm_newTab); |
a4d3b5
|
48 |
$('#newTextFile').on('click', fm_menu_neue_textdatei); |
305573
|
49 |
$('#newDoc').on('click', fm_menu_neues_dokument); |
adf812
|
50 |
$('#newFolder').on('click', fm_get_new_folder); |
fc8db1
|
51 |
$('#viewFile').on('click', fm_view_file); |
977e5d
|
52 |
$('#viewSlideshow').on('click', fm_view_slideshow); |
7d8ef6
|
53 |
$('#editTextFile').on('click', function() { |
U |
54 |
fm_get_file_content('text'); |
|
55 |
}); |
|
56 |
$('#editDocFile').on('click', function() { |
|
57 |
fm_get_file_content('dok'); |
|
58 |
}); |
e5ff42
|
59 |
$('#saveFile').on('click', fm_menu_datei_speichern); |
5ebb8e
|
60 |
$('#saveFileAs').on('click', fm_menu_datei_speichern_unter); |
a4d3b5
|
61 |
$('#closeFile').on('click', fm_menu_datei_schliessen); |
8446c2
|
62 |
$('#renameFile').on('click', fm_menu_datei_umbenennen); |
af9930
|
63 |
$('#m-zip').on('click', fm_menu_ordner_packen); |
6bd2c1
|
64 |
$('#m-unzip').on('click', fm_menu_datei_entpacken); |
fad719
|
65 |
$('#m-html-export').on('click', fm_menu_html_export); |
fc1897
|
66 |
$('#m-del').on('click', fm_menu_delete); |
7165a1
|
67 |
$('#m-cut').on('click', fm_menu_cut); |
U |
68 |
$('#m-copy').on('click', fm_menu_copy); |
|
69 |
$('#m-paste').on('click', fm_menu_paste); |
438b16
|
70 |
$('#m-shrink').on('click', fm_menu_shrink); |
bb9f8c
|
71 |
$('#m-rotate').on('click', fm_menu_rotate); |
76660f
|
72 |
$('#m-toggle-slideshow').on('click', fm_toggle_show_slideshow); |
bef5c6
|
73 |
$('#m-test').on('click', fm_menu_test); |
72e43d
|
74 |
$('#m-test-2').on('click', fm_menu_compile); |
U |
75 |
$('#m-test-3').on('click', fm_menu_compile_all); |
a450f2
|
76 |
$('#m-compile-results').on('click', fm_fusszeile_zeigen); |
7b3372
|
77 |
$('#m-build-app').on('click', fm_menu_build_app); |
f59dce
|
78 |
$('#m-ant-build').on('click', fm_menu_ant_build); |
c509a0
|
79 |
$('#saveModal').on('hidden.bs.modal', function (e) { |
915927
|
80 |
$('#modal_ok').attr('onclick','').unbind('click'); |
b7475d
|
81 |
}); |
U |
82 |
$('#logout').click(fm_logout); |
a450f2
|
83 |
$('#fusszeile-schliessen').on('click', fm_fusszeile_schliessen); |
05cfa7
|
84 |
fm_get_login(); |
53119f
|
85 |
|
U |
86 |
//console.log(window.location); |
|
87 |
//console.log(window.location.search); |
|
88 |
var parsedUrl = new URL(window.location.href); |
|
89 |
//console.log(parsedUrl.searchParams.get("pfad")); |
|
90 |
var wunschPfad = parsedUrl.searchParams.get("pfad"); |
|
91 |
|
74fab1
|
92 |
if(wunschPfad !== null) { |
U |
93 |
if(wunschPfad.length > 0) { |
|
94 |
pfad = wunschPfad; |
|
95 |
fm_get_list(wunschPfad); |
|
96 |
fm_init_uploader(); |
|
97 |
} else { |
|
98 |
fm_get_list(''); |
|
99 |
fm_init_uploader(); |
|
100 |
} |
53119f
|
101 |
} else { |
U |
102 |
fm_get_list(''); |
|
103 |
fm_init_uploader(); |
|
104 |
} |
fa012b
|
105 |
/* |
U |
106 |
console.log('href: ' + window.location.href); |
|
107 |
console.log('host: ' + window.location.host); |
|
108 |
console.log('hostname: ' + window.location.hostname); |
|
109 |
console.log('port: ' + window.location.port); |
|
110 |
console.log('protocol: ' + window.location.protocol); |
|
111 |
*/ |
|
112 |
loc = window.location.protocol + '//' + window.location.host; |
fc8db1
|
113 |
} |
U |
114 |
|
53119f
|
115 |
function fm_newTab() { |
U |
116 |
window.open('/file-cms/ui/?pfad=' + pfad, '_blank'); |
|
117 |
} |
|
118 |
|
76660f
|
119 |
function fm_toggle_show_slideshow() { |
U |
120 |
if(fm_slideshow) { |
968b07
|
121 |
$('#m-toggle-slideshow').text('Diashow einschalten'); |
76660f
|
122 |
fm_slideshow = false; |
U |
123 |
} else { |
968b07
|
124 |
$('#m-toggle-slideshow').text('Diashow ausschalten'); |
76660f
|
125 |
fm_slideshow = true; |
U |
126 |
} |
|
127 |
} |
|
128 |
|
0c1d5b
|
129 |
function fm_resize_editor() { |
U |
130 |
window.clearTimeout(tmo); |
|
131 |
tmo = window.setTimeout(function () { |
|
132 |
try { |
|
133 |
var myHeight = $('.zentrum').height() - $('.nord').height() - 4; |
|
134 |
ed.theme.resizeTo('100%', myHeight); // sets the dimensions of the editable area |
|
135 |
} catch (err) { |
|
136 |
} |
|
137 |
}, 200); |
a450f2
|
138 |
} |
U |
139 |
|
|
140 |
function fm_fusszeile_schliessen() { |
|
141 |
$('.sued').hide(); |
|
142 |
} |
|
143 |
|
|
144 |
function fm_fusszeile_zeigen() { |
|
145 |
$('.sued').show(); |
fc8db1
|
146 |
} |
U |
147 |
|
0c1d5b
|
148 |
function fm_get_path(uid) { |
U |
149 |
//console.log('pfad: ' + pfad); |
|
150 |
var restdir; |
cccd2b
|
151 |
if(pfad.indexOf(PUB_DIR) > -1) { |
U |
152 |
restdir = pfad.substr(PUB_DIR.length); |
|
153 |
} else if(pfad.indexOf(PERS_DIR) > -1) { |
|
154 |
restdir = pfad.substr(PERS_DIR.length); |
1f550a
|
155 |
} else if(pfad.indexOf(BASE_DIR) > -1) { |
U |
156 |
restdir = pfad.substr(BASE_DIR.length); |
|
157 |
} else if(pfad.indexOf(DATA_DIR) > -1) { |
|
158 |
restdir = pfad.substr(DATA_DIR.length); |
45ad00
|
159 |
} else if(pfad.indexOf(DAV_DIR) > -1) { |
U |
160 |
restdir = pfad.substr(DAV_DIR.length); |
0c1d5b
|
161 |
} |
U |
162 |
if(restdir !== undefined && restdir.startsWith('/')) { |
|
163 |
restdir = restdir.substr(1); |
11536c
|
164 |
if(restdir.indexOf(WWW_DIR) > -1) { |
U |
165 |
restdir = restdir.replace(WWW_DIR, 'data'); |
|
166 |
} |
0c1d5b
|
167 |
} |
U |
168 |
var pdir = fm_get_base(uid); |
11536c
|
169 |
// console.log('fm_get_path path: ' + pdir + "/" + restdir); |
0c1d5b
|
170 |
if(restdir.length > 1) { |
U |
171 |
return pdir + "/" + restdir; |
|
172 |
} else { |
|
173 |
return pdir; |
|
174 |
} |
|
175 |
} |
|
176 |
|
|
177 |
function fm_get_base(uid) { |
|
178 |
//console.log('pfad: ' + pfad); |
|
179 |
var pdir; |
cccd2b
|
180 |
if(pfad.indexOf(PUB_DIR) > -1) { |
11536c
|
181 |
pdir = '/data/' + uid; |
cccd2b
|
182 |
} else if(pfad.indexOf(PERS_DIR) > -1) { |
11536c
|
183 |
pdir = '/home/' + uid; |
U |
184 |
} else if(pfad.indexOf(BASE_DIR) > -1) { |
|
185 |
pdir = ''; |
|
186 |
} else if(pfad.indexOf(DATA_DIR) > -1) { |
|
187 |
pdir = ''; |
0c1d5b
|
188 |
} |
11536c
|
189 |
//console.log('fm_get_base base: ' + pdir + uid); |
U |
190 |
return pdir; |
0c1d5b
|
191 |
} |
05cfa7
|
192 |
|
0c1d5b
|
193 |
function fm_dok_editor_init(uid) { |
U |
194 |
var base = fm_get_path(uid); |
a75859
|
195 |
edCount = 0; |
11536c
|
196 |
//console.log("fm_dok_editor_init calling tinymce.init with base: " + base + "/"); |
fc8db1
|
197 |
|
0c1d5b
|
198 |
/* |
U |
199 |
* vgl. |
|
200 |
* http://stackoverflow.com/questions/4651676/how-do-i-remove-tinymce-and-then-re-add-it |
|
201 |
*/ |
|
202 |
//tinymce.EditorManager.execCommand('mceRemoveControl',true, 'textarea.text-editor'); |
|
203 |
//tinymce.EditorManager.execCommand('mceAddControl',true, editor_id); |
|
204 |
if(ed !== undefined) { |
|
205 |
ed.destroy(); |
|
206 |
} |
|
207 |
tinymce.remove('textarea.text-editor'); |
|
208 |
tinymce.EditorManager.editors = []; |
305573
|
209 |
|
U |
210 |
/* |
|
211 |
* Konfiguration TinyMCE |
|
212 |
*/ |
|
213 |
tinymce.init({ |
547755
|
214 |
content_css : "/file-cms/ui/mce.css", |
7b7627
|
215 |
//content_css: "/jslib/bootstrap/css/bootstrap.min.css", |
7d8ef6
|
216 |
selector: "textarea.text-editor", |
305573
|
217 |
statusbar: false, |
U |
218 |
menubar: false, |
bbb632
|
219 |
plugins: 'advlist charmap code image link lists media table print preview save table textcolor importcss', |
U |
220 |
toolbar: 'undo redo | styleselect | image table | link unlink | bullist numlist | outdent indent | code', |
305573
|
221 |
/* |
U |
222 |
menu: { |
|
223 |
file: {title: 'File', items: 'savevers | exit'}, |
|
224 |
edit: {title: 'Edit', items: 'undo redo | cut copy paste pastetext | selectall'}, |
|
225 |
view: {title: 'View', items: 'visualaid | code | link image media | template hr'}, |
|
226 |
}, |
|
227 |
*/ |
0c1d5b
|
228 |
resize: 'both', |
ea1ae0
|
229 |
importcss_append: true, |
305573
|
230 |
width: "100%", |
U |
231 |
height: '100%', |
11536c
|
232 |
relative_urls : true, |
U |
233 |
convert_urls : false, |
0c1d5b
|
234 |
document_base_url : base + "/", |
305573
|
235 |
setup: function (editor) { |
U |
236 |
ed = editor; |
|
237 |
} |
|
238 |
}); |
0c1d5b
|
239 |
|
U |
240 |
$(window).on('resize', fm_resize_editor); |
|
241 |
fm_resize_editor(); |
10d3d3
|
242 |
} |
7aa566
|
243 |
|
U |
244 |
/* ----- Uploader Anfang ----------*/ |
|
245 |
|
|
246 |
var dateien = new Array(); |
|
247 |
|
|
248 |
function fm_init_uploader() { |
|
249 |
var dropzone = document.getElementById("dateien"); |
|
250 |
dropzone.ondragover = dropzone.ondragenter = function(event) { |
|
251 |
event.stopPropagation(); |
|
252 |
event.preventDefault(); |
|
253 |
}; |
|
254 |
|
|
255 |
dropzone.ondrop = function(event) { |
|
256 |
event.stopPropagation(); |
|
257 |
event.preventDefault(); |
7ebde1
|
258 |
var fileList = event.dataTransfer.files; |
U |
259 |
for (var i=0; i<fileList.length; i++) { |
|
260 |
dateien.push(fileList[i]); |
|
261 |
} |
|
262 |
sendFile(dateien.pop()); |
7aa566
|
263 |
}; |
U |
264 |
} |
|
265 |
|
|
266 |
/* ----- Uploader Ende --------------- */ |
10d3d3
|
267 |
|
7165a1
|
268 |
/* ------- Dateifunktionen Start ----------- */ |
U |
269 |
|
|
270 |
function fm_menu_cut() { |
98f088
|
271 |
//alert('fm_menu_cut'); |
U |
272 |
fm_cut_files(); |
7165a1
|
273 |
} |
U |
274 |
function fm_menu_copy() { |
98f088
|
275 |
//alert('fm_menu_copy'); |
U |
276 |
fm_copy_files(); |
7165a1
|
277 |
} |
U |
278 |
function fm_menu_paste() { |
98f088
|
279 |
//alert('fm_menu_paste'); |
U |
280 |
fm_paste_files(); |
7165a1
|
281 |
} |
fc1897
|
282 |
function fm_menu_delete() { |
U |
283 |
$('#confirmOk').click(function() { |
a75859
|
284 |
$('#confirmOk').attr('onclick','').unbind('click'); |
fc1897
|
285 |
fm_del_files(); |
U |
286 |
}); |
a75859
|
287 |
$('#confirmOk').text("Loeschen"); |
U |
288 |
$('#confirmOk').removeClass('btn-primary'); |
|
289 |
$('#confirmOk').addClass('btn-danger'); |
|
290 |
$('#confirmClose').hide(); |
957b51
|
291 |
$('#confirmModalTitle').text("Löschen"); |
U |
292 |
$('#confirmModalBody').text("Wirklich löschen?"); |
fc1897
|
293 |
$('#confirmModal').modal({ |
U |
294 |
keyboard: false, |
|
295 |
show: true |
|
296 |
}); |
|
297 |
} |
7165a1
|
298 |
|
U |
299 |
/* |
|
300 |
* Gewaehlte Dateien feststellen |
|
301 |
* |
|
302 |
* @returns {String} eine per JSON.stringify schon vorbereitete List zum |
|
303 |
* Absenden als Parameter an den Server |
|
304 |
*/ |
|
305 |
function fm_gewaehlte_dateien() { |
|
306 |
var gewaehlte = $('.datei-gewaehlt'); |
a450f2
|
307 |
/* |
7165a1
|
308 |
//console.log('anzahl: ' + gewaehlte.length); |
U |
309 |
var fnames = new Array(); |
|
310 |
var i = 0; |
|
311 |
while(i < gewaehlte.length) { |
|
312 |
var str = { "java.lang.String": $(gewaehlte[i]).text()}; |
|
313 |
fnames.push(str); |
|
314 |
//console.log('loeschen ' + pfad + ' ' + $(gewaehlte[i]).text()); |
|
315 |
//i += 2; |
|
316 |
i++; |
|
317 |
} |
|
318 |
var liste = '{"List":' + JSON.stringify(fnames) + '}'; |
|
319 |
// 'liste' enthaelt: |
|
320 |
// {"List":[{"java.lang.String":"test3.txt"},{"java.lang.String":"Test1.txt"},{"java.lang.String":"Test2.txt"}]} |
|
321 |
// und wird auf dem Server zu einer List[ArrayList<String>] bei der jede ArrayList<String> nur ein Element hat |
|
322 |
return liste; |
a450f2
|
323 |
*/ |
U |
324 |
return fm_dateiliste_bilden(gewaehlte); |
7165a1
|
325 |
} |
a450f2
|
326 |
|
U |
327 |
function fm_dateiliste_bilden(gewaehlte) { |
|
328 |
var fnames = new Array(); |
|
329 |
var i = 0; |
|
330 |
while(i < gewaehlte.length) { |
|
331 |
var str = { "java.lang.String": $(gewaehlte[i]).text()}; |
|
332 |
fnames.push(str); |
|
333 |
//console.log('loeschen ' + pfad + ' ' + $(gewaehlte[i]).text()); |
|
334 |
//i += 2; |
|
335 |
i++; |
|
336 |
} |
|
337 |
var liste = '{"List":' + JSON.stringify(fnames) + '}'; |
|
338 |
// 'liste' enthaelt: |
|
339 |
// {"List":[{"java.lang.String":"test3.txt"},{"java.lang.String":"Test1.txt"},{"java.lang.String":"Test2.txt"}]} |
|
340 |
// und wird auf dem Server zu einer List[ArrayList<String>] bei der jede ArrayList<String> nur ein Element hat |
|
341 |
return liste; |
|
342 |
} |
|
343 |
|
fad719
|
344 |
function fm_menu_html_export() { |
U |
345 |
fm_export_html(); |
|
346 |
} |
|
347 |
|
7165a1
|
348 |
/* --------- Dateifunktionen Ende ---------- */ |
fc1897
|
349 |
|
bef5c6
|
350 |
function fm_menu_test() { |
U |
351 |
var w = $('.ost').width(); |
|
352 |
if(w == 0) { |
|
353 |
$('.ost').width('20%'); |
|
354 |
$('.ost').text('Hallo Welt!'); |
|
355 |
} else { |
|
356 |
$('.ost').empty(); |
|
357 |
$('.ost').width(0); |
|
358 |
} |
|
359 |
} |
|
360 |
|
72e43d
|
361 |
function fm_menu_compile() { |
fd0b4c
|
362 |
fm_compile('0', fm_mark_compile_results_in_editor); |
72e43d
|
363 |
} |
U |
364 |
function fm_menu_compile_all() { |
|
365 |
fm_compile_all(); |
fd0b4c
|
366 |
} |
U |
367 |
|
7b3372
|
368 |
function fm_menu_build_app() { |
U |
369 |
fm_build_app(); |
|
370 |
} |
|
371 |
|
f59dce
|
372 |
function fm_menu_ant_build() { |
U |
373 |
fm_ant_build(); |
|
374 |
} |
|
375 |
|
fd0b4c
|
376 |
function fm_mark_compile_results_in_editor(resp) { |
U |
377 |
cm.clearGutter("breakpoints"); |
|
378 |
|
|
379 |
if(resp.List[0].CompilerIssue !== undefined) { |
d9d37b
|
380 |
cm.setGutterMarker(0, "breakpoints", makeMarker("Code hat Fehler")); |
fd0b4c
|
381 |
var lno; |
U |
382 |
var eMsg; |
|
383 |
if(resp.List[0].CompilerIssue instanceof Array) { |
|
384 |
var issueNo = 0; |
|
385 |
while(issueNo < resp.List[0].CompilerIssue.length) { |
|
386 |
// console.log(resp.List[0].CompilerIssue[issueNo].kind); |
|
387 |
// console.log(resp.List[0].CompilerIssue[issueNo].lineNumber); |
|
388 |
// console.log(resp.List[0].CompilerIssue[issueNo].sourceName); |
|
389 |
// console.log(resp.List[0].CompilerIssue[issueNo].message); |
|
390 |
lno = resp.List[0].CompilerIssue[issueNo].lineNumber; |
|
391 |
eMsg = resp.List[0].CompilerIssue[issueNo].kind + ' ' + resp.List[0].CompilerIssue[issueNo].message; |
|
392 |
cm.setGutterMarker(lno-1, "breakpoints", makeMarker(eMsg)); |
|
393 |
issueNo++; |
|
394 |
} |
|
395 |
} else { |
|
396 |
lno = resp.List[0].CompilerIssue.lineNumber; |
|
397 |
eMsg = resp.List[0].CompilerIssue.kind + ' ' + resp.List[0].CompilerIssue.message; |
|
398 |
cm.setGutterMarker(lno-1, "breakpoints", makeMarker(eMsg)); |
|
399 |
} |
|
400 |
} |
0ac262
|
401 |
} |
U |
402 |
|
10d3d3
|
403 |
function fm_ansicht_umschalten() { |
U |
404 |
if($('#ansicht').children(0).hasClass('fa-th-list')) { |
|
405 |
$('#ansicht').children(0).addClass('fa-th-large'); |
|
406 |
$('#ansicht').children(0).removeClass('fa-th-list'); |
|
407 |
modus = 'liste'; |
|
408 |
} else { |
|
409 |
$('#ansicht').children(0).addClass('fa-th-list'); |
|
410 |
$('#ansicht').children(0).removeClass('fa-th-large'); |
|
411 |
modus = 'kacheln'; |
|
412 |
} |
|
413 |
fm_get_list(pfad); |
|
414 |
} |
|
415 |
|
|
416 |
function fm_set_modus() { |
|
417 |
if(modus == 'kacheln') { |
|
418 |
$('#ansicht').children(0).addClass('fa-th-list'); |
|
419 |
$('#ansicht').children(0).removeClass('fa-th-large'); |
|
420 |
} else { |
|
421 |
$('#ansicht').children(0).addClass('fa-th-large'); |
|
422 |
$('#ansicht').children(0).removeClass('fa-th-list'); |
|
423 |
} |
a4d3b5
|
424 |
} |
U |
425 |
|
|
426 |
function fm_menu_neue_textdatei() { |
adf812
|
427 |
fm_text_edit('Neue Datei'); |
a4d3b5
|
428 |
} |
U |
429 |
|
305573
|
430 |
function fm_menu_neues_dokument() { |
7d8ef6
|
431 |
fm_dok_edit(''); |
305573
|
432 |
} |
U |
433 |
|
a4d3b5
|
434 |
function fm_menu_datei_schliessen() { |
3003b2
|
435 |
if(openEditor === 'text') { |
U |
436 |
if(!cm.getDoc().isClean()) { |
|
437 |
fm_ask_for_save(); |
|
438 |
} else { |
|
439 |
fm_do_close(); |
|
440 |
} |
|
441 |
} else { |
|
442 |
if(tinymce.activeEditor.undoManager.hasUndo()) { |
|
443 |
fm_ask_for_save(); |
|
444 |
} else { |
|
445 |
fm_do_close(); |
|
446 |
} |
|
447 |
} |
|
448 |
} |
|
449 |
|
|
450 |
function fm_ask_for_save() { |
|
451 |
// hier Abfrage ob gespeichert werden soll |
|
452 |
$('#confirmOk').click(function() { |
|
453 |
$('#confirmOk').attr('onclick','').unbind('click'); |
|
454 |
fm_menu_datei_speichern(function() { |
a75859
|
455 |
fm_do_close(); |
U |
456 |
}); |
3003b2
|
457 |
}); |
U |
458 |
$('#confirmCancel').click(function() { |
|
459 |
$('#confirmCancel').attr('onclick','').unbind('click'); |
|
460 |
}); |
|
461 |
$('#confirmClose').show(); |
|
462 |
$('#confirmClose').click(function() { |
|
463 |
$('#confirmClose').attr('onclick','').unbind('click'); |
a75859
|
464 |
fm_do_close(); |
3003b2
|
465 |
}); |
U |
466 |
$('#confirmOk').text("Speichern"); |
|
467 |
$('#confirmOk').addClass('btn-primary'); |
|
468 |
$('#confirmOk').removeClass('btn-danger'); |
|
469 |
$('#confirmModalTitle').text("Schliessen"); |
|
470 |
$('#confirmModalBody').text("Speichern vor dem Schliessen?"); |
|
471 |
$('#confirmModal').modal({ |
|
472 |
keyboard: false, |
|
473 |
show: true |
|
474 |
}); |
a75859
|
475 |
} |
U |
476 |
|
|
477 |
function fm_do_close() { |
a4d3b5
|
478 |
$('.codeeditor-space').hide(); |
U |
479 |
$('.code-editor-container').hide(); |
305573
|
480 |
$("#mce-editor").hide(); |
U |
481 |
if(cm !== undefined) { |
|
482 |
cm.toTextArea(); |
|
483 |
} |
5ebb8e
|
484 |
openFileName = ''; |
7d8ef6
|
485 |
openEditor = ''; |
adf812
|
486 |
fm_get_list(pfad); |
305573
|
487 |
fm_filectls_show(); |
e5ff42
|
488 |
} |
U |
489 |
|
17919c
|
490 |
function fm_dateiwahl(ev) { |
5dfab6
|
491 |
var elem = this; |
17919c
|
492 |
//console.log('dateiwahl nach click, event shift: ' + ev.shiftKey + ", event ctrl: " + ev.ctrlKey); |
10d3d3
|
493 |
if(modus == 'kacheln') { |
957b51
|
494 |
// Kacheln |
10d3d3
|
495 |
if($(elem).children(0).hasClass('fa-folder')) { |
957b51
|
496 |
if(/*ev.shiftKey || */ ev.ctrlKey) { |
U |
497 |
$(elem).find('.dateiname').addClass('datei-gewaehlt'); |
10d3d3
|
498 |
} else { |
957b51
|
499 |
var ordner = $(elem).text().trim(); |
U |
500 |
if(pfad.length > 0) { |
|
501 |
pfad = pfad + '/' + ordner; |
|
502 |
} else { |
|
503 |
pfad = ordner; |
|
504 |
} |
|
505 |
fm_get_list(pfad); |
10d3d3
|
506 |
} |
7f2a41
|
507 |
} else if($(elem).children(0).hasClass('datei')) { |
17919c
|
508 |
if(/*ev.shiftKey || */ ev.ctrlKey) { |
U |
509 |
// mehrere Dateien sollen gewaehlt werden |
|
510 |
} else { |
|
511 |
$('.datei-gewaehlt').removeClass('datei-gewaehlt'); |
|
512 |
} |
957b51
|
513 |
$(elem).find('.dateiname').addClass('datei-gewaehlt'); |
5dfab6
|
514 |
} else { |
10d3d3
|
515 |
//console.log('kein folder oder file...'); |
5dfab6
|
516 |
} |
U |
517 |
} else { |
957b51
|
518 |
// Liste |
10d3d3
|
519 |
if($(elem).find('.datei-elem').children(0).hasClass('fa-file-o')) { |
957b51
|
520 |
// Datei |
17919c
|
521 |
if(/*ev.shiftKey || */ ev.ctrlKey) { |
U |
522 |
// mehrere Dateien sollen gewaehlt werden |
|
523 |
} else { |
|
524 |
$('.table-info').removeClass('table-info'); |
957b51
|
525 |
$('.datei-gewaehlt').removeClass('datei-gewaehlt'); |
17919c
|
526 |
} |
10d3d3
|
527 |
$(elem).addClass('table-info'); |
U |
528 |
$(elem).find('.dateiname').addClass('datei-gewaehlt'); |
|
529 |
} else { |
957b51
|
530 |
// Ordner |
U |
531 |
if(/*ev.shiftKey || */ ev.ctrlKey) { |
|
532 |
$(elem).children(0).addClass('datei-gewaehlt'); |
10d3d3
|
533 |
} else { |
957b51
|
534 |
var ordner = $(elem).find('.dateiname').text(); |
U |
535 |
if(pfad.length > 0) { |
|
536 |
pfad = pfad + '/' + ordner; |
|
537 |
} else { |
|
538 |
pfad = ordner; |
|
539 |
} |
|
540 |
fm_get_list(pfad); |
10d3d3
|
541 |
} |
U |
542 |
} |
5dfab6
|
543 |
} |
c509a0
|
544 |
} |
U |
545 |
|
a94216
|
546 |
function fm_bc_click() { |
U |
547 |
var elem = this; |
|
548 |
var bcPfad = $(elem).attr('rpath'); |
|
549 |
if(bcPfad !== undefined) { |
c509a0
|
550 |
pfad = bcPfad; |
a94216
|
551 |
fm_get_list(bcPfad); |
U |
552 |
} else { |
|
553 |
pfad = ''; |
|
554 |
fm_get_list(''); |
|
555 |
} |
|
556 |
} |
|
557 |
|
42fece
|
558 |
function fm_text_edit(content, mode) { |
305573
|
559 |
fm_filectls_hide(); |
3ad4db
|
560 |
$('.codeeditor-space').show(); |
U |
561 |
$('.code-editor-container').show(); |
42fece
|
562 |
fm_code_edit(content, mode); |
7d8ef6
|
563 |
openEditor = 'text'; |
U |
564 |
} |
|
565 |
|
|
566 |
function fm_dok_edit(content) { |
|
567 |
fm_filectls_hide(); |
0c1d5b
|
568 |
fm_dok_editor_init(userid); |
7d8ef6
|
569 |
$("#mce-editor").show(); |
be9b6d
|
570 |
|
U |
571 |
window.clearTimeout(tmo2); |
|
572 |
tmo2 = window.setTimeout(function () { |
|
573 |
try { |
|
574 |
ed.setContent(content); |
|
575 |
openEditor = 'dok'; |
|
576 |
} catch (err) { |
|
577 |
} |
|
578 |
}, 200); |
3ad4db
|
579 |
} |
U |
580 |
|
305573
|
581 |
function fm_filectls_hide() { |
U |
582 |
$('#zentrum_bc').hide(); |
|
583 |
$('#dateien').hide(); |
547755
|
584 |
$('#editMenu').addClass('disabled'); |
305573
|
585 |
} |
U |
586 |
|
|
587 |
function fm_filectls_show() { |
|
588 |
$('#zentrum_bc').show(); |
|
589 |
$('#dateien').show(); |
547755
|
590 |
$('#editMenu').removeClass('disabled'); |
305573
|
591 |
} |
b7475d
|
592 |
/* ----- API Calls ------------- */ |
U |
593 |
|
c509a0
|
594 |
|
2121cc
|
595 |
|
fc8db1
|
596 |
function fm_view_file() { |
U |
597 |
// http://localhost:8080/file-cms/ui/# |
|
598 |
// http://localhost:8080/file-cms/data/admin/usw. |
|
599 |
|
|
600 |
var userid = $('#userMenu').text(); |
|
601 |
var gewaehlte = $('.datei-gewaehlt'); |
|
602 |
var fname = $(gewaehlte[0]).text(); |
0c1d5b
|
603 |
|
U |
604 |
var path = fm_get_path(userid); |
|
605 |
|
|
606 |
window.open(path + '/' + fname, '_blank'); |
fc8db1
|
607 |
} |
U |
608 |
|
977e5d
|
609 |
function fm_view_slideshow() { |
U |
610 |
|
|
611 |
// https://localhost:8443/file-cms/fotos/?o=ulrich/bilder/diashow/ordnername |
|
612 |
|
|
613 |
|
|
614 |
var userid = $('#userMenu').text(); |
|
615 |
var gewaehlte = $('.datei-gewaehlt'); |
|
616 |
var fname = $(gewaehlte[0]).text(); |
|
617 |
|
|
618 |
var path = fm_get_path(userid); |
|
619 |
var restdir = path; |
|
620 |
if(path.indexOf('/data/') > -1) { |
|
621 |
restdir = path.substr('/data/'.length); |
|
622 |
} |
|
623 |
|
|
624 |
//window.open('/file-cms/fotos/?o=' + userid + '/' + path + '/' + fname, '_blank'); |
|
625 |
window.open('/file-cms/fotos/?o=' + restdir + '/' + fname, '_blank'); |
|
626 |
} |
|
627 |
|
8446c2
|
628 |
function fm_menu_datei_umbenennen() { |
U |
629 |
var gewaehlte = $('.datei-gewaehlt'); |
|
630 |
var fname = $(gewaehlte[0]).text(); |
663ee9
|
631 |
|
U |
632 |
$('#modal_ok').click(function() { |
|
633 |
// hier umbenennen |
50bb41
|
634 |
fm_rename_file(fname, pfad, $('#dateiname').val()); |
663ee9
|
635 |
}); |
U |
636 |
$('#saveModalTitle').text('Datei umbenennen'); |
|
637 |
$('#dialogfrage').text("Neuer Dateiname?"); |
|
638 |
|
|
639 |
if(fname !== undefined) { |
|
640 |
$('#dateiname').val(fname); |
|
641 |
$('#dateiname').attr('placeholder', 'Dateiname'); |
|
642 |
$('#saveModal').modal({ |
|
643 |
keyboard: false, |
|
644 |
show: true |
|
645 |
}); |
|
646 |
} |
|
647 |
} |
|
648 |
|
6bd2c1
|
649 |
function fm_menu_datei_entpacken() { |
U |
650 |
var gewaehlte = $('.datei-gewaehlt'); |
|
651 |
var fname = $(gewaehlte[0]).text(); |
|
652 |
fm_unzip_file(fname); |
|
653 |
} |
|
654 |
|
af9930
|
655 |
/** |
U |
656 |
* Anname: Man ist in dem Ordner, der gepackt werden soll. |
|
657 |
* Dann ist das Archiv anschliessend im Eltern-Ordner. |
|
658 |
*/ |
|
659 |
function fm_menu_ordner_packen() { |
|
660 |
//var gewaehlte = $('.datei-gewaehlt'); |
|
661 |
//var fname = $(gewaehlte[0]).text(); |
|
662 |
//console.log("Pfad: " + pfad + ", Datei: " + fname); |
|
663 |
fm_pack_folder(); |
|
664 |
} |
|
665 |
|
7165a1
|
666 |
/* |
U |
667 |
* Hier merkt sich die Dateiverwalting die markierten Dateien fuer |
|
668 |
* eine Dateioperation. Bei cut wird in der 'paste' Operation auf dem Server |
|
669 |
* fuer die 'gemerkten' Dateien ein Move gemacht. Die Dateien werden |
|
670 |
* vom gewaehlten Ort zum Zielort verschoben. |
|
671 |
* |
|
672 |
* @returns {undefined} |
|
673 |
*/ |
|
674 |
function fm_cut_files() { |
|
675 |
cutCopySrcDir = pfad; |
|
676 |
cutCopyFiles = fm_gewaehlte_dateien(); |
|
677 |
cutCopyOperation = 'cut'; |
|
678 |
} |
|
679 |
|
|
680 |
/* |
|
681 |
* Hier merkt sich die Dateiverwalting die markierten Dateien fuer |
|
682 |
* eine Dateioperation. Bei copy wird in der 'paste' Operation auf dem Server |
|
683 |
* fuer die 'gemerkten' Dateien eine Kopie gemacht. Die Dateien werden |
|
684 |
* am gewaehlten Ort behalten und am Zielort wird eine Kopier der |
|
685 |
* gewaehlten DAteien erstellt |
|
686 |
* |
|
687 |
* @returns {undefined} |
|
688 |
*/ |
|
689 |
function fm_copy_files() { |
|
690 |
cutCopySrcDir = pfad; |
|
691 |
cutCopyFiles = fm_gewaehlte_dateien(); |
9e2964
|
692 |
cutCopyOperation = 'copy'; |
7165a1
|
693 |
} |
U |
694 |
|
fc1897
|
695 |
|
10d3d3
|
696 |
function fm_render_list(fl) { |
U |
697 |
if(modus == 'kacheln') { |
|
698 |
// Kachelansicht |
7d8ef6
|
699 |
var template = $('#tpl-kacheln').html(); |
U |
700 |
Mustache.parse(template); // optional, speeds up future uses |
|
701 |
$('.datei-zeile').attr('onclick','').unbind('click'); |
|
702 |
$('#dateien').empty(); |
|
703 |
$('#dateien').html(Mustache.render(template, fl)); |
|
704 |
$('.figure').click(fm_dateiwahl); |
|
705 |
} else { |
|
706 |
// Listenansicht |
|
707 |
var template = $('#tpl-liste').html(); |
|
708 |
Mustache.parse(template); // optional, speeds up future uses |
|
709 |
$('.figure').attr('onclick','').unbind('click'); |
|
710 |
$('#dateien').empty(); |
|
711 |
$('#dateien').html(Mustache.render(template, fl)); |
|
712 |
$('.datei-zeile').click(fm_dateiwahl); |
|
713 |
} |
|
714 |
/* |
|
715 |
if(modus == 'kacheln') { |
|
716 |
// Kachelansicht |
a3d410
|
717 |
$.get('tpl-kacheln.txt', function(template) { |
U |
718 |
$('#dateien').empty(); |
|
719 |
$('#dateien').html(Mustache.render(template, fl)); |
|
720 |
$('.figure').click(fm_dateiwahl); |
|
721 |
}); |
10d3d3
|
722 |
$('.datei-zeile').attr('onclick','').unbind('click'); |
U |
723 |
} else { |
|
724 |
// Listenansicht |
a3d410
|
725 |
$.get('tpl-liste.txt', function(template) { |
U |
726 |
$('#dateien').empty(); |
|
727 |
$('#dateien').html(Mustache.render(template, fl)); |
|
728 |
$('.datei-zeile').click(fm_dateiwahl); |
|
729 |
}); |
10d3d3
|
730 |
$('.figure').attr('onclick','').unbind('click'); |
U |
731 |
} |
7d8ef6
|
732 |
*/ |
10d3d3
|
733 |
} |
U |
734 |
|
a75859
|
735 |
function fm_menu_datei_speichern(callback) { |
5ebb8e
|
736 |
//var fname = $('.datei-gewaehlt').text(); |
U |
737 |
var fname = openFileName; |
|
738 |
if(fname !== undefined && fname !== '') { |
a75859
|
739 |
fm_save_file(fname, 'saveTextFile', callback); |
5ebb8e
|
740 |
} else { |
a75859
|
741 |
fm_menu_datei_speichern_unter(callback); |
5ebb8e
|
742 |
} |
U |
743 |
} |
|
744 |
|
|
745 |
|
a75859
|
746 |
function fm_menu_datei_speichern_unter(callback) { |
915927
|
747 |
$('#modal_ok').click(function() { |
a75859
|
748 |
$('#modal_ok').attr('onclick','').unbind('click'); |
915927
|
749 |
// hier speichern |
a75859
|
750 |
fm_save_file($('#dateiname').val(), 'saveTextFileAs', callback); |
915927
|
751 |
}); |
957b51
|
752 |
$('#saveModalTitle').text('Datei speichern'); |
c509a0
|
753 |
$('#dialogfrage').text("Dateiname?"); |
3ad4db
|
754 |
|
U |
755 |
var fname = $('.datei-gewaehlt').text(); |
|
756 |
if(fname !== undefined) { |
|
757 |
$('#dateiname').val(fname); |
|
758 |
} else { |
|
759 |
$('#dateiname').val(''); |
|
760 |
} |
c509a0
|
761 |
$('#dateiname').attr('placeholder', 'Dateiname'); |
915927
|
762 |
$('#saveModal').modal({ |
U |
763 |
keyboard: false, |
|
764 |
show: true |
|
765 |
}); |
a4d3b5
|
766 |
} |
U |
767 |
|
b7475d
|
768 |
|
U |
769 |
|
a4d3b5
|
770 |
/* ---- codemirror editor handling -------- */ |
U |
771 |
|
64d8b9
|
772 |
/* |
942d63
|
773 |
function htmlDecode(value){ |
U |
774 |
return $('<div/>').html(value).text(); |
|
775 |
} |
64d8b9
|
776 |
*/ |
942d63
|
777 |
|
42fece
|
778 |
function fm_code_edit(content, m) { |
a4d3b5
|
779 |
cm = CodeMirror.fromTextArea(document.getElementById("editspace"), { |
U |
780 |
lineNumbers: true, |
6413b4
|
781 |
lineWrapping: true, |
e3043f
|
782 |
gutters: ["CodeMirror-linenumbers", "breakpoints"], |
42fece
|
783 |
mode: m, |
a4d3b5
|
784 |
viewportMargin : Infinity, |
d920b7
|
785 |
tabSize: 2, |
a4d3b5
|
786 |
extraKeys: { |
915927
|
787 |
"F9": function(cm) { |
U |
788 |
cm.setOption("fullScreen", !cm.getOption("fullScreen")); |
|
789 |
}, |
|
790 |
"Esc": function(cm) { |
|
791 |
if (cm.getOption("fullScreen")) cm.setOption("fullScreen", false); |
7ad1b7
|
792 |
}, |
U |
793 |
".": function(cm) { |
|
794 |
console.log('dot pressed: perhaps look up class or method name'); |
3b7c5b
|
795 |
/* |
U |
796 |
* Hier kann man eine Funktion ausloesen, die fuer das |
|
797 |
* Wort vor dem Punkt (Name der Klasse) eine Liste mit |
|
798 |
* Vorschlaegen fuer Methodennamen einblendet. |
|
799 |
*/ |
|
800 |
|
|
801 |
/* |
|
802 |
* CodeMirror.Pass laesst das Zeichen zum Editorinhalt durch, |
|
803 |
* verhindert aber das Ausloesen von 'keyHandled' |
|
804 |
*/ |
|
805 |
return CodeMirror.Pass; |
915927
|
806 |
} |
a4d3b5
|
807 |
} |
U |
808 |
}); |
fab80c
|
809 |
//cm.setValue(htmlDecode(content)); |
U |
810 |
//cm.setValue(content); |
|
811 |
cm.setValue(unescapeHtml(content)); |
3003b2
|
812 |
cm.getDoc().markClean(); |
e3043f
|
813 |
cm.on("gutterClick", function(theEditor, lineNumber) { |
U |
814 |
var info = theEditor.lineInfo(lineNumber); |
|
815 |
//--lineNumber; |
|
816 |
//console.log(info.gutterMarkers.breakpoints.message); |
|
817 |
//var marker = info.gutterMarkers.breakpoints; |
|
818 |
//$(marker).tooltip('toggle'); |
|
819 |
}); |
3b7c5b
|
820 |
/* |
7ad1b7
|
821 |
cm.on("keyHandled", function(theEditor, keyName, event){ |
3b7c5b
|
822 |
console.log('cm.keyHandled keyName: ' + keyName + ', event.type: ' + event.type); |
7ad1b7
|
823 |
}); |
3b7c5b
|
824 |
*/ |
e3043f
|
825 |
} |
U |
826 |
|
|
827 |
function makeMarker(msg) { |
|
828 |
var marker = document.createElement("div"); |
|
829 |
marker.style.color = "#822"; |
|
830 |
marker.innerHTML = "●"; |
|
831 |
//marker.message = msg; |
|
832 |
$(marker).tooltip({ |
|
833 |
placement: 'right', |
|
834 |
title: msg, |
ed12de
|
835 |
offset: '0 -30' |
e3043f
|
836 |
}); |
U |
837 |
return marker; |
915927
|
838 |
} |
a4d3b5
|
839 |
|
U |
840 |
/* -------- helper functions ----------- */ |
|
841 |
|
e5ff42
|
842 |
function fm_serialise(obj) { |
U |
843 |
return '{"' + obj.constructor.name + '":' + JSON.stringify(obj) + '}'; |
915927
|
844 |
} |
e5ff42
|
845 |
|
fab80c
|
846 |
function escapeHtml(text) { |
U |
847 |
text = text.replace(/\u228/g,'ä'); |
|
848 |
text = text.replace(/\u246/g,'ö'); |
|
849 |
text = text.replace(/\u252/g,'ü'); |
|
850 |
text = text.replace(/\u196/g,'Ä'); |
|
851 |
text = text.replace(/\u214/g,'Ö'); |
|
852 |
text = text.replace(/\u220/g,'Ü'); |
|
853 |
text = text.replace(/\u223/g,'ß'); |
|
854 |
text = text.replace(/\u26/g,'&'); |
|
855 |
return text; |
|
856 |
} |
|
857 |
|
|
858 |
function unescapeHtml(text) { |
|
859 |
text = text.replace(/ä/g, String.fromCharCode(228)); |
|
860 |
text = text.replace(/ö/g, String.fromCharCode(246)); |
|
861 |
text = text.replace(/ü/g, String.fromCharCode(252)); |
|
862 |
text = text.replace(/Ä/g, String.fromCharCode(196)); |
|
863 |
text = text.replace(/Ö/g, String.fromCharCode(214)); |
|
864 |
text = text.replace(/Ü/g, String.fromCharCode(220)); |
|
865 |
text = text.replace(/ß/g, String.fromCharCode(223)); |
|
866 |
text = text.replace(/&/g, String.fromCharCode(26)); |
|
867 |
return text; |
|
868 |
} |
|
869 |
|
7aa566
|
870 |
|