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; function fo_init() { $('.sued').hide(); loc = window.location.protocol + '//' + window.location.host; ordner = getURLParameter('o'); fo_get_list(ordner); } 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(resp) { 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(); } }); } function fo_render_list(fl) { if(modus == 'kacheln') { // Kachelansicht var template = $('#tpl-kacheln').html(); Mustache.parse(template); // optional, speeds up future uses $('.datei-zeile').attr('onclick','').unbind('click'); $('#dateien').empty(); $('#dateien').html(Mustache.render(template, fl)); //$('.figure').click(fm_dateiwahl); } else { // Listenansicht var template = $('#tpl-liste').html(); Mustache.parse(template); // optional, speeds up future uses $('.figure').attr('onclick','').unbind('click'); $('#dateien').empty(); $('#dateien').html(Mustache.render(template, fl)); //$('.datei-zeile').click(fm_dateiwahl); } } function fo_get(u, dtype, scallback) { $.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 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'); } } var pdir = fm_get_base(uid); // console.log('fm_get_path path: ' + pdir + "/" + restdir); if(restdir.length > 1) { return pdir + "/" + restdir + "/" + ordner; } else { 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; }