move classification out of load

This commit is contained in:
TreetopFlyer 2021-05-14 13:53:28 -04:00
parent 27990678c2
commit 5a64ee41c3

View File

@ -259,31 +259,6 @@ let Node = {
{ {
Node.IterateUp(inNode.Parent, inIterator); 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++)
{
Node.Decedents(inNode.Children[i], inList);
}
}
else
{
inList.push(inNode);
}
} }
}; };
@ -417,9 +392,7 @@ var App = {
]) ])
} }
}, },
Update: OldClassifier:()=>
{
Load:(file)=>
{ {
let leafStructure = inTree=> let leafStructure = inTree=>
{ {
@ -433,38 +406,14 @@ var App = {
}); });
return output; return output;
}; };
let structTopics = leafStructure(App.State.Topics) let structTopics = leafStructure(App.State.Topics)
let structBible = leafStructure(App.State.Bible); let structBible = leafStructure(App.State.Bible);
let structDate = leafStructure(App.State.Date); let structDate = leafStructure(App.State.Date);
fetch(file)
.then(inAccept=>inAccept.text())
.then(inAccept=>
{
let itrUp = inLeaf=>
{
Node.IterateUp(inLeaf, inBranch=>
{
inBranch.Leaves = _.union(inBranch.Leaves, inLeaf.Leaves)
});
};
let columns = inAccept.split("|");
for(let i=0; i<columns.length; i+=5)
{
let title = columns[i+0];
let id = columns[i+1];
let date = columns[i+2];
let bible = columns[i+3].split("*");
let topics = columns[i+4].split("*");
let output = { title, id, date, topics, bible };
////
var matched, match; var matched, match;
// match topics // match topics
matched = false; matched = false;
topics.forEach(t=> topics.forEach(t=>
@ -510,12 +459,41 @@ var App = {
structDate[""].Leaves.push(output); structDate[""].Leaves.push(output);
} }
App.State.Items.All.push(output); ////
}
let itrUp = inLeaf=>
{
Node.IterateUp(inLeaf, inBranch=>
{
inBranch.Leaves = _.union(inBranch.Leaves, inLeaf.Leaves)
});
};
Object.values(structTopics).forEach(itrUp); Object.values(structTopics).forEach(itrUp);
Object.values(structBible).forEach(itrUp); Object.values(structBible).forEach(itrUp);
Object.values(structDate).forEach(itrUp); Object.values(structDate).forEach(itrUp);
},
Update:
{
Load:(file)=>
{
fetch(file)
.then(inAccept=>inAccept.text())
.then(inAccept=>
{
let columns = inAccept.split("|");
for(let i=0; i<columns.length; i+=5)
{
let title = columns[i+0];
let id = columns[i+1];
let date = columns[i+2];
let bible = columns[i+3].split("*");
let topics = columns[i+4].split("*");
let output = { title, id, date, topics, bible };
App.State.Items.All.push(output);
}
}) })
.then(inAccept=> .then(inAccept=>
{ {