1app.filter('tel', function () { 2 return function (tel) { 3 if (!tel) { return ''; } 4 5 var value = tel.toString().trim().replace(/^\+/, ''); 6 7 if (value.match(/[^0-9]/)) { 8 return tel; 9 } 10 11 var country, city, number; 12 13 switch (value.length) { 14 case 10: // +1PPP####### -> C (PPP) ###-#### 15 country = 1; 16 city = value.slice(0, 3); 17 number = value.slice(3); 18 break; 19 20 case 11: // +CPPP####### -> CCC (PP) ###-#### 21 country = value[0]; 22 city = value.slice(1, 4); 23 number = value.slice(4); 24 break; 25 26 case 12: // +CCCPP####### -> CCC (PP) ###-#### 27 country = value.slice(0, 3); 28 city = value.slice(3, 5); 29 number = value.slice(5); 30 break; 31 32 default: 33 return tel; 34 } 35 36 if (country == 1) { 37 country = ""; 38 } 39 40 number = number.slice(0, 3) + '-' + number.slice(3); 41 42 return (country + " (" + city + ") " + number).trim(); 43 }; 44});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.