2021-03-18 14:03:57 -04:00
|
|
|
<div id="root"></div>
|
|
|
|
<script type="module">
|
2021-03-19 17:09:38 -04:00
|
|
|
|
2021-03-18 14:03:57 -04:00
|
|
|
import _ from "https://dev.jspm.io/lodash";
|
2021-03-29 22:30:58 -04:00
|
|
|
import styled from "https://dev.jspm.io/styled-components";
|
2021-03-18 14:03:57 -04:00
|
|
|
import React from "https://dev.jspm.io/react/index.js";
|
|
|
|
import ReactDOM from "https://dev.jspm.io/react-dom/index.js";
|
|
|
|
import ReactDOMServer from "https://dev.jspm.io/react-dom/server.js";
|
2021-03-19 17:09:38 -04:00
|
|
|
|
2021-03-29 22:30:58 -04:00
|
|
|
|
2021-03-19 17:09:38 -04:00
|
|
|
let Util = {
|
|
|
|
ParsePassage:inRef=>
|
|
|
|
{
|
|
|
|
let indexNumeric = inRef.lastIndexOf(" ");
|
|
|
|
let partBook = inRef.substring(0, indexNumeric);
|
|
|
|
let chapterVerse = inRef.substring(indexNumeric+1).split(":");
|
|
|
|
return [partBook, chapterVerse[0], chapterVerse[1]];
|
|
|
|
}
|
|
|
|
};
|
2021-03-23 14:15:21 -04:00
|
|
|
|
2021-03-18 14:03:57 -04:00
|
|
|
let h = React.createElement;
|
2021-03-29 22:30:58 -04:00
|
|
|
let s = styled.default;
|
2021-03-18 14:03:57 -04:00
|
|
|
|
|
|
|
let ElemApp = props =>
|
|
|
|
{
|
|
|
|
return h("div", null,
|
|
|
|
[
|
2021-03-25 17:04:58 -04:00
|
|
|
h(ElemTree, {key:"tree1", tree:App.State.Topics}),
|
2021-03-26 15:57:03 -04:00
|
|
|
h(ElemTree, {key:"tree2", tree:App.State.Bible}),
|
2021-03-29 22:30:58 -04:00
|
|
|
h(ElemTree, {key:"tree3", tree:App.State.Date}),
|
2021-03-18 14:03:57 -04:00
|
|
|
h(ElemItems, {key:3})
|
|
|
|
]
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
let ElemItems = props =>
|
|
|
|
{
|
2021-03-25 17:04:58 -04:00
|
|
|
if(App.State.Items.Active.length == 0)
|
|
|
|
{
|
|
|
|
return h("div", null,
|
|
|
|
h("h3", null, "no results found")
|
|
|
|
)
|
|
|
|
}
|
2021-03-26 15:57:03 -04:00
|
|
|
let list = App.State.Pages.All[App.State.Pages.Active].map( i=>h(ElemItem, {...i, key:i.ID} ) );
|
2021-03-19 17:09:38 -04:00
|
|
|
let pages = h(ElemPager, {count:App.State.Pages.All.length, active:App.State.Pages.Active}, null);
|
|
|
|
|
|
|
|
return h("div", null, [
|
|
|
|
h("h4", {key:0}, App.State.Items.Active.length+" results"),
|
|
|
|
h("div", {key:1}, pages),
|
|
|
|
h("div", {key:2}, list),
|
|
|
|
h("div", {key:3}, pages)
|
|
|
|
]);
|
2021-03-29 22:30:58 -04:00
|
|
|
};
|
2021-03-18 14:03:57 -04:00
|
|
|
let ElemItem = props =>
|
|
|
|
{
|
|
|
|
return h("div", {key:0}, [
|
2021-03-19 17:09:38 -04:00
|
|
|
h("div", {key:1},
|
|
|
|
[
|
2021-03-26 22:02:27 -04:00
|
|
|
h("span", {key:2}, props.title),
|
2021-03-29 22:30:58 -04:00
|
|
|
h("em", {key:3}, props.id),
|
|
|
|
h("strong", {key:4}, props.date),
|
2021-03-19 17:09:38 -04:00
|
|
|
]
|
|
|
|
),
|
2021-03-26 22:02:27 -04:00
|
|
|
h("small", {key:4}, props.bible)
|
2021-03-18 14:03:57 -04:00
|
|
|
])
|
|
|
|
};
|
2021-03-19 17:09:38 -04:00
|
|
|
let ElemPager = ({count, active}) =>
|
|
|
|
{
|
|
|
|
var children;
|
|
|
|
var blockIntro, blockAt, blockOutro;
|
|
|
|
var hitLeft, hitRight;
|
|
|
|
|
|
|
|
let renderRange = (inStart, inStop) =>
|
|
|
|
{
|
|
|
|
let output = [];
|
|
|
|
for(let i=inStart; i<=inStop; i++)
|
|
|
|
{
|
2021-03-22 10:31:35 -04:00
|
|
|
output.push(h("button", {key:i, onClick:e=>App.Update.Page(i)}, i+1));
|
2021-03-19 17:09:38 -04:00
|
|
|
}
|
|
|
|
return output;
|
|
|
|
}
|
|
|
|
let renderSpacer = () => h("span", {key:Math.random()}, "…");
|
|
|
|
|
|
|
|
|
|
|
|
blockIntro = [0, 1, 2];
|
|
|
|
blockAt = [active-1, active, active+1];
|
|
|
|
blockOutro = [count-3, count-2, count-1];
|
|
|
|
|
|
|
|
hitLeft = _.last(blockIntro) >= _.head(blockAt);
|
|
|
|
hitRight = _.last(blockAt) >= _.head(blockOutro);
|
|
|
|
|
|
|
|
if(count < 2)
|
|
|
|
{
|
|
|
|
children = [];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( (hitLeft && hitRight) || count < 7)
|
|
|
|
{
|
2021-03-22 10:31:35 -04:00
|
|
|
children = renderRange(_.head(blockIntro), _.last(blockOutro)) /* merge all */
|
2021-03-19 17:09:38 -04:00
|
|
|
}
|
|
|
|
else if(!hitLeft && hitRight)
|
|
|
|
{
|
|
|
|
children = [
|
|
|
|
...renderRange(_.head(blockIntro), _.last(blockIntro)),
|
|
|
|
renderSpacer(),
|
|
|
|
...renderRange(Math.min(_.head(blockAt), _.head(blockOutro)), _.last(blockOutro)) /* merge end */
|
|
|
|
];
|
|
|
|
}
|
|
|
|
else if(hitLeft && !hitRight)
|
|
|
|
{
|
|
|
|
children = [
|
|
|
|
...renderRange(_.head(blockIntro), Math.max(_.last(blockAt), _.last(blockIntro)) ), /* merge beginning */
|
|
|
|
renderSpacer(),
|
|
|
|
...renderRange(_.head(blockOutro), _.last(blockOutro))
|
|
|
|
];
|
|
|
|
}
|
|
|
|
else if(!hitLeft && !hitRight)
|
|
|
|
{
|
|
|
|
children = [
|
|
|
|
...renderRange(_.head(blockIntro), _.last(blockIntro)),
|
|
|
|
renderSpacer(),
|
|
|
|
...renderRange(_.head(blockAt), _.last(blockAt)),
|
|
|
|
renderSpacer(),
|
|
|
|
...renderRange(_.head(blockOutro), _.last(blockOutro))
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return h("div", {}, children);
|
|
|
|
};
|
2021-03-18 14:03:57 -04:00
|
|
|
|
2021-03-29 22:30:58 -04:00
|
|
|
let ElemColumn = s.div`
|
|
|
|
display:inline-block;
|
|
|
|
vertical-align:top;
|
|
|
|
`;
|
2021-03-18 14:03:57 -04:00
|
|
|
|
2021-03-24 17:11:32 -04:00
|
|
|
let ElemTree = ({tree}) =>
|
|
|
|
{
|
2021-03-25 11:59:34 -04:00
|
|
|
let activeItems = tree.Active.map( a=>{
|
|
|
|
return h("button", {disabled:a.Parent?false:true, key:a.ID, onClick:e=>App.Update.Select(a, tree)}, a.Display )
|
2021-03-29 22:30:58 -04:00
|
|
|
});
|
|
|
|
return h(ElemColumn, {},
|
2021-03-24 17:11:32 -04:00
|
|
|
[
|
|
|
|
h("h3", {key:"title"}, tree.Display),
|
2021-03-25 11:59:34 -04:00
|
|
|
h("div", {key:"filters-active"}, [
|
|
|
|
h("strong", {key:"label"}, "Showing:"),
|
|
|
|
h("span", {key:"list"}, activeItems)
|
|
|
|
]),
|
|
|
|
h("div", {key:"filters-browse"}, [
|
|
|
|
h("strong", {key:"label"}, "Available:"),
|
|
|
|
h(ElemTreeNode, {key:"tree", node:tree.Root, tree:tree})
|
|
|
|
])
|
2021-03-24 17:11:32 -04:00
|
|
|
]);
|
2021-03-29 22:30:58 -04:00
|
|
|
};
|
2021-03-24 17:11:32 -04:00
|
|
|
let ElemTreeNode = ({node, tree}) =>
|
2021-03-23 14:15:21 -04:00
|
|
|
{
|
|
|
|
let children = [];
|
2021-03-24 17:11:32 -04:00
|
|
|
if(node.Children && node.Open)
|
|
|
|
{
|
|
|
|
children = node.Children.map( c=>h(ElemTreeNode, {node:c, tree:tree, key:c.ID}));
|
|
|
|
}
|
|
|
|
|
|
|
|
let elemTitle = (inExpandable, inButton) =>
|
|
|
|
{
|
|
|
|
let attributes = null;
|
2021-03-26 15:57:03 -04:00
|
|
|
let parts = [h("span", null, node.Display+" ("+node.Leaves.length+") ")];
|
2021-03-24 17:11:32 -04:00
|
|
|
|
|
|
|
if(inExpandable)
|
|
|
|
{
|
|
|
|
attributes = {onClick:e=>{ e.stopPropagation(); App.Update.Interact(node); }};
|
|
|
|
parts.unshift(h("span", null, node.Open?"-":"+"));
|
|
|
|
}
|
2021-03-27 09:38:54 -04:00
|
|
|
if(inButton)
|
|
|
|
{
|
|
|
|
parts.push(
|
|
|
|
h("button",
|
|
|
|
{
|
|
|
|
onClick:e=>{ e.stopPropagation(); App.Update.Select(node, tree); }
|
|
|
|
},
|
|
|
|
node.Active?"remove":"add")
|
|
|
|
);
|
|
|
|
}
|
2021-03-24 17:11:32 -04:00
|
|
|
return h("div", attributes, parts);
|
|
|
|
}
|
|
|
|
|
|
|
|
var partTitle;
|
|
|
|
|
|
|
|
if(!node.Parent)
|
|
|
|
{
|
|
|
|
partTitle = elemTitle(true, false);
|
|
|
|
}
|
|
|
|
else
|
2021-03-23 14:15:21 -04:00
|
|
|
{
|
2021-03-24 17:11:32 -04:00
|
|
|
if(node.Children)
|
|
|
|
{
|
|
|
|
partTitle = elemTitle(true, true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
partTitle = elemTitle(false, true);
|
|
|
|
}
|
2021-03-23 14:15:21 -04:00
|
|
|
}
|
2021-03-24 17:11:32 -04:00
|
|
|
|
2021-03-23 14:15:21 -04:00
|
|
|
return h("div", {style:{padding:"10px"}}, [
|
2021-03-24 17:11:32 -04:00
|
|
|
partTitle,
|
|
|
|
h("div", {}, children)
|
|
|
|
]);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
let Node = {
|
|
|
|
Create:(inID, inDisplay, inChildren)=>
|
|
|
|
{
|
2021-03-26 22:02:27 -04:00
|
|
|
if(!inDisplay)
|
|
|
|
{
|
|
|
|
inDisplay = inID;
|
|
|
|
}
|
2021-03-24 17:11:32 -04:00
|
|
|
let node = {
|
|
|
|
ID:inID,
|
|
|
|
Display:inDisplay,
|
|
|
|
Open:false,
|
|
|
|
Active:false,
|
|
|
|
Parent:false,
|
|
|
|
Children:inChildren,
|
|
|
|
Leaves:[]
|
|
|
|
};
|
|
|
|
if(inChildren)
|
|
|
|
{
|
|
|
|
inChildren.forEach(c=>c.Parent = node);
|
|
|
|
}
|
|
|
|
return node;
|
|
|
|
},
|
|
|
|
IterateDown:(inNode, inIterator)=>
|
|
|
|
{
|
|
|
|
if( inIterator(inNode) )
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if(inNode.Children)
|
|
|
|
{
|
|
|
|
for(let i=0; i<inNode.Children.length; i++)
|
2021-03-23 14:15:21 -04:00
|
|
|
{
|
2021-03-24 17:11:32 -04:00
|
|
|
if(Node.IterateDown(inNode.Children[i], inIterator))
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
IterateUp:(inNode, inIterator)=>
|
|
|
|
{
|
|
|
|
if( inIterator(inNode) )
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if(inNode.Parent)
|
|
|
|
{
|
|
|
|
Node.IterateUp(inNode.Parent, inIterator);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
Path:(inNode, inList) =>
|
|
|
|
{
|
|
|
|
let node = inNode;
|
|
|
|
while(node)
|
|
|
|
{
|
|
|
|
inList.push(node);
|
|
|
|
node = node.Parent;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
Leaves:(inNode, inList) =>
|
|
|
|
{
|
|
|
|
var i;
|
|
|
|
var child;
|
|
|
|
if(inNode.Children)
|
|
|
|
{
|
|
|
|
for(i=0; i<inNode.Children.length; i++)
|
2021-03-23 14:15:21 -04:00
|
|
|
{
|
2021-03-24 17:11:32 -04:00
|
|
|
Node.Decedents(inNode.Children[i], inList);
|
2021-03-23 14:15:21 -04:00
|
|
|
}
|
2021-03-24 17:11:32 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
inList.push(inNode);
|
|
|
|
}
|
|
|
|
}
|
2021-03-23 14:15:21 -04:00
|
|
|
};
|
|
|
|
|
2021-03-18 14:03:57 -04:00
|
|
|
var App = {
|
|
|
|
State:
|
|
|
|
{
|
|
|
|
Items:
|
|
|
|
{
|
|
|
|
All:[],
|
|
|
|
Active:[]
|
|
|
|
},
|
2021-03-19 17:09:38 -04:00
|
|
|
Pages:
|
|
|
|
{
|
|
|
|
All:[],
|
|
|
|
Active:0,
|
|
|
|
},
|
2021-03-25 17:04:58 -04:00
|
|
|
Topics:
|
2021-03-23 14:15:21 -04:00
|
|
|
{
|
2021-03-24 17:11:32 -04:00
|
|
|
Display:"Topics",
|
2021-03-27 09:38:54 -04:00
|
|
|
Results:[],
|
2021-03-24 17:11:32 -04:00
|
|
|
Active:[],
|
2021-03-23 14:15:21 -04:00
|
|
|
Root:
|
2021-03-24 17:11:32 -04:00
|
|
|
Node.Create("root", "All", [
|
2021-03-26 22:02:27 -04:00
|
|
|
Node.Create("", "Unclassified"),
|
2021-03-25 17:04:58 -04:00
|
|
|
Node.Create("ideologies", "Ideologies", [
|
|
|
|
Node.Create("gospel-the", "The Gospel"),
|
|
|
|
Node.Create("free-will", "Free Will"),
|
|
|
|
Node.Create("secular-culture", "Secular Culture")
|
2021-03-23 14:15:21 -04:00
|
|
|
]),
|
2021-03-25 17:04:58 -04:00
|
|
|
Node.Create("people", "People", [
|
|
|
|
Node.Create("biblical-figures", "Biblical Figures"),
|
|
|
|
Node.Create("jesus-christ", "Jesus Christ"),
|
2021-03-24 17:11:32 -04:00
|
|
|
])
|
|
|
|
])
|
|
|
|
},
|
|
|
|
Bible:
|
|
|
|
{
|
|
|
|
Display:"Bible",
|
2021-03-27 09:38:54 -04:00
|
|
|
Results:[],
|
2021-03-24 17:11:32 -04:00
|
|
|
Active:[],
|
|
|
|
Root:
|
|
|
|
Node.Create("all", "All", [
|
2021-03-26 22:02:27 -04:00
|
|
|
Node.Create("", "Unclassified"),
|
2021-03-26 15:57:03 -04:00
|
|
|
Node.Create("old ", "Old Testament",
|
|
|
|
[
|
|
|
|
Node.Create("pent", "Pentatuch",
|
|
|
|
[
|
|
|
|
Node.Create("Genesis", "Genesis"),
|
|
|
|
Node.Create("Exodus", "Exodus"),
|
|
|
|
Node.Create("Leviticus", "Leviticus"),
|
|
|
|
Node.Create("Duteronomy", "Duteronomy"),
|
|
|
|
Node.Create("Numbers", "Numbers")
|
|
|
|
]),
|
|
|
|
Node.Create("hist", "History",
|
|
|
|
[
|
|
|
|
Node.Create("Josua", "Josua"),
|
|
|
|
Node.Create("Judges", "Judges"),
|
|
|
|
Node.Create("Ruth", "Ruth"),
|
|
|
|
Node.Create("1 Samuel", "1 Samuel"),
|
|
|
|
Node.Create("2 Samuel", "2 Samuel"),
|
|
|
|
Node.Create("1 Kings", "1 Kings"),
|
|
|
|
Node.Create("2 Kings", "2 Kings"),
|
|
|
|
Node.Create("1 Chronicles", "1 Chronicles"),
|
|
|
|
Node.Create("2 Chronicles", "2 Chronicles"),
|
|
|
|
Node.Create("Ezra", "Ezra"),
|
|
|
|
Node.Create("Nehemiah", "Nehemiah"),
|
|
|
|
Node.Create("Esther", "Esther")
|
|
|
|
]),
|
|
|
|
Node.Create("poet", "Poetry",
|
|
|
|
[
|
|
|
|
Node.Create("Job", "Job"),
|
|
|
|
Node.Create("Psalms", "Psalms"),
|
|
|
|
Node.Create("Proverbs", "Proverbs"),
|
|
|
|
Node.Create("Ecclesiastes", "Ecclesiastes"),
|
2021-03-26 22:02:27 -04:00
|
|
|
Node.Create("Song of Solomon", "Song of Songs"),
|
2021-03-26 15:57:03 -04:00
|
|
|
]),
|
|
|
|
Node.Create("majo", "Major Prophets",
|
|
|
|
[
|
|
|
|
Node.Create("Isaiah", "Isaiah"),
|
|
|
|
Node.Create("Jeremiah", "Jeremiah"),
|
|
|
|
Node.Create("Lamentations", "Lamentations"),
|
|
|
|
Node.Create("Ezekiel", "Ezekiel"),
|
|
|
|
Node.Create("Daniel", "Daniel"),
|
|
|
|
]),
|
|
|
|
Node.Create("mino", "Minor Prophets",
|
|
|
|
[
|
2021-03-26 22:02:27 -04:00
|
|
|
Node.Create("Hosea"),
|
|
|
|
Node.Create("Joel"),
|
|
|
|
Node.Create("Amos"),
|
|
|
|
Node.Create("Obadiah"),
|
|
|
|
Node.Create("Jonah"),
|
|
|
|
Node.Create("Micah"),
|
|
|
|
Node.Create("Nahum"),
|
|
|
|
Node.Create("Habakkuk"),
|
|
|
|
Node.Create("Zephaniah"),
|
|
|
|
Node.Create("Haggai"),
|
|
|
|
Node.Create("Zechariah"),
|
|
|
|
Node.Create("Malachi")
|
2021-03-26 15:57:03 -04:00
|
|
|
])
|
2021-03-24 17:11:32 -04:00
|
|
|
]),
|
|
|
|
Node.Create("nt", "New Testament", [
|
2021-03-26 22:02:27 -04:00
|
|
|
Node.Create("gospels", "The Gospels", [
|
|
|
|
Node.Create("Matthew"),
|
|
|
|
Node.Create("Mark"),
|
|
|
|
Node.Create("Luke"),
|
|
|
|
Node.Create("John"),
|
|
|
|
]),
|
|
|
|
Node.Create("Acts"),
|
|
|
|
Node.Create("Romans"),
|
|
|
|
Node.Create("1 Corinthians"),
|
|
|
|
Node.Create("2 Corinthians"),
|
|
|
|
Node.Create("Galatians"),
|
|
|
|
Node.Create("Ephesians"),
|
2021-03-27 09:38:54 -04:00
|
|
|
Node.Create("1 Thessalonians")
|
2021-03-23 14:15:21 -04:00
|
|
|
])
|
|
|
|
])
|
2021-03-29 22:30:58 -04:00
|
|
|
},
|
|
|
|
Date:
|
2021-03-17 15:43:19 -04:00
|
|
|
{
|
2021-03-29 22:30:58 -04:00
|
|
|
Display:"Date",
|
|
|
|
Results:[],
|
|
|
|
Active:[],
|
|
|
|
Root:
|
|
|
|
Node.Create("all", "All", [
|
|
|
|
Node.Create("", "Unclassified"),
|
|
|
|
Node.Create("8", "1980s"),
|
|
|
|
Node.Create("9", "1990s"),
|
|
|
|
Node.Create("0", "2000s"),
|
|
|
|
Node.Create("1", "2010s"),
|
|
|
|
Node.Create("2", "2020s")
|
|
|
|
])
|
2021-03-27 09:38:54 -04:00
|
|
|
}
|
2021-03-25 17:04:58 -04:00
|
|
|
},
|
2021-03-22 10:31:35 -04:00
|
|
|
Update:
|
2021-03-18 14:03:57 -04:00
|
|
|
{
|
2021-03-29 22:30:58 -04:00
|
|
|
Load:(file)=>
|
2021-03-24 17:11:32 -04:00
|
|
|
{
|
2021-03-29 22:30:58 -04:00
|
|
|
let leafStructure = inTree=>
|
2021-03-25 11:59:34 -04:00
|
|
|
{
|
2021-03-29 22:30:58 -04:00
|
|
|
let output = [];
|
|
|
|
Node.IterateDown(inTree.Root, n=>
|
2021-03-25 11:59:34 -04:00
|
|
|
{
|
2021-03-29 22:30:58 -04:00
|
|
|
if(!n.Children)
|
|
|
|
{
|
|
|
|
output[n.ID] = n;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return output;
|
2021-03-25 11:59:34 -04:00
|
|
|
};
|
2021-03-23 14:15:21 -04:00
|
|
|
|
2021-03-29 22:30:58 -04:00
|
|
|
let structTopics = leafStructure(App.State.Topics)
|
|
|
|
let structBible = leafStructure(App.State.Bible);
|
|
|
|
let structDate = leafStructure(App.State.Date);
|
2021-03-27 09:38:54 -04:00
|
|
|
|
2021-03-22 10:31:35 -04:00
|
|
|
fetch(file)
|
2021-03-24 17:11:32 -04:00
|
|
|
.then(inAccept=>inAccept.text())
|
|
|
|
.then(inAccept=>
|
|
|
|
{
|
2021-03-26 15:57:03 -04:00
|
|
|
let itrUp = inLeaf=>
|
|
|
|
{
|
|
|
|
Node.IterateUp(inLeaf, inBranch=>
|
|
|
|
{
|
2021-03-26 22:02:27 -04:00
|
|
|
inBranch.Leaves = _.union(inBranch.Leaves, inLeaf.Leaves)
|
2021-03-26 15:57:03 -04:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2021-03-24 17:11:32 -04:00
|
|
|
let columns = inAccept.split("|");
|
2021-03-25 17:04:58 -04:00
|
|
|
|
2021-03-26 17:36:00 -04:00
|
|
|
for(let i=0; i<columns.length; i+=5)
|
2021-03-22 10:31:35 -04:00
|
|
|
{
|
2021-03-26 17:36:00 -04:00
|
|
|
let title = columns[i+0];
|
|
|
|
let id = columns[i+1];
|
2021-03-29 22:30:58 -04:00
|
|
|
let date = columns[i+2];
|
2021-03-26 17:36:00 -04:00
|
|
|
let bible = columns[i+3].split("*");
|
2021-03-26 22:02:27 -04:00
|
|
|
let topics = columns[i+4].split("*");
|
2021-03-25 17:04:58 -04:00
|
|
|
|
2021-03-29 22:30:58 -04:00
|
|
|
let output = { title, id, date, topics, bible };
|
2021-03-25 17:04:58 -04:00
|
|
|
|
2021-03-29 22:30:58 -04:00
|
|
|
|
|
|
|
var matched, match;
|
|
|
|
|
|
|
|
// match topics
|
|
|
|
matched = false;
|
2021-03-25 17:04:58 -04:00
|
|
|
topics.forEach(t=>
|
|
|
|
{
|
2021-03-29 22:30:58 -04:00
|
|
|
match = structTopics[t];
|
2021-03-25 17:04:58 -04:00
|
|
|
if(match)
|
|
|
|
{
|
2021-03-26 11:41:52 -04:00
|
|
|
match.Leaves.push(output);
|
2021-03-26 22:02:27 -04:00
|
|
|
matched = true;
|
2021-03-25 17:04:58 -04:00
|
|
|
}
|
|
|
|
});
|
2021-03-26 22:02:27 -04:00
|
|
|
if(!matched)
|
|
|
|
{
|
|
|
|
structTopics[""].Leaves.push(output);
|
|
|
|
}
|
2021-03-29 22:30:58 -04:00
|
|
|
|
|
|
|
// match bible
|
2021-03-26 22:02:27 -04:00
|
|
|
matched = false;
|
2021-03-26 15:57:03 -04:00
|
|
|
bible.forEach(t=>
|
|
|
|
{
|
2021-03-29 22:30:58 -04:00
|
|
|
match = structBible[ Util.ParsePassage(t)[0] ];
|
2021-03-26 15:57:03 -04:00
|
|
|
if(match)
|
|
|
|
{
|
|
|
|
match.Leaves.push(output);
|
2021-03-26 22:02:27 -04:00
|
|
|
matched = true;
|
2021-03-26 15:57:03 -04:00
|
|
|
}
|
|
|
|
});
|
2021-03-26 22:02:27 -04:00
|
|
|
if(!matched)
|
|
|
|
{
|
|
|
|
structBible[""].Leaves.push(output);
|
|
|
|
}
|
2021-03-25 17:04:58 -04:00
|
|
|
|
2021-03-29 22:30:58 -04:00
|
|
|
// match date
|
|
|
|
matched = false;
|
|
|
|
match = structDate[date[2]];
|
|
|
|
if(match)
|
|
|
|
{
|
|
|
|
match.Leaves.push(output);
|
|
|
|
matched = true;
|
|
|
|
}
|
|
|
|
if(!matched)
|
|
|
|
{
|
|
|
|
structDate[""].Leaves.push(output);
|
|
|
|
}
|
|
|
|
|
2021-03-26 22:02:27 -04:00
|
|
|
App.State.Items.All.push(output);
|
2021-03-22 10:31:35 -04:00
|
|
|
}
|
2021-03-26 11:41:52 -04:00
|
|
|
|
2021-03-26 15:57:03 -04:00
|
|
|
Object.values(structTopics).forEach(itrUp);
|
|
|
|
Object.values(structBible).forEach(itrUp);
|
2021-03-29 22:30:58 -04:00
|
|
|
Object.values(structDate).forEach(itrUp);
|
2021-03-24 17:11:32 -04:00
|
|
|
})
|
|
|
|
.then(inAccept=>
|
|
|
|
{
|
|
|
|
App.ApplyFilters();
|
|
|
|
App.Render();
|
2021-03-25 17:04:58 -04:00
|
|
|
});
|
2021-03-22 10:31:35 -04:00
|
|
|
},
|
2021-03-29 22:30:58 -04:00
|
|
|
Interact:(inNode)=>
|
2021-03-22 10:31:35 -04:00
|
|
|
{
|
2021-03-29 22:30:58 -04:00
|
|
|
if(inNode.Open)
|
|
|
|
{
|
|
|
|
Node.IterateDown(inNode, n=>{n.Open=false;});
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Node.IterateUp(inNode, n=>{n.Open=true;});
|
|
|
|
}
|
|
|
|
App.Render();
|
|
|
|
},
|
|
|
|
Select:(inNode, inTree)=>
|
|
|
|
{
|
|
|
|
let clear = c =>
|
|
|
|
{
|
|
|
|
let index = _.indexOf(inTree.Active, c);
|
|
|
|
inTree.Active.splice( index, 1 );
|
|
|
|
c.Active = false;
|
|
|
|
};
|
|
|
|
let add = a =>
|
|
|
|
{
|
|
|
|
a.Active = true;
|
|
|
|
inTree.Active.push(a);
|
|
|
|
};
|
|
|
|
let itr = n=>
|
|
|
|
{
|
|
|
|
if(n.Active)
|
|
|
|
{
|
|
|
|
clear(n);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
if(inNode.Active)
|
2021-03-22 10:31:35 -04:00
|
|
|
{
|
2021-03-29 22:30:58 -04:00
|
|
|
clear(inNode);
|
2021-03-22 10:31:35 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-03-29 22:30:58 -04:00
|
|
|
Node.IterateUp(inNode, itr);
|
|
|
|
Node.IterateDown(inNode, itr);
|
|
|
|
add(inNode);
|
2021-03-22 10:31:35 -04:00
|
|
|
}
|
2021-03-29 22:30:58 -04:00
|
|
|
|
|
|
|
inTree.Results = [];
|
|
|
|
inTree.Active.forEach(inNode =>
|
|
|
|
{
|
|
|
|
inTree.Results = inTree.Results.concat( inNode.Leaves );
|
|
|
|
});
|
|
|
|
|
2021-03-22 10:31:35 -04:00
|
|
|
App.ApplyFilters();
|
|
|
|
App.Render();
|
|
|
|
},
|
|
|
|
Page:(page)=>
|
|
|
|
{
|
|
|
|
if(page !== false)
|
|
|
|
{
|
|
|
|
App.State.Pages.Active = page;
|
|
|
|
App.Render();
|
2021-03-18 14:03:57 -04:00
|
|
|
}
|
|
|
|
}
|
2021-03-29 22:30:58 -04:00
|
|
|
},
|
|
|
|
RootDOM:document.querySelector("#root"),
|
|
|
|
RootComponent:ElemApp,
|
|
|
|
Render:()=>ReactDOM.render( h(App.RootComponent), App.RootDOM ),
|
|
|
|
ApplyFilters:()=>
|
|
|
|
{
|
|
|
|
App.State.Items.Active = _.union(App.State.Topics.Results, App.State.Bible.Results, App.State.Date.Results);
|
|
|
|
if(App.State.Items.Active.length == 0)
|
|
|
|
{
|
|
|
|
App.State.Items.Active = App.State.Items.All;
|
|
|
|
}
|
|
|
|
App.State.Pages.All = _.chunk(App.State.Items.Active, 10);
|
|
|
|
App.State.Pages.Active = 0;
|
2021-03-18 14:03:57 -04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-03-26 17:36:00 -04:00
|
|
|
App.Update.Load("data-1.csv");
|
|
|
|
App.Update.Load("data-2.csv");
|
|
|
|
App.Update.Load("data-3.csv");
|
2021-03-18 14:03:57 -04:00
|
|
|
|
2021-03-17 15:43:19 -04:00
|
|
|
</script>
|