This repository was archived by the owner on Jun 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathoutline.js
More file actions
64 lines (58 loc) · 2.09 KB
/
outline.js
File metadata and controls
64 lines (58 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
var Outline = function (node, title, fileName, filePath, parentNavigationObject) {
var navigationObject = parentNavigationObject.map(function (navBar) {
return navBar.map(function (link) {
return {
displayText: link.displayText,
path: '../' + link.path,
selected: link.selected || link.displayText == title
};
});
});
var htmlPages = [];
var navLevel = parentNavigationObject.length;
this.process = function (siteTitle, generator) {
var childPages = getChildPages();
updateNavigationObject(childPages);
if (isPage(title)) {
htmlPages.push({
filePath: filePath + '/' + fileName + '.html',
content: generator.generate(node, siteTitle, title, navigationObject, navLevel)
});
}
processChildren(childPages, siteTitle, generator);
return htmlPages;
};
function getChildPages() {
var pages = [];
$.each($(node).children(), function (index, child) {
var childTitle = getTitle(child);
if (isPage(childTitle)) {
getChildTitles(childTitle).map(function(subTitle) {
pages.push({ title: subTitle, fileName: stripText(subTitle, true).toLowerCase(), node: child });
});
}
});
return pages;
};
function getChildTitles(childTitle) {
if (childTitle[0] == '[') {
return childTitle.substring(1, childTitle.length - 1).split(',')
} else {
return [childTitle];
}
}
function updateNavigationObject(childPages) {
if (childPages.length > 0) {
navigationObject.push(childPages.map(function (childPage) {
return { displayText: childPage.title, path: (fileName || filePath) + '/' + childPage.fileName + '.html', selected: false };
}));
}
};
function processChildren(childPages, siteTitle, generator) {
$.each(childPages, function (index, childPage) {
var path = fileName ? filePath + '/' + fileName : filePath;
var outline = new Outline(childPage.node, childPage.title, childPage.fileName, path, navigationObject);
htmlPages = htmlPages.concat(outline.process(siteTitle, generator));
});
};
};