on master help sign in
Added related words
commitc8ebf17f3c1d6ac0fbb5cd5c60332ecbefe3f202 authorDevine Lu Linvega <aliceffekt@gmail.com> dateMon 29 Jul 2019, 10:26 (7 years ago) parentb372e31
2 files changed+21−7
links/main.css+6−5 scripts/wiki.js+15−2
links/main.css+6−5
@@ -2,23 +2,24 @@
22
33body { background:#f4f4f4; padding:0px; margin:0px; }
44body > div { display:block; background: #111;min-height: calc(100vh - 60px);width: calc(100vw - 60px);margin: 15px;color: #333;padding: 15px;font-family:'input_mono_regular', 'Monospaced','Courier New',courier;font-size:11px; position: relative; border-radius: 2px; color:white; overflow: hidden;}
5−body div ul { max-width: 800px; border-bottom: 2px solid white;padding-bottom: 15px;margin-bottom:15px; overflow: hidden;}
5+body div ul { max-width: 800px; padding-bottom: 15px;margin-bottom:15px; overflow: hidden;}
66body div p { display:block; padding:0px 5px; line-height: 20px; max-width: 600px}
77body div p a { text-decoration: underline; cursor: pointer;}
88body div p a:hover { text-decoration: underline; }
99body b { font-weight: normal; font-family: 'input_mono_medium' }
1010body div p.readme { max-width:500px; }
11+body .col3 { columns:3; }
12+body .selected { background: white; color:black; }
1113
1214body #sidebar { position: absolute;top: 0px;right: 0px;padding: 15px;width: 200px; overflow: hidden;}
1315body #sidebar > * { border-bottom: 0px; line-height: 16px; padding-bottom: 0px }
1416body #sidebar > * li { text-transform: lowercase; }
15−body #sidebar > * li.selected { background: white; color:black; }
1617body #sidebar > * li:hover { cursor: pointer; }
1718body #sidebar > * li span.right { color:#555; float:right; }
1819body #sidebar > * li span.right:after { content: " msgs"; }
1920body #sidebar #channels li:before, body #sidebar #categories li:before { content:'/'; }
2021body #sidebar #users li:before { content:'@'; }
21−body #footer { padding-left: 60px;background-image: url(../icon.white.svg);background-size: 40px;background-repeat: no-repeat;background-position: 0px 15px;border-top: 2px solid white;padding-top: 15px; margin-top:15px;}
22+body #footer { padding-left: 60px;background-image: url(../icon.white.svg);background-size: 40px;background-repeat: no-repeat;background-position: 0px 15px;border-top: 2px solid white;padding-top: 15px; margin-top:15px; max-width: 100%}
2223
2324@media only screen and (min-width:200px) and (max-width: 800px) {
2425 body #hallway #sidebar { position: absolute;top: 0px;right: 0px;padding: 15px;width: 200px;display: none;background-color: #000; }
@@ -31,7 +32,6 @@ body #hallway #entries { width: calc(100vw - 300px) !important; }
3132
3233body #hallway #pagination { margin: 10px; text-align: center; }
3334body #hallway #pagination span { padding: 3px; margin: 2px; cursor: pointer; }
34−body #hallway #pagination span.selected { background: white; color:black; }
3535
3636body #hallway .entry { line-height: 16px; display: block; position: relative; padding-left:100px; }
3737body #hallway .entry .date { color: #555;display: block;float:right; margin-left:20px; padding-bottom: 16px;}
@@ -79,9 +79,10 @@ body #portal ul li a:hover { text-decoration: underline; }
7979
8080/* Wiki */
8181
82−body #wiki #entry { max-width: calc(100% - 230px); margin-bottom: 30px }
82+body #wiki #entry { max-width: calc(100% - 230px); margin-bottom: 30px; line-height: 15px }
8383body #wiki #entry a { text-decoration: underline; }
8484body #wiki ul.term { border-bottom: 0px; margin-bottom: 0px; padding-bottom: 0px}
85+body #wiki ul.term li { margin-bottom: 5px }
8586body #wiki ul.term li.name { margin-bottom: 5px }
8687body #wiki ul.term li a.author { color:#555; text-decoration: none !important; }
8788
scripts/wiki.js+15−2
@@ -35,8 +35,8 @@ function Wiki (sites) {
3535 this.refresh = () => {
3636 // Main
3737 if (this.loc) {
38− if (this.byCat[this.byName]) {
39− let html = `term: ${this.loc}`
38+ if (this.byName[this.loc]) {
39+ let html = `${this.templateTerm(this.loc, this.byName[this.loc])}<br />${this.templateRelated(this.loc, this.byName[this.loc])}`
4040 this._entry.innerHTML = html
4141 } else if (this.byCat[this.loc]) {
4242 let html = ''
@@ -74,6 +74,19 @@ function Wiki (sites) {
7474 return keys[target]
7575 }
7676
77+ this.related = (name) => {
78+ const cat = this.byName[name][0].cat
79+ return this.byCat[cat]
80+ }
81+
82+ this.templateRelated = (name, entry) => {
83+ let html = ''
84+ const cat = entry.cat
85+ const relatedWords = this.related(name)
86+ html += `<ul class='col3'>${relatedWords.reduce((acc, item, id) => { return `${acc}<li onclick='wiki.go("${item.name}")' class='${wiki.at(item.name) ? 'selected' : ''}'>${item.name.toLowerCase()}</li>` }, '')}</ul>`
87+ return html
88+ }
89+
7790 this.templateTerm = (name, entry) => {
7891 return '<ul class="term"><li class="name"><b>' + name.toLowerCase() + '</b></li>' + entry.reduce((acc, item) => { return `${acc}<li>${item.value} <a class='author' target='_blank' href='${item.origin.url}'> — @${item.origin.author}</a></li>` }, '') + '</ul>'
7992 }