var WarningsRenderer = {}; // renders a Wikibase entity into a link WarningsRenderer._renderEntity = function(entity) { if (!entity.id && entity.value) { entity.id = entity.value.id; } var id = entity.id; var is_new = entity.siteIri == "http://localhost/entity/"; if (is_new) { id = $.i18n._('wikidata-preview')['new-id']; } var fullLabel = id; if (entity.label) { fullLabel = entity.label + ' (' + id + ')'; } var url = entity.iri; if (!url && entity.value) { url = 'http://www.wikidata.org/entity/'+entity.value.id; } if (is_new) { return ''+fullLabel+''; } else { return ''+fullLabel+''; } } // replaces the issue properties in localization template WarningsRenderer._replaceIssueProperties = function(template, properties) { if (!properties) { return template; } var expanded = template; for (var key in properties) { if (properties.hasOwnProperty(key)) { var rendered = properties[key]; if (key.endsWith('_entity')) { rendered = WarningsRenderer._renderEntity(properties[key]); } expanded = expanded.replace(new RegExp('{'+key+'}', 'g'), rendered); } } return expanded; } WarningsRenderer._renderWarning = function(warning) { var localized = $.i18n._('warnings-messages')[warning.type]; var title = warning.type; var body = ""; if (localized) { title = WarningsRenderer._replaceIssueProperties(localized.title, warning.properties); body = WarningsRenderer._replaceIssueProperties(localized.body, warning.properties); } var tr = $('