From 040257fd449e2845a30561336ce9ebd46bc0b522 Mon Sep 17 00:00:00 2001 From: Martin Raifer Date: Thu, 18 Nov 2021 17:27:38 +0100 Subject: [PATCH] replace unnecessary setting of raw "html" with "text" --- modules/actions/merge_remote_changes.js | 1 - modules/behavior/draw_way.js | 8 +++--- modules/modes/drag_node.js | 4 +-- modules/modes/draw_area.js | 2 +- modules/modes/draw_line.js | 2 +- modules/modes/select.js | 2 +- modules/renderer/background_source.js | 7 ++--- modules/renderer/tile_layer.js | 10 ++++--- modules/services/kartaview.js | 20 +++++++------- modules/services/streetside.js | 10 +++---- modules/ui/attribution.js | 4 +-- modules/ui/combobox.js | 2 +- modules/ui/conflicts.js | 4 +-- modules/ui/contributors.js | 2 +- modules/ui/feature_list.js | 4 +-- modules/ui/field_help.js | 18 ++++++------- modules/ui/fields/combo.js | 4 +-- modules/ui/fields/lanes.js | 6 ++--- modules/ui/improveOSM_comments.js | 4 +-- modules/ui/improveOSM_details.js | 2 +- modules/ui/improveOSM_header.js | 2 +- modules/ui/issues_info.js | 2 +- modules/ui/note_editor.js | 4 +-- modules/ui/note_header.js | 6 ++--- modules/ui/osmose_details.js | 2 +- modules/ui/osmose_header.js | 2 +- modules/ui/panels/background.js | 8 +++--- modules/ui/panels/history.js | 26 +++++++++---------- modules/ui/panels/location.js | 10 +++---- modules/ui/panels/measurement.js | 26 +++++++++---------- modules/ui/preset_list.js | 4 +-- modules/ui/scale.js | 2 +- .../ui/sections/background_display_options.js | 2 +- modules/ui/sections/changes.js | 6 ++--- modules/ui/sections/data_layers.js | 6 ++--- modules/ui/sections/entity_issues.js | 2 +- modules/ui/sections/raw_member_editor.js | 6 ++--- modules/ui/sections/raw_membership_editor.js | 6 ++--- modules/ui/sections/selection_list.js | 4 +-- modules/ui/sections/validation_rules.js | 2 +- modules/ui/sections/validation_status.js | 2 +- modules/ui/shortcuts.js | 10 +++---- modules/ui/success.js | 10 +++---- modules/ui/tools/save.js | 4 +-- modules/ui/tools/undo_redo.js | 4 +-- modules/ui/version.js | 2 +- 46 files changed, 139 insertions(+), 137 deletions(-) diff --git a/modules/actions/merge_remote_changes.js b/modules/actions/merge_remote_changes.js index 2e8b748a2..358f6a66b 100644 --- a/modules/actions/merge_remote_changes.js +++ b/modules/actions/merge_remote_changes.js @@ -179,7 +179,6 @@ export function actionMergeRemoteChanges(id, localGraph, remoteGraph, discardTag if (o[k] !== a[k]) { // changed locally.. _conflicts.push(t.html('merge_remote_changes.conflict.tags', { tag: k, local: a[k], remote: b[k], user: { html: user(remote.user) } })); - } else { // unchanged locally, accept remote change.. if (b.hasOwnProperty(k)) { tags[k] = b[k]; diff --git a/modules/behavior/draw_way.js b/modules/behavior/draw_way.js index 92d6e7c21..44e61f1bc 100644 --- a/modules/behavior/draw_way.js +++ b/modules/behavior/draw_way.js @@ -447,7 +447,7 @@ export function behaviorDrawWay(context, wayID, mode, startGraph) { context.ui().flash .duration(4000) .iconName('#iD-icon-no') - .label(t('operations.follow.error.needs_more_initial_nodes'))(); + .label(t.html('operations.follow.error.needs_more_initial_nodes'))(); return; } @@ -461,7 +461,7 @@ export function behaviorDrawWay(context, wayID, mode, startGraph) { context.ui().flash .duration(4000) .iconName('#iD-icon-no') - .label(t(`operations.follow.error.intersection_of_multiple_ways.${featureType}`))(); + .label(t.html(`operations.follow.error.intersection_of_multiple_ways.${featureType}`))(); return; } @@ -472,7 +472,7 @@ export function behaviorDrawWay(context, wayID, mode, startGraph) { context.ui().flash .duration(4000) .iconName('#iD-icon-no') - .label(t(`operations.follow.error.intersection_of_different_ways.${featureType}`))(); + .label(t.html(`operations.follow.error.intersection_of_different_ways.${featureType}`))(); return; } @@ -501,7 +501,7 @@ export function behaviorDrawWay(context, wayID, mode, startGraph) { context.ui().flash .duration(4000) .iconName('#iD-icon-no') - .label(t('operations.follow.error.unknown'))(); + .label(t.html('operations.follow.error.unknown'))(); } } diff --git a/modules/modes/drag_node.js b/modules/modes/drag_node.js index 92ea7c285..0e531df9c 100644 --- a/modules/modes/drag_node.js +++ b/modules/modes/drag_node.js @@ -239,7 +239,7 @@ export function modeDragNode(context) { context.ui().flash .duration(4000) .iconName('#iD-icon-no') - .label(t('operations.connect.' + isInvalid, + .label(t.html('operations.connect.' + isInvalid, { relation: presetManager.item('type/restriction').name() } ))(); } @@ -248,7 +248,7 @@ export function modeDragNode(context) { context.ui().flash .duration(3000) .iconName('#iD-icon-no') - .label(t('self_intersection.error.' + errorID))(); + .label(t.html('self_intersection.error.' + errorID))(); } else { if (nope) { // about to un-nope, remove hint context.ui().flash diff --git a/modules/modes/draw_area.js b/modules/modes/draw_area.js index e488a667f..213fa127b 100644 --- a/modules/modes/draw_area.js +++ b/modules/modes/draw_area.js @@ -12,7 +12,7 @@ export function modeDrawArea(context, wayID, startGraph, button) { .on('rejectedSelfIntersection.modeDrawArea', function() { context.ui().flash .iconName('#iD-icon-no') - .label(t('self_intersection.error.areas'))(); + .label(t.html('self_intersection.error.areas'))(); }); mode.wayID = wayID; diff --git a/modules/modes/draw_line.js b/modules/modes/draw_line.js index e629ae7d1..b5dd99429 100644 --- a/modules/modes/draw_line.js +++ b/modules/modes/draw_line.js @@ -12,7 +12,7 @@ export function modeDrawLine(context, wayID, startGraph, button, affix, continui .on('rejectedSelfIntersection.modeDrawLine', function() { context.ui().flash .iconName('#iD-icon-no') - .label(t('self_intersection.error.lines'))(); + .label(t.html('self_intersection.error.lines'))(); }); mode.wayID = wayID; diff --git a/modules/modes/select.js b/modules/modes/select.js index d141ce773..d66d6e599 100644 --- a/modules/modes/select.js +++ b/modules/modes/select.js @@ -400,7 +400,7 @@ export function modeSelect(context, selectedIDs) { .duration(4000) .iconName('#iD-icon-no') .iconClass('operation disabled') - .label(t('operations.scale.' + disabled + '.' + multi))(); + .label(t.html('operations.scale.' + disabled + '.' + multi))(); } else { const pivot = context.projection(extent.center()); const annotation = t('operations.scale.annotation.' + (isUp ? 'up' : 'down') + '.feature', { n: selectedIDs.length }); diff --git a/modules/renderer/background_source.js b/modules/renderer/background_source.js index 764fd6fd5..4321c2804 100644 --- a/modules/renderer/background_source.js +++ b/modules/renderer/background_source.js @@ -1,5 +1,6 @@ import { geoArea as d3_geoArea, geoMercatorRaw as d3_geoMercatorRaw } from 'd3-geo'; import { json as d3_json } from 'd3-fetch'; +import { escape } from 'lodash'; import { t, localizer } from '../core/localizer'; import { geoExtent, geoSphericalDistance } from '../geo'; @@ -68,19 +69,19 @@ export function rendererBackgroundSource(data) { source.name = function() { var id_safe = source.id.replace(/\./g, ''); - return t('imagery.' + id_safe + '.name', { default: _name }); + return t('imagery.' + id_safe + '.name', { default: escape(_name) }); }; source.label = function() { var id_safe = source.id.replace(/\./g, ''); - return t.html('imagery.' + id_safe + '.name', { default: _name }); + return t.html('imagery.' + id_safe + '.name', { default: escape(_name) }); }; source.description = function() { var id_safe = source.id.replace(/\./g, ''); - return t.html('imagery.' + id_safe + '.description', { default: _description }); + return t.html('imagery.' + id_safe + '.description', { default: escape(_description) }); }; diff --git a/modules/renderer/tile_layer.js b/modules/renderer/tile_layer.js index be2d5a951..aa2870089 100644 --- a/modules/renderer/tile_layer.js +++ b/modules/renderer/tile_layer.js @@ -238,7 +238,7 @@ export function rendererTileLayer(context) { debug .selectAll('.tile-label-debug-coord') - .html(function(d) { return d[2] + ' / ' + d[0] + ' / ' + d[1]; }); + .text(function(d) { return d[2] + ' / ' + d[0] + ' / ' + d[1]; }); debug .selectAll('.tile-label-debug-vintage') @@ -246,9 +246,11 @@ export function rendererTileLayer(context) { var span = d3_select(this); var center = context.projection.invert(tileCenter(d)); _source.getMetadata(center, d, function(err, result) { - span.html((result && result.vintage && result.vintage.range) || - t('info_panels.background.vintage') + ': ' + t('info_panels.background.unknown') - ); + if (result && result.vintage && result.vintage.range) { + span.text(result.vintage.range); + } else { + span.html(t.html('info_panels.background.vintage') + ': ' + t.html('info_panels.background.unknown')); + } }); }); } diff --git a/modules/services/kartaview.js b/modules/services/kartaview.js index 577227fc7..9d6038978 100644 --- a/modules/services/kartaview.js +++ b/modules/services/kartaview.js @@ -276,22 +276,22 @@ export default { controlsEnter .append('button') .on('click.back', step(-1)) - .html('◄'); + .text('◄'); controlsEnter .append('button') .on('click.rotate-ccw', rotate(-90)) - .html('⤿'); + .text('⤿'); controlsEnter .append('button') .on('click.rotate-cw', rotate(90)) - .html('⤾'); + .text('⤾'); controlsEnter .append('button') .on('click.forward', step(1)) - .html('►'); + .text('►'); wrapEnter .append('div') @@ -428,7 +428,7 @@ export default { var wrap = context.container().select('.photoviewer .kartaview-wrapper'); var imageWrap = wrap.selectAll('.kartaview-image-wrap'); - var attribution = wrap.selectAll('.photo-attribution').html(''); + var attribution = wrap.selectAll('.photo-attribution').text(''); wrap .transition() @@ -455,22 +455,22 @@ export default { .attr('class', 'captured_by') .attr('target', '_blank') .attr('href', 'https://kartaview.org/user/' + encodeURIComponent(d.captured_by)) - .html('@' + d.captured_by); + .text('@' + d.captured_by); attribution .append('span') - .html('|'); + .text('|'); } if (d.captured_at) { attribution .append('span') .attr('class', 'captured_at') - .html(localeDateString(d.captured_at)); + .text(localeDateString(d.captured_at)); attribution .append('span') - .html('|'); + .text('|'); } attribution @@ -478,7 +478,7 @@ export default { .attr('class', 'image-link') .attr('target', '_blank') .attr('href', 'https://kartaview.org/details/' + d.sequence_id + '/' + d.sequence_index) - .html('kartaview.org'); + .text('kartaview.org'); } return this; diff --git a/modules/services/streetside.js b/modules/services/streetside.js index fb6472534..a3c370e11 100644 --- a/modules/services/streetside.js +++ b/modules/services/streetside.js @@ -544,12 +544,12 @@ export default { controlsEnter .append('button') .on('click.back', step(-1)) - .html('◄'); + .text('◄'); controlsEnter .append('button') .on('click.forward', step(1)) - .html('►'); + .text('►'); // create working canvas for stitching together images @@ -810,18 +810,18 @@ export default { .attr('class', 'captured_by') .attr('target', '_blank') .attr('href', 'https://www.microsoft.com/en-us/maps/streetside') - .html('©' + yyyy + ' Microsoft'); + .text('©' + yyyy + ' Microsoft'); captureInfo .append('span') - .html('|'); + .text('|'); } if (d.captured_at) { captureInfo .append('span') .attr('class', 'captured_at') - .html(localeTimestamp(d.captured_at)); + .text(localeTimestamp(d.captured_at)); } // Add image links diff --git a/modules/ui/attribution.js b/modules/ui/attribution.js index 27cf0e0e7..4001d3e25 100644 --- a/modules/ui/attribution.js +++ b/modules/ui/attribution.js @@ -56,7 +56,7 @@ export function uiAttribution(context) { attribution .append('span') .attr('class', 'attribution-text') - .html(terms_text); + .text(terms_text); }) .merge(attributions); @@ -76,7 +76,7 @@ export function uiAttribution(context) { .merge(copyright); copyright - .html(String); + .text(String); } diff --git a/modules/ui/combobox.js b/modules/ui/combobox.js index 57555078f..fa7b75c8a 100644 --- a/modules/ui/combobox.js +++ b/modules/ui/combobox.js @@ -384,7 +384,7 @@ export function uiCombobox(context, klass) { return 'combobox-option ' + (d.klass || ''); }) .attr('title', function(d) { return d.title; }) - .html(function(d) { return d.display || d.value; }) + .text(function(d) { return d.display || d.value; }) .on('mouseenter', _mouseEnterHandler) .on('mouseleave', _mouseLeaveHandler) .merge(options) diff --git a/modules/ui/conflicts.js b/modules/ui/conflicts.js index 078a494d4..623ca6885 100644 --- a/modules/ui/conflicts.js +++ b/modules/ui/conflicts.js @@ -182,7 +182,7 @@ export function uiConflicts(context) { .append('a') .attr('class', 'conflict-description') .attr('href', '#') - .html(function(d) { return d.name; }) + .text(function(d) { return d.name; }) .on('click', function(d3_event, d) { d3_event.preventDefault(); zoomToEntity(d.id); @@ -264,7 +264,7 @@ export function uiConflicts(context) { labelEnter .append('span') - .html(function(d) { return d.text; }); + .text(function(d) { return d.text; }); // update choicesEnter diff --git a/modules/ui/contributors.js b/modules/ui/contributors.js index 607f0037d..933bd78bc 100644 --- a/modules/ui/contributors.js +++ b/modules/ui/contributors.js @@ -51,7 +51,7 @@ export function uiContributors(context) { .attr('href', function() { return osm.changesetsURL(context.map().center(), context.map().zoom()); }) - .html(othersNum); + .text(othersNum); wrap.append('span') .html(t.html('contributors.truncated_list', { n: othersNum, users: { html: userList.html() }, count: { html: count.html() } })); diff --git a/modules/ui/feature_list.js b/modules/ui/feature_list.js index f0ccc7d18..4bd3c5794 100644 --- a/modules/ui/feature_list.js +++ b/modules/ui/feature_list.js @@ -304,12 +304,12 @@ export function uiFeatureList(context) { label .append('span') .attr('class', 'entity-type') - .html(function(d) { return d.type; }); + .text(function(d) { return d.type; }); label .append('span') .attr('class', 'entity-name') - .html(function(d) { return d.name; }); + .text(function(d) { return d.name; }); enter .style('opacity', 0) diff --git a/modules/ui/field_help.js b/modules/ui/field_help.js index 806fa04a5..22a570bea 100644 --- a/modules/ui/field_help.js +++ b/modules/ui/field_help.js @@ -54,15 +54,15 @@ export function uiFieldHelp(context, fieldName) { var fieldHelpHeadings = {}; var replacements = { - distField: t.html('restriction.controls.distance'), - viaField: t.html('restriction.controls.via'), - fromShadow: icon('#iD-turn-shadow', 'inline shadow from'), - allowShadow: icon('#iD-turn-shadow', 'inline shadow allow'), - restrictShadow: icon('#iD-turn-shadow', 'inline shadow restrict'), - onlyShadow: icon('#iD-turn-shadow', 'inline shadow only'), - allowTurn: icon('#iD-turn-yes', 'inline turn'), - restrictTurn: icon('#iD-turn-no', 'inline turn'), - onlyTurn: icon('#iD-turn-only', 'inline turn') + distField: { html: t.html('restriction.controls.distance') }, + viaField: { html: t.html('restriction.controls.via') }, + fromShadow: { html: icon('#iD-turn-shadow', 'inline shadow from') }, + allowShadow: { html: icon('#iD-turn-shadow', 'inline shadow allow') }, + restrictShadow: { html: icon('#iD-turn-shadow', 'inline shadow restrict') }, + onlyShadow: { html: icon('#iD-turn-shadow', 'inline shadow only') }, + allowTurn: { html: icon('#iD-turn-yes', 'inline turn') }, + restrictTurn: { html: icon('#iD-turn-no', 'inline turn') }, + onlyTurn: { html: icon('#iD-turn-only', 'inline turn') } }; diff --git a/modules/ui/fields/combo.js b/modules/ui/fields/combo.js index 349803617..a80ad1445 100644 --- a/modules/ui/fields/combo.js +++ b/modules/ui/fields/combo.js @@ -527,13 +527,13 @@ export function uiFieldCombo(field, context) { } chips.select('span') - .html(function(d) { return d.value; }); + .text(function(d) { return d.value; }); chips.select('a') .attr('href', '#') .on('click', removeMultikey) .attr('class', 'remove') - .html('×'); + .text('×'); } else { var isMixed = Array.isArray(tags[field.key]); diff --git a/modules/ui/fields/lanes.js b/modules/ui/fields/lanes.js index d442678f9..61297df9c 100644 --- a/modules/ui/fields/lanes.js +++ b/modules/ui/fields/lanes.js @@ -77,7 +77,7 @@ export function uiFieldLanes(field, context) { .append('text') .attr('y', 40) .attr('x', 14) - .html('▲'); + .text('▲'); enter .append('g') @@ -85,7 +85,7 @@ export function uiFieldLanes(field, context) { .append('text') .attr('y', 40) .attr('x', 14) - .html('▲▼'); + .text('▲▼'); enter .append('g') @@ -93,7 +93,7 @@ export function uiFieldLanes(field, context) { .append('text') .attr('y', 40) .attr('x', 14) - .html('▼'); + .text('▼'); lane = lane diff --git a/modules/ui/improveOSM_comments.js b/modules/ui/improveOSM_comments.js index c00493056..92bdefc91 100644 --- a/modules/ui/improveOSM_comments.js +++ b/modules/ui/improveOSM_comments.js @@ -55,7 +55,7 @@ export function uiImproveOsmComments() { .attr('target', '_blank'); } selection - .html(d => d.username); + .text(d => d.username); }); metadataEnter @@ -67,7 +67,7 @@ export function uiImproveOsmComments() { .append('div') .attr('class', 'comment-text') .append('p') - .html(d => d.text); + .text(d => d.text); }) .catch(err => { console.log(err); // eslint-disable-line no-console diff --git a/modules/ui/improveOSM_details.js b/modules/ui/improveOSM_details.js index 9c64496d8..d7138e565 100644 --- a/modules/ui/improveOSM_details.js +++ b/modules/ui/improveOSM_details.js @@ -47,7 +47,7 @@ export function uiImproveOsmDetails(context) { descriptionEnter .append('div') .attr('class', 'qa-details-description-text') - .html(issueDetail); + .text(issueDetail); // If there are entity links in the error message.. let relatedEntities = []; diff --git a/modules/ui/improveOSM_header.js b/modules/ui/improveOSM_header.js index 4ad79e32a..1505cbe57 100644 --- a/modules/ui/improveOSM_header.js +++ b/modules/ui/improveOSM_header.js @@ -62,7 +62,7 @@ export function uiImproveOsmHeader() { headerEnter .append('div') .attr('class', 'qa-header-label') - .html(issueTitle); + .text(issueTitle); } improveOsmHeader.issue = function(val) { diff --git a/modules/ui/issues_info.js b/modules/ui/issues_info.js index efe830121..04f70348e 100644 --- a/modules/ui/issues_info.js +++ b/modules/ui/issues_info.js @@ -83,7 +83,7 @@ export function uiIssuesInfo(context) { enter.merge(chips) .selectAll('span.count') - .html(function(d) { + .text(function(d) { return d.count.toString(); }); } diff --git a/modules/ui/note_editor.js b/modules/ui/note_editor.js index bb1c7cadf..1f1a4e5d8 100644 --- a/modules/ui/note_editor.js +++ b/modules/ui/note_editor.js @@ -148,7 +148,7 @@ export function uiNoteEditor(context) { .append('h4') .attr('class', '.note-save-header') .html(function() { - return _note.isNew() ? t('note.newDescription') : t('note.newComment'); + return _note.isNew() ? t.html('note.newDescription') : t.html('note.newComment'); }); var commentTextarea = noteSaveEnter @@ -368,7 +368,7 @@ export function uiNoteEditor(context) { .html(function(d) { var action = (d.status === 'open' ? 'close' : 'open'); var andComment = (d.newComment ? '_comment' : ''); - return t('note.' + action + andComment); + return t.html('note.' + action + andComment); }) .on('click.status', clickStatus); diff --git a/modules/ui/note_header.js b/modules/ui/note_header.js index c496e5b8c..77dbc523c 100644 --- a/modules/ui/note_header.js +++ b/modules/ui/note_header.js @@ -49,9 +49,9 @@ export function uiNoteHeader() { .append('div') .attr('class', 'note-header-label') .html(function(d) { - if (_note.isNew()) { return t('note.new'); } - return t('note.note') + ' ' + d.id + ' ' + - (d.status === 'closed' ? t('note.closed') : ''); + if (_note.isNew()) { return t.html('note.new'); } + return t.html('note.note') + ' ' + d.id + ' ' + + (d.status === 'closed' ? t.html('note.closed') : ''); }); } diff --git a/modules/ui/osmose_details.js b/modules/ui/osmose_details.js index 2ad35eb12..1eed25485 100644 --- a/modules/ui/osmose_details.js +++ b/modules/ui/osmose_details.js @@ -140,7 +140,7 @@ export function uiOsmoseDetails(context) { .append('a') .attr('href', '#') .attr('class', 'error_entity_link') - .html(d => d) + .text(d => d) .each(function() { const link = d3_select(this); const entityID = this.textContent; diff --git a/modules/ui/osmose_header.js b/modules/ui/osmose_header.js index 8486df3a2..5932a0438 100644 --- a/modules/ui/osmose_header.js +++ b/modules/ui/osmose_header.js @@ -65,7 +65,7 @@ export function uiOsmoseHeader() { headerEnter .append('div') .attr('class', 'qa-header-label') - .html(issueTitle); + .text(issueTitle); } osmoseHeader.issue = function(val) { diff --git a/modules/ui/panels/background.js b/modules/ui/panels/background.js index 798a37e40..8ea6295f4 100644 --- a/modules/ui/panels/background.js +++ b/modules/ui/panels/background.js @@ -46,7 +46,7 @@ export function uiPanelBackground(context) { .html(t.html('info_panels.background.' + k) + ':') .append('span') .attr('class', 'background-info-span-' + k) - .html(_metadata[k]); + .text(_metadata[k]); }); debouncedGetMetadata(selection); @@ -110,7 +110,7 @@ export function uiPanelBackground(context) { selection.selectAll('.background-info-list-zoom') .classed('hide', false) .selectAll('.background-info-span-zoom') - .html(_metadata.zoom); + .text(_metadata.zoom); if (!d || !d.length >= 3) return; @@ -123,7 +123,7 @@ export function uiPanelBackground(context) { selection.selectAll('.background-info-list-vintage') .classed('hide', false) .selectAll('.background-info-span-vintage') - .html(_metadata.vintage); + .text(_metadata.vintage); // update other _metadata _metadataKeys.forEach(function(k) { @@ -133,7 +133,7 @@ export function uiPanelBackground(context) { selection.selectAll('.background-info-list-' + k) .classed('hide', !val) .selectAll('.background-info-span-' + k) - .html(val); + .text(val); }); }); } diff --git a/modules/ui/panels/history.js b/modules/ui/panels/history.js index fe96df751..03b16de35 100644 --- a/modules/ui/panels/history.js +++ b/modules/ui/panels/history.js @@ -40,7 +40,7 @@ export function uiPanelHistory(context) { .attr('class', 'user-osm-link') .attr('href', osm.userURL(userName)) .attr('target', '_blank') - .html('OSM'); + .text('OSM'); } links @@ -49,7 +49,7 @@ export function uiPanelHistory(context) { .attr('href', 'https://hdyc.neis-one.org/?' + userName) .attr('target', '_blank') .attr('tabindex', -1) - .html('HDYC'); + .text('HDYC'); } @@ -64,7 +64,7 @@ export function uiPanelHistory(context) { selection .append('span') .attr('class', 'changeset-id') - .html(changeset); + .text(changeset); var links = selection .append('div') @@ -76,7 +76,7 @@ export function uiPanelHistory(context) { .attr('class', 'changeset-osm-link') .attr('href', osm.changesetURL(changeset)) .attr('target', '_blank') - .html('OSM'); + .text('OSM'); } links @@ -84,14 +84,14 @@ export function uiPanelHistory(context) { .attr('class', 'changeset-osmcha-link') .attr('href', 'https://osmcha.org/changesets/' + changeset) .attr('target', '_blank') - .html('OSMCha'); + .text('OSMCha'); links .append('a') .attr('class', 'changeset-achavi-link') .attr('href', 'https://overpass-api.de/achavi/?changeset=' + changeset) .attr('target', '_blank') - .html('Achavi'); + .text('Achavi'); } @@ -101,7 +101,7 @@ export function uiPanelHistory(context) { var selected, note, entity; if (selectedNoteID && osm) { // selected 1 note - selected = [ t('note.note') + ' ' + selectedNoteID ]; + selected = [ t.html('note.note') + ' ' + selectedNoteID ]; note = osm.getNote(selectedNoteID); } else { // selected 1..n entities selected = context.selectedIDs() @@ -145,14 +145,14 @@ export function uiPanelHistory(context) { .append('li') .html(t.html('info_panels.history.note_comments') + ':') .append('span') - .html(note.comments.length); + .text(note.comments.length); if (note.comments.length) { list .append('li') .html(t.html('info_panels.history.note_created_date') + ':') .append('span') - .html(displayTimestamp(note.comments[0].date)); + .text(displayTimestamp(note.comments[0].date)); list .append('li') @@ -192,7 +192,7 @@ export function uiPanelHistory(context) { .attr('href', osm.historyURL(entity)) .attr('target', '_blank') .attr('title', t('info_panels.history.link_text')) - .html('OSM'); + .text('OSM'); } links .append('a') @@ -200,7 +200,7 @@ export function uiPanelHistory(context) { .attr('href', 'https://pewu.github.io/osm-history/#/' + entity.type + '/' + entity.osmId()) .attr('target', '_blank') .attr('tabindex', -1) - .html('PeWu'); + .text('PeWu'); var list = selection .append('ul'); @@ -209,13 +209,13 @@ export function uiPanelHistory(context) { .append('li') .html(t.html('info_panels.history.version') + ':') .append('span') - .html(entity.version); + .text(entity.version); list .append('li') .html(t.html('info_panels.history.last_edit') + ':') .append('span') - .html(displayTimestamp(entity.timestamp)); + .text(displayTimestamp(entity.timestamp)); list .append('li') diff --git a/modules/ui/panels/location.js b/modules/ui/panels/location.js index a40017a59..f2b3548d5 100644 --- a/modules/ui/panels/location.js +++ b/modules/ui/panels/location.js @@ -23,15 +23,15 @@ export function uiPanelLocation(context) { list .append('li') - .html(dmsCoordinatePair(coord)) + .text(dmsCoordinatePair(coord)) .append('li') - .html(decimalCoordinatePair(coord)); + .text(decimalCoordinatePair(coord)); // Location Info selection .append('div') .attr('class', 'location-info') - .html(currLocation || ' '); + .text(currLocation || ' '); debouncedGetLocation(selection, coord); } @@ -42,12 +42,12 @@ export function uiPanelLocation(context) { if (!services.geocoder) { currLocation = t('info_panels.location.unknown_location'); selection.selectAll('.location-info') - .html(currLocation); + .text(currLocation); } else { services.geocoder.reverse(coord, function(err, result) { currLocation = result ? result.display_name : t('info_panels.location.unknown_location'); selection.selectAll('.location-info') - .html(currLocation); + .text(currLocation); }); } } diff --git a/modules/ui/panels/measurement.js b/modules/ui/panels/measurement.js index 9424bae28..52f71e816 100644 --- a/modules/ui/panels/measurement.js +++ b/modules/ui/panels/measurement.js @@ -52,7 +52,7 @@ export function uiPanelMeasurement(context) { if (selectedNoteID && osm) { // selected 1 note var note = osm.getNote(selectedNoteID); - heading = t('note.note') + ' ' + selectedNoteID; + heading = t.html('note.note') + ' ' + selectedNoteID; location = note.loc; geometry = 'note'; @@ -65,7 +65,7 @@ export function uiPanelMeasurement(context) { }); heading = selected.length === 1 ? selected[0].id : - t('info_panels.selected', { n: selected.length }); + t.html('info_panels.selected', { n: selected.length }); if (selected.length) { var extent = geoExtent(); @@ -132,7 +132,7 @@ export function uiPanelMeasurement(context) { .html(t.html('info_panels.measurement.geometry') + ':') .append('span') .html( - closed ? t('info_panels.measurement.closed_' + geometry) : t('geometry.' + geometry) + closed ? t('info_panels.measurement.closed_' + geometry) : t.html('geometry.' + geometry) ); } @@ -141,7 +141,7 @@ export function uiPanelMeasurement(context) { .append('li') .html(t.html('info_panels.measurement.node_count') + ':') .append('span') - .html(totalNodeCount.toLocaleString(localeCode)); + .text(totalNodeCount.toLocaleString(localeCode)); } if (area) { @@ -149,7 +149,7 @@ export function uiPanelMeasurement(context) { .append('li') .html(t.html('info_panels.measurement.area') + ':') .append('span') - .html(displayArea(area, _isImperial)); + .text(displayArea(area, _isImperial)); } if (length) { @@ -157,7 +157,7 @@ export function uiPanelMeasurement(context) { .append('li') .html(t.html('info_panels.measurement.' + (closed ? 'perimeter' : 'length')) + ':') .append('span') - .html(displayLength(length, _isImperial)); + .text(displayLength(length, _isImperial)); } if (typeof distance === 'number') { @@ -165,7 +165,7 @@ export function uiPanelMeasurement(context) { .append('li') .html(t.html('info_panels.measurement.distance') + ':') .append('span') - .html(displayLength(distance, _isImperial)); + .text(displayLength(distance, _isImperial)); } if (location) { @@ -173,9 +173,9 @@ export function uiPanelMeasurement(context) { .append('li') .html(t.html('info_panels.measurement.location') + ':'); coordItem.append('span') - .html(dmsCoordinatePair(location)); + .text(dmsCoordinatePair(location)); coordItem.append('span') - .html(decimalCoordinatePair(location)); + .text(decimalCoordinatePair(location)); } if (centroid) { @@ -183,9 +183,9 @@ export function uiPanelMeasurement(context) { .append('li') .html(t.html('info_panels.measurement.centroid') + ':'); coordItem.append('span') - .html(dmsCoordinatePair(centroid)); + .text(dmsCoordinatePair(centroid)); coordItem.append('span') - .html(decimalCoordinatePair(centroid)); + .text(decimalCoordinatePair(centroid)); } if (center) { @@ -193,9 +193,9 @@ export function uiPanelMeasurement(context) { .append('li') .html(t.html('info_panels.measurement.center') + ':'); coordItem.append('span') - .html(dmsCoordinatePair(center)); + .text(dmsCoordinatePair(center)); coordItem.append('span') - .html(decimalCoordinatePair(center)); + .text(decimalCoordinatePair(center)); } if (length || area || typeof distance === 'number') { diff --git a/modules/ui/preset_list.js b/modules/ui/preset_list.js index 84a833c76..606251cdd 100644 --- a/modules/ui/preset_list.js +++ b/modules/ui/preset_list.js @@ -96,13 +96,13 @@ export function uiPresetList(context) { var results, messageText; if (value.length) { results = presets.search(value, entityGeometries()[0], _currLoc); - messageText = t('inspector.results', { + messageText = t.html('inspector.results', { n: results.collection.length, search: value }); } else { results = presetManager.defaults(entityGeometries()[0], 36, !context.inIntro(), _currLoc); - messageText = t('inspector.choose'); + messageText = t.html('inspector.choose'); } list.call(drawList, results); message.html(messageText); diff --git a/modules/ui/scale.js b/modules/ui/scale.js index 40c7d0a80..c558e7ee4 100644 --- a/modules/ui/scale.js +++ b/modules/ui/scale.js @@ -55,7 +55,7 @@ export function uiScale(context) { selection.select('.scale-text') .style(localizer.textDirection() === 'ltr' ? 'left' : 'right', (scale.px + 16) + 'px') - .html(scale.text); + .text(scale.text); } diff --git a/modules/ui/sections/background_display_options.js b/modules/ui/sections/background_display_options.js index 2e3a44714..faa3e5955 100644 --- a/modules/ui/sections/background_display_options.js +++ b/modules/ui/sections/background_display_options.js @@ -119,7 +119,7 @@ export function uiSectionBackgroundDisplayOptions(context) { .property('value', function(d) { return _options[d]; }); container.selectAll('.display-option-value') - .html(function(d) { return Math.floor(_options[d] * 100) + '%'; }); + .text(function(d) { return Math.floor(_options[d] * 100) + '%'; }); container.selectAll('.display-option-reset') .classed('disabled', function(d) { return _options[d] === 1; }); diff --git a/modules/ui/sections/changes.js b/modules/ui/sections/changes.js index bad671b1c..339ba1339 100644 --- a/modules/ui/sections/changes.js +++ b/modules/ui/sections/changes.js @@ -29,7 +29,7 @@ export function uiSectionChanges(context) { .label(function() { var history = context.history(); var summary = history.difference().summary(); - return t('inspector.title_count', { title: t.html('commit.changes'), count: summary.length }); + return t.html('inspector.title_count', { title: t('commit.changes'), count: summary.length }); }) .disclosureContent(renderDisclosureContent); @@ -79,7 +79,7 @@ export function uiSectionChanges(context) { buttons .append('strong') .attr('class', 'entity-type') - .html(function(d) { + .text(function(d) { var matched = presetManager.match(d.entity, d.graph); return (matched && matched.name()) || utilDisplayType(d.entity.id); }); @@ -87,7 +87,7 @@ export function uiSectionChanges(context) { buttons .append('span') .attr('class', 'entity-name') - .html(function(d) { + .text(function(d) { var name = utilDisplayName(d.entity) || '', string = ''; if (name !== '') { diff --git a/modules/ui/sections/data_layers.js b/modules/ui/sections/data_layers.js index cb9f4b2f6..463ca83e7 100644 --- a/modules/ui/sections/data_layers.js +++ b/modules/ui/sections/data_layers.js @@ -217,7 +217,7 @@ export function uiSectionDataLayers(context) { containerEnter .append('h4') .attr('class', 'vectortile-header') - .html('Detroit Vector Tiles (Beta)'); + .text('Detroit Vector Tiles (Beta)'); containerEnter .append('ul') @@ -231,7 +231,7 @@ export function uiSectionDataLayers(context) { .call(svgIcon('#iD-icon-out-link', 'inline')) .attr('href', 'https://github.com/osmus/detroit-mapping-challenge') .append('span') - .html('About these layers'); + .text('About these layers'); container = container .merge(containerEnter); @@ -265,7 +265,7 @@ export function uiSectionDataLayers(context) { labelEnter .append('span') - .html(function(d) { return d.name; }); + .text(function(d) { return d.name; }); // Update li diff --git a/modules/ui/sections/entity_issues.js b/modules/ui/sections/entity_issues.js index 5ca2d1de7..13f11d49f 100644 --- a/modules/ui/sections/entity_issues.js +++ b/modules/ui/sections/entity_issues.js @@ -24,7 +24,7 @@ export function uiSectionEntityIssues(context) { return _issues.length > 0; }) .label(function() { - return t('inspector.title_count', { title: t.html('issues.list_title'), count: _issues.length }); + return t.html('inspector.title_count', { title: t('issues.list_title'), count: _issues.length }); }) .disclosureContent(renderDisclosureContent); diff --git a/modules/ui/sections/raw_member_editor.js b/modules/ui/sections/raw_member_editor.js index 5f52dcfc9..44c40a6c3 100644 --- a/modules/ui/sections/raw_member_editor.js +++ b/modules/ui/sections/raw_member_editor.js @@ -33,7 +33,7 @@ export function uiSectionRawMemberEditor(context) { var gt = entity.members.length > _maxMembers ? '>' : ''; var count = gt + entity.members.slice(0, _maxMembers).length; - return t('inspector.title_count', { title: t.html('inspector.members'), count: count }); + return t.html('inspector.title_count', { title: t('inspector.members'), count: count }); }) .disclosureContent(renderDisclosureContent); @@ -190,7 +190,7 @@ export function uiSectionRawMemberEditor(context) { labelLink .append('span') .attr('class', 'member-entity-type') - .html(function(d) { + .text(function(d) { var matched = presetManager.match(d.member, context.graph()); return (matched && matched.name()) || utilDisplayType(d.member.id); }); @@ -198,7 +198,7 @@ export function uiSectionRawMemberEditor(context) { labelLink .append('span') .attr('class', 'member-entity-name') - .html(function(d) { return utilDisplayName(d.member); }); + .text(function(d) { return utilDisplayName(d.member); }); label .append('button') diff --git a/modules/ui/sections/raw_membership_editor.js b/modules/ui/sections/raw_membership_editor.js index 9dc566835..fec8414a1 100644 --- a/modules/ui/sections/raw_membership_editor.js +++ b/modules/ui/sections/raw_membership_editor.js @@ -341,15 +341,15 @@ export function uiSectionRawMembershipEditor(context) { labelLink .append('span') .attr('class', 'member-entity-type') - .html(function(d) { + .text(function(d) { var matched = presetManager.match(d.relation, context.graph()); - return (matched && matched.name()) || t('inspector.relation'); + return (matched && matched.name()) || t.html('inspector.relation'); }); labelLink .append('span') .attr('class', 'member-entity-name') - .html(function(d) { return utilDisplayName(d.relation); }); + .text(function(d) { return utilDisplayName(d.relation); }); labelEnter .append('button') diff --git a/modules/ui/sections/selection_list.js b/modules/ui/sections/selection_list.js index 2fea9fcbe..fcea89e68 100644 --- a/modules/ui/sections/selection_list.js +++ b/modules/ui/sections/selection_list.js @@ -116,10 +116,10 @@ export function uiSectionSelectionList(context) { }); items.selectAll('.entity-type') - .html(function(entity) { return presetManager.match(entity, context.graph()).name(); }); + .text(function(entity) { return presetManager.match(entity, context.graph()).name(); }); items.selectAll('.entity-name') - .html(function(d) { + .text(function(d) { // fetch latest entity var entity = context.entity(d.id); return utilDisplayName(entity); diff --git a/modules/ui/sections/validation_rules.js b/modules/ui/sections/validation_rules.js index d8fbd5864..c44f625aa 100644 --- a/modules/ui/sections/validation_rules.js +++ b/modules/ui/sections/validation_rules.js @@ -104,7 +104,7 @@ export function uiSectionValidationRules(context) { .html(function(d) { var params = {}; if (d === 'unsquare_way') { - params.val = ''; + params.val = { html: '' }; } return t.html('issues.' + d + '.title', params); }); diff --git a/modules/ui/sections/validation_status.js b/modules/ui/sections/validation_status.js index 1aa7d9df6..9c0f6b1ca 100644 --- a/modules/ui/sections/validation_status.js +++ b/modules/ui/sections/validation_status.js @@ -78,7 +78,7 @@ export function uiSectionValidationStatus(context) { .merge(resetIgnoredEnter); resetIgnored.select('a') - .html(t('inspector.title_count', { title: t.html('issues.reset_ignored'), count: ignoredIssues.length })); + .html(t.html('inspector.title_count', { title: t('issues.reset_ignored'), count: ignoredIssues.length })); resetIgnored.on('click', function(d3_event) { d3_event.preventDefault(); diff --git a/modules/ui/shortcuts.js b/modules/ui/shortcuts.js index df50176f5..f0e310bd6 100644 --- a/modules/ui/shortcuts.js +++ b/modules/ui/shortcuts.js @@ -152,11 +152,11 @@ export function uiShortcuts(context) { selection .append('kbd') .attr('class', 'modifier') - .html(function (d) { return uiCmd.display(d); }); + .text(function (d) { return uiCmd.display(d); }); selection .append('span') - .html('+'); + .text('+'); }); @@ -201,7 +201,7 @@ export function uiShortcuts(context) { selection .append('kbd') .attr('class', 'shortcut') - .html(function (d) { return d.shortcut; }); + .text(function (d) { return d.shortcut; }); } if (i < nodes.length - 1) { @@ -211,7 +211,7 @@ export function uiShortcuts(context) { } else if (i === nodes.length - 1 && d.suffix) { selection .append('span') - .html(d.suffix); + .text(d.suffix); } }); @@ -223,7 +223,7 @@ export function uiShortcuts(context) { selection .append('span') - .html('+'); + .text('+'); selection .append('span') diff --git a/modules/ui/success.js b/modules/ui/success.js index 719b4a677..568b55f47 100644 --- a/modules/ui/success.js +++ b/modules/ui/success.js @@ -292,7 +292,7 @@ export function uiSuccess(context) { .select('.hide-toggle') .append('span') .attr('class', 'badge-text') - .html(nextEvents.length); + .text(nextEvents.length); } @@ -342,7 +342,7 @@ export function uiSuccess(context) { .append('a') .attr('target', '_blank') .attr('href', d => d.url) - .html(d => { + .text(d => { let name = d.name; if (d.i18n && d.id) { name = t(`community.${communityID}.events.${d.id}.name`, { default: name }); @@ -353,7 +353,7 @@ export function uiSuccess(context) { itemEnter .append('div') .attr('class', 'community-event-when') - .html(d => { + .text(d => { let options = { weekday: 'short', day: 'numeric', month: 'short', year: 'numeric' }; if (d.date.getHours() || d.date.getMinutes()) { // include time if it has one options.hour = 'numeric'; @@ -365,7 +365,7 @@ export function uiSuccess(context) { itemEnter .append('div') .attr('class', 'community-event-where') - .html(d => { + .text(d => { let where = d.where; if (d.i18n && d.id) { where = t(`community.${communityID}.events.${d.id}.where`, { default: where }); @@ -376,7 +376,7 @@ export function uiSuccess(context) { itemEnter .append('div') .attr('class', 'community-event-description') - .html(d => { + .text(d => { let description = d.description; if (d.i18n && d.id) { description = t(`community.${communityID}.events.${d.id}.description`, { default: description }); diff --git a/modules/ui/tools/save.js b/modules/ui/tools/save.js index a277f6379..ceff49c42 100644 --- a/modules/ui/tools/save.js +++ b/modules/ui/tools/save.js @@ -67,7 +67,7 @@ export function uiToolSave(context) { .style('background', bgColor(_numChanges)); button.select('span.count') - .html(_numChanges); + .text(_numChanges); } } @@ -112,7 +112,7 @@ export function uiToolSave(context) { .append('span') .attr('class', 'count') .attr('aria-hidden', 'true') - .html('0'); + .text('0'); updateCount(); diff --git a/modules/ui/tools/undo_redo.js b/modules/ui/tools/undo_redo.js index b38cdfbdf..d8b7b4e5d 100644 --- a/modules/ui/tools/undo_redo.js +++ b/modules/ui/tools/undo_redo.js @@ -85,8 +85,8 @@ export function uiToolUndoRedo(context) { // there are no tooltips for touch interactions so flash feedback instead var text = annotation ? - t(d.id + '.tooltip', { action: annotation }) : - t(d.id + '.nothing'); + t.html(d.id + '.tooltip', { action: annotation }) : + t.html(d.id + '.nothing'); context.ui().flash .duration(2000) .iconName('#' + d.icon) diff --git a/modules/ui/version.js b/modules/ui/version.js index a8b29eda5..7acbbb6ac 100644 --- a/modules/ui/version.js +++ b/modules/ui/version.js @@ -32,7 +32,7 @@ export function uiVersion(context) { .append('a') .attr('target', '_blank') .attr('href', 'https://github.com/openstreetmap/iD') - .html(currVersion); + .text(currVersion); // only show new version indicator to users that have used iD before if (isNewVersion && !isNewUser) {