Display tooltips for tags
This commit is contained in:
parent
f8d2cc1b03
commit
c4e35fbf54
@ -77,8 +77,12 @@ templates['term.html'] = template({"1":function(container,depth0,helpers,partial
|
|||||||
+ ((stack1 = helpers.each.call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.tags : depth0),{"name":"each","hash":{},"fn":container.program(11, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
|
+ ((stack1 = helpers.each.call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.tags : depth0),{"name":"each","hash":{},"fn":container.program(11, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
|
||||||
+ "</div>\n";
|
+ "</div>\n";
|
||||||
},"11":function(container,depth0,helpers,partials,data) {
|
},"11":function(container,depth0,helpers,partials,data) {
|
||||||
return " <span class=\"tag\">"
|
var helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
|
||||||
+ container.escapeExpression(container.lambda(depth0, depth0))
|
|
||||||
|
return " <span class=\"tag\" title=\""
|
||||||
|
+ alias4(((helper = (helper = helpers.desc || (depth0 != null ? depth0.desc : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"desc","hash":{},"data":data}) : helper)))
|
||||||
|
+ "\">"
|
||||||
|
+ alias4(((helper = (helper = helpers.key || (data && data.key)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"key","hash":{},"data":data}) : helper)))
|
||||||
+ "</span>\n";
|
+ "</span>\n";
|
||||||
},"13":function(container,depth0,helpers,partials,data) {
|
},"13":function(container,depth0,helpers,partials,data) {
|
||||||
return " <li><span>"
|
return " <li><span>"
|
||||||
|
@ -19,14 +19,16 @@
|
|||||||
|
|
||||||
class Translator {
|
class Translator {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.loaded = false;
|
this.paths = {
|
||||||
this.paths = {
|
|
||||||
rules: 'bg/data/rules.json',
|
rules: 'bg/data/rules.json',
|
||||||
|
tags: 'bg/data/tags.json',
|
||||||
edict: 'bg/data/edict.json',
|
edict: 'bg/data/edict.json',
|
||||||
enamdict: 'bg/data/enamdict.json',
|
enamdict: 'bg/data/enamdict.json',
|
||||||
kanjidic: 'bg/data/kanjidic.json'
|
kanjidic: 'bg/data/kanjidic.json'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.loaded = false;
|
||||||
|
this.tags = null;
|
||||||
this.dictionary = new Dictionary();
|
this.dictionary = new Dictionary();
|
||||||
this.deinflector = new Deinflector();
|
this.deinflector = new Deinflector();
|
||||||
}
|
}
|
||||||
@ -38,13 +40,16 @@ class Translator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const pendingLoads = [];
|
const pendingLoads = [];
|
||||||
for (const key of ['rules', 'edict', 'enamdict', 'kanjidic']) {
|
for (const key of ['rules', 'tags', 'edict', 'enamdict', 'kanjidic']) {
|
||||||
pendingLoads.push(key);
|
pendingLoads.push(key);
|
||||||
Translator.loadData(this.paths[key], (response) => {
|
Translator.loadData(this.paths[key], (response) => {
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case 'rules':
|
case 'rules':
|
||||||
this.deinflector.setRules(JSON.parse(response));
|
this.deinflector.setRules(JSON.parse(response));
|
||||||
break;
|
break;
|
||||||
|
case 'tags':
|
||||||
|
this.tags = JSON.parse(response);
|
||||||
|
break;
|
||||||
case 'kanjidic':
|
case 'kanjidic':
|
||||||
this.dictionary.addKanjiDict(key, JSON.parse(response));
|
this.dictionary.addKanjiDict(key, JSON.parse(response));
|
||||||
break;
|
break;
|
||||||
@ -98,8 +103,8 @@ class Translator {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const p1 = v1.tags.indexOf('P') >= 0;
|
const p1 = v1.tags.hasOwnProperty('P');
|
||||||
const p2 = v2.tags.indexOf('P') >= 0;
|
const p2 = v2.tags.hasOwnProperty('P');
|
||||||
if (p1 && !p2) {
|
if (p1 && !p2) {
|
||||||
return -1;
|
return -1;
|
||||||
} else if (!p1 && p2) {
|
} else if (!p1 && p2) {
|
||||||
@ -153,12 +158,20 @@ class Translator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let tagInfo = {};
|
||||||
|
for (const tag of entry.tags) {
|
||||||
|
const info = this.tags[tag];
|
||||||
|
if (info) {
|
||||||
|
tagInfo[tag] = info;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (matched) {
|
if (matched) {
|
||||||
groups[entry.id] = {
|
groups[entry.id] = {
|
||||||
expression: entry.expression,
|
expression: entry.expression,
|
||||||
reading: entry.reading,
|
reading: entry.reading,
|
||||||
glossary: entry.glossary,
|
glossary: entry.glossary,
|
||||||
tags: entry.tags,
|
tags: tagInfo,
|
||||||
source: source,
|
source: source,
|
||||||
rules: rules
|
rules: rules
|
||||||
};
|
};
|
||||||
|
@ -46,6 +46,7 @@ body {
|
|||||||
background-color: #777;
|
background-color: #777;
|
||||||
border-radius: 0.25em;
|
border-radius: 0.25em;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
|
cursor: default;
|
||||||
display: inline;
|
display: inline;
|
||||||
font-size: 75%;
|
font-size: 75%;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
{{#if tags}}
|
{{#if tags}}
|
||||||
<div class="tags">
|
<div class="tags">
|
||||||
{{#each tags}}
|
{{#each tags}}
|
||||||
<span class="tag">{{.}}</span>
|
<span class="tag" title="{{desc}}">{{@key}}</span>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
Loading…
Reference in New Issue
Block a user