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/index.html |    2 +-
 web/ui/ui.js      |   37 ++++++++++++++++++++++++++++++-------
 2 files changed, 31 insertions(+), 8 deletions(-)

diff --git a/web/ui/index.html b/web/ui/index.html
index be73900..8817813 100644
--- a/web/ui/index.html
+++ b/web/ui/index.html
@@ -24,7 +24,7 @@
       {{/files}}
     </script>
     <script id="tpl-bcr2" type="x-tmpl-mustache">
-      <span class="breadcrumb-item active">Bootstrap</span>
+      <span class="breadcrumb-item active">{{ fName }}</span>
     </script>
     <script id="tpl-bcr3" type="x-tmpl-mustache">
       <div class="pull-right align-middle">
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