var modus = 'kacheln'; var fm_slideshow = true; var PERS_DIR = "Persoenlich"; var PUB_DIR = "Oeffentlich"; var BASE_DIR = "$basis"; var DATA_DIR = "$daten"; var WWW_DIR = "www"; var loc; var pfad = PUB_DIR; var ordner; var userid; function fo_init() { //$('.sued').hide(); document.querySelector('.sued').style.display = 'none'; loc = window.location.protocol + '//' + window.location.host; ordner = getURLParameter('o'); fo_get_list(ordner); fo_get_login(); } function getURLParameter(name) { return decodeURI( (RegExp(name + '=' + '(.+?)(&|$)').exec(location.search)||[,null])[1] ); } // http://localhost:8079/file-cms/svc?c=de.uhilger.filecms.api.FileMgr&f=JSONNICE&m=list&p= // https://uhilger.de/file-cms/pub?c=de.uhilger.filecms.pub.Catalog&m=listOrdered&p=ulrich/bilder/alben/farbe&p=date&p=asc function fo_get_list(relPfad) { //$('#ansicht').attr('onclick','').unbind('click'); var m = '?c=de.uhilger.filecms.pub.Catalog&m=listOrdered&p=' + relPfad + '&p=date&p=asc'; var u = '../pub' + m; fo_get(u, "json", function(respText) { var resp = JSON.parse(respText); if(resp.List[0].FileRef !== undefined) { var files = new Array(); if(resp.List[0].FileRef instanceof Array) { for(var i = 0; i < resp.List[0].FileRef.length; i++) { files.push(new FileRef(resp.List[0].FileRef[i])); } } else { files.push(new FileRef(resp.List[0].FileRef)); } var fl = new FileList(files); fo_render_list(fl); } else { //$('#dateien').empty(); document.querySelector('#dateien').innerHTML = ''; } }); } function fo_render_list(fl) { if(modus === 'kacheln') { // Kachelansicht var template = document.querySelector('#tpl-kacheln').innerHTML; //$('#tpl-kacheln').html(); console.log(template); Mustache.parse(template); // optional, speeds up future uses //$('.datei-zeile').attr('onclick','').unbind('click'); //$('#dateien').empty(); var elem = document.querySelector('#dateien'); elem.innerHTML = Mustache.render(template, fl); //$('#dateien').html(Mustache.render(template, fl)); //$('.figure').click(fm_dateiwahl); } else { // Listenansicht var template = document.querySelector('#tpl-liste').innerHTML; //var template = $('#tpl-liste').html(); Mustache.parse(template); // optional, speeds up future uses //$('.figure').attr('onclick','').unbind('click'); var elem = document.querySelector('#dateien'); elem.innerHTML = Mustache.render(template, fl); //$('#dateien').empty(); //$('#dateien').html(Mustache.render(template, fl)); //$('.datei-zeile').click(fm_dateiwahl); } } function fo_get(u, dtype, scallback) { var xmlhttp = new XMLHttpRequest(); var url = u; xmlhttp.onreadystatechange = function() { if (this.readyState === 4 && this.status === 200) { scallback(this.responseText); } }; xmlhttp.open("GET", url, true); xmlhttp.send(); /* $.ajax({ url: u, type: "GET", dataType: dtype, success: scallback, error: function (xhr, status, errorThrown) { alert("Error: " + errorThrown + " Status: " + status + " URL: " + u); }, complete: function (xhr, status) { //console.log( "The request is complete!" ); } }); */ } function fo_get_login() { var m = '?c=de.uhilger.filecms.pub.SessionManager&m=getSessionUser'; var u = '../pub' + m; fo_get(u, "text", function (resp) { userid = resp; //self.login_zeigen(); //document.querySelector("#userMenu").textContent = resp; }); } function fm_get_path(uid) { //console.log('pfad: ' + pfad); var restdir; if(pfad.indexOf(PUB_DIR) > -1) { restdir = pfad.substr(PUB_DIR.length); } else if(pfad.indexOf(PERS_DIR) > -1) { restdir = pfad.substr(PERS_DIR.length); } else if(pfad.indexOf(BASE_DIR) > -1) { restdir = pfad.substr(BASE_DIR.length); } else if(pfad.indexOf(DATA_DIR) > -1) { restdir = pfad.substr(DATA_DIR.length); } if(restdir !== undefined && restdir.startsWith('/')) { restdir = restdir.substr(1); if(restdir.indexOf(WWW_DIR) > -1) { restdir = restdir.replace(WWW_DIR, 'data'); } } console.log('restdir ' + restdir); var pdir = fm_get_base(uid); console.log('pdir ' + pdir); console.log('ordner ' + ordner); // console.log('fm_get_path path: ' + pdir + "/" + restdir); if(restdir !== undefined && restdir.length > 1) { console.log('fm_get_path ' + pdir + "/" + restdir + "/" + ordner); return pdir + "/" + restdir + "/" + ordner; } else { console.log('fm_get_path ' + pdir + "/" + ordner); return pdir + "/" + ordner; } } function fm_get_base(uid) { //console.log('pfad: ' + pfad); var pdir; if(pfad.indexOf(PUB_DIR) > -1) { pdir = '/data/'; //+ uid; } else if(pfad.indexOf(PERS_DIR) > -1) { pdir = '/home/'; // + uid; } else if(pfad.indexOf(BASE_DIR) > -1) { pdir = ''; } else if(pfad.indexOf(DATA_DIR) > -1) { pdir = ''; } //console.log('fm_get_base base: ' + pdir + uid); return pdir; }