Mon 21 Jul 22:43:21 CEST 2025
This commit is contained in:
parent
d8214797ef
commit
62e48f5177
46
js/dos/ext/vis/docs/js/main.js
Normal file
46
js/dos/ext/vis/docs/js/main.js
Normal 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…
Reference in New Issue
Block a user