'use strict' function Wiki (sites) { const feeds = {} this.sites = sites this._el = document.createElement('div') this._el.id = 'wiki' this._sidebar = document.createElement('div') this._sidebar.id = 'sidebar' this._categories = document.createElement('ul') this._categories.id = 'categories' this._entry = document.createElement('div') this._entry.id = 'entry' this.loc = '' this.index = {} this.categories = {} this.install = (host) => { console.log('Wiki', 'Installing..') this.fetch() this._el.appendChild(this._entry) this._sidebar.appendChild(this._categories) this._el.appendChild(this._sidebar) host.appendChild(this._el) } this.start = () => { console.log('Wiki', 'Starting..') // this.el.innerHTML = 'hello.' } this.refresh = () => { console.log(Object.keys(this.index).length + ' terms') // Main if (this.loc) { if (this.categories[this.index]) { let html = `term: ${this.loc}` this._entry.innerHTML = html } else if (this.categories[this.loc]) { let html = `category: ${this.loc}` this._entry.innerHTML = html } else { let html = `Unknown: ${this.loc}` this._entry.innerHTML = html } } else { this._entry.innerHTML = 'Click a /topic to get started.' } // Sidebar this._categories.innerHTML = Object.keys(this.categories).reduce((acc, id) => { return `${acc}