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