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) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue