Browse Source

added breadcrums js file

gh-pages
Alex de Mulder 9 years ago
parent
commit
df836ed712
2 changed files with 57 additions and 0 deletions
  1. +11
    -0
      docs/index.html
  2. +46
    -0
      docs/js/main.js

+ 11
- 0
docs/index.html View File

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="refresh" content="0;url=../index.html#modules">
<title>Page Redirection</title>
</head>
<body>
If you are not redirected automatically, follow this <a href="../index.html#modules">link</a>.
</body>
</html>

+ 46
- 0
docs/js/main.js View File

@ -0,0 +1,46 @@
$(document).ready(function() {
vis.createBreadcrumbs($(".container.full").first());
});
// namespace
var vis = {};
/**
* Adds a breadcrumb as first child to the specified container.
*
* @author felixhayashi
*/
vis.createBreadcrumbs = function(container) {
// use the url to infer the path
var crumbs = location.pathname.split('/');
// number of ancestor directories
var stepbackIndex = crumbs.length-1;
var breadcrumbs = $.map(crumbs, function(crumb, i) {
// first and last element of the split
if(!crumb) return;
stepbackIndex--;
if(/\.html$/.test(crumb)) {
// strip the .html to make it look prettier
return "<span>" + crumb.replace(/\.html$/, "") + "</span>";
} else {
// calculate the relative url
for(var ref=crumb+"/", j=0; j<stepbackIndex; j++, ref="../"+ref);
return "<a href='" + ref + "'>" + crumb + "</a>";
}
}).join("") || "Home";
// insert into the container at the beginning.
$(container).prepend("<div id=\"breadcrumbs\">" + breadcrumbs + "</div>");
};

Loading…
Cancel
Save