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