@@ -12,6 +12,7 @@ function Wiki (sites) {
1212 this._names = document.createElement('div')
1313 this._names.id = 'names'
1414
15+ this.loc = ''
1516 this.index = {}
1617 this.categories = {}
1718
@@ -31,16 +32,23 @@ function Wiki (sites) {
3132
3233 this.refresh = () => {
3334 console.log(Object.keys(this.index).length + ' terms')
34−
35− // Cats
36−
35+ // Sidebar
3736 let html = ''
3837 for (const id in this.categories) {
39− html += `<li>${id} <span class='right'>${this.categories[id].length}</span></li>`
38+ html += `<li onclick='wiki.go("${id}")' class='${wiki.at(id) ? 'selected' : ''}'>${id} <span class='right'>${this.categories[id].length}</span></li>`
4039 }
4140 this._categories.innerHTML = `${html}`
4241 }
4342
43+ this.go = (q) => {
44+ this.loc = q
45+ this.refresh()
46+ }
47+
48+ this.at = (q = '') => {
49+ return this.loc.toLowerCase() === q.toLowerCase()
50+ }
51+
4452 this.fetch = () => {
4553 console.log('Wiki', 'Fetching..')
4654 for (const site of sites) {