Added lorem ipsum generation and Javascript search
This commit is contained in:
parent
05be8548fe
commit
8d6ec8b4ff
8 changed files with 87 additions and 1 deletions
|
|
@ -242,6 +242,35 @@ export class NodeStore {
|
|||
req.onerror = (event) => reject(event.target.error)
|
||||
})
|
||||
}//}}}
|
||||
async search(searchfor, parent) {//{{{
|
||||
return new Promise((resolve, reject) => {
|
||||
const trx = this.db.transaction('nodes', 'readonly')
|
||||
const nodeStore = trx.objectStore('nodes')
|
||||
const index = nodeStore.index('byParent')
|
||||
const req = index.getAll(parent)
|
||||
req.onsuccess = async (event) => {
|
||||
let nodes = []
|
||||
for (const i in event.target.result) {
|
||||
const nodeData = event.target.result[i]
|
||||
const children = await this.search(searchfor, nodeData.UUID)
|
||||
|
||||
// Data is searched for the provided text.
|
||||
// TODO: implement an array of words to search?
|
||||
if (nodeData.Content.toLowerCase().includes(searchfor))
|
||||
nodes.push({
|
||||
uuid: nodeData.UUID,
|
||||
name: nodeData.Name,
|
||||
ancestry: await this.getNodeAncestry(nodeData, []),
|
||||
})
|
||||
|
||||
nodes = nodes.concat(children)
|
||||
}
|
||||
resolve(nodes)
|
||||
return
|
||||
}
|
||||
req.onerror = (event) => reject(event.target.error)
|
||||
})
|
||||
}//}}}
|
||||
|
||||
async add(records) {//{{{
|
||||
return new Promise((resolve, reject) => {
|
||||
|
|
|
|||
|
|
@ -99,6 +99,7 @@ class Tree extends Component {
|
|||
<div id="tree" ref=${this.treeDiv} tabindex="0">
|
||||
<div id="logo" onclick=${() => _notes2.current.goToNode(ROOT_NODE)}><img src="/images/${_VERSION}/logo.svg" /></div>
|
||||
<div class="icons">
|
||||
<img src="/images/${_VERSION}/icon_search.svg" style="height: 22px" onclick=${()=>_sync.run()} />
|
||||
<img src="/images/${_VERSION}/icon_refresh.svg" onclick=${()=>_sync.run()} />
|
||||
</div>
|
||||
${renderedTreeTrunk}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue