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