commit | author | age
|
e4fec9
|
1 |
|
U |
2 |
var modus = 'kacheln'; |
|
3 |
var fm_slideshow = true; |
|
4 |
var PERS_DIR = "Persoenlich"; |
|
5 |
var PUB_DIR = "Oeffentlich"; |
|
6 |
var BASE_DIR = "$basis"; |
|
7 |
var DATA_DIR = "$daten"; |
|
8 |
var WWW_DIR = "www"; |
|
9 |
var loc; |
|
10 |
var pfad = PUB_DIR; |
|
11 |
var ordner; |
bf56be
|
12 |
var userid; |
e4fec9
|
13 |
|
U |
14 |
|
|
15 |
function fo_init() { |
bf56be
|
16 |
//$('.sued').hide(); |
U |
17 |
document.querySelector('.sued').style.display = 'none'; |
e4fec9
|
18 |
loc = window.location.protocol + '//' + window.location.host; |
U |
19 |
ordner = getURLParameter('o'); |
|
20 |
fo_get_list(ordner); |
bf56be
|
21 |
fo_get_login(); |
e4fec9
|
22 |
} |
U |
23 |
|
|
24 |
function getURLParameter(name) { |
|
25 |
return decodeURI( |
|
26 |
(RegExp(name + '=' + '(.+?)(&|$)').exec(location.search)||[,null])[1] |
|
27 |
); |
|
28 |
} |
|
29 |
|
|
30 |
// http://localhost:8079/file-cms/svc?c=de.uhilger.filecms.api.FileMgr&f=JSONNICE&m=list&p= |
|
31 |
// https://uhilger.de/file-cms/pub?c=de.uhilger.filecms.pub.Catalog&m=listOrdered&p=ulrich/bilder/alben/farbe&p=date&p=asc |
|
32 |
function fo_get_list(relPfad) { |
bf56be
|
33 |
//$('#ansicht').attr('onclick','').unbind('click'); |
e4fec9
|
34 |
var m = '?c=de.uhilger.filecms.pub.Catalog&m=listOrdered&p=' + relPfad + '&p=date&p=asc'; |
U |
35 |
var u = '../pub' + m; |
bf56be
|
36 |
fo_get(u, "json", function(respText) { |
U |
37 |
var resp = JSON.parse(respText); |
e4fec9
|
38 |
if(resp.List[0].FileRef !== undefined) { |
U |
39 |
var files = new Array(); |
|
40 |
if(resp.List[0].FileRef instanceof Array) { |
|
41 |
for(var i = 0; i < resp.List[0].FileRef.length; i++) { |
|
42 |
files.push(new FileRef(resp.List[0].FileRef[i])); |
|
43 |
} |
|
44 |
} else { |
|
45 |
files.push(new FileRef(resp.List[0].FileRef)); |
|
46 |
} |
|
47 |
var fl = new FileList(files); |
|
48 |
fo_render_list(fl); |
|
49 |
} else { |
bf56be
|
50 |
//$('#dateien').empty(); |
U |
51 |
document.querySelector('#dateien').innerHTML = ''; |
e4fec9
|
52 |
} |
U |
53 |
}); |
|
54 |
} |
|
55 |
|
|
56 |
function fo_render_list(fl) { |
bf56be
|
57 |
if(modus === 'kacheln') { |
e4fec9
|
58 |
// Kachelansicht |
bf56be
|
59 |
var template = document.querySelector('#tpl-kacheln').innerHTML; //$('#tpl-kacheln').html(); |
U |
60 |
console.log(template); |
e4fec9
|
61 |
Mustache.parse(template); // optional, speeds up future uses |
bf56be
|
62 |
//$('.datei-zeile').attr('onclick','').unbind('click'); |
U |
63 |
//$('#dateien').empty(); |
|
64 |
var elem = document.querySelector('#dateien'); |
|
65 |
elem.innerHTML = Mustache.render(template, fl); |
|
66 |
//$('#dateien').html(Mustache.render(template, fl)); |
e4fec9
|
67 |
//$('.figure').click(fm_dateiwahl); |
U |
68 |
} else { |
|
69 |
// Listenansicht |
bf56be
|
70 |
var template = document.querySelector('#tpl-liste').innerHTML; //var template = $('#tpl-liste').html(); |
e4fec9
|
71 |
Mustache.parse(template); // optional, speeds up future uses |
bf56be
|
72 |
//$('.figure').attr('onclick','').unbind('click'); |
U |
73 |
var elem = document.querySelector('#dateien'); |
|
74 |
elem.innerHTML = Mustache.render(template, fl); |
|
75 |
//$('#dateien').empty(); |
|
76 |
//$('#dateien').html(Mustache.render(template, fl)); |
e4fec9
|
77 |
//$('.datei-zeile').click(fm_dateiwahl); |
U |
78 |
} |
|
79 |
} |
|
80 |
|
|
81 |
|
|
82 |
function fo_get(u, dtype, scallback) { |
bf56be
|
83 |
var xmlhttp = new XMLHttpRequest(); |
U |
84 |
var url = u; |
|
85 |
xmlhttp.onreadystatechange = function() { |
|
86 |
if (this.readyState === 4 && this.status === 200) { |
|
87 |
scallback(this.responseText); |
|
88 |
} |
|
89 |
}; |
|
90 |
xmlhttp.open("GET", url, true); |
|
91 |
xmlhttp.send(); |
|
92 |
|
|
93 |
|
|
94 |
|
|
95 |
/* |
e4fec9
|
96 |
$.ajax({ |
U |
97 |
url: u, |
|
98 |
type: "GET", |
|
99 |
dataType: dtype, |
|
100 |
success: scallback, |
|
101 |
error: function (xhr, status, errorThrown) { |
|
102 |
alert("Error: " + errorThrown + " Status: " + status + " URL: " + u); |
|
103 |
}, |
|
104 |
complete: function (xhr, status) { |
|
105 |
//console.log( "The request is complete!" ); |
|
106 |
} |
|
107 |
|
|
108 |
}); |
bf56be
|
109 |
*/ |
e4fec9
|
110 |
} |
bf56be
|
111 |
function fo_get_login() { |
U |
112 |
var m = '?c=de.uhilger.filecms.pub.SessionManager&m=getSessionUser'; |
|
113 |
var u = '../pub' + m; |
|
114 |
fo_get(u, "text", function (resp) { |
|
115 |
userid = resp; |
|
116 |
//self.login_zeigen(); |
|
117 |
//document.querySelector("#userMenu").textContent = resp; |
|
118 |
}); |
|
119 |
} |
|
120 |
|
e4fec9
|
121 |
|
U |
122 |
function fm_get_path(uid) { |
|
123 |
//console.log('pfad: ' + pfad); |
|
124 |
var restdir; |
|
125 |
if(pfad.indexOf(PUB_DIR) > -1) { |
|
126 |
restdir = pfad.substr(PUB_DIR.length); |
|
127 |
} else if(pfad.indexOf(PERS_DIR) > -1) { |
|
128 |
restdir = pfad.substr(PERS_DIR.length); |
|
129 |
} else if(pfad.indexOf(BASE_DIR) > -1) { |
|
130 |
restdir = pfad.substr(BASE_DIR.length); |
|
131 |
} else if(pfad.indexOf(DATA_DIR) > -1) { |
|
132 |
restdir = pfad.substr(DATA_DIR.length); |
|
133 |
} |
|
134 |
if(restdir !== undefined && restdir.startsWith('/')) { |
|
135 |
restdir = restdir.substr(1); |
|
136 |
if(restdir.indexOf(WWW_DIR) > -1) { |
|
137 |
restdir = restdir.replace(WWW_DIR, 'data'); |
|
138 |
} |
|
139 |
} |
bf56be
|
140 |
console.log('restdir ' + restdir); |
e4fec9
|
141 |
var pdir = fm_get_base(uid); |
bf56be
|
142 |
console.log('pdir ' + pdir); |
U |
143 |
console.log('ordner ' + ordner); |
e4fec9
|
144 |
// console.log('fm_get_path path: ' + pdir + "/" + restdir); |
bf56be
|
145 |
if(restdir !== undefined && restdir.length > 1) { |
U |
146 |
console.log('fm_get_path ' + pdir + "/" + restdir + "/" + ordner); |
e4fec9
|
147 |
return pdir + "/" + restdir + "/" + ordner; |
U |
148 |
} else { |
bf56be
|
149 |
console.log('fm_get_path ' + pdir + "/" + ordner); |
e4fec9
|
150 |
return pdir + "/" + ordner; |
U |
151 |
} |
|
152 |
} |
|
153 |
|
|
154 |
function fm_get_base(uid) { |
|
155 |
//console.log('pfad: ' + pfad); |
|
156 |
var pdir; |
|
157 |
if(pfad.indexOf(PUB_DIR) > -1) { |
bf56be
|
158 |
pdir = '/data/'; //+ uid; |
e4fec9
|
159 |
} else if(pfad.indexOf(PERS_DIR) > -1) { |
bf56be
|
160 |
pdir = '/home/'; // + uid; |
e4fec9
|
161 |
} else if(pfad.indexOf(BASE_DIR) > -1) { |
U |
162 |
pdir = ''; |
|
163 |
} else if(pfad.indexOf(DATA_DIR) > -1) { |
|
164 |
pdir = ''; |
|
165 |
} |
|
166 |
//console.log('fm_get_base base: ' + pdir + uid); |
|
167 |
return pdir; |
|
168 |
} |