From 2315a035f7273a7d11fa4b7c6ce470f084544efb Mon Sep 17 00:00:00 2001
From: ulrich <not disclosed>
Date: Mon, 20 Feb 2017 16:15:35 +0000
Subject: [PATCH] Breadcrumb berichtigt

---
 web/ui/ui.js |   37 ++++++++++++++++++++++++++++++-------
 1 files changed, 30 insertions(+), 7 deletions(-)

diff --git a/web/ui/ui.js b/web/ui/ui.js
index dfa880e..9ec23e2 100644
--- a/web/ui/ui.js
+++ b/web/ui/ui.js
@@ -106,25 +106,48 @@
       $('#dateien').empty();
     }
     
+    var template;
+    $('#bcnav').empty();
     var dirList = new Array();
     var rp = '';
+    console.log("'" + relPath + "'");
     var dirs = relPath.split('/');
+    console.log(dirs.length);
     dirList.push(new BcrFile(rp, 'Home'));
-    if(dirs.length > 0) {
-      for(var i = 0; i < dirs.length; i++) {
+    if(relPath.length > 0) {
+      for(var i = 0; i < dirs.length - 1; i++) {
         if(rp.length > 0 ) {
           dirList.push(new BcrFile(rp + '/' + dirs[i], dirs[i]));
+          rp = rp + '/' + dirs[i];
         } else {
           dirList.push(new BcrFile(dirs[i], dirs[i]));
+          rp = dirs[i];
         }
       }
       var bl = new BcrFiles(dirList);
-      var template = $('#tpl-bcr').html();
-      Mustache.parse(template);   // optional, speeds up future uses
-      $('#bcnav').empty();
-      $('#bcnav').html(Mustache.render(template, bl));
-      $('#bcnav').append($('#tpl-bcr2').html());
+
+      if(dirList.length > 0) {
+        template = $('#tpl-bcr').html();
+        Mustache.parse(template);   // optional, speeds up future uses
+        $('#bcnav').html(Mustache.render(template, bl));
+      }
+      
+      if(dirs.length > 0) {
+        dirList.push(new BcrFile(rp + '/' + dirs[dirs.length-1], dirs[dirs.length-1]));
+        template = $('#tpl-bcr2').html();
+        Mustache.parse(template);   // optional, speeds up future uses
+        $('#bcnav').append(Mustache.render(template, dirList[dirList.length-1]));        
+      } else {
+        template = $('#tpl-bcr2').html();
+        Mustache.parse(template);   // optional, speeds up future uses
+        $('#bcnav').append(Mustache.render(template, dirList[0]));        
+      }
+      
       $('#bcnav').append($('#tpl-bcr3').html());
+    } else {
+      template = $('#tpl-bcr2').html();
+      Mustache.parse(template);   // optional, speeds up future uses
+      $('#bcnav').append(Mustache.render(template, dirList[0]));        
     }
   });  
 }

--
Gitblit v1.9.3