on master help sign in
Added home
6096efeDevine Lu Linvega
scripts/wiki.js+2−2
@@ -56,7 +56,7 @@ function Wiki (sites) {
56 this._entry.innerHTML = `Click a /topic to get started, or try a <a href='#${random.toUrl()}' onclick='wiki.go("${random}")'>random page</a>.<br />The wiki contains ${Object.keys(this.byName).length} terms, in ${Object.keys(this.byCat).length} categories, by ${Object.keys(this.byAuthor).length} authors.`
56 this._entry.innerHTML = `Click a /topic to get started, or try a <a href='#${random.toUrl()}' onclick='wiki.go("${random}")'>random page</a>.<br />The wiki contains ${Object.keys(this.byName).length} terms, in ${Object.keys(this.byCat).length} categories, by ${Object.keys(this.byAuthor).length} authors.`
57 }
57 }
58 // Sidebar
58 // Sidebar
59− this._categories.innerHTML = Object.keys(this.byCat).reduce((acc, id) => { return this.byCat[id].length > 5 ? `${acc}<li onclick='wiki.go("${id}")' class='${wiki.at(id) ? 'selected' : ''}'>${id.substr(0, 20)} <span class='right'>${this.byCat[id].length}</span></li>` : acc }, '')
59+ this._categories.innerHTML = Object.keys(this.byCat).reduce((acc, id) => { return this.byCat[id].length > 5 ? `${acc}<li onclick='wiki.go("${id}")' class='${wiki.at(id) ? 'selected' : ''}'>${id.substr(0, 20)} <span class='right'>${this.byCat[id].length}</span></li>` : acc }, `<li onclick='wiki.go("")' class='${wiki.at() ? 'selected' : ''}'>home <span class='right'>${Object.keys(this.byName).length}</span></li>`)
60 }
60 }
61
61
62 this.go = (q = window.location.hash.substr(1).replace(/\+/g, ' ').toUpperCase()) => {
62 this.go = (q = window.location.hash.substr(1).replace(/\+/g, ' ').toUpperCase()) => {
@@ -66,7 +66,7 @@ function Wiki (sites) {
66 }
66 }
67
67
68 this.at = (q = '') => {
68 this.at = (q = '') => {
69− return this.loc.toUpperCase() === q.toUpperCase() || this.cat(this.loc).toUpperCase() === q.toUpperCase()
69+ return this.loc.toUpperCase() === q.toUpperCase() || (this.cat(this.loc).toUpperCase() === q.toUpperCase() && q !== '')
70 }
70 }
71
71
72 this.random = () => {
72 this.random = () => {