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