(context, what)
| 15 | // } |
| 16 | // |
| 17 | export function uiTagReference(context, what) { |
| 18 | const l10n = context.systems.l10n; |
| 19 | const wikibase = context.services[what.qid ? 'wikidata' : 'osmwikibase']; |
| 20 | let tagReference = {}; |
| 21 | |
| 22 | let _button = d3_select(null); |
| 23 | let _body = d3_select(null); |
| 24 | let _loaded; |
| 25 | let _showing; |
| 26 | |
| 27 | |
| 28 | function load() { |
| 29 | if (!wikibase) return; |
| 30 | |
| 31 | _button |
| 32 | .classed('tag-reference-loading', true); |
| 33 | |
| 34 | wikibase.getDocs(what, gotDocs); |
| 35 | } |
| 36 | |
| 37 | |
| 38 | function gotDocs(err, docs) { |
| 39 | _body.html(''); |
| 40 | |
| 41 | if (!docs || !docs.title) { |
| 42 | _body |
| 43 | .append('p') |
| 44 | .attr('class', 'tag-reference-description') |
| 45 | .html(l10n.tHtml('inspector.no_documentation_key')); |
| 46 | done(); |
| 47 | return; |
| 48 | } |
| 49 | |
| 50 | if (docs.imageURL) { |
| 51 | _body |
| 52 | .append('img') |
| 53 | .attr('class', 'tag-reference-wiki-image') |
| 54 | .attr('src', docs.imageURL) |
| 55 | .on('load', () => done()) |
| 56 | .on('error', function() { |
| 57 | d3_select(this).remove(); |
| 58 | done(); |
| 59 | }); |
| 60 | } else { |
| 61 | done(); |
| 62 | } |
| 63 | |
| 64 | let docsHtml; |
| 65 | if (docs.description) { |
| 66 | docsHtml = utilSanitizeHTML(l10n.htmlForLocalizedText(docs.description, docs.descriptionLocaleCode)); |
| 67 | } else { |
| 68 | docsHtml = l10n.tHtml('inspector.no_documentation_key'); |
| 69 | } |
| 70 | |
| 71 | _body |
| 72 | .append('p') |
| 73 | .attr('class', 'tag-reference-description') |
| 74 | .html(docsHtml) |
no test coverage detected