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