mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-18 14:45:12 +02:00
updated: variable and function names, html regex
This commit is contained in:
committed by
Bryan Housel
parent
ed34d522ff
commit
d125c62c78
@@ -83,7 +83,7 @@ export default {
|
||||
_keepRightCache = { loaded: {}, inflight: {}, keepRight: {}, rtree: rbush()};
|
||||
},
|
||||
|
||||
loadKeepRight: function(context, projection, options, callback) {
|
||||
loadKeepRightErrors: function(context, projection, options, callback) {
|
||||
options = _extend({ 'format': 'geojson' }, options);
|
||||
if (_off) return;
|
||||
|
||||
|
||||
@@ -188,7 +188,7 @@ export function svgKeepRight(projection, context, dispatch) {
|
||||
ch: [0,30,40,50,70,90,100,110,120,130,150,160,170,180,191,192,193,194,195,196,197,198,201,202,203,204,205,206,207,208,210,220,231,232,270,281,282,283,284,285,291,292,293,294,295,296,297,298,311,312,313,320,350,370,380,401,402,411,412,413]
|
||||
};
|
||||
|
||||
service.loadKeepRight(context, projection, options, exampleCallback);
|
||||
service.loadKeepRightErrors(context, projection, options, exampleCallback);
|
||||
} else {
|
||||
editOff();
|
||||
}
|
||||
|
||||
@@ -11,11 +11,12 @@ export function uiKeepRightDetails(context) {
|
||||
var _templateErrorType;
|
||||
var _category;
|
||||
var _categoryElements;
|
||||
var _parent_error_type = '';
|
||||
var _parent_error_type;
|
||||
var _titleBase;
|
||||
|
||||
|
||||
function initDetails() {
|
||||
_parent_error_type = '';
|
||||
if (errorTypes.errors['_' + _error.error_type]) {
|
||||
_templateErrorType = '_' + _error.error_type;
|
||||
_template = errorTypes.errors[_templateErrorType];
|
||||
|
||||
@@ -50,7 +50,6 @@ var keepRightSchemaFromWeb = {
|
||||
'title': 'intersections without junctions, highway-waterway'
|
||||
};
|
||||
|
||||
// TODO: clean up description parsing some: remove or ignore spurious characters
|
||||
export function parseErrorDescriptions(entity) {
|
||||
if (!(entity instanceof krError)) return;
|
||||
|
||||
@@ -60,11 +59,12 @@ export function parseErrorDescriptions(entity) {
|
||||
if (!matchingTemplate) return;
|
||||
|
||||
// tokenize descriptions
|
||||
var errorDescriptions = entity.description.split(' ');
|
||||
var templateDescriptions = matchingTemplate.description.split(' ');
|
||||
var errorDescription = entity.description.split(' ');
|
||||
var templateDescription = matchingTemplate.description.split(' ');
|
||||
|
||||
var parsedDescriptions = [];
|
||||
var re = new RegExp(/{\$[0-9]}/);
|
||||
var variable_re = new RegExp(/{\$[0-9]}/);
|
||||
var html_re = new RegExp(/<\/[a-z][\s\S]*>/);
|
||||
|
||||
var commonEntities = ['node', 'way', 'relation', 'highway', 'cycleway', 'waterway', 'riverbank']; // TODO: expand this list, or implement a different translation function
|
||||
|
||||
@@ -85,26 +85,26 @@ export function parseErrorDescriptions(entity) {
|
||||
return result;
|
||||
}
|
||||
|
||||
templateDescriptions.forEach(function(word, index) {
|
||||
if (!re.test(word)) return;
|
||||
templateDescription.forEach(function(word, index) {
|
||||
if (!variable_re.test(word)) return;
|
||||
|
||||
// get the word at this index, and at the next index value
|
||||
var nextWord = templateDescriptions[index + 1] ? templateDescriptions[index + 1] : null;
|
||||
var nextWord = templateDescription[index + 1] ? templateDescription[index + 1] : null;
|
||||
|
||||
var parsedPhrase = '';
|
||||
|
||||
// parse error description words
|
||||
for (var i = index; i <= errorDescriptions.length - 1; i++) {
|
||||
if (errorDescriptions[i] !== nextWord) {
|
||||
var currWord = errorDescriptions[i];
|
||||
for (var i = index; i <= errorDescription.length - 1; i++) {
|
||||
if (errorDescription[i] !== nextWord) {
|
||||
var currWord = errorDescription[i];
|
||||
|
||||
// strip leading # if present
|
||||
if (currWord.charAt(0) === '#' || errorDescriptions[i-1] === '(id') {
|
||||
// select just numeric part of id
|
||||
if (currWord.charAt(0) === '#' || errorDescription[i-1] === '(id') { // NOTE: hacky way of selecting the token before
|
||||
currWord = currWord.replace(/\D/g,'');
|
||||
|
||||
// get the entity type of the id
|
||||
var lastWord = errorDescriptions[i-1];
|
||||
var secondLastWord = errorDescriptions[i-2];
|
||||
var lastWord = errorDescription[i-1];
|
||||
var secondLastWord = errorDescription[i-2];
|
||||
var base;
|
||||
if (lastWord) { base = getEntityBase(lastWord) || getEntityBase(secondLastWord); }
|
||||
if (!base) {
|
||||
@@ -120,9 +120,13 @@ export function parseErrorDescriptions(entity) {
|
||||
currWord = t('QA.keepRight.entities.' + currWord);
|
||||
}
|
||||
|
||||
// add phrase (or single word) to variable list
|
||||
parsedPhrase += currWord;
|
||||
}
|
||||
// add phrase (or single word) to variable list
|
||||
// if any variables have html, escape them
|
||||
if (html_re.test(parsedPhrase)) {
|
||||
parsedPhrase = '\\' + parsedPhrase + '\\';
|
||||
}
|
||||
parsedDescriptions.push(parsedPhrase);
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user