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"; |
e3043f
|
36 |
var compilerIssues; |
c7c502
|
37 |
|
U |
38 |
function fm_init() { |
305573
|
39 |
$("#mce-editor").hide(); |
a4d3b5
|
40 |
$('.codeeditor-space').hide(); |
U |
41 |
$('.code-editor-container').hide(); |
bef5c6
|
42 |
//$('.ost').attr('flex-basis', 0); |
a4d3b5
|
43 |
$('#newTextFile').on('click', fm_menu_neue_textdatei); |
305573
|
44 |
$('#newDoc').on('click', fm_menu_neues_dokument); |
adf812
|
45 |
$('#newFolder').on('click', fm_get_new_folder); |
fc8db1
|
46 |
$('#viewFile').on('click', fm_view_file); |
7d8ef6
|
47 |
$('#editTextFile').on('click', function() { |
U |
48 |
fm_get_file_content('text'); |
|
49 |
}); |
|
50 |
$('#editDocFile').on('click', function() { |
|
51 |
fm_get_file_content('dok'); |
|
52 |
}); |
e5ff42
|
53 |
$('#saveFile').on('click', fm_menu_datei_speichern); |
5ebb8e
|
54 |
$('#saveFileAs').on('click', fm_menu_datei_speichern_unter); |
a4d3b5
|
55 |
$('#closeFile').on('click', fm_menu_datei_schliessen); |
8446c2
|
56 |
$('#renameFile').on('click', fm_menu_datei_umbenennen); |
fc1897
|
57 |
$('#m-del').on('click', fm_menu_delete); |
7165a1
|
58 |
$('#m-cut').on('click', fm_menu_cut); |
U |
59 |
$('#m-copy').on('click', fm_menu_copy); |
|
60 |
$('#m-paste').on('click', fm_menu_paste); |
438b16
|
61 |
$('#m-shrink').on('click', fm_menu_shrink); |
bef5c6
|
62 |
$('#m-test').on('click', fm_menu_test); |
0ac262
|
63 |
$('#m-test-2').on('click', fm_menu_test_2); |
c509a0
|
64 |
$('#saveModal').on('hidden.bs.modal', function (e) { |
915927
|
65 |
$('#modal_ok').attr('onclick','').unbind('click'); |
b7475d
|
66 |
}); |
U |
67 |
$('#logout').click(fm_logout); |
05cfa7
|
68 |
fm_get_login(); |
7342b1
|
69 |
fm_get_list(''); |
7aa566
|
70 |
fm_init_uploader(); |
fa012b
|
71 |
/* |
U |
72 |
console.log('href: ' + window.location.href); |
|
73 |
console.log('host: ' + window.location.host); |
|
74 |
console.log('hostname: ' + window.location.hostname); |
|
75 |
console.log('port: ' + window.location.port); |
|
76 |
console.log('protocol: ' + window.location.protocol); |
|
77 |
*/ |
|
78 |
loc = window.location.protocol + '//' + window.location.host; |
fc8db1
|
79 |
} |
U |
80 |
|
0c1d5b
|
81 |
function fm_resize_editor() { |
U |
82 |
window.clearTimeout(tmo); |
|
83 |
tmo = window.setTimeout(function () { |
|
84 |
try { |
|
85 |
var myHeight = $('.zentrum').height() - $('.nord').height() - 4; |
|
86 |
ed.theme.resizeTo('100%', myHeight); // sets the dimensions of the editable area |
|
87 |
} catch (err) { |
|
88 |
} |
|
89 |
}, 200); |
fc8db1
|
90 |
} |
U |
91 |
|
0c1d5b
|
92 |
function fm_get_path(uid) { |
U |
93 |
//console.log('pfad: ' + pfad); |
|
94 |
var restdir; |
cccd2b
|
95 |
if(pfad.indexOf(PUB_DIR) > -1) { |
U |
96 |
restdir = pfad.substr(PUB_DIR.length); |
|
97 |
} else if(pfad.indexOf(PERS_DIR) > -1) { |
|
98 |
restdir = pfad.substr(PERS_DIR.length); |
1f550a
|
99 |
} else if(pfad.indexOf(BASE_DIR) > -1) { |
U |
100 |
restdir = pfad.substr(BASE_DIR.length); |
|
101 |
} else if(pfad.indexOf(DATA_DIR) > -1) { |
|
102 |
restdir = pfad.substr(DATA_DIR.length); |
0c1d5b
|
103 |
} |
U |
104 |
if(restdir !== undefined && restdir.startsWith('/')) { |
|
105 |
restdir = restdir.substr(1); |
|
106 |
} |
|
107 |
var pdir = fm_get_base(uid); |
|
108 |
//console.log('path: ' + pdir + "/" + restdir); |
|
109 |
if(restdir.length > 1) { |
|
110 |
return pdir + "/" + restdir; |
|
111 |
} else { |
|
112 |
return pdir; |
|
113 |
} |
|
114 |
} |
|
115 |
|
|
116 |
function fm_get_base(uid) { |
|
117 |
//console.log('pfad: ' + pfad); |
|
118 |
var pdir; |
cccd2b
|
119 |
if(pfad.indexOf(PUB_DIR) > -1) { |
0c1d5b
|
120 |
pdir = '/data/'; |
cccd2b
|
121 |
} else if(pfad.indexOf(PERS_DIR) > -1) { |
0c1d5b
|
122 |
pdir = '/home/'; |
U |
123 |
} |
|
124 |
//console.log('base: ' + pdir + uid); |
|
125 |
return pdir + uid; |
|
126 |
} |
05cfa7
|
127 |
|
0c1d5b
|
128 |
function fm_dok_editor_init(uid) { |
U |
129 |
var base = fm_get_path(uid); |
a75859
|
130 |
edCount = 0; |
0c1d5b
|
131 |
//console.log("calling tinymce.init with base: " + base + "/"); |
fc8db1
|
132 |
|
0c1d5b
|
133 |
/* |
U |
134 |
* vgl. |
|
135 |
* http://stackoverflow.com/questions/4651676/how-do-i-remove-tinymce-and-then-re-add-it |
|
136 |
*/ |
|
137 |
//tinymce.EditorManager.execCommand('mceRemoveControl',true, 'textarea.text-editor'); |
|
138 |
//tinymce.EditorManager.execCommand('mceAddControl',true, editor_id); |
|
139 |
if(ed !== undefined) { |
|
140 |
ed.destroy(); |
|
141 |
} |
|
142 |
tinymce.remove('textarea.text-editor'); |
|
143 |
tinymce.EditorManager.editors = []; |
305573
|
144 |
|
U |
145 |
/* |
|
146 |
* Konfiguration TinyMCE |
|
147 |
*/ |
|
148 |
tinymce.init({ |
547755
|
149 |
content_css : "/file-cms/ui/mce.css", |
7b7627
|
150 |
//content_css: "/jslib/bootstrap/css/bootstrap.min.css", |
7d8ef6
|
151 |
selector: "textarea.text-editor", |
305573
|
152 |
statusbar: false, |
U |
153 |
menubar: false, |
ea1ae0
|
154 |
plugins: 'advlist charmap code image link lists media print preview save table textcolor importcss', |
7d8ef6
|
155 |
toolbar: 'undo redo | styleselect | image | link unlink | bullist numlist | outdent indent | code', |
305573
|
156 |
/* |
U |
157 |
menu: { |
|
158 |
file: {title: 'File', items: 'savevers | exit'}, |
|
159 |
edit: {title: 'Edit', items: 'undo redo | cut copy paste pastetext | selectall'}, |
|
160 |
view: {title: 'View', items: 'visualaid | code | link image media | template hr'}, |
|
161 |
}, |
|
162 |
*/ |
0c1d5b
|
163 |
resize: 'both', |
ea1ae0
|
164 |
importcss_append: true, |
305573
|
165 |
width: "100%", |
U |
166 |
height: '100%', |
0c1d5b
|
167 |
document_base_url : base + "/", |
305573
|
168 |
setup: function (editor) { |
U |
169 |
ed = editor; |
|
170 |
} |
|
171 |
}); |
0c1d5b
|
172 |
|
U |
173 |
$(window).on('resize', fm_resize_editor); |
|
174 |
fm_resize_editor(); |
10d3d3
|
175 |
} |
7aa566
|
176 |
|
U |
177 |
/* ----- Uploader Anfang ----------*/ |
|
178 |
|
|
179 |
var dateien = new Array(); |
|
180 |
|
|
181 |
function fm_init_uploader() { |
|
182 |
var dropzone = document.getElementById("dateien"); |
|
183 |
dropzone.ondragover = dropzone.ondragenter = function(event) { |
|
184 |
event.stopPropagation(); |
|
185 |
event.preventDefault(); |
|
186 |
}; |
|
187 |
|
|
188 |
dropzone.ondrop = function(event) { |
|
189 |
event.stopPropagation(); |
|
190 |
event.preventDefault(); |
7ebde1
|
191 |
var fileList = event.dataTransfer.files; |
U |
192 |
for (var i=0; i<fileList.length; i++) { |
|
193 |
dateien.push(fileList[i]); |
|
194 |
} |
|
195 |
sendFile(dateien.pop()); |
7aa566
|
196 |
}; |
U |
197 |
} |
|
198 |
|
|
199 |
function sendFile(datei) { |
7ebde1
|
200 |
var uri = "../api/upload"; |
7aa566
|
201 |
var xhr = new XMLHttpRequest(); |
U |
202 |
var fd = new FormData(); |
|
203 |
xhr.open("POST", uri, true); |
|
204 |
xhr.onreadystatechange = function() { |
|
205 |
if (xhr.readyState == 4 && xhr.status == 200) { |
|
206 |
fm_get_list(pfad); |
7ebde1
|
207 |
if(dateien.length > 0) { |
U |
208 |
sendFile(dateien.pop()); |
|
209 |
} |
7aa566
|
210 |
} |
U |
211 |
}; |
7ebde1
|
212 |
fd.append('dateiauswahlfeld', datei); |
42fece
|
213 |
fd.append('pfad', pfad); |
7aa566
|
214 |
xhr.send(fd); |
U |
215 |
} |
|
216 |
|
|
217 |
/* ----- Uploader Ende --------------- */ |
10d3d3
|
218 |
|
7165a1
|
219 |
/* ------- Dateifunktionen Start ----------- */ |
U |
220 |
|
|
221 |
function fm_menu_cut() { |
98f088
|
222 |
//alert('fm_menu_cut'); |
U |
223 |
fm_cut_files(); |
7165a1
|
224 |
} |
U |
225 |
function fm_menu_copy() { |
98f088
|
226 |
//alert('fm_menu_copy'); |
U |
227 |
fm_copy_files(); |
7165a1
|
228 |
} |
U |
229 |
function fm_menu_paste() { |
98f088
|
230 |
//alert('fm_menu_paste'); |
U |
231 |
fm_paste_files(); |
7165a1
|
232 |
} |
fc1897
|
233 |
function fm_menu_delete() { |
U |
234 |
$('#confirmOk').click(function() { |
a75859
|
235 |
$('#confirmOk').attr('onclick','').unbind('click'); |
fc1897
|
236 |
fm_del_files(); |
U |
237 |
}); |
a75859
|
238 |
$('#confirmOk').text("Loeschen"); |
U |
239 |
$('#confirmOk').removeClass('btn-primary'); |
|
240 |
$('#confirmOk').addClass('btn-danger'); |
|
241 |
$('#confirmClose').hide(); |
957b51
|
242 |
$('#confirmModalTitle').text("Löschen"); |
U |
243 |
$('#confirmModalBody').text("Wirklich löschen?"); |
fc1897
|
244 |
$('#confirmModal').modal({ |
U |
245 |
keyboard: false, |
|
246 |
show: true |
|
247 |
}); |
|
248 |
} |
7165a1
|
249 |
|
U |
250 |
/* |
|
251 |
* Gewaehlte Dateien feststellen |
|
252 |
* |
|
253 |
* @returns {String} eine per JSON.stringify schon vorbereitete List zum |
|
254 |
* Absenden als Parameter an den Server |
|
255 |
*/ |
|
256 |
function fm_gewaehlte_dateien() { |
|
257 |
var gewaehlte = $('.datei-gewaehlt'); |
|
258 |
//console.log('anzahl: ' + gewaehlte.length); |
|
259 |
var fnames = new Array(); |
|
260 |
var i = 0; |
|
261 |
while(i < gewaehlte.length) { |
|
262 |
var str = { "java.lang.String": $(gewaehlte[i]).text()}; |
|
263 |
fnames.push(str); |
|
264 |
//console.log('loeschen ' + pfad + ' ' + $(gewaehlte[i]).text()); |
|
265 |
//i += 2; |
|
266 |
i++; |
|
267 |
} |
|
268 |
var liste = '{"List":' + JSON.stringify(fnames) + '}'; |
|
269 |
// 'liste' enthaelt: |
|
270 |
// {"List":[{"java.lang.String":"test3.txt"},{"java.lang.String":"Test1.txt"},{"java.lang.String":"Test2.txt"}]} |
|
271 |
// und wird auf dem Server zu einer List[ArrayList<String>] bei der jede ArrayList<String> nur ein Element hat |
|
272 |
return liste; |
|
273 |
} |
|
274 |
/* --------- Dateifunktionen Ende ---------- */ |
fc1897
|
275 |
|
bef5c6
|
276 |
function fm_menu_test() { |
U |
277 |
var w = $('.ost').width(); |
|
278 |
if(w == 0) { |
|
279 |
$('.ost').width('20%'); |
|
280 |
$('.ost').text('Hallo Welt!'); |
|
281 |
} else { |
|
282 |
$('.ost').empty(); |
|
283 |
$('.ost').width(0); |
|
284 |
} |
|
285 |
} |
|
286 |
|
0ac262
|
287 |
function fm_menu_test_2() { |
fd0b4c
|
288 |
fm_compile('0', fm_mark_compile_results_in_editor); |
U |
289 |
} |
|
290 |
|
|
291 |
function fm_mark_compile_results_in_editor(resp) { |
|
292 |
cm.clearGutter("breakpoints"); |
|
293 |
|
|
294 |
if(resp.List[0].CompilerIssue !== undefined) { |
|
295 |
var lno; |
|
296 |
var eMsg; |
|
297 |
if(resp.List[0].CompilerIssue instanceof Array) { |
|
298 |
var issueNo = 0; |
|
299 |
while(issueNo < resp.List[0].CompilerIssue.length) { |
|
300 |
// console.log(resp.List[0].CompilerIssue[issueNo].kind); |
|
301 |
// console.log(resp.List[0].CompilerIssue[issueNo].lineNumber); |
|
302 |
// console.log(resp.List[0].CompilerIssue[issueNo].sourceName); |
|
303 |
// console.log(resp.List[0].CompilerIssue[issueNo].message); |
|
304 |
lno = resp.List[0].CompilerIssue[issueNo].lineNumber; |
|
305 |
eMsg = resp.List[0].CompilerIssue[issueNo].kind + ' ' + resp.List[0].CompilerIssue[issueNo].message; |
|
306 |
cm.setGutterMarker(lno-1, "breakpoints", makeMarker(eMsg)); |
|
307 |
issueNo++; |
|
308 |
} |
|
309 |
} else { |
|
310 |
lno = resp.List[0].CompilerIssue.lineNumber; |
|
311 |
eMsg = resp.List[0].CompilerIssue.kind + ' ' + resp.List[0].CompilerIssue.message; |
|
312 |
cm.setGutterMarker(lno-1, "breakpoints", makeMarker(eMsg)); |
|
313 |
} |
|
314 |
} |
|
315 |
} |
|
316 |
|
|
317 |
function fm_compile(modeStr, callback) { |
0ac262
|
318 |
var liste = fm_gewaehlte_dateien(); |
fd0b4c
|
319 |
var m = '?c=de.uhilger.filecms.api.CompileService&m=compile&p=' + pfad + '&p=' + encodeURIComponent(liste) + |
U |
320 |
'&p=' + modeStr; |
0ac262
|
321 |
var u = '../svc' + m; |
e3043f
|
322 |
fm_get(u, "json", function(resp) { |
fd0b4c
|
323 |
callback(resp); |
0ac262
|
324 |
}); |
U |
325 |
} |
|
326 |
|
10d3d3
|
327 |
function fm_ansicht_umschalten() { |
U |
328 |
if($('#ansicht').children(0).hasClass('fa-th-list')) { |
|
329 |
$('#ansicht').children(0).addClass('fa-th-large'); |
|
330 |
$('#ansicht').children(0).removeClass('fa-th-list'); |
|
331 |
modus = 'liste'; |
|
332 |
} else { |
|
333 |
$('#ansicht').children(0).addClass('fa-th-list'); |
|
334 |
$('#ansicht').children(0).removeClass('fa-th-large'); |
|
335 |
modus = 'kacheln'; |
|
336 |
} |
|
337 |
fm_get_list(pfad); |
|
338 |
} |
|
339 |
|
|
340 |
function fm_set_modus() { |
|
341 |
if(modus == 'kacheln') { |
|
342 |
$('#ansicht').children(0).addClass('fa-th-list'); |
|
343 |
$('#ansicht').children(0).removeClass('fa-th-large'); |
|
344 |
} else { |
|
345 |
$('#ansicht').children(0).addClass('fa-th-large'); |
|
346 |
$('#ansicht').children(0).removeClass('fa-th-list'); |
|
347 |
} |
a4d3b5
|
348 |
} |
U |
349 |
|
|
350 |
function fm_menu_neue_textdatei() { |
adf812
|
351 |
fm_text_edit('Neue Datei'); |
a4d3b5
|
352 |
} |
U |
353 |
|
305573
|
354 |
function fm_menu_neues_dokument() { |
7d8ef6
|
355 |
fm_dok_edit(''); |
305573
|
356 |
} |
U |
357 |
|
a4d3b5
|
358 |
function fm_menu_datei_schliessen() { |
3003b2
|
359 |
if(openEditor === 'text') { |
U |
360 |
if(!cm.getDoc().isClean()) { |
|
361 |
fm_ask_for_save(); |
|
362 |
} else { |
|
363 |
fm_do_close(); |
|
364 |
} |
|
365 |
} else { |
|
366 |
if(tinymce.activeEditor.undoManager.hasUndo()) { |
|
367 |
fm_ask_for_save(); |
|
368 |
} else { |
|
369 |
fm_do_close(); |
|
370 |
} |
|
371 |
} |
|
372 |
} |
|
373 |
|
|
374 |
function fm_ask_for_save() { |
|
375 |
// hier Abfrage ob gespeichert werden soll |
|
376 |
$('#confirmOk').click(function() { |
|
377 |
$('#confirmOk').attr('onclick','').unbind('click'); |
|
378 |
fm_menu_datei_speichern(function() { |
a75859
|
379 |
fm_do_close(); |
U |
380 |
}); |
3003b2
|
381 |
}); |
U |
382 |
$('#confirmCancel').click(function() { |
|
383 |
$('#confirmCancel').attr('onclick','').unbind('click'); |
|
384 |
}); |
|
385 |
$('#confirmClose').show(); |
|
386 |
$('#confirmClose').click(function() { |
|
387 |
$('#confirmClose').attr('onclick','').unbind('click'); |
a75859
|
388 |
fm_do_close(); |
3003b2
|
389 |
}); |
U |
390 |
$('#confirmOk').text("Speichern"); |
|
391 |
$('#confirmOk').addClass('btn-primary'); |
|
392 |
$('#confirmOk').removeClass('btn-danger'); |
|
393 |
$('#confirmModalTitle').text("Schliessen"); |
|
394 |
$('#confirmModalBody').text("Speichern vor dem Schliessen?"); |
|
395 |
$('#confirmModal').modal({ |
|
396 |
keyboard: false, |
|
397 |
show: true |
|
398 |
}); |
a75859
|
399 |
} |
U |
400 |
|
|
401 |
function fm_do_close() { |
a4d3b5
|
402 |
$('.codeeditor-space').hide(); |
U |
403 |
$('.code-editor-container').hide(); |
305573
|
404 |
$("#mce-editor").hide(); |
U |
405 |
if(cm !== undefined) { |
|
406 |
cm.toTextArea(); |
|
407 |
} |
5ebb8e
|
408 |
openFileName = ''; |
7d8ef6
|
409 |
openEditor = ''; |
adf812
|
410 |
fm_get_list(pfad); |
305573
|
411 |
fm_filectls_show(); |
e5ff42
|
412 |
} |
U |
413 |
|
17919c
|
414 |
function fm_dateiwahl(ev) { |
5dfab6
|
415 |
var elem = this; |
17919c
|
416 |
//console.log('dateiwahl nach click, event shift: ' + ev.shiftKey + ", event ctrl: " + ev.ctrlKey); |
10d3d3
|
417 |
if(modus == 'kacheln') { |
957b51
|
418 |
// Kacheln |
10d3d3
|
419 |
if($(elem).children(0).hasClass('fa-folder')) { |
957b51
|
420 |
if(/*ev.shiftKey || */ ev.ctrlKey) { |
U |
421 |
$(elem).find('.dateiname').addClass('datei-gewaehlt'); |
10d3d3
|
422 |
} else { |
957b51
|
423 |
var ordner = $(elem).text().trim(); |
U |
424 |
if(pfad.length > 0) { |
|
425 |
pfad = pfad + '/' + ordner; |
|
426 |
} else { |
|
427 |
pfad = ordner; |
|
428 |
} |
|
429 |
fm_get_list(pfad); |
10d3d3
|
430 |
} |
7f2a41
|
431 |
} else if($(elem).children(0).hasClass('datei')) { |
17919c
|
432 |
if(/*ev.shiftKey || */ ev.ctrlKey) { |
U |
433 |
// mehrere Dateien sollen gewaehlt werden |
|
434 |
} else { |
|
435 |
$('.datei-gewaehlt').removeClass('datei-gewaehlt'); |
|
436 |
} |
957b51
|
437 |
$(elem).find('.dateiname').addClass('datei-gewaehlt'); |
5dfab6
|
438 |
} else { |
10d3d3
|
439 |
//console.log('kein folder oder file...'); |
5dfab6
|
440 |
} |
U |
441 |
} else { |
957b51
|
442 |
// Liste |
10d3d3
|
443 |
if($(elem).find('.datei-elem').children(0).hasClass('fa-file-o')) { |
957b51
|
444 |
// Datei |
17919c
|
445 |
if(/*ev.shiftKey || */ ev.ctrlKey) { |
U |
446 |
// mehrere Dateien sollen gewaehlt werden |
|
447 |
} else { |
|
448 |
$('.table-info').removeClass('table-info'); |
957b51
|
449 |
$('.datei-gewaehlt').removeClass('datei-gewaehlt'); |
17919c
|
450 |
} |
10d3d3
|
451 |
$(elem).addClass('table-info'); |
U |
452 |
$(elem).find('.dateiname').addClass('datei-gewaehlt'); |
|
453 |
} else { |
957b51
|
454 |
// Ordner |
U |
455 |
if(/*ev.shiftKey || */ ev.ctrlKey) { |
|
456 |
$(elem).children(0).addClass('datei-gewaehlt'); |
10d3d3
|
457 |
} else { |
957b51
|
458 |
var ordner = $(elem).find('.dateiname').text(); |
U |
459 |
if(pfad.length > 0) { |
|
460 |
pfad = pfad + '/' + ordner; |
|
461 |
} else { |
|
462 |
pfad = ordner; |
|
463 |
} |
|
464 |
fm_get_list(pfad); |
10d3d3
|
465 |
} |
U |
466 |
} |
5dfab6
|
467 |
} |
c509a0
|
468 |
} |
U |
469 |
|
a94216
|
470 |
function fm_bc_click() { |
U |
471 |
var elem = this; |
|
472 |
var bcPfad = $(elem).attr('rpath'); |
|
473 |
if(bcPfad !== undefined) { |
c509a0
|
474 |
pfad = bcPfad; |
a94216
|
475 |
fm_get_list(bcPfad); |
U |
476 |
} else { |
|
477 |
pfad = ''; |
|
478 |
fm_get_list(''); |
|
479 |
} |
|
480 |
} |
|
481 |
|
42fece
|
482 |
function fm_text_edit(content, mode) { |
305573
|
483 |
fm_filectls_hide(); |
3ad4db
|
484 |
$('.codeeditor-space').show(); |
U |
485 |
$('.code-editor-container').show(); |
42fece
|
486 |
fm_code_edit(content, mode); |
7d8ef6
|
487 |
openEditor = 'text'; |
U |
488 |
} |
|
489 |
|
|
490 |
function fm_dok_edit(content) { |
|
491 |
fm_filectls_hide(); |
0c1d5b
|
492 |
fm_dok_editor_init(userid); |
7d8ef6
|
493 |
$("#mce-editor").show(); |
be9b6d
|
494 |
|
U |
495 |
window.clearTimeout(tmo2); |
|
496 |
tmo2 = window.setTimeout(function () { |
|
497 |
try { |
|
498 |
ed.setContent(content); |
|
499 |
openEditor = 'dok'; |
|
500 |
} catch (err) { |
|
501 |
} |
|
502 |
}, 200); |
3ad4db
|
503 |
} |
U |
504 |
|
305573
|
505 |
function fm_filectls_hide() { |
U |
506 |
$('#zentrum_bc').hide(); |
|
507 |
$('#dateien').hide(); |
547755
|
508 |
$('#editMenu').addClass('disabled'); |
305573
|
509 |
} |
U |
510 |
|
|
511 |
function fm_filectls_show() { |
|
512 |
$('#zentrum_bc').show(); |
|
513 |
$('#dateien').show(); |
547755
|
514 |
$('#editMenu').removeClass('disabled'); |
305573
|
515 |
} |
b7475d
|
516 |
/* ----- API Calls ------------- */ |
U |
517 |
|
0c1d5b
|
518 |
function fm_get_login() { |
3ad4db
|
519 |
var m = '?c=de.uhilger.filecms.pub.SessionManager&m=getSessionUser'; |
U |
520 |
var u = '../pub' + m; |
|
521 |
fm_get(u, "text", function(resp) { |
0c1d5b
|
522 |
userid = resp; |
3ad4db
|
523 |
$('#userMenu').text(resp); |
7342b1
|
524 |
}); |
c509a0
|
525 |
} |
U |
526 |
|
|
527 |
function fm_get_new_folder() { |
|
528 |
$('#modal_ok').click(function() { |
|
529 |
// hier speichern |
|
530 |
var m = '?c=de.uhilger.filecms.api.FileMgr&m=newFolder&p=' + pfad + '&p=' + $('#dateiname').val(); |
|
531 |
var u = '../svc' + m; |
|
532 |
fm_get(u, "json", function(resp) { |
adf812
|
533 |
fm_get_list(pfad); |
c509a0
|
534 |
}); |
U |
535 |
}); |
957b51
|
536 |
$('#saveModalTitle').text('Neuer Ordner'); |
c509a0
|
537 |
$('#dialogfrage').text("Name?"); |
U |
538 |
$('#dateiname').val(''); |
|
539 |
$('#dateiname').attr('placeholder', 'Ordnername'); |
|
540 |
$('#saveModal').modal({ |
|
541 |
keyboard: false, |
|
542 |
show: true |
|
543 |
}); |
7342b1
|
544 |
} |
U |
545 |
|
7d8ef6
|
546 |
function fm_get_file_content(typ) { |
fc1897
|
547 |
var gewaehlte = $('.datei-gewaehlt'); |
957b51
|
548 |
//var fname = $(gewaehlte).find('.dateiname').text(); |
U |
549 |
|
|
550 |
var fname = $(gewaehlte[0]).text(); |
5ebb8e
|
551 |
openFileName = fname; |
3ad4db
|
552 |
var m = '?c=de.uhilger.filecms.api.FileMgr&m=getCode&p=' + pfad + '&p=' + fname; |
2121cc
|
553 |
var u = '../svc' + m; |
3ad4db
|
554 |
fm_get(u, "text", function(resp) { |
7d8ef6
|
555 |
if(typ == 'text') { |
42fece
|
556 |
var mode = "text/x-java"; |
U |
557 |
if(fname.endsWith('js')) { |
|
558 |
mode = 'javascript'; |
|
559 |
} else if(fname.endsWith('xml')) { |
|
560 |
mode = 'xml'; |
|
561 |
} else if(fname.endsWith('properties')) { |
|
562 |
mode = 'xml'; |
|
563 |
} |
|
564 |
fm_text_edit(resp, mode); |
7d8ef6
|
565 |
} else { |
U |
566 |
fm_dok_edit(resp); |
|
567 |
} |
2121cc
|
568 |
}); |
3ad4db
|
569 |
|
2121cc
|
570 |
} |
U |
571 |
|
fc8db1
|
572 |
function fm_view_file() { |
U |
573 |
// http://localhost:8080/file-cms/ui/# |
|
574 |
// http://localhost:8080/file-cms/data/admin/usw. |
|
575 |
|
|
576 |
var userid = $('#userMenu').text(); |
|
577 |
var gewaehlte = $('.datei-gewaehlt'); |
|
578 |
var fname = $(gewaehlte[0]).text(); |
0c1d5b
|
579 |
|
U |
580 |
var path = fm_get_path(userid); |
|
581 |
|
|
582 |
window.open(path + '/' + fname, '_blank'); |
fc8db1
|
583 |
} |
U |
584 |
|
8446c2
|
585 |
function fm_menu_datei_umbenennen() { |
U |
586 |
var gewaehlte = $('.datei-gewaehlt'); |
|
587 |
var fname = $(gewaehlte[0]).text(); |
663ee9
|
588 |
|
U |
589 |
$('#modal_ok').click(function() { |
|
590 |
// hier umbenennen |
50bb41
|
591 |
fm_rename_file(fname, pfad, $('#dateiname').val()); |
663ee9
|
592 |
}); |
U |
593 |
$('#saveModalTitle').text('Datei umbenennen'); |
|
594 |
$('#dialogfrage').text("Neuer Dateiname?"); |
|
595 |
|
|
596 |
if(fname !== undefined) { |
|
597 |
$('#dateiname').val(fname); |
|
598 |
$('#dateiname').attr('placeholder', 'Dateiname'); |
|
599 |
$('#saveModal').modal({ |
|
600 |
keyboard: false, |
|
601 |
show: true |
|
602 |
}); |
|
603 |
} |
|
604 |
} |
|
605 |
|
|
606 |
function fm_rename_file(fn, p, neuerName) { |
|
607 |
var m = '?c=de.uhilger.filecms.api.FileMgr&m=renameFile'; |
|
608 |
m = m + '&p=' + p; |
|
609 |
m = m + '&p=' + fn; |
|
610 |
m = m + '&p=' + neuerName; |
|
611 |
var u = '../svc' + m; |
|
612 |
fm_get(u, "text", function(resp) { |
|
613 |
fm_get_list(pfad); |
|
614 |
}); |
8446c2
|
615 |
} |
U |
616 |
|
438b16
|
617 |
function fm_menu_shrink() { |
U |
618 |
var gewaehlte = $('.datei-gewaehlt'); |
|
619 |
var fname = $(gewaehlte[0]).text(); |
|
620 |
var m = '?c=de.uhilger.filecms.api.FileMgr&m=bildVerkleinern'; |
|
621 |
m = m + '&p=' + pfad; |
|
622 |
m = m + '&p=' + fname; |
|
623 |
var u = '../svc' + m; |
|
624 |
fm_get(u, "text", function(resp) { |
|
625 |
fm_get_list(pfad); |
|
626 |
}); |
|
627 |
} |
|
628 |
|
7165a1
|
629 |
/* |
U |
630 |
* Hier merkt sich die Dateiverwalting die markierten Dateien fuer |
|
631 |
* eine Dateioperation. Bei cut wird in der 'paste' Operation auf dem Server |
|
632 |
* fuer die 'gemerkten' Dateien ein Move gemacht. Die Dateien werden |
|
633 |
* vom gewaehlten Ort zum Zielort verschoben. |
|
634 |
* |
|
635 |
* @returns {undefined} |
|
636 |
*/ |
|
637 |
function fm_cut_files() { |
|
638 |
cutCopySrcDir = pfad; |
|
639 |
cutCopyFiles = fm_gewaehlte_dateien(); |
|
640 |
cutCopyOperation = 'cut'; |
|
641 |
} |
|
642 |
|
|
643 |
/* |
|
644 |
* Hier merkt sich die Dateiverwalting die markierten Dateien fuer |
|
645 |
* eine Dateioperation. Bei copy wird in der 'paste' Operation auf dem Server |
|
646 |
* fuer die 'gemerkten' Dateien eine Kopie gemacht. Die Dateien werden |
|
647 |
* am gewaehlten Ort behalten und am Zielort wird eine Kopier der |
|
648 |
* gewaehlten DAteien erstellt |
|
649 |
* |
|
650 |
* @returns {undefined} |
|
651 |
*/ |
|
652 |
function fm_copy_files() { |
|
653 |
cutCopySrcDir = pfad; |
|
654 |
cutCopyFiles = fm_gewaehlte_dateien(); |
9e2964
|
655 |
cutCopyOperation = 'copy'; |
7165a1
|
656 |
} |
U |
657 |
|
|
658 |
/* |
|
659 |
* Hier wird fuer eine zuvor markierte Liste von Dateien, fuer die |
|
660 |
* Cut oder Copy gewaehlt wurde, die Operations ausgefuehrt (move oder copy) |
|
661 |
* @returns {undefined} |
|
662 |
*/ |
|
663 |
function fm_paste_files() { |
|
664 |
var m; |
9e2964
|
665 |
if(cutCopyOperation === 'cut') { |
U |
666 |
//m = '?c=de.uhilger.filecms.api.FileMgr&m=moveFiles'; //&p=' + cutCopySrcDir + '&p=' + pfad + '&p=' + encodeURIComponent(liste); |
|
667 |
m = '?c=de.uhilger.filecms.api.FileMgr&m=moveFiles&p=' + cutCopySrcDir + '&p=' + pfad + '&p=' + encodeURIComponent(cutCopyFiles); |
7165a1
|
668 |
} else { |
9e2964
|
669 |
//m = '?c=de.uhilger.filecms.api.FileMgr&m=copyFiles'; //&p=' + cutCopySrcDir + '&p=' + pfad + '&p=' + encodeURIComponent(liste); |
U |
670 |
m = '?c=de.uhilger.filecms.api.FileMgr&m=copyFiles&p=' + cutCopySrcDir + '&p=' + pfad + '&p=' + encodeURIComponent(cutCopyFiles); |
fc1897
|
671 |
} |
7165a1
|
672 |
var u = '../svc' + m; |
9e2964
|
673 |
fm_get(u, "text", function(resp) { |
U |
674 |
// console.log('deleteFiles gab folgendes zurueck: ' + resp); |
|
675 |
fm_get_list(pfad); |
|
676 |
}); |
|
677 |
/* |
|
678 |
fm_post(u, {p1: encodeURIComponent(cutCopySrcDir), p2: encodeURIComponent(pfad), p3: encodeURIComponent(cutCopyFiles)},'text', function(resp) { |
7165a1
|
679 |
// resp evtl. zeigen.. |
U |
680 |
fm_get_list(pfad); |
|
681 |
}); |
9e2964
|
682 |
*/ |
7165a1
|
683 |
} |
U |
684 |
|
|
685 |
function fm_del_files() { |
|
686 |
var liste = fm_gewaehlte_dateien(); |
fc1897
|
687 |
var m = '?c=de.uhilger.filecms.api.FileMgr&m=deleteFiles&p=' + pfad + '&p=' + encodeURIComponent(liste); |
U |
688 |
var u = '../svc' + m; |
|
689 |
fm_get(u, "text", function(resp) { |
|
690 |
// console.log('deleteFiles gab folgendes zurueck: ' + resp); |
|
691 |
fm_get_list(pfad); |
|
692 |
}); |
|
693 |
} |
|
694 |
|
10d3d3
|
695 |
function fm_render_list(fl) { |
U |
696 |
if(modus == 'kacheln') { |
|
697 |
// Kachelansicht |
7d8ef6
|
698 |
var template = $('#tpl-kacheln').html(); |
U |
699 |
Mustache.parse(template); // optional, speeds up future uses |
|
700 |
$('.datei-zeile').attr('onclick','').unbind('click'); |
|
701 |
$('#dateien').empty(); |
|
702 |
$('#dateien').html(Mustache.render(template, fl)); |
|
703 |
$('.figure').click(fm_dateiwahl); |
|
704 |
} else { |
|
705 |
// Listenansicht |
|
706 |
var template = $('#tpl-liste').html(); |
|
707 |
Mustache.parse(template); // optional, speeds up future uses |
|
708 |
$('.figure').attr('onclick','').unbind('click'); |
|
709 |
$('#dateien').empty(); |
|
710 |
$('#dateien').html(Mustache.render(template, fl)); |
|
711 |
$('.datei-zeile').click(fm_dateiwahl); |
|
712 |
} |
|
713 |
/* |
|
714 |
if(modus == 'kacheln') { |
|
715 |
// Kachelansicht |
a3d410
|
716 |
$.get('tpl-kacheln.txt', function(template) { |
U |
717 |
$('#dateien').empty(); |
|
718 |
$('#dateien').html(Mustache.render(template, fl)); |
|
719 |
$('.figure').click(fm_dateiwahl); |
|
720 |
}); |
10d3d3
|
721 |
$('.datei-zeile').attr('onclick','').unbind('click'); |
U |
722 |
} else { |
|
723 |
// Listenansicht |
a3d410
|
724 |
$.get('tpl-liste.txt', function(template) { |
U |
725 |
$('#dateien').empty(); |
|
726 |
$('#dateien').html(Mustache.render(template, fl)); |
|
727 |
$('.datei-zeile').click(fm_dateiwahl); |
|
728 |
}); |
10d3d3
|
729 |
$('.figure').attr('onclick','').unbind('click'); |
U |
730 |
} |
7d8ef6
|
731 |
*/ |
10d3d3
|
732 |
} |
U |
733 |
|
7342b1
|
734 |
// http://localhost:8079/file-cms/svc?c=de.uhilger.filecms.api.FileMgr&f=JSONNICE&m=list&p= |
a94216
|
735 |
function fm_get_list(relPfad) { |
10d3d3
|
736 |
$('#ansicht').attr('onclick','').unbind('click'); |
a94216
|
737 |
var m = '?c=de.uhilger.filecms.api.FileMgr&m=list&p=' + relPfad; |
7342b1
|
738 |
var u = '../svc' + m; |
U |
739 |
fm_get(u, "json", function(resp) { |
10d3d3
|
740 |
|
2121cc
|
741 |
if(resp.List[0].FileRef !== undefined) { |
U |
742 |
var files = new Array(); |
c509a0
|
743 |
if(resp.List[0].FileRef instanceof Array) { |
U |
744 |
for(var i = 0; i < resp.List[0].FileRef.length; i++) { |
|
745 |
files.push(new FileRef(resp.List[0].FileRef[i])); |
|
746 |
} |
|
747 |
} else { |
|
748 |
files.push(new FileRef(resp.List[0].FileRef)); |
2121cc
|
749 |
} |
U |
750 |
var fl = new FileList(files); |
10d3d3
|
751 |
fm_render_list(fl); |
2121cc
|
752 |
} else { |
U |
753 |
$('#dateien').empty(); |
7342b1
|
754 |
} |
5dfab6
|
755 |
|
10d3d3
|
756 |
// Breadcrumb-Ansicht |
7d8ef6
|
757 |
var template; |
a94216
|
758 |
$('.breadcrumb-item').attr('onclick','').unbind('click'); |
2315a0
|
759 |
$('#bcnav').empty(); |
5dfab6
|
760 |
var dirList = new Array(); |
U |
761 |
var rp = ''; |
a94216
|
762 |
//console.log("'" + relPfad + "'"); |
U |
763 |
var dirs = relPfad.split('/'); |
|
764 |
//console.log(dirs.length); |
2121cc
|
765 |
dirList.push(new BcrFile(rp, 'Home')); |
a94216
|
766 |
if(relPfad.length > 0) { |
2315a0
|
767 |
for(var i = 0; i < dirs.length - 1; i++) { |
5dfab6
|
768 |
if(rp.length > 0 ) { |
U |
769 |
dirList.push(new BcrFile(rp + '/' + dirs[i], dirs[i])); |
2315a0
|
770 |
rp = rp + '/' + dirs[i]; |
5dfab6
|
771 |
} else { |
U |
772 |
dirList.push(new BcrFile(dirs[i], dirs[i])); |
2315a0
|
773 |
rp = dirs[i]; |
5dfab6
|
774 |
} |
U |
775 |
} |
|
776 |
var bl = new BcrFiles(dirList); |
7d8ef6
|
777 |
|
U |
778 |
if(dirList.length > 0) { |
|
779 |
template = $('#tpl-bcr').html(); |
|
780 |
Mustache.parse(template); // optional, speeds up future uses |
|
781 |
$('#bcnav').html(Mustache.render(template, bl)); |
2315a0
|
782 |
} |
7d8ef6
|
783 |
|
U |
784 |
if(dirs.length > 0) { |
|
785 |
dirList.push(new BcrFile(rp + '/' + dirs[dirs.length-1], dirs[dirs.length-1])); |
|
786 |
template = $('#tpl-bcr2').html(); |
|
787 |
Mustache.parse(template); // optional, speeds up future uses |
|
788 |
$('#bcnav').append(Mustache.render(template, dirList[dirList.length-1])); |
|
789 |
} else { |
|
790 |
template = $('#tpl-bcr2').html(); |
|
791 |
Mustache.parse(template); // optional, speeds up future uses |
|
792 |
$('#bcnav').append(Mustache.render(template, dirList[0])); |
|
793 |
} |
|
794 |
|
|
795 |
$('#bcnav').append($('#tpl-bcr3').html()); |
2315a0
|
796 |
} else { |
a94216
|
797 |
pfad = ''; |
7d8ef6
|
798 |
template = $('#tpl-bcr2').html(); |
U |
799 |
Mustache.parse(template); // optional, speeds up future uses |
|
800 |
$('#bcnav').append(Mustache.render(template, dirList[0])); |
|
801 |
$('#bcnav').append($('#tpl-bcr3').html()); |
5dfab6
|
802 |
} |
7d8ef6
|
803 |
$('.breadcrumb-item').click(fm_bc_click); |
U |
804 |
$('#ansicht').click(fm_ansicht_umschalten); |
|
805 |
fm_set_modus(); |
|
806 |
}); |
e5ff42
|
807 |
} |
U |
808 |
|
a75859
|
809 |
function fm_menu_datei_speichern(callback) { |
5ebb8e
|
810 |
//var fname = $('.datei-gewaehlt').text(); |
U |
811 |
var fname = openFileName; |
|
812 |
if(fname !== undefined && fname !== '') { |
a75859
|
813 |
fm_save_file(fname, 'saveTextFile', callback); |
5ebb8e
|
814 |
} else { |
a75859
|
815 |
fm_menu_datei_speichern_unter(callback); |
5ebb8e
|
816 |
} |
U |
817 |
} |
|
818 |
|
a75859
|
819 |
function fm_save_file(saveFileName, method, callback) { |
7d8ef6
|
820 |
var content; |
U |
821 |
if(openEditor === 'text') { |
|
822 |
content = cm.getValue(); |
3003b2
|
823 |
cm.getDoc().markClean(); |
7d8ef6
|
824 |
} else { |
U |
825 |
content = ed.getContent(); |
3003b2
|
826 |
tinymce.activeEditor.undoManager.clear(); |
7d8ef6
|
827 |
} |
47e9d4
|
828 |
var m = '?c=de.uhilger.filecms.api.FileMgr&m=' + method; |
5ebb8e
|
829 |
var u = '../svc' + m; |
7d8ef6
|
830 |
fm_post(u, {p1: pfad, p2: saveFileName, p3: content}, function(resp) { |
a75859
|
831 |
// hier scheint nichts zurueckzukommen.. |
5ebb8e
|
832 |
}); |
a75859
|
833 |
openFileName = saveFileName; |
3003b2
|
834 |
if(typeof (callback) !== 'function') { |
U |
835 |
|
|
836 |
} else { |
a75859
|
837 |
callback(); |
U |
838 |
} |
5ebb8e
|
839 |
} |
U |
840 |
|
a75859
|
841 |
function fm_menu_datei_speichern_unter(callback) { |
915927
|
842 |
$('#modal_ok').click(function() { |
a75859
|
843 |
$('#modal_ok').attr('onclick','').unbind('click'); |
915927
|
844 |
// hier speichern |
a75859
|
845 |
fm_save_file($('#dateiname').val(), 'saveTextFileAs', callback); |
915927
|
846 |
}); |
957b51
|
847 |
$('#saveModalTitle').text('Datei speichern'); |
c509a0
|
848 |
$('#dialogfrage').text("Dateiname?"); |
3ad4db
|
849 |
|
U |
850 |
var fname = $('.datei-gewaehlt').text(); |
|
851 |
if(fname !== undefined) { |
|
852 |
$('#dateiname').val(fname); |
|
853 |
} else { |
|
854 |
$('#dateiname').val(''); |
|
855 |
} |
c509a0
|
856 |
$('#dateiname').attr('placeholder', 'Dateiname'); |
915927
|
857 |
$('#saveModal').modal({ |
U |
858 |
keyboard: false, |
|
859 |
show: true |
|
860 |
}); |
a4d3b5
|
861 |
} |
U |
862 |
|
b7475d
|
863 |
function fm_logout() { |
U |
864 |
var m = '?c=de.uhilger.filecms.pub.SessionManager&m=expireSession'; |
|
865 |
var u = '../pub' + m; |
|
866 |
|
|
867 |
fm_get(u, "text", function(resp) { |
|
868 |
$('#userMenu').text('nicht angemeldet'); |
|
869 |
window.location.href = '../logout.html'; |
|
870 |
}); |
|
871 |
} |
|
872 |
|
|
873 |
|
a4d3b5
|
874 |
/* ---- codemirror editor handling -------- */ |
U |
875 |
|
64d8b9
|
876 |
/* |
942d63
|
877 |
function htmlDecode(value){ |
U |
878 |
return $('<div/>').html(value).text(); |
|
879 |
} |
64d8b9
|
880 |
*/ |
942d63
|
881 |
|
42fece
|
882 |
function fm_code_edit(content, m) { |
a4d3b5
|
883 |
cm = CodeMirror.fromTextArea(document.getElementById("editspace"), { |
U |
884 |
lineNumbers: true, |
e3043f
|
885 |
gutters: ["CodeMirror-linenumbers", "breakpoints"], |
42fece
|
886 |
mode: m, |
a4d3b5
|
887 |
viewportMargin : Infinity, |
d920b7
|
888 |
tabSize: 2, |
a4d3b5
|
889 |
extraKeys: { |
915927
|
890 |
"F9": function(cm) { |
U |
891 |
cm.setOption("fullScreen", !cm.getOption("fullScreen")); |
|
892 |
}, |
|
893 |
"Esc": function(cm) { |
|
894 |
if (cm.getOption("fullScreen")) cm.setOption("fullScreen", false); |
7ad1b7
|
895 |
}, |
U |
896 |
".": function(cm) { |
|
897 |
console.log('dot pressed: perhaps look up class or method name'); |
3b7c5b
|
898 |
/* |
U |
899 |
* Hier kann man eine Funktion ausloesen, die fuer das |
|
900 |
* Wort vor dem Punkt (Name der Klasse) eine Liste mit |
|
901 |
* Vorschlaegen fuer Methodennamen einblendet. |
|
902 |
*/ |
|
903 |
|
|
904 |
/* |
|
905 |
* CodeMirror.Pass laesst das Zeichen zum Editorinhalt durch, |
|
906 |
* verhindert aber das Ausloesen von 'keyHandled' |
|
907 |
*/ |
|
908 |
return CodeMirror.Pass; |
915927
|
909 |
} |
a4d3b5
|
910 |
} |
U |
911 |
}); |
fab80c
|
912 |
//cm.setValue(htmlDecode(content)); |
U |
913 |
//cm.setValue(content); |
|
914 |
cm.setValue(unescapeHtml(content)); |
3003b2
|
915 |
cm.getDoc().markClean(); |
e3043f
|
916 |
cm.on("gutterClick", function(theEditor, lineNumber) { |
U |
917 |
var info = theEditor.lineInfo(lineNumber); |
|
918 |
//--lineNumber; |
|
919 |
//console.log(info.gutterMarkers.breakpoints.message); |
|
920 |
//var marker = info.gutterMarkers.breakpoints; |
|
921 |
//$(marker).tooltip('toggle'); |
|
922 |
}); |
3b7c5b
|
923 |
/* |
7ad1b7
|
924 |
cm.on("keyHandled", function(theEditor, keyName, event){ |
3b7c5b
|
925 |
console.log('cm.keyHandled keyName: ' + keyName + ', event.type: ' + event.type); |
7ad1b7
|
926 |
}); |
3b7c5b
|
927 |
*/ |
e3043f
|
928 |
} |
U |
929 |
|
|
930 |
function makeMarker(msg) { |
|
931 |
var marker = document.createElement("div"); |
|
932 |
marker.style.color = "#822"; |
|
933 |
marker.innerHTML = "●"; |
|
934 |
//marker.message = msg; |
|
935 |
$(marker).tooltip({ |
|
936 |
placement: 'right', |
|
937 |
title: msg, |
ed12de
|
938 |
offset: '0 -30' |
e3043f
|
939 |
}); |
U |
940 |
return marker; |
915927
|
941 |
} |
a4d3b5
|
942 |
|
U |
943 |
/* -------- helper functions ----------- */ |
|
944 |
|
b7475d
|
945 |
function fm_get(u, dtype, scallback) { |
a4d3b5
|
946 |
$.ajax({ |
U |
947 |
url: u, |
|
948 |
type: "GET", |
b7475d
|
949 |
dataType: dtype, |
a4d3b5
|
950 |
success: scallback, |
U |
951 |
error: function (xhr, status, errorThrown) { |
|
952 |
alert("Error: " + errorThrown + " Status: " + status + " URL: " + u); |
|
953 |
}, |
|
954 |
complete: function (xhr, status) { |
|
955 |
//console.log( "The request is complete!" ); |
|
956 |
} |
|
957 |
|
|
958 |
}); |
915927
|
959 |
} |
a4d3b5
|
960 |
|
9e2964
|
961 |
function fm_post(u, d, dtype, scallback) { |
a4d3b5
|
962 |
$.ajax({ |
U |
963 |
url: u, |
|
964 |
data: d, |
|
965 |
type: "POST", |
9e2964
|
966 |
dataType: dtype, |
a4d3b5
|
967 |
success: scallback, |
U |
968 |
error: function (xhr, status, errorThrown) { |
|
969 |
$('#fehler').html("Error: " + errorThrown + " Status: " + status); |
|
970 |
}, |
|
971 |
complete: function (xhr, status) { |
|
972 |
//alert( "The request is complete!" ); |
|
973 |
} |
|
974 |
}); |
915927
|
975 |
} |
a4d3b5
|
976 |
|
e5ff42
|
977 |
function fm_serialise(obj) { |
U |
978 |
return '{"' + obj.constructor.name + '":' + JSON.stringify(obj) + '}'; |
915927
|
979 |
} |
e5ff42
|
980 |
|
fab80c
|
981 |
function escapeHtml(text) { |
U |
982 |
text = text.replace(/\u228/g,'ä'); |
|
983 |
text = text.replace(/\u246/g,'ö'); |
|
984 |
text = text.replace(/\u252/g,'ü'); |
|
985 |
text = text.replace(/\u196/g,'Ä'); |
|
986 |
text = text.replace(/\u214/g,'Ö'); |
|
987 |
text = text.replace(/\u220/g,'Ü'); |
|
988 |
text = text.replace(/\u223/g,'ß'); |
|
989 |
text = text.replace(/\u26/g,'&'); |
|
990 |
return text; |
|
991 |
} |
|
992 |
|
|
993 |
function unescapeHtml(text) { |
|
994 |
text = text.replace(/ä/g, String.fromCharCode(228)); |
|
995 |
text = text.replace(/ö/g, String.fromCharCode(246)); |
|
996 |
text = text.replace(/ü/g, String.fromCharCode(252)); |
|
997 |
text = text.replace(/Ä/g, String.fromCharCode(196)); |
|
998 |
text = text.replace(/Ö/g, String.fromCharCode(214)); |
|
999 |
text = text.replace(/Ü/g, String.fromCharCode(220)); |
|
1000 |
text = text.replace(/ß/g, String.fromCharCode(223)); |
|
1001 |
text = text.replace(/&/g, String.fromCharCode(26)); |
|
1002 |
return text; |
|
1003 |
} |
|
1004 |
|
|
1005 |
|
7342b1
|
1006 |
/* ----- Objekte ----- */ |
U |
1007 |
|
|
1008 |
function FileList(fl) { |
|
1009 |
this.files = fl; |
|
1010 |
} |
|
1011 |
|
|
1012 |
function FileRef(obj) { |
|
1013 |
var self = this; |
|
1014 |
this.fr = obj; |
7f2a41
|
1015 |
this.fnx; |
7342b1
|
1016 |
|
U |
1017 |
this.typeClass = function() { |
10d3d3
|
1018 |
if(modus == 'kacheln') { |
U |
1019 |
if(self.fr.isDirectory) { |
a3d410
|
1020 |
return 'fa-folder ordner'; |
10d3d3
|
1021 |
} else { |
a3d410
|
1022 |
return 'fa-file datei'; |
10d3d3
|
1023 |
} |
7342b1
|
1024 |
} else { |
10d3d3
|
1025 |
if(self.fr.isDirectory) { |
a3d410
|
1026 |
return 'fa-folder ordner'; |
10d3d3
|
1027 |
} else { |
a3d410
|
1028 |
return 'fa-file-o datei'; |
10d3d3
|
1029 |
} |
7342b1
|
1030 |
} |
2121cc
|
1031 |
}; |
U |
1032 |
|
7f2a41
|
1033 |
this.mini = function() { |
U |
1034 |
var miniatur = false; |
|
1035 |
var namen = self.fr.absolutePath.split('/'); |
|
1036 |
if(namen.length > 0) { |
|
1037 |
self.fnx = decodeURIComponent(namen[namen.length - 1]); |
|
1038 |
} else { |
|
1039 |
self.fnx = decodeURIComponent(self.fr.absolutePath); |
|
1040 |
} |
|
1041 |
if(self.fnx.indexOf('.jpg') > -1 || self.fnx.indexOf('.png') > -1 || self.fnx.indexOf('.gif') > -1 || self.fnx.indexOf('.jpeg') > -1) { |
|
1042 |
miniatur = true; |
|
1043 |
} |
|
1044 |
return miniatur; |
|
1045 |
}; |
|
1046 |
|
|
1047 |
this.miniurl = function() { |
|
1048 |
var userid = $('#userMenu').text(); |
|
1049 |
var ext = ''; |
|
1050 |
var dotpos = self.fnx.indexOf('.'); |
|
1051 |
if(dotpos > -1) { |
|
1052 |
var fny = self.fnx; |
|
1053 |
self.fnx = self.fnx.substring(0, dotpos); |
|
1054 |
ext = fny.substr(dotpos); |
|
1055 |
} |
|
1056 |
var path = fm_get_path(userid); |
fa012b
|
1057 |
var imgurl = loc + path + '/' + self.fnx + '_tn' + ext; |
7f2a41
|
1058 |
return imgurl; |
U |
1059 |
|
|
1060 |
}; |
|
1061 |
|
2121cc
|
1062 |
this.fileName = function() { |
7f2a41
|
1063 |
|
2121cc
|
1064 |
var namen = self.fr.absolutePath.split('/'); |
U |
1065 |
if(namen.length > 0) { |
f7d8bf
|
1066 |
return decodeURIComponent(namen[namen.length - 1]); |
2121cc
|
1067 |
} else { |
f7d8bf
|
1068 |
return decodeURIComponent(self.fr.absolutePath); |
2121cc
|
1069 |
} |
7f2a41
|
1070 |
|
2121cc
|
1071 |
}; |
7342b1
|
1072 |
} |
5dfab6
|
1073 |
|
U |
1074 |
function BcrFiles(fl) { |
|
1075 |
this.files = fl; |
|
1076 |
} |
|
1077 |
|
|
1078 |
function BcrFile(rp, n) { |
|
1079 |
this.relPath = rp; |
|
1080 |
this.fName = n; |
7aa566
|
1081 |
} |
U |
1082 |
|