diff --git a/src/infotemplates.js b/src/infotemplates.js index da8cbce..6d8c12b 100644 --- a/src/infotemplates.js +++ b/src/infotemplates.js @@ -10,7 +10,11 @@ define(function(require, exports) { list: Handlebars.compile(''), directions: Handlebars.compile('{{title}}'), simple: Handlebars.compile('{{text}}'), - phone_numbers: Handlebars.compile('{{text}}'), + phone_numbers: Handlebars.compile( + '{{#if secondValue}}{{text}}
' + + '{{secondValue}}' + + '{{else}}{{text}}{{/if}}' + ), popup: Handlebars.compile('
{{#popup}}
{{{rendered}}}
{{/popup}}
') }; var formatters = { @@ -41,6 +45,17 @@ define(function(require, exports) { }, phone_numbers: function(value) { + if(value.length > 12) { + var regex = new RegExp("\\+?\\(?\\d*\\)? ?\\(?\\d+\\)?\\d*([\\s./-]?\\d{2,})+", + "g"); + var firstValue = regex.exec(value); + var secondValue = regex.exec(value); + value = firstValue[0]; + if(secondValue[0].length >= 12) { + return templates.phone_numbers({text: value, + secondValue: secondValue[0]}); + } + } return templates.phone_numbers({text: value}); },