@@ -6,23 +6,55 @@ function Wiki (sites) {
6 this.el = document.createElement('div')
6 this.el = document.createElement('div')
7 this.el.id = 'wiki'
7 this.el.id = 'wiki'
9− this.install = function (host) {
11+ this.install = (host) => {
10− console.log('Wiki','Installing..')
12+ console.log('Wiki', 'Installing..')
11 this.fetch()
13 this.fetch()
12 host.appendChild(this.el)
14 host.appendChild(this.el)
15− this.start = function () {
17+ this.start = () => {
16− console.log('Wiki','Starting..')
18+ console.log('Wiki', 'Starting..')
17 this.el.innerHTML = 'hello.'
19 this.el.innerHTML = 'hello.'
20− this.fetch = function () {
22+ this.fetch = () => {
21− console.log('Wiki','Fetching..')
23+ console.log('Wiki', 'Fetching..')
22 for (const site of sites) {
24 for (const site of sites) {
23− if(!site.wiki || !site.author){continue}
25+ if (!site.wiki || !site.author) { continue }
24− console.log(site)
26+ fetch(site.wiki, { cache: 'no-store' }).then(x => x.text()).then((content) => {
27+ this.parse(site, content)
30+ console.warn(`${site.wiki}`, err)
35+ this.refresh = () => {
36+ console.log(Object.keys(this.index).length + ' terms')
39+ this.add = (name, value, cat, origin) => {
40+ if (!this.index[name]) {
41+ this.index[name] = []
26− console.log(`Found ${Object.keys(feeds).length} feeds.`)
43+ this.index[name].push({ value, cat, origin })
46+ this.parse = (site, content) => {
47+ console.log('Wiki', 'Parsing ' + site.wiki)
48+ const cats = indental(this.filter(content))
49+ for (const cat in cats) {
50+ const terms = cats[cat]
51+ for (const name in terms) {
52+ this.add(name, terms[name], cat, site)
57+ this.filter = (lines) => {
58+ return lines.split('\n').filter((line) => { return line.indexOf(' = `') < 0 && line.trim().length > 1 }).join('\n')