commit | author | age
|
05e9c4
|
1 |
function AppVorlage() { |
U |
2 |
var self = this; |
41ab37
|
3 |
this.appMenu; |
4e450e
|
4 |
//this.vorlagen; |
41ab37
|
5 |
this.api; |
U |
6 |
this.userid; |
|
7 |
this.pfad = ''; |
|
8 |
this.loc; |
|
9 |
this.modus = 'kacheln'; |
ebc1f3
|
10 |
this.cm; |
4e450e
|
11 |
//this.tinymce; |
U |
12 |
this.ed; |
|
13 |
this.tmo; |
|
14 |
this.tmo2; |
41ab37
|
15 |
this.PERS_DIR = "Persoenlich"; |
U |
16 |
this.PUB_DIR = "Oeffentlich"; |
|
17 |
this.DAV_DIR = "Austausch"; |
|
18 |
this.BASE_DIR = "$basis"; |
|
19 |
this.DATA_DIR = "$daten"; |
|
20 |
this.WWW_DIR = "www"; |
f002d9
|
21 |
this.openEditor; |
U |
22 |
this.openFileName; |
beb124
|
23 |
this.cutCopyOperation; |
U |
24 |
this.cutCopySrcDir; |
|
25 |
this.cutCopyFiles; |
9350c9
|
26 |
this.fm_slideshow = false; |
820953
|
27 |
this.dateien; |
41ab37
|
28 |
this.cache = {}; // mustache template cache |
05e9c4
|
29 |
|
94b871
|
30 |
this.datei_neuer_text = function () { |
ebc1f3
|
31 |
//self.meldung_mit_timeout("Neuer Text", 1500); |
U |
32 |
self.fm_text_edit('Neue Datei'); |
|
33 |
}; |
|
34 |
|
05e9c4
|
35 |
/* Funktionen aus App-Vorlage */ |
94b871
|
36 |
|
4e450e
|
37 |
this.init = function () { |
f002d9
|
38 |
document.querySelector(".codeeditor-space").style.display = "none"; |
U |
39 |
document.querySelector("#mce-editor").style.display = "none"; |
05e9c4
|
40 |
self.appMenu = new AppMenu(); |
U |
41 |
self.appMenu.init( |
94b871
|
42 |
"data/menu/", |
U |
43 |
"hauptmenue.json", |
|
44 |
"data/tpl/app-menu.tpl", |
|
45 |
".west", |
|
46 |
"8em"); |
|
47 |
document.querySelector('.hamburger').addEventListener('click', function (e) { |
05e9c4
|
48 |
self.menue_umschalten(); |
U |
49 |
}); |
f32042
|
50 |
document.querySelector('#top-neuer-text-btn').addEventListener('click', self.datei_neuer_text); |
U |
51 |
document.querySelector('#top-neuer-ordner-btn').addEventListener('click', self.datei_neuer_ordner); |
|
52 |
document.querySelector('#top-close-btn').addEventListener('click', self.fm_menu_datei_schliessen); |
58bcbd
|
53 |
self.fm_get_login(); |
41ab37
|
54 |
|
U |
55 |
var parsedUrl = new URL(window.location.href); |
|
56 |
var wunschPfad = parsedUrl.searchParams.get("pfad"); |
|
57 |
|
|
58 |
if(wunschPfad !== null && wunschPfad.length > 0) { |
|
59 |
self.pfad = wunschPfad; |
|
60 |
self.fm_get_list(wunschPfad); |
|
61 |
} else { |
|
62 |
self.fm_get_list(''); |
|
63 |
} |
ebc1f3
|
64 |
|
U |
65 |
self.seitenleiste_umschalten(); |
820953
|
66 |
self.fm_init_uploader(); |
58bcbd
|
67 |
self.loc = window.location.protocol + '//' + window.location.host; |
05e9c4
|
68 |
}; |
820953
|
69 |
|
U |
70 |
/* ----- Uploader Anfang ----------*/ |
|
71 |
|
|
72 |
this.fm_init_uploader = function() { |
|
73 |
//console.log('init_uploader'); |
|
74 |
self.dateien = new Array(); |
8e238e
|
75 |
var dropzone = document.getElementById("upload-target"); |
820953
|
76 |
dropzone.ondragover = dropzone.ondragenter = function(event) { |
U |
77 |
event.stopPropagation(); |
|
78 |
event.preventDefault(); |
|
79 |
}; |
|
80 |
|
|
81 |
dropzone.ondrop = function(event) { |
|
82 |
//console.log('dateien ondrop'); |
|
83 |
event.stopPropagation(); |
|
84 |
event.preventDefault(); |
|
85 |
var fileList = event.dataTransfer.files; |
|
86 |
for (var i=0; i<fileList.length; i++) { |
|
87 |
self.dateien.push(fileList[i]); |
|
88 |
//console.log('upload ' + fileList[i]); |
|
89 |
} |
|
90 |
self.sendFile(self.dateien.pop()); |
|
91 |
}; |
|
92 |
}; |
|
93 |
|
|
94 |
/* ----- Uploader Ende --------------- */ |
05e9c4
|
95 |
|
58bcbd
|
96 |
this.login_zeigen = function() { |
U |
97 |
self.meldung_mit_timeout("Benutzer: " + self.userid, 1500); |
|
98 |
}; |
|
99 |
|
b20b74
|
100 |
this.fm_neuer_reiter = function() { |
U |
101 |
window.open('/file-cms/ui2/?pfad=' + self.pfad, '_blank'); |
|
102 |
}; |
820953
|
103 |
|
U |
104 |
this.fm_hilfe = function() { |
|
105 |
window.open('/data/dok/wbx-doku.html#wbx-bedienung', '_blank'); |
|
106 |
}; |
9350c9
|
107 |
|
U |
108 |
this.fm_toggle_show_slideshow = function() { |
|
109 |
if(self.fm_slideshow) { |
|
110 |
//$('#m-toggle-slideshow').text('Diashow einschalten'); |
|
111 |
self.fm_slideshow = false; |
|
112 |
} else { |
|
113 |
//$('#m-toggle-slideshow').text('Diashow ausschalten'); |
|
114 |
self.fm_slideshow = true; |
|
115 |
} |
|
116 |
}; |
|
117 |
|
820953
|
118 |
this.fm_view_slideshow = function() { |
U |
119 |
|
|
120 |
// https://localhost:8443/file-cms/fotos/?o=ulrich/bilder/diashow/ordnername |
|
121 |
|
|
122 |
|
|
123 |
var userid = self.userid; // $('#userMenu').text(); |
|
124 |
//var gewaehlte = $('.datei-gewaehlt'); |
|
125 |
//var gewaehlte = document.querySelector('.datei-gewaehlt'); |
|
126 |
//var fname = gewaehlte.textContent; |
|
127 |
|
|
128 |
var path = self.fm_get_path(userid); |
|
129 |
var restdir = path; |
|
130 |
if(path.indexOf('/data/') > -1) { |
|
131 |
restdir = path.substr('/data/'.length); |
|
132 |
} |
|
133 |
|
|
134 |
//window.open('/file-cms/fotos/?o=' + userid + '/' + path + '/' + fname, '_blank'); |
|
135 |
window.open('/file-cms/fotos/?o=' + restdir + '/' /*+ fname*/, '_blank'); |
|
136 |
}; |
|
137 |
|
122cf8
|
138 |
this.fm_menu_datei_entpacken = function() { |
U |
139 |
//var gewaehlte = $('.datei-gewaehlt'); |
|
140 |
//var fname = $(gewaehlte[0]).text(); |
|
141 |
var gewaehlte = document.querySelector('.datei-gewaehlt'); |
|
142 |
var fname = gewaehlte.textContent; |
|
143 |
self.fm_unzip_file(fname); |
|
144 |
}; |
|
145 |
|
94b871
|
146 |
this.menue_umschalten = function () { |
05e9c4
|
147 |
var ham = document.querySelector(".hamburger"); |
U |
148 |
ham.classList.toggle("is-active"); // hamburger-icon umschalten |
|
149 |
self.appMenu.toggle(); // menue oeffnen/schliessen |
|
150 |
}; |
|
151 |
|
94b871
|
152 |
this.info_dialog_zeigen = function () { |
05e9c4
|
153 |
self.dialog_laden_und_zeigen('data/tpl/dlg-info.tpl', ''); |
e342e0
|
154 |
//self.menue_umschalten(); |
05e9c4
|
155 |
}; |
U |
156 |
|
94b871
|
157 |
this.seitenleiste_umschalten = function () { |
05e9c4
|
158 |
var ostDiv = document.querySelector('.ost'); |
94b871
|
159 |
if (ostDiv.classList.contains('ost-open')) { |
05e9c4
|
160 |
ostDiv.classList.remove('ost-open'); |
94b871
|
161 |
ostDiv.style.flexBasis = '0em'; |
05e9c4
|
162 |
} else { |
94b871
|
163 |
ostDiv.classList.add('ost-open'); |
U |
164 |
ostDiv.style.flexBasis = '6em'; |
05e9c4
|
165 |
} |
ebc1f3
|
166 |
//self.menue_umschalten(); |
05e9c4
|
167 |
}; |
U |
168 |
|
94b871
|
169 |
this.fusszeile_umschalten = function () { |
05e9c4
|
170 |
var suedDiv = document.querySelector('.sued'); |
94b871
|
171 |
if (suedDiv.classList.contains('sued-open')) { |
05e9c4
|
172 |
suedDiv.classList.remove('sued-open'); |
94b871
|
173 |
suedDiv.style.height = '0'; |
05e9c4
|
174 |
} else { |
U |
175 |
suedDiv.classList.add('sued-open'); |
94b871
|
176 |
suedDiv.style.height = '1.5em'; |
05e9c4
|
177 |
} |
U |
178 |
self.menue_umschalten(); |
|
179 |
}; |
122cf8
|
180 |
|
U |
181 |
this.fm_fusszeile_zeigen = function() { |
|
182 |
var suedDiv = document.querySelector('.sued'); |
|
183 |
suedDiv.classList.add('sued-open'); |
e3cec2
|
184 |
suedDiv.style.height = '7em'; |
122cf8
|
185 |
//$('.sued').show(); |
U |
186 |
}; |
|
187 |
|
05e9c4
|
188 |
|
94b871
|
189 |
this.meldung_mit_timeout = function (meldung, timeout) { |
05e9c4
|
190 |
var s = document.querySelector('.sued'); |
U |
191 |
s.textContent = meldung; |
85ba85
|
192 |
s.classList.add('sued-open'); |
U |
193 |
s.style.height = '1.5em'; |
94b871
|
194 |
setTimeout(function () { |
05e9c4
|
195 |
s.textContent = 'Bereit.'; |
94b871
|
196 |
setTimeout(function () { |
05e9c4
|
197 |
var suedDiv = document.querySelector('.sued'); |
94b871
|
198 |
if (suedDiv.classList.contains('sued-open')) { |
U |
199 |
suedDiv.classList.remove('sued-open'); |
|
200 |
suedDiv.style.height = '0'; |
05e9c4
|
201 |
} |
U |
202 |
}, 500); |
|
203 |
}, timeout); |
|
204 |
}; |
ebc1f3
|
205 |
|
U |
206 |
this.fm_menu_datei_schliessen = function() { |
|
207 |
if(self.openEditor === 'text') { |
|
208 |
if(!self.cm.getDoc().isClean()) { |
|
209 |
self.fm_ask_for_save(); |
|
210 |
} else { |
|
211 |
self.fm_do_close(); |
|
212 |
} |
|
213 |
} else { |
4e450e
|
214 |
if(tinymce.activeEditor.undoManager.hasUndo()) { |
ebc1f3
|
215 |
self.fm_ask_for_save(); |
U |
216 |
} else { |
|
217 |
self.fm_do_close(); |
|
218 |
} |
|
219 |
} |
|
220 |
}; |
|
221 |
|
|
222 |
this.fm_ask_for_save = function() { |
|
223 |
self.dialog_laden_und_zeigen('data/tpl/dlg-ask-save.tpl', '', function() { |
|
224 |
// wenn dialog da ist, hier events verknuepfen |
|
225 |
document.querySelector('#cancel-btn').addEventListener('click', function() { |
|
226 |
self.fm_do_close(); |
|
227 |
self.dialog_schliessen(); |
|
228 |
}); |
|
229 |
document.querySelector('#speichern-btn').addEventListener('click', function() { |
|
230 |
self.fm_menu_datei_speichern(function() { |
|
231 |
self.fm_do_close(); |
|
232 |
self.dialog_schliessen(); |
|
233 |
}); |
|
234 |
}); |
|
235 |
}); |
|
236 |
}; |
|
237 |
|
|
238 |
this.fm_menu_datei_speichern = function(callback) { |
|
239 |
//var fname = $('.datei-gewaehlt').text(); |
|
240 |
var fname = self.openFileName; |
|
241 |
if(fname !== undefined && fname !== '') { |
|
242 |
self.fm_save_file(fname, 'saveTextFile', callback); |
03be8f
|
243 |
self.meldung_mit_timeout(fname + ' gespeichert.', 1500); |
ebc1f3
|
244 |
} else { |
U |
245 |
self.fm_menu_datei_speichern_unter(callback); |
|
246 |
} |
|
247 |
}; |
|
248 |
|
|
249 |
this.fm_menu_datei_speichern_unter = function(callback) { |
|
250 |
self.dialog_laden_und_zeigen('data/tpl/dlg-save-as.tpl', '', function() { |
5b4d03
|
251 |
document.querySelector('#cancel-btn').addEventListener('click', function() { |
U |
252 |
//self.fm_do_close(); |
|
253 |
self.dialog_schliessen(); |
|
254 |
}); |
|
255 |
document.querySelector('#speichern-btn').addEventListener('click', function() { |
1a9589
|
256 |
//self.fm_menu_datei_speichern(function() { |
U |
257 |
//console.log(document.querySelector('#datei-name-in').value); |
03be8f
|
258 |
var fname = document.querySelector('#datei-name-in').value; |
U |
259 |
self.fm_save_file(fname, 'saveTextFileAs', callback); |
|
260 |
self.meldung_mit_timeout(fname + ' gespeichert.', 1500); |
4e450e
|
261 |
if(typeof(callback) !== 'function') { |
03be8f
|
262 |
//self.fm_do_close(); |
4e450e
|
263 |
self.dialog_schliessen(); |
U |
264 |
} |
1a9589
|
265 |
//}); |
5b4d03
|
266 |
}); |
ebc1f3
|
267 |
}); |
4e450e
|
268 |
}; |
U |
269 |
|
|
270 |
this.fm_menu_neues_dokument = function() { |
|
271 |
self.fm_dok_edit(''); |
ebc1f3
|
272 |
}; |
05e9c4
|
273 |
|
U |
274 |
/* Dialog-Funktionen */ |
|
275 |
|
|
276 |
/* |
94b871
|
277 |
Einen Dialog aus Vorlagen erzeugen |
U |
278 |
|
|
279 |
vurl - URL zur Dialogvorlage |
|
280 |
msgTpl - URL mit einer Vorlage eines Mitteilungstextes (optional) |
|
281 |
*/ |
ebc1f3
|
282 |
this.dialog_laden_und_zeigen = function (vurl, msgTpl, cb) { |
U |
283 |
var vorlage = self.cache[vurl]; |
|
284 |
if(vorlage === undefined) { |
|
285 |
self.fm_get(vurl, "text", function(antwort) { |
|
286 |
self.cache[vurl] = antwort; |
|
287 |
self.dialog_zeigen(vurl, antwort, cb); |
|
288 |
//self.vorlage_fuellen(vurl, inhalt, cb); |
94b871
|
289 |
}); |
05e9c4
|
290 |
} else { |
ebc1f3
|
291 |
self.dialog_zeigen(vurl, vorlage, cb); |
05e9c4
|
292 |
} |
U |
293 |
}; |
|
294 |
|
ebc1f3
|
295 |
this.dialog_zeigen = function (vurl, inhalt, cb) { |
05e9c4
|
296 |
var dlg = document.querySelector(".dialog"); |
ebc1f3
|
297 |
self.html_erzeugen( |
94b871
|
298 |
vurl, |
U |
299 |
inhalt, |
|
300 |
function (html) { |
|
301 |
//dlg.html(html); |
1a9589
|
302 |
dlg.style.height = '7em'; |
94b871
|
303 |
dlg.innerHTML = html; |
U |
304 |
document.querySelector('.close-btn').addEventListener('click', self.dialog_schliessen); |
|
305 |
//dlg.slideDown(300); |
ebc1f3
|
306 |
if(typeof(cb) !== 'function') { |
U |
307 |
// .. |
|
308 |
} else { |
|
309 |
cb(); |
|
310 |
} |
94b871
|
311 |
}); |
05e9c4
|
312 |
}; |
U |
313 |
|
58bcbd
|
314 |
this.dialog_schliessen = function () { |
05e9c4
|
315 |
document.querySelector('.close-btn').removeEventListener('click', self.dialog_schliessen); |
U |
316 |
//$('.dialog').slideUp(300); |
|
317 |
var dlg = document.querySelector('.dialog'); |
|
318 |
//dlg.style.display = "none"; |
|
319 |
dlg.style.height = '0'; |
|
320 |
dlg.innerHTML = ''; |
5b4d03
|
321 |
self.removeAllListeners('#cancel-btn'); |
U |
322 |
self.removeAllListeners('#speichern-btn'); |
05e9c4
|
323 |
}; |
39e714
|
324 |
|
U |
325 |
this.fm_auswahl_marke_entfernen = function() { |
|
326 |
var gew = document.querySelector('.datei-gewaehlt'); |
|
327 |
if(gew !== null) { |
|
328 |
gew.classList.remove('datei-gewaehlt'); |
|
329 |
} |
|
330 |
}; |
0783c5
|
331 |
|
U |
332 |
this.fm_view_file = function() { |
|
333 |
var fname = document.querySelector('.datei-gewaehlt').textContent; |
|
334 |
var path = self.fm_get_path(self.userid); |
|
335 |
window.open(path + '/' + fname, '_blank'); |
|
336 |
}; |
39e714
|
337 |
|
0783c5
|
338 |
this.datei_ansehen_oder_bearbeiten = function(dateiname) { |
U |
339 |
if(dateiname.endsWith('htmi')) { |
|
340 |
self.fm_get_file_content('doc', dateiname); |
|
341 |
} else if(dateiname.endsWith('jpg') || dateiname.endsWith('png') || |
98f80c
|
342 |
dateiname.endsWith('gif') || dateiname.endsWith('pdf') ) { |
U |
343 |
self.fm_view_file(); |
0783c5
|
344 |
} else { |
U |
345 |
self.fm_get_file_content('text', dateiname); |
|
346 |
} |
39e714
|
347 |
}; |
U |
348 |
|
|
349 |
/** |
85ba85
|
350 |
* Hier werden die folgenden Faelle einer Datei- |
U |
351 |
* bzw. Ordnerauswahl ausgefuehrt: |
|
352 |
* |
|
353 |
* geklickt, nicht gewaehlt: |
|
354 |
* auswaehlen, evtl. bestehende andere Auswahl entfernen |
|
355 |
* |
|
356 |
* geklickt, ausgewaehlt: |
|
357 |
* Datei ansehen oder oeffnen bzw. Ordner oeffnen |
|
358 |
* |
|
359 |
* geklickt mit [Strg], nicht gewahlt: |
|
360 |
* auswaehlen, bestehende Auswahl beibehalten (Mehrfachauswahl) |
|
361 |
* |
|
362 |
* geklickt mit [Strg], gewaehlt: |
|
363 |
* Auswahl bei diesem Element entfernen |
39e714
|
364 |
* |
U |
365 |
* Diese Fälle sind unterteilt in |
85ba85
|
366 |
* 1. Kachel-Modus |
U |
367 |
* 2. Listenmodus |
39e714
|
368 |
* |
85ba85
|
369 |
* @param {type} ev Klick-Event |
U |
370 |
* @returns {undefined} nichts |
39e714
|
371 |
*/ |
6648a8
|
372 |
this.fm_dateiwahl = function(ev) { |
U |
373 |
var elem = ev.target; |
|
374 |
if(self.modus == 'kacheln') { |
|
375 |
// Kacheln |
9350c9
|
376 |
//var par = elem.parentElement; |
U |
377 |
var par = elem.closest('.datei-figure'); |
0783c5
|
378 |
var dElem = par.querySelector('.dateiname'); |
6648a8
|
379 |
if(elem.classList.contains("icon-folder")) { |
39e714
|
380 |
// Ordner |
0783c5
|
381 |
//var par = elem.parentElement; |
U |
382 |
var istGewaehlt = dElem.classList.contains('datei-gewaehlt'); |
39e714
|
383 |
if(istGewaehlt) { |
U |
384 |
if(/*ev.shiftKey || */ ev.ctrlKey) { |
|
385 |
// mehrere Ordner sind gewaehlt, diese eine wieder entfernen |
0783c5
|
386 |
dElem.classList.remove('datei-gewaehlt'); |
6648a8
|
387 |
} else { |
39e714
|
388 |
// Ordner oeffnen |
0783c5
|
389 |
var ordner = dElem.textContent.trim(); |
39e714
|
390 |
if(self.pfad.length > 0) { |
U |
391 |
self.pfad = self.pfad + '/' + ordner; |
|
392 |
} else { |
|
393 |
self.pfad = ordner; |
|
394 |
} |
|
395 |
self.fm_get_list(self.pfad); |
6648a8
|
396 |
} |
39e714
|
397 |
} else { |
U |
398 |
// Ordner auswaehlen |
|
399 |
if(/*ev.shiftKey || */ ev.ctrlKey) { |
|
400 |
// Mehrfachauswahl |
|
401 |
} else { |
|
402 |
self.fm_auswahl_marke_entfernen(); |
|
403 |
} |
0783c5
|
404 |
dElem.classList.add('datei-gewaehlt'); |
6648a8
|
405 |
} |
U |
406 |
} else if(elem.classList.contains('datei')) { |
39e714
|
407 |
// Datei |
0783c5
|
408 |
//var par = elem.parentElement; |
U |
409 |
//var dElem = par.querySelector('.dateiname'); |
|
410 |
var istGewaehlt = dElem.classList.contains('datei-gewaehlt'); |
39e714
|
411 |
if(istGewaehlt) { |
U |
412 |
if(/*ev.shiftKey || */ ev.ctrlKey) { |
|
413 |
// mehrere Dateien sind gewaehlt, diese eine wieder entfernen |
0783c5
|
414 |
dElem.classList.remove('datei-gewaehlt'); |
39e714
|
415 |
} else { |
U |
416 |
// Datei zum Bearbeiten oeffnen |
0783c5
|
417 |
self.datei_ansehen_oder_bearbeiten(dElem.textContent); |
39e714
|
418 |
} |
U |
419 |
} else { |
|
420 |
if(/*ev.shiftKey || */ ev.ctrlKey) { |
|
421 |
// mehrere Dateien sollen gewaehlt werden |
|
422 |
} else { |
|
423 |
self.fm_auswahl_marke_entfernen(); |
|
424 |
} |
0783c5
|
425 |
dElem.classList.add('datei-gewaehlt'); |
39e714
|
426 |
} |
6648a8
|
427 |
} else { |
U |
428 |
//console.log('kein folder oder file...'); |
|
429 |
} |
|
430 |
} else { |
4f01b8
|
431 |
// Liste |
U |
432 |
var pElem = elem.closest('.datei-zeile'); |
|
433 |
var dElem = pElem.querySelector('.datei-elem'); |
0783c5
|
434 |
var dnElem = pElem.querySelector('.dateiname'); |
U |
435 |
var istGewaehlt = dnElem.classList.contains('datei-gewaehlt'); |
4f01b8
|
436 |
if(dElem.getElementsByTagName("i")[0].classList.contains('icon-doc-text-inv')) { |
6648a8
|
437 |
// Datei |
39e714
|
438 |
if(istGewaehlt) { |
U |
439 |
if(/*ev.shiftKey || */ ev.ctrlKey) { |
|
440 |
// mehrere Dateien sind gewaehlt, diese eine wieder entfernen |
0783c5
|
441 |
dnElem.classList.remove('datei-gewaehlt'); |
39e714
|
442 |
} else { |
U |
443 |
// gewaehlte Datei ohne [Strg] geklickt: ansehen oder oeffnen |
0783c5
|
444 |
self.datei_ansehen_oder_bearbeiten(dnElem.textContent); |
39e714
|
445 |
} |
6648a8
|
446 |
} else { |
39e714
|
447 |
if(/*ev.shiftKey || */ ev.ctrlKey) { |
U |
448 |
// mehrere Dateien sollen gewaehlt werden, Auswahl ist weiter unten |
|
449 |
} else { |
|
450 |
var ti = document.querySelector('.table-info'); |
|
451 |
if(ti !== null) { |
|
452 |
ti.classList.remove('table-info'); |
|
453 |
} |
|
454 |
self.fm_auswahl_marke_entfernen(); |
4f01b8
|
455 |
} |
39e714
|
456 |
pElem.classList.add('table-info'); |
0783c5
|
457 |
dnElem.classList.add('datei-gewaehlt'); |
6648a8
|
458 |
} |
U |
459 |
} else { |
|
460 |
// Ordner |
39e714
|
461 |
if(istGewaehlt) { |
U |
462 |
if(/*ev.shiftKey || */ ev.ctrlKey) { |
|
463 |
// ein gewaehlter Ordner ist mit [Strg] geklickt, Auswahl entfernen |
0783c5
|
464 |
dnElem.classList.remove('datei-gewaehlt'); |
6648a8
|
465 |
} else { |
39e714
|
466 |
// Ordner oeffnen |
0783c5
|
467 |
var ordner = dnElem.textContent; |
39e714
|
468 |
if(self.pfad.length > 0) { |
U |
469 |
self.pfad = self.pfad + '/' + ordner; |
|
470 |
} else { |
|
471 |
self.pfad = ordner; |
|
472 |
} |
|
473 |
self.fm_get_list(self.pfad); |
6648a8
|
474 |
} |
39e714
|
475 |
} else { |
U |
476 |
if(/*ev.shiftKey || */ ev.ctrlKey) { |
|
477 |
// nicht gewaehlter Ordner und [Strg]: zu Mehrfachauswahl hinzufuegen |
|
478 |
} else { |
|
479 |
// nicht gewaehlter Ordner ohne [Strg]: andere Auswhalen entfernen und weiter unten Ordner auswaehlen |
|
480 |
self.fm_auswahl_marke_entfernen(); |
|
481 |
} |
0783c5
|
482 |
dnElem.classList.add('datei-gewaehlt'); |
6648a8
|
483 |
} |
U |
484 |
} |
|
485 |
} |
|
486 |
}; |
|
487 |
|
41ab37
|
488 |
|
58bcbd
|
489 |
this.fm_render_list = function (fl) { |
4f01b8
|
490 |
if (self.modus === 'kacheln') { |
58bcbd
|
491 |
// Kachelansicht |
6648a8
|
492 |
self.html_erzeugen("data/tpl/kacheln.tpl", fl, function(html) { |
U |
493 |
var elem = document.querySelector('#dateien'); |
|
494 |
elem.innerHTML = html; |
|
495 |
self.addEvtListener('.figure', 'click', self.fm_dateiwahl); |
|
496 |
}); |
58bcbd
|
497 |
} else { |
U |
498 |
// Listenansicht |
4f01b8
|
499 |
self.html_erzeugen("data/tpl/liste.tpl", fl, function(html) { |
U |
500 |
var elem = document.querySelector('#dateien'); |
|
501 |
elem.innerHTML = html; |
|
502 |
self.addEvtListener('.datei-zeile', 'click', self.fm_dateiwahl); |
|
503 |
}); |
58bcbd
|
504 |
} |
U |
505 |
}; |
|
506 |
|
|
507 |
this.fm_get_path = function (uid) { |
|
508 |
var restdir; |
|
509 |
if (self.pfad.indexOf(self.PUB_DIR) > -1) { |
|
510 |
restdir = self.pfad.substr(self.PUB_DIR.length); |
|
511 |
} else if (self.pfad.indexOf(self.PERS_DIR) > -1) { |
|
512 |
restdir = self.pfad.substr(self.PERS_DIR.length); |
|
513 |
} else if (self.pfad.indexOf(self.BASE_DIR) > -1) { |
|
514 |
restdir = self.pfad.substr(self.BASE_DIR.length); |
|
515 |
} else if (self.pfad.indexOf(self.DATA_DIR) > -1) { |
|
516 |
restdir = self.pfad.substr(self.DATA_DIR.length); |
|
517 |
} else if (self.pfad.indexOf(self.DAV_DIR) > -1) { |
|
518 |
restdir = self.pfad.substr(self.DAV_DIR.length); |
|
519 |
} |
|
520 |
if (restdir !== undefined && restdir.startsWith('/')) { |
|
521 |
restdir = restdir.substr(1); |
|
522 |
if (restdir.indexOf(self.WWW_DIR) > -1) { |
|
523 |
restdir = restdir.replace(self.WWW_DIR, 'data'); |
|
524 |
} |
|
525 |
} |
41ab37
|
526 |
var pdir = self.fm_get_base(uid); |
58bcbd
|
527 |
if (restdir.length > 1) { |
U |
528 |
return pdir + "/" + restdir; |
|
529 |
} else { |
|
530 |
return pdir; |
|
531 |
} |
|
532 |
}; |
|
533 |
|
|
534 |
this.fm_get_base = function (uid) { |
|
535 |
var pdir; |
|
536 |
if (self.pfad.indexOf(self.PUB_DIR) > -1) { |
|
537 |
pdir = '/data/' + uid; |
|
538 |
} else if (self.pfad.indexOf(self.PERS_DIR) > -1) { |
|
539 |
pdir = '/home/' + uid; |
|
540 |
} else if (self.pfad.indexOf(self.BASE_DIR) > -1) { |
|
541 |
pdir = ''; |
|
542 |
} else if (self.pfad.indexOf(self.DATA_DIR) > -1) { |
|
543 |
pdir = ''; |
|
544 |
} |
|
545 |
return pdir; |
|
546 |
}; |
2864b2
|
547 |
|
U |
548 |
/** |
|
549 |
* Aus einem relativen Pfad ein Array aus BcrFile Objekten |
|
550 |
* machen |
|
551 |
* |
|
552 |
* @param {String} relPfad der relative Pfad |
|
553 |
* @returns {Array} die BcrFile-Objekte zum Pfad als Array |
|
554 |
*/ |
|
555 |
this.fm_buildBreadcrumb = function(relPfad) { |
|
556 |
var rp = ''; |
|
557 |
var dirList = new Array(); |
|
558 |
dirList.push(new BcrFile(rp, 'Home')); |
|
559 |
if(relPfad.length > 1) { |
|
560 |
var dirs = relPfad.split('/'); |
|
561 |
for(var i = 0; i < dirs.length; i++) { |
|
562 |
if(rp.length > 0 ) { |
|
563 |
// weitere Einträge |
|
564 |
dirList.push(new BcrFile(rp + '/' + dirs[i], dirs[i])); |
|
565 |
rp = rp + '/' + dirs[i]; |
|
566 |
} else { |
|
567 |
// erster Eintrag |
|
568 |
dirList.push(new BcrFile(dirs[i], dirs[i])); |
|
569 |
rp = dirs[i]; |
|
570 |
} |
|
571 |
} |
|
572 |
} |
|
573 |
return dirList; |
|
574 |
}; |
|
575 |
|
4f01b8
|
576 |
/* |
U |
577 |
* icon-th-large |
|
578 |
* icon-th-list |
|
579 |
* @returns {undefined} |
|
580 |
*/ |
|
581 |
this.fm_ansicht_umschalten = function() { |
|
582 |
var elem = document.querySelector('#ansicht'); |
|
583 |
var iElem = elem.getElementsByTagName("i")[0]; |
|
584 |
if(iElem.classList.contains('icon-th-list')) { |
|
585 |
iElem.classList.add('icon-th-large'); |
|
586 |
iElem.classList.remove('icon-th-list'); |
|
587 |
self.modus = 'liste'; |
|
588 |
} else { |
|
589 |
iElem.classList.add('icon-th-list'); |
|
590 |
iElem.classList.remove('icon-th-large'); |
|
591 |
self.modus = 'kacheln'; |
|
592 |
} |
|
593 |
self.fm_get_list(self.pfad); |
|
594 |
}; |
|
595 |
|
|
596 |
this.fm_set_modus = function() { |
|
597 |
var elem = document.querySelector('#ansicht'); |
|
598 |
var iElem = elem.getElementsByTagName("i")[0]; |
|
599 |
if(self.modus === 'kacheln') { |
|
600 |
iElem.classList.add('icon-th-list'); |
|
601 |
iElem.classList.remove('icon-th-large'); |
|
602 |
} else { |
|
603 |
iElem.classList.add('icon-th-large'); |
|
604 |
iElem.classList.remove('icon-th-list'); |
|
605 |
} |
|
606 |
}; |
|
607 |
|
|
608 |
|
2864b2
|
609 |
/** |
U |
610 |
* Der letzte Eintrag in dirs ist der aktuelle Ordner und |
|
611 |
* deshalb ausgegraut. |
|
612 |
* |
|
613 |
* Wenn nur ein Ordner in dirs enthalten ist, dann sind wir |
|
614 |
* an der obersten Ebene (Home). |
|
615 |
* |
|
616 |
* @param {Array} dirList ein Array aus BcrFile-Objekten |
|
617 |
* @returns nichts |
|
618 |
*/ |
|
619 |
this.fm_renderBreadcrumb = function(dirList) { |
|
620 |
var elem = document.querySelector('.breadcrumb'); |
|
621 |
if(dirList.length > 1) { |
|
622 |
var last = dirList.pop(); |
|
623 |
var bcList = new BcrFiles(dirList); |
4f01b8
|
624 |
|
2864b2
|
625 |
self.html_erzeugen("data/tpl/bcr.tpl", bcList, function(html) { |
4f01b8
|
626 |
var htmlGesamt = html; |
2864b2
|
627 |
self.html_erzeugen("data/tpl/bcr2.tpl", last, function(html) { |
4f01b8
|
628 |
htmlGesamt += html; |
U |
629 |
self.html_erzeugen("data/tpl/bcr3.tpl", dirList[0], function(html) { |
|
630 |
htmlGesamt += html; |
|
631 |
elem.innerHTML = htmlGesamt; |
|
632 |
self.addEvtListener('.bc-link', 'click', self.fm_bc_click); |
|
633 |
self.addEvtListener('#ansicht', 'click', self.fm_ansicht_umschalten); |
|
634 |
self.fm_set_modus(); |
|
635 |
}); |
|
636 |
|
2864b2
|
637 |
}); |
U |
638 |
}); |
|
639 |
} else { |
|
640 |
// oberste Ebene |
4f01b8
|
641 |
var htmla; |
U |
642 |
var htmlb; |
2864b2
|
643 |
self.html_erzeugen("data/tpl/bcr2.tpl", dirList[0], function(html) { |
4f01b8
|
644 |
htmla = html; |
U |
645 |
self.html_erzeugen("data/tpl/bcr3.tpl", dirList[0], function(html) { |
|
646 |
htmlb = html; |
|
647 |
elem.innerHTML = htmla + htmlb; |
|
648 |
self.addEvtListener('.bc-link', 'click', self.fm_bc_click); |
|
649 |
self.addEvtListener('#ansicht', 'click', self.fm_ansicht_umschalten); |
|
650 |
self.fm_set_modus(); |
|
651 |
}); |
2864b2
|
652 |
}); |
U |
653 |
} |
|
654 |
}; |
|
655 |
|
|
656 |
/** |
|
657 |
* Auf den Klick auf ein Breadcrumb-Element reagieren: |
|
658 |
* Den Ordner-Inhalt des geklickten Elements anzeigen |
|
659 |
* @returns nichts |
|
660 |
*/ |
|
661 |
this.fm_bc_click = function() { |
|
662 |
var elem = this; |
|
663 |
var bcPfad = elem.getAttribute("rpath"); |
|
664 |
if(bcPfad !== undefined) { |
|
665 |
self.pfad = bcPfad; |
|
666 |
self.fm_get_list(bcPfad); |
|
667 |
} else { |
|
668 |
pfad = ''; |
|
669 |
self.fm_get_list(''); |
|
670 |
} |
|
671 |
}; |
|
672 |
|
beb124
|
673 |
/* ------- Dateifunktionen Start ----------- */ |
U |
674 |
|
|
675 |
this.fm_menu_cut = function() { |
|
676 |
console.log('fm_menu_cut'); |
|
677 |
self.fm_cut_files(); |
|
678 |
}; |
39e714
|
679 |
this.fm_menu_copy = function() { |
03be8f
|
680 |
//console.log('fm_menu_kopie'); |
beb124
|
681 |
self.fm_copy_files(); |
U |
682 |
}; |
|
683 |
this.fm_menu_paste = function() { |
|
684 |
console.log('fm_menu_paste'); |
|
685 |
self.fm_paste_files(); |
|
686 |
}; |
|
687 |
this.fm_menu_delete = function() { |
|
688 |
self.dialog_laden_und_zeigen('data/tpl/dlg-ask-del.tpl', '', function() { |
|
689 |
// wenn dialog da ist, hier events verknuepfen |
|
690 |
document.querySelector('#cancel-btn').addEventListener('click', function() { |
|
691 |
//self.fm_do_close(); |
|
692 |
self.dialog_schliessen(); |
|
693 |
}); |
|
694 |
document.querySelector('#speichern-btn').addEventListener('click', function() { |
39e714
|
695 |
//self.fm_menu_datei_speichern(function() { |
beb124
|
696 |
self.fm_del_files(); |
U |
697 |
self.dialog_schliessen(); |
39e714
|
698 |
//}); |
beb124
|
699 |
}); |
U |
700 |
}); |
|
701 |
}; |
|
702 |
|
|
703 |
/* |
|
704 |
* Hier merkt sich die Dateiverwalting die markierten Dateien fuer |
|
705 |
* eine Dateioperation. Bei cut wird in der 'paste' Operation auf dem Server |
|
706 |
* fuer die 'gemerkten' Dateien ein Move gemacht. Die Dateien werden |
|
707 |
* vom gewaehlten Ort zum Zielort verschoben. |
|
708 |
* |
|
709 |
* @returns {undefined} |
|
710 |
*/ |
|
711 |
this.fm_cut_files = function() { |
|
712 |
console.log('fm_cut_files'); |
|
713 |
self.cutCopySrcDir = self.pfad; |
|
714 |
self.cutCopyFiles = self.fm_gewaehlte_dateien(); |
|
715 |
self.cutCopyOperation = 'cut'; |
03be8f
|
716 |
self.meldung_mit_timeout('zum Ausschneiden in Zwischenablage', 1500); |
beb124
|
717 |
}; |
U |
718 |
|
|
719 |
/* |
|
720 |
* Hier merkt sich die Dateiverwalting die markierten Dateien fuer |
|
721 |
* eine Dateioperation. Bei copy wird in der 'paste' Operation auf dem Server |
|
722 |
* fuer die 'gemerkten' Dateien eine Kopie gemacht. Die Dateien werden |
|
723 |
* am gewaehlten Ort behalten und am Zielort wird eine Kopier der |
|
724 |
* gewaehlten DAteien erstellt |
|
725 |
* |
|
726 |
* @returns {undefined} |
|
727 |
*/ |
|
728 |
this.fm_copy_files = function() { |
03be8f
|
729 |
//console.log('fm_copy_files'); |
beb124
|
730 |
self.cutCopySrcDir = self.pfad; |
U |
731 |
self.cutCopyFiles = self.fm_gewaehlte_dateien(); |
|
732 |
self.cutCopyOperation = 'copy'; |
03be8f
|
733 |
self.meldung_mit_timeout('in Zwischenablage kopiert', 1500); |
beb124
|
734 |
}; |
U |
735 |
|
|
736 |
|
|
737 |
|
|
738 |
/* |
|
739 |
* Gewaehlte Dateien feststellen |
|
740 |
* |
|
741 |
* @returns {String} eine per JSON.stringify schon vorbereitete List zum |
|
742 |
* Absenden als Parameter an den Server |
|
743 |
*/ |
|
744 |
this.fm_gewaehlte_dateien = function() { |
|
745 |
var gewaehlte = document.querySelectorAll('.datei-gewaehlt'); |
|
746 |
return self.fm_dateiliste_bilden(gewaehlte); |
|
747 |
}; |
|
748 |
|
|
749 |
this.fm_dateiliste_bilden = function(gewaehlte) { |
|
750 |
var fnames = new Array(); |
|
751 |
var i = 0; |
|
752 |
while(i < gewaehlte.length) { |
|
753 |
var str = { "java.lang.String": gewaehlte[i].innerText}; |
|
754 |
fnames.push(str); |
|
755 |
//console.log('loeschen ' + pfad + ' ' + $(gewaehlte[i]).text()); |
|
756 |
//i += 2; |
|
757 |
i++; |
|
758 |
} |
|
759 |
var liste = '{"List":' + JSON.stringify(fnames) + '}'; |
|
760 |
// 'liste' enthaelt: |
|
761 |
// {"List":[{"java.lang.String":"test3.txt"},{"java.lang.String":"Test1.txt"},{"java.lang.String":"Test2.txt"}]} |
|
762 |
// und wird auf dem Server zu einer List[ArrayList<String>] bei der jede ArrayList<String> nur ein Element hat |
e3cec2
|
763 |
//console.log(liste); |
beb124
|
764 |
return liste; |
U |
765 |
}; |
|
766 |
|
98f80c
|
767 |
this.fm_menu_datei_umbenennen = function() { |
U |
768 |
//var gewaehlte = $('.datei-gewaehlt'); |
|
769 |
var gewaehlte = document.querySelector('.datei-gewaehlt'); |
|
770 |
var fname = gewaehlte.textContent; |
|
771 |
|
|
772 |
self.dialog_laden_und_zeigen('data/tpl/dlg-rename.tpl', '', function() { |
|
773 |
document.querySelector('#cancel-btn').addEventListener('click', function() { |
|
774 |
self.dialog_schliessen(); |
|
775 |
}); |
|
776 |
document.querySelector('#speichern-btn').addEventListener('click', function() { |
|
777 |
self.fm_rename_file(fname, self.pfad, document.querySelector('#datei-name-in').value); |
|
778 |
self.dialog_schliessen(); |
|
779 |
}); |
|
780 |
}); |
|
781 |
}; |
|
782 |
|
beb124
|
783 |
this.fm_menu_html_export = function() { |
U |
784 |
self.fm_export_html(); |
|
785 |
}; |
012d5f
|
786 |
|
U |
787 |
this.sued_schliessen = function() { |
|
788 |
var suedDiv = document.querySelector('.sued'); |
|
789 |
document.querySelector('.close-btn-fuss').removeEventListener('click', this); |
|
790 |
suedDiv.classList.remove('sued-open'); |
|
791 |
suedDiv.style.height = '0'; |
|
792 |
}; |
beb124
|
793 |
|
U |
794 |
/* --------- Dateifunktionen Ende ---------- */ |
|
795 |
|
94b871
|
796 |
/* API functions */ |
05e9c4
|
797 |
|
94b871
|
798 |
// http://localhost:8079/file-cms/svc?c=de.uhilger.filecms.api.FileMgr&f=JSONNICE&m=list&p= |
U |
799 |
this.fm_get_list = function (relPfad) { |
|
800 |
var m = '?c=de.uhilger.filecms.api.FileMgr&m=list&p=' + relPfad; |
|
801 |
var u = '../svc' + m; |
58bcbd
|
802 |
self.fm_get(u, "json", function (respText) { |
U |
803 |
var resp = JSON.parse(respText); |
94b871
|
804 |
if (resp.List[0].FileRef !== undefined) { |
U |
805 |
var files = new Array(); |
|
806 |
if (resp.List[0].FileRef instanceof Array) { |
|
807 |
for (var i = 0; i < resp.List[0].FileRef.length; i++) { |
|
808 |
files.push(new FileRef(resp.List[0].FileRef[i])); |
05e9c4
|
809 |
} |
U |
810 |
} else { |
94b871
|
811 |
files.push(new FileRef(resp.List[0].FileRef)); |
05e9c4
|
812 |
} |
94b871
|
813 |
var fl = new FileList(files); |
58bcbd
|
814 |
self.fm_render_list(fl); |
94b871
|
815 |
} else { |
58bcbd
|
816 |
// #dateien leeren |
8ba358
|
817 |
var elem = document.querySelector("#dateien"); |
U |
818 |
elem.innerHTML = ''; |
94b871
|
819 |
} |
8ba358
|
820 |
|
U |
821 |
// Breadcrumb |
|
822 |
|
2864b2
|
823 |
var dirList = self.fm_buildBreadcrumb(relPfad); |
4f01b8
|
824 |
self.fm_renderBreadcrumb(dirList); |
94b871
|
825 |
}); |
U |
826 |
}; |
f002d9
|
827 |
|
1a9589
|
828 |
this.datei_neuer_ordner = function() { |
U |
829 |
self.dialog_laden_und_zeigen('data/tpl/dlg-ask-folder.tpl', '', function() { |
|
830 |
document.querySelector('#cancel-btn').addEventListener('click', function() { |
|
831 |
self.dialog_schliessen(); |
|
832 |
}); |
|
833 |
document.querySelector('#speichern-btn').addEventListener('click', function() { |
|
834 |
var m = '?c=de.uhilger.filecms.api.FileMgr&m=newFolder&p=' + |
|
835 |
self.pfad + |
|
836 |
'&p=' + document.querySelector('#folder-name-in').value; |
|
837 |
var u = '../svc' + m; |
|
838 |
self.fm_get(u, "json", function(resp) { |
|
839 |
self.dialog_schliessen(); |
|
840 |
self.fm_get_list(self.pfad); |
|
841 |
}); |
|
842 |
}); |
|
843 |
}); |
|
844 |
}; |
03be8f
|
845 |
|
U |
846 |
this.fm_open_file = function() { |
|
847 |
var gewaehlte = document.querySelector('.datei-gewaehlt'); |
|
848 |
var fname = gewaehlte.textContent; |
e342e0
|
849 |
self.datei_ansehen_oder_bearbeiten(fname); |
03be8f
|
850 |
}; |
1a9589
|
851 |
|
0783c5
|
852 |
this.fm_get_file_content = function(typ, fname) { |
f002d9
|
853 |
self.openFileName = fname; |
U |
854 |
var m = '?c=de.uhilger.filecms.api.FileMgr&m=getCode&p=' + self.pfad + '&p=' + fname; |
|
855 |
var u = '../svc' + m; |
|
856 |
self.fm_get(u, "text", function(resp) { |
|
857 |
if(typ === 'text') { |
|
858 |
var mode = "text/x-java"; |
|
859 |
if(fname.endsWith('js')) { |
|
860 |
mode = 'javascript'; |
|
861 |
} else if(fname.endsWith('xml')) { |
|
862 |
mode = 'xml'; |
|
863 |
} else if(fname.endsWith('properties')) { |
|
864 |
mode = 'xml'; |
|
865 |
} else if(fname.endsWith('adoc')) { |
|
866 |
mode = 'text/x-markdown'; |
|
867 |
} |
|
868 |
self.fm_text_edit(resp, mode); |
|
869 |
} else { |
|
870 |
self.fm_dok_edit(resp); |
|
871 |
} |
|
872 |
}); |
|
873 |
}; |
|
874 |
|
ebc1f3
|
875 |
this.fm_save_file = function(saveFileName, method, callback) { |
U |
876 |
var content; |
|
877 |
if(self.openEditor === 'text') { |
|
878 |
content = self.cm.getValue(); |
|
879 |
self.cm.getDoc().markClean(); |
|
880 |
} else { |
4e450e
|
881 |
content = self.ed.getContent(); |
ebc1f3
|
882 |
tinymce.activeEditor.undoManager.clear(); |
U |
883 |
} |
|
884 |
var m = '?c=de.uhilger.filecms.api.FileMgr&m=' + method; |
5b4d03
|
885 |
var u = '../svc' + m; |
c79727
|
886 |
var data = '&p=' + self.pfad + '&p=' + saveFileName + '&p=' + |
U |
887 |
encodeURIComponent(content); |
5b4d03
|
888 |
self.fm_post(u, data, "text", function(resp) { |
U |
889 |
// ... |
ebc1f3
|
890 |
}); |
U |
891 |
self.openFileName = saveFileName; |
|
892 |
if(typeof (callback) !== 'function') { |
|
893 |
|
|
894 |
} else { |
|
895 |
callback(); |
|
896 |
} |
|
897 |
}; |
|
898 |
|
beb124
|
899 |
/* |
U |
900 |
* Hier wird fuer eine zuvor markierte Liste von Dateien, fuer die |
|
901 |
* Cut oder Copy gewaehlt wurde, die Operations ausgefuehrt (move oder copy) |
|
902 |
* @returns {undefined} |
|
903 |
*/ |
|
904 |
this.fm_paste_files = function() { |
|
905 |
var m; |
|
906 |
if(self.cutCopyOperation === 'cut') { |
|
907 |
//m = '?c=de.uhilger.filecms.api.FileMgr&m=moveFiles'; //&p=' + cutCopySrcDir + '&p=' + pfad + '&p=' + encodeURIComponent(liste); |
|
908 |
m = '?c=de.uhilger.filecms.api.FileMgr&m=moveFiles&p=' + self.cutCopySrcDir + '&p=' + self.pfad + '&p=' + encodeURIComponent(self.cutCopyFiles); |
|
909 |
} else { |
|
910 |
//m = '?c=de.uhilger.filecms.api.FileMgr&m=copyFiles'; //&p=' + cutCopySrcDir + '&p=' + pfad + '&p=' + encodeURIComponent(liste); |
|
911 |
m = '?c=de.uhilger.filecms.api.FileMgr&m=copyFiles&p=' + self.cutCopySrcDir + '&p=' + self.pfad + '&p=' + encodeURIComponent(self.cutCopyFiles); |
|
912 |
} |
|
913 |
var u = '../svc' + m; |
|
914 |
self.fm_get(u, "text", function(resp) { |
|
915 |
// console.log('deleteFiles gab folgendes zurueck: ' + resp); |
|
916 |
self.fm_get_list(self.pfad); |
|
917 |
}); |
|
918 |
}; |
ebc1f3
|
919 |
|
beb124
|
920 |
this.fm_del_files = function() { |
U |
921 |
var liste = self.fm_gewaehlte_dateien(); |
|
922 |
var m = '?c=de.uhilger.filecms.api.FileMgr&m=deleteFiles&p=' + self.pfad + '&p=' + encodeURIComponent(liste); |
|
923 |
var u = '../svc' + m; |
|
924 |
self.fm_get(u, "text", function(resp) { |
|
925 |
// console.log('deleteFiles gab folgendes zurueck: ' + resp); |
|
926 |
self.fm_get_list(self.pfad); |
|
927 |
}); |
|
928 |
}; |
f002d9
|
929 |
|
98f80c
|
930 |
this.fm_rename_file = function(fn, p, neuerName) { |
U |
931 |
var m = '?c=de.uhilger.filecms.api.FileMgr&m=renameFile'; |
|
932 |
m = m + '&p=' + p; |
|
933 |
m = m + '&p=' + fn; |
|
934 |
m = m + '&p=' + neuerName; |
|
935 |
var u = '../svc' + m; |
|
936 |
self.fm_get(u, "text", function(resp) { |
|
937 |
self.fm_get_list(self.pfad); |
|
938 |
}); |
|
939 |
}; |
122cf8
|
940 |
|
U |
941 |
this.fm_unzip_file = function(fn) { |
|
942 |
var m = '?c=de.uhilger.filecms.api.FileMgr&m=extractZipfile'; |
|
943 |
m = m + '&p=' + self.pfad; |
|
944 |
m = m + '&p=' + fn; |
|
945 |
var u = '../svc' + m; |
|
946 |
self.fm_get(u, "text", function(resp) { |
e3cec2
|
947 |
var mtx = new Meldung('Rueckmeldung vom Entpacken: ' + resp); |
U |
948 |
//console.log(mtx); |
|
949 |
self.html_erzeugen("data/tpl/fuss.tpl", mtx, function(html) { |
|
950 |
//console.log(html); |
|
951 |
var elem = document.querySelector('.sued'); |
|
952 |
elem.innerHTML = html; |
012d5f
|
953 |
document.querySelector('.close-btn-fuss').addEventListener('click', self.sued_schliessen); |
U |
954 |
|
|
955 |
/* |
e3cec2
|
956 |
document.querySelector('.close-btn-fuss').addEventListener('click', function(){ |
U |
957 |
var suedDiv = document.querySelector('.sued'); |
|
958 |
document.querySelector('.close-btn-fuss').removeEventListener('click', this); |
|
959 |
suedDiv.classList.remove('sued-open'); |
|
960 |
suedDiv.style.height = '0'; |
|
961 |
}); |
012d5f
|
962 |
*/ |
e3cec2
|
963 |
self.fm_fusszeile_zeigen(); |
U |
964 |
self.fm_get_list(self.pfad); |
|
965 |
}); |
122cf8
|
966 |
}); |
U |
967 |
}; |
012d5f
|
968 |
|
U |
969 |
this.fm_pack_folder = function() { |
|
970 |
//var liste = fm_gewaehlte_dateien(); |
|
971 |
var m = '?c=de.uhilger.filecms.api.FileMgr&m=packFolder&p=' + self.pfad; |
|
972 |
var u = '../svc' + m; |
|
973 |
self.fm_get(u, "text", function(resp) { |
|
974 |
// console.log('deleteFiles gab folgendes zurueck: ' + resp); |
|
975 |
self.fm_get_list(self.pfad); |
|
976 |
}); |
|
977 |
}; |
|
978 |
|
|
979 |
this.fm_export_html = function() { |
|
980 |
var m = '?c=de.uhilger.filecms.api.HtmlExportService&m=exportHtml'; |
|
981 |
m = m + '&p=' + self.pfad; |
|
982 |
var u = '../svc' + m; |
|
983 |
self.fm_get(u, "text", function(resp) { |
|
984 |
var mtx = new Meldung('Rueckmeldung vom HTML-Export: ' + resp); |
|
985 |
//console.log(mtx); |
|
986 |
self.html_erzeugen("data/tpl/fuss.tpl", mtx, function(html) { |
|
987 |
var elem = document.querySelector('.sued'); |
|
988 |
elem.innerHTML = html; |
|
989 |
document.querySelector('.close-btn-fuss').addEventListener('click', self.sued_schliessen); |
|
990 |
self.fm_fusszeile_zeigen(); |
|
991 |
//self.fm_get_list(self.pfad); |
|
992 |
/* |
|
993 |
$('.system-out').empty(); |
|
994 |
$('.system-out').append('Rueckmeldung vom HTML-Export: ' + resp); |
|
995 |
fm_fusszeile_zeigen(); |
|
996 |
*/ |
|
997 |
}); |
|
998 |
}); |
|
999 |
}; |
|
1000 |
|
98f80c
|
1001 |
|
820953
|
1002 |
/* -------- upload ----------- */ |
U |
1003 |
|
|
1004 |
this.sendFile = function(datei) { |
|
1005 |
//console.log('sendFile ' + datei); |
|
1006 |
var uri = "../api/upload"; |
|
1007 |
var xhr = new XMLHttpRequest(); |
|
1008 |
var fd = new FormData(); |
|
1009 |
xhr.open("POST", uri, true); |
|
1010 |
xhr.onreadystatechange = function() { |
|
1011 |
if (xhr.readyState === 4 && xhr.status === 200) { |
|
1012 |
self.fm_get_list(self.pfad); |
|
1013 |
if(self.dateien.length > 0) { |
|
1014 |
self.sendFile(self.dateien.pop()); |
|
1015 |
} |
|
1016 |
} |
|
1017 |
}; |
|
1018 |
fd.append('dateiauswahlfeld', datei); |
|
1019 |
fd.append('pfad', self.pfad); |
|
1020 |
xhr.send(fd); |
|
1021 |
}; |
|
1022 |
|
|
1023 |
/* ---- codemirror editor handling -------- */ |
f002d9
|
1024 |
|
U |
1025 |
/* |
|
1026 |
function htmlDecode(value){ |
|
1027 |
return $('<div/>').html(value).text(); |
|
1028 |
} |
|
1029 |
*/ |
|
1030 |
|
|
1031 |
this.fm_code_edit = function(content, m) { |
ebc1f3
|
1032 |
//console.log('fm_code_edit content: ' + content.substring(0,30)); |
U |
1033 |
self.cm = CodeMirror.fromTextArea(document.getElementById("editspace"), { |
f002d9
|
1034 |
lineNumbers: true, |
U |
1035 |
lineWrapping: true, |
|
1036 |
gutters: ["CodeMirror-linenumbers", "breakpoints"], |
|
1037 |
mode: m, |
|
1038 |
viewportMargin : Infinity, |
|
1039 |
tabSize: 2, |
|
1040 |
extraKeys: { |
|
1041 |
"F9": function(cm) { |
|
1042 |
cm.setOption("fullScreen", !cm.getOption("fullScreen")); |
|
1043 |
}, |
|
1044 |
"Esc": function(cm) { |
|
1045 |
if (cm.getOption("fullScreen")) cm.setOption("fullScreen", false); |
|
1046 |
}, |
|
1047 |
".": function(cm) { |
|
1048 |
console.log('dot pressed: perhaps look up class or method name'); |
|
1049 |
/* |
|
1050 |
* Hier kann man eine Funktion ausloesen, die fuer das |
|
1051 |
* Wort vor dem Punkt (Name der Klasse) eine Liste mit |
|
1052 |
* Vorschlaegen fuer Methodennamen einblendet. |
|
1053 |
*/ |
|
1054 |
|
|
1055 |
/* |
|
1056 |
* CodeMirror.Pass laesst das Zeichen zum Editorinhalt durch, |
|
1057 |
* verhindert aber das Ausloesen von 'keyHandled' |
|
1058 |
*/ |
|
1059 |
return CodeMirror.Pass; |
|
1060 |
} |
|
1061 |
} |
|
1062 |
}); |
|
1063 |
//cm.setValue(htmlDecode(content)); |
c79727
|
1064 |
//self.cm.setValue(content); |
ebc1f3
|
1065 |
self.cm.setValue(self.unescapeHtml(content)); |
U |
1066 |
self.cm.getDoc().markClean(); |
|
1067 |
self.cm.on("gutterClick", function(theEditor, lineNumber) { |
f002d9
|
1068 |
var info = theEditor.lineInfo(lineNumber); |
U |
1069 |
//--lineNumber; |
|
1070 |
//console.log(info.gutterMarkers.breakpoints.message); |
|
1071 |
//var marker = info.gutterMarkers.breakpoints; |
|
1072 |
//$(marker).tooltip('toggle'); |
|
1073 |
}); |
|
1074 |
/* |
|
1075 |
cm.on("keyHandled", function(theEditor, keyName, event){ |
|
1076 |
console.log('cm.keyHandled keyName: ' + keyName + ', event.type: ' + event.type); |
|
1077 |
}); |
|
1078 |
*/ |
|
1079 |
}; |
|
1080 |
|
|
1081 |
this.makeMarker = function(msg) { |
|
1082 |
var marker = document.createElement("div"); |
|
1083 |
marker.style.color = "#822"; |
|
1084 |
marker.innerHTML = "●"; |
|
1085 |
//marker.message = msg; |
|
1086 |
$(marker).tooltip({ |
|
1087 |
placement: 'right', |
|
1088 |
title: msg, |
|
1089 |
offset: '0 -30' |
|
1090 |
}); |
|
1091 |
return marker; |
|
1092 |
}; |
|
1093 |
|
4e450e
|
1094 |
/* ---- TinyMCE editor handling -------- */ |
U |
1095 |
|
|
1096 |
this.fm_dok_editor_init = function(uid) { |
|
1097 |
var base = self.fm_get_path(uid); |
|
1098 |
//var edCount = 0; |
|
1099 |
//console.log("fm_dok_editor_init calling tinymce.init with base: " + base + "/"); |
|
1100 |
|
|
1101 |
/* |
|
1102 |
* vgl. |
|
1103 |
* http://stackoverflow.com/questions/4651676/how-do-i-remove-tinymce-and-then-re-add-it |
|
1104 |
*/ |
|
1105 |
//tinymce.EditorManager.execCommand('mceRemoveControl',true, 'textarea.text-editor'); |
|
1106 |
//tinymce.EditorManager.execCommand('mceAddControl',true, editor_id); |
|
1107 |
if(self.ed !== undefined) { |
|
1108 |
self.ed.destroy(); |
|
1109 |
} |
|
1110 |
if(tinymce !== undefined) { |
|
1111 |
tinymce.remove('textarea.text-editor'); |
|
1112 |
tinymce.EditorManager.editors = []; |
|
1113 |
} |
|
1114 |
|
|
1115 |
/* |
|
1116 |
* Konfiguration TinyMCE |
|
1117 |
*/ |
|
1118 |
tinymce.init({ |
|
1119 |
content_css : "/file-cms/ui/mce.css", |
|
1120 |
//content_css: "/jslib/bootstrap/css/bootstrap.min.css", |
|
1121 |
selector: "textarea.text-editor", |
|
1122 |
statusbar: false, |
|
1123 |
menubar: false, |
|
1124 |
plugins: 'advlist charmap code image link lists media table print preview save table textcolor importcss', |
|
1125 |
toolbar: 'undo redo | styleselect | image table | link unlink | bullist numlist | outdent indent | code', |
|
1126 |
/* |
|
1127 |
menu: { |
|
1128 |
file: {title: 'File', items: 'savevers | exit'}, |
|
1129 |
edit: {title: 'Edit', items: 'undo redo | cut copy paste pastetext | selectall'}, |
|
1130 |
view: {title: 'View', items: 'visualaid | code | link image media | template hr'}, |
|
1131 |
}, |
|
1132 |
*/ |
|
1133 |
resize: 'both', |
|
1134 |
importcss_append: true, |
|
1135 |
width: "100%", |
|
1136 |
height: '100%', |
|
1137 |
relative_urls : true, |
|
1138 |
convert_urls : false, |
|
1139 |
document_base_url : base + "/", |
|
1140 |
setup: function (editor) { |
|
1141 |
self.ed = editor; |
|
1142 |
} |
|
1143 |
}); |
|
1144 |
|
|
1145 |
window.addEventListener('resize', self.fm_resize_editor); |
|
1146 |
//$(window).on('resize', self.fm_resize_editor); |
|
1147 |
self.fm_resize_editor(); |
|
1148 |
}; |
|
1149 |
|
|
1150 |
this.fm_resize_editor = function() { |
|
1151 |
window.clearTimeout(self.tmo); |
|
1152 |
self.tmo = window.setTimeout(function () { |
|
1153 |
try { |
|
1154 |
var myHeight = document.querySelector('.inhalt').offsetHeight - |
|
1155 |
document.querySelector('.nord').offsetHeight + 2; // - 4; |
|
1156 |
//console.log('myHeight: ' + myHeight); |
|
1157 |
self.ed.theme.resizeTo('100%', myHeight); // sets the dimensions of the editable area |
|
1158 |
} catch (err) { |
|
1159 |
} |
|
1160 |
}, 200); |
|
1161 |
}; |
|
1162 |
|
|
1163 |
|
f002d9
|
1164 |
|
U |
1165 |
/* -------- Editoren --------- */ |
|
1166 |
|
|
1167 |
this.fm_text_edit = function(content, mode) { |
|
1168 |
document.querySelector(".codeeditor-space").style.display = "block"; |
5b4d03
|
1169 |
//document.querySelector(".code-editor-container").style.display = "block"; |
U |
1170 |
//document.querySelector(".zentrum-behaelter").style.display = "none"; |
|
1171 |
document.querySelector(".breadcrumb").style.display = "none"; |
|
1172 |
document.querySelector(".zentrum").style.display = "none"; |
f002d9
|
1173 |
self.fm_code_edit(content, mode); |
U |
1174 |
self.openEditor = 'text'; |
|
1175 |
}; |
|
1176 |
|
|
1177 |
this.fm_dok_edit = function(content) { |
|
1178 |
//fm_filectls_hide(); |
4e450e
|
1179 |
self.fm_dok_editor_init(self.userid); |
U |
1180 |
document.querySelector("#mce-editor").style.display = "block"; |
|
1181 |
//$("#mce-editor").show(); |
|
1182 |
document.querySelector(".breadcrumb").style.display = "none"; |
|
1183 |
document.querySelector(".zentrum").style.display = "none"; |
f002d9
|
1184 |
|
4e450e
|
1185 |
window.clearTimeout(self.tmo2); |
U |
1186 |
self.tmo2 = window.setTimeout(function () { |
f002d9
|
1187 |
try { |
4e450e
|
1188 |
self.ed.setContent(content); |
U |
1189 |
self.openEditor = 'dok'; |
f002d9
|
1190 |
} catch (err) { |
U |
1191 |
} |
|
1192 |
}, 200); |
|
1193 |
}; |
ebc1f3
|
1194 |
|
U |
1195 |
this.fm_do_close = function() { |
|
1196 |
document.querySelector(".codeeditor-space").style.display = "none"; |
4e450e
|
1197 |
document.querySelector("#mce-editor").style.display = "none"; |
U |
1198 |
// $("#mce-editor").hide(); |
5b4d03
|
1199 |
//document.querySelector(".code-editor-container").style.display = "none"; |
U |
1200 |
//document.querySelector(".zentrum-behaelter").style.display = "block"; |
|
1201 |
document.querySelector(".breadcrumb").style.display = "block"; |
|
1202 |
document.querySelector(".zentrum").style.display = "block"; |
ebc1f3
|
1203 |
if(self.cm !== undefined) { |
U |
1204 |
self.cm.toTextArea(); |
|
1205 |
} |
|
1206 |
self.openFileName = ''; |
|
1207 |
self.openEditor = ''; |
|
1208 |
self.fm_get_list(self.pfad); |
|
1209 |
}; |
05e9c4
|
1210 |
|
94b871
|
1211 |
/* -------- An- und Abmelden ------------- */ |
05e9c4
|
1212 |
|
94b871
|
1213 |
this.fm_get_login = function() { |
U |
1214 |
var m = '?c=de.uhilger.filecms.pub.SessionManager&m=getSessionUser'; |
|
1215 |
var u = '../pub' + m; |
|
1216 |
self.fm_get(u, "text", function (resp) { |
|
1217 |
self.userid = resp; |
58bcbd
|
1218 |
self.login_zeigen(); |
U |
1219 |
//document.querySelector("#userMenu").textContent = resp; |
94b871
|
1220 |
}); |
U |
1221 |
}; |
05e9c4
|
1222 |
|
94b871
|
1223 |
this.fm_logout = function() { |
U |
1224 |
var m = '?c=de.uhilger.filecms.pub.SessionManager&m=expireSession'; |
|
1225 |
var u = '../pub' + m; |
|
1226 |
self.fm_get(u, "text", function (resp) { |
|
1227 |
//$('#userMenu').text('nicht angemeldet'); |
|
1228 |
window.location.href = '../logout.html'; |
|
1229 |
}); |
|
1230 |
}; |
41ab37
|
1231 |
|
6648a8
|
1232 |
/* ----- Hilfsfunktionen ----- */ |
U |
1233 |
|
|
1234 |
this.serialisieren = function(obj) { |
|
1235 |
return '{"' + obj.constructor.name + '":' + JSON.stringify(obj) + '}'; |
|
1236 |
}; |
|
1237 |
|
|
1238 |
this.addEvtListener = function(selector, eventName, func) { |
|
1239 |
document.querySelectorAll(selector).forEach(elem => { elem.addEventListener(eventName, func); }); |
|
1240 |
}; |
|
1241 |
|
|
1242 |
this.removeAllListeners = function(id) { |
|
1243 |
var el = document.getElementById(id); |
5b4d03
|
1244 |
if(el !== null) { |
U |
1245 |
elClone = el.cloneNode(true); |
|
1246 |
el.parentNode.replaceChild(elClone, el); |
|
1247 |
} |
6648a8
|
1248 |
}; // https://stackoverflow.com/questions/19469881/remove-all-event-listeners-of-specific-type |
U |
1249 |
|
ebc1f3
|
1250 |
this.escapeHtml = function(text) { |
U |
1251 |
text = text.replace(/\u228/g,'ä'); |
|
1252 |
text = text.replace(/\u246/g,'ö'); |
|
1253 |
text = text.replace(/\u252/g,'ü'); |
|
1254 |
text = text.replace(/\u196/g,'Ä'); |
|
1255 |
text = text.replace(/\u214/g,'Ö'); |
|
1256 |
text = text.replace(/\u220/g,'Ü'); |
|
1257 |
text = text.replace(/\u223/g,'ß'); |
|
1258 |
text = text.replace(/\u26/g,'&'); |
|
1259 |
return text; |
|
1260 |
}; |
|
1261 |
|
|
1262 |
this.unescapeHtml = function(text) { |
|
1263 |
text = text.replace(/ä/g, String.fromCharCode(228)); |
|
1264 |
text = text.replace(/ö/g, String.fromCharCode(246)); |
|
1265 |
text = text.replace(/ü/g, String.fromCharCode(252)); |
|
1266 |
text = text.replace(/Ä/g, String.fromCharCode(196)); |
|
1267 |
text = text.replace(/Ö/g, String.fromCharCode(214)); |
|
1268 |
text = text.replace(/Ü/g, String.fromCharCode(220)); |
|
1269 |
text = text.replace(/ß/g, String.fromCharCode(223)); |
|
1270 |
text = text.replace(/&/g, String.fromCharCode(26)); |
|
1271 |
return text; |
|
1272 |
}; |
|
1273 |
|
41ab37
|
1274 |
/* ---- Vorlagen ---- */ |
U |
1275 |
|
|
1276 |
this.html_erzeugen = function(vurl, inhalt, cb) { |
|
1277 |
var vorlage = self.cache[vurl]; |
|
1278 |
if(vorlage === undefined) { |
|
1279 |
self.vorlage_laden_und_fuellen(vurl, inhalt, cb); |
|
1280 |
} else { |
|
1281 |
self.vorlage_fuellen(vurl, inhalt, cb); |
|
1282 |
} |
|
1283 |
}; |
|
1284 |
|
|
1285 |
this.vorlage_fuellen = function(vurl, inhalt, cb) { |
|
1286 |
cb(Mustache.render(self.cache[vurl], inhalt)); |
|
1287 |
}; |
|
1288 |
|
|
1289 |
this.vorlage_laden_und_fuellen = function(vurl, inhalt, cb) { |
|
1290 |
self.fm_get(vurl, "text", function(antwort) { |
|
1291 |
self.cache[vurl] = antwort; |
|
1292 |
self.vorlage_fuellen(vurl, inhalt, cb); |
|
1293 |
}); |
|
1294 |
}; |
94b871
|
1295 |
|
U |
1296 |
/* -------- ajax helper functions ----------- */ |
|
1297 |
|
58bcbd
|
1298 |
this.fm_get = function (u, dtype, scallback) { |
U |
1299 |
var xmlhttp = new XMLHttpRequest(); |
|
1300 |
var url = u; |
|
1301 |
xmlhttp.onreadystatechange = function() { |
5b4d03
|
1302 |
if (this.readyState === 4 && this.status === 200) { |
58bcbd
|
1303 |
scallback(this.responseText); |
94b871
|
1304 |
} |
58bcbd
|
1305 |
}; |
U |
1306 |
xmlhttp.open("GET", url, true); |
|
1307 |
xmlhttp.send(); |
94b871
|
1308 |
}; |
ebc1f3
|
1309 |
|
U |
1310 |
self.fm_post = function(u, d, dtype, scallback) { |
|
1311 |
var xmlhttp = new XMLHttpRequest(); |
|
1312 |
var url = u; |
|
1313 |
xmlhttp.onreadystatechange = function() { |
5b4d03
|
1314 |
if (this.readyState === 4 && this.status === 200) { |
ebc1f3
|
1315 |
scallback(this.responseText); |
U |
1316 |
} |
|
1317 |
}; |
|
1318 |
xmlhttp.open("POST", url, true); |
c79727
|
1319 |
xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded; charset=utf-8'); |
5b4d03
|
1320 |
xmlhttp.send(d); |
ebc1f3
|
1321 |
}; |
U |
1322 |
|
5b4d03
|
1323 |
/* |
ebc1f3
|
1324 |
this.http_get = function(u, cb) { |
U |
1325 |
self.http_call('GET', u, null, cb); |
|
1326 |
}; |
|
1327 |
|
|
1328 |
this.http_post = function(u, data, cb) { |
|
1329 |
self.http_call('POST', u, data, cb); |
|
1330 |
}; |
|
1331 |
|
|
1332 |
this.http_call = function (method, u, data, scallback) { |
|
1333 |
var xhr = new XMLHttpRequest(); |
|
1334 |
var url = u; |
|
1335 |
xhr.onreadystatechange = function() { |
|
1336 |
if (this.readyState === 4 && this.status === 200) { |
|
1337 |
scallback(this.responseText); |
|
1338 |
} |
|
1339 |
}; |
5b4d03
|
1340 |
xhr.open(method, url, false); |
ebc1f3
|
1341 |
if(method === 'GET') { |
U |
1342 |
xhr.send(); |
|
1343 |
} else if(method === 'POST' || method === 'PUT') { |
|
1344 |
xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); |
|
1345 |
xhr.send(data); |
|
1346 |
} |
|
1347 |
}; |
5b4d03
|
1348 |
*/ |
ebc1f3
|
1349 |
|
94b871
|
1350 |
|
05e9c4
|
1351 |
} |