move classification out of load
This commit is contained in:
parent
27990678c2
commit
5a64ee41c3
184
index.html
184
index.html
@ -259,31 +259,6 @@ let Node = {
|
||||
{
|
||||
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,41 +392,96 @@ var App = {
|
||||
])
|
||||
}
|
||||
},
|
||||
OldClassifier:()=>
|
||||
{
|
||||
let leafStructure = inTree=>
|
||||
{
|
||||
let output = [];
|
||||
Node.IterateDown(inTree.Root, n=>
|
||||
{
|
||||
if(!n.Children)
|
||||
{
|
||||
output[n.ID] = n;
|
||||
}
|
||||
});
|
||||
return output;
|
||||
};
|
||||
let structTopics = leafStructure(App.State.Topics)
|
||||
let structBible = leafStructure(App.State.Bible);
|
||||
let structDate = leafStructure(App.State.Date);
|
||||
|
||||
|
||||
////
|
||||
|
||||
var matched, match;
|
||||
// match topics
|
||||
matched = false;
|
||||
topics.forEach(t=>
|
||||
{
|
||||
match = structTopics[t];
|
||||
if(match)
|
||||
{
|
||||
match.Leaves.push(output);
|
||||
matched = true;
|
||||
}
|
||||
});
|
||||
if(!matched)
|
||||
{
|
||||
structTopics[""].Leaves.push(output);
|
||||
}
|
||||
|
||||
// match bible
|
||||
matched = false;
|
||||
bible.forEach(t=>
|
||||
{
|
||||
match = structBible[ Util.ParsePassage(t)[0] ];
|
||||
if(match)
|
||||
{
|
||||
match.Leaves.push(output);
|
||||
matched = true;
|
||||
}
|
||||
});
|
||||
if(!matched)
|
||||
{
|
||||
structBible[""].Leaves.push(output);
|
||||
}
|
||||
|
||||
// match date
|
||||
matched = false;
|
||||
match = structDate[date[2]];
|
||||
if(match)
|
||||
{
|
||||
match.Leaves.push(output);
|
||||
matched = true;
|
||||
}
|
||||
if(!matched)
|
||||
{
|
||||
structDate[""].Leaves.push(output);
|
||||
}
|
||||
|
||||
////
|
||||
|
||||
|
||||
let itrUp = inLeaf=>
|
||||
{
|
||||
Node.IterateUp(inLeaf, inBranch=>
|
||||
{
|
||||
inBranch.Leaves = _.union(inBranch.Leaves, inLeaf.Leaves)
|
||||
});
|
||||
};
|
||||
Object.values(structTopics).forEach(itrUp);
|
||||
Object.values(structBible).forEach(itrUp);
|
||||
Object.values(structDate).forEach(itrUp);
|
||||
},
|
||||
Update:
|
||||
{
|
||||
Load:(file)=>
|
||||
{
|
||||
let leafStructure = inTree=>
|
||||
{
|
||||
let output = [];
|
||||
Node.IterateDown(inTree.Root, n=>
|
||||
{
|
||||
if(!n.Children)
|
||||
{
|
||||
output[n.ID] = n;
|
||||
}
|
||||
});
|
||||
return output;
|
||||
};
|
||||
|
||||
let structTopics = leafStructure(App.State.Topics)
|
||||
let structBible = leafStructure(App.State.Bible);
|
||||
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];
|
||||
@ -462,60 +492,8 @@ var App = {
|
||||
|
||||
let output = { title, id, date, topics, bible };
|
||||
|
||||
|
||||
var matched, match;
|
||||
|
||||
// match topics
|
||||
matched = false;
|
||||
topics.forEach(t=>
|
||||
{
|
||||
match = structTopics[t];
|
||||
if(match)
|
||||
{
|
||||
match.Leaves.push(output);
|
||||
matched = true;
|
||||
}
|
||||
});
|
||||
if(!matched)
|
||||
{
|
||||
structTopics[""].Leaves.push(output);
|
||||
}
|
||||
|
||||
// match bible
|
||||
matched = false;
|
||||
bible.forEach(t=>
|
||||
{
|
||||
match = structBible[ Util.ParsePassage(t)[0] ];
|
||||
if(match)
|
||||
{
|
||||
match.Leaves.push(output);
|
||||
matched = true;
|
||||
}
|
||||
});
|
||||
if(!matched)
|
||||
{
|
||||
structBible[""].Leaves.push(output);
|
||||
}
|
||||
|
||||
// match date
|
||||
matched = false;
|
||||
match = structDate[date[2]];
|
||||
if(match)
|
||||
{
|
||||
match.Leaves.push(output);
|
||||
matched = true;
|
||||
}
|
||||
if(!matched)
|
||||
{
|
||||
structDate[""].Leaves.push(output);
|
||||
}
|
||||
|
||||
App.State.Items.All.push(output);
|
||||
}
|
||||
|
||||
Object.values(structTopics).forEach(itrUp);
|
||||
Object.values(structBible).forEach(itrUp);
|
||||
Object.values(structDate).forEach(itrUp);
|
||||
})
|
||||
.then(inAccept=>
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user