1/* 2intl-tel-input 3version: 0.9.2 4description: A jQuery plugin for entering international telephone numbers 5repository: https://github.com/Bluefieldscom/intl-tel-input.git 6license: MIT 7author: Jack O'Connor (http://jackocnr.com) 8*/ 9(function($, window, document, undefined) { 10 var pluginName = "intlTelInput", defaults = { 11 preferredCountries: [ "us", "gb" ], 12 // united states and united kingdom 13 initialDialCode: true, 14 americaMode: false, 15 onlyCountries: [] 16 }; 17 function Plugin(element, options) { 18 this.element = element; 19 this.options = $.extend({}, defaults, options); 20 this._defaults = defaults; 21 this._name = pluginName; 22 this.init(); 23 } 24 Plugin.prototype = { 25 init: function() { 26 var that = this; 27 // process onlyCountries array and update intlTelInput.countries 28 // and intlTelInput.countryCodes accordingly 29 if (this.options.onlyCountries.length > 0) { 30 var newCountries = [], newCountryCodes = {}; 31 $.each(this.options.onlyCountries, function(i, countryCode) { 32 var countryData = that._getCountryData(countryCode); 33 if (countryData) { 34 newCountries.push(countryData); 35 var callingCode = countryData["calling-code"]; 36 if (newCountryCodes[callingCode]) { 37 newCountryCodes[callingCode].push(countryCode); 38 } else { 39 newCountryCodes[callingCode] = [ countryCode ]; 40 } 41 } 42 }); 43 // update the global data object 44 intlTelInput.countries = newCountries; 45 intlTelInput.countryCodes = newCountryCodes; 46 } 47 // process preferred countries - iterate through the preferences, 48 // finding the relevant data from the provided intlTelInput.countries array 49 var preferredCountries = []; 50 $.each(this.options.preferredCountries, function(i, countryCode) { 51 var countryData = that._getCountryData(countryCode); 52 if (countryData) { 53 preferredCountries.push(countryData); 54 } 55 }); 56 this.defaultCountry = preferredCountries.length ? preferredCountries[0] : intlTelInput.countries[0]; 57 // telephone input 58 this.telInput = $(this.element); 59 // if initialDialCode is enabled, insert the default dial code 60 if (this.options.initialDialCode && this.telInput.val() === "") { 61 this.telInput.val("+" + this.defaultCountry["calling-code"] + " "); 62 } 63 // containers (mostly for positioning) 64 this.telInput.wrap($("<div>", { 65 "class": "intl-tel-input" 66 })); 67 var flagsContainer = $("<div>", { 68 "class": "flag-dropdown f16" 69 }).insertBefore(this.telInput); 70 // currently selected flag (displayed to left of input) 71 var selectedFlag = $("<div>", { 72 "class": "selected-flag" 73 }).appendTo(flagsContainer); 74 // here we default to the first country in the list 75 var firstCountry = this.defaultCountry.cca2; 76 this.selectedFlagInner = $("<div>", { 77 "class": "flag " + firstCountry 78 }).appendTo(selectedFlag); 79 // CSS triangle 80 $("<div>", { 81 "class": "down-arrow" 82 }).appendTo(this.selectedFlagInner); 83 // country list contains: preferred countries, then divider, then all countries 84 this.countryList = $("<ul>", { 85 "class": "country-list hide" 86 }).appendTo(flagsContainer); 87 if (preferredCountries.length) { 88 this._appendListItems(preferredCountries, "preferred"); 89 $("<li>", { 90 "class": "divider" 91 }).appendTo(this.countryList); 92 } 93 this._appendListItems(intlTelInput.countries, ""); 94 this.countryListItems = this.countryList.children(".country"); 95 // auto select the top one 96 this.countryListItems.first().addClass("active"); 97 // update flag on keyup 98 // (by extracting the dial code from the input value) 99 this.telInput.keyup(function() { 100 var countryCode, alreadySelected = false; 101 // try and extract valid dial code from input 102 var dialCode = that._getDialCode(that.telInput.val()); 103 if (dialCode) { 104 // check if one of the matching country's is already selected 105 var countryCodes = intlTelInput.countryCodes[dialCode]; 106 $.each(countryCodes, function(i, c) { 107 if (that.selectedFlagInner.hasClass(c)) { 108 alreadySelected = true; 109 } 110 }); 111 countryCode = countryCodes[0]; 112 } else { 113 countryCode = that.defaultCountry.cca2; 114 } 115 if (!alreadySelected) { 116 that._selectFlag(countryCode); 117 } 118 }); 119 // trigger it now in case there is already a number in the input 120 this.telInput.keyup(); 121 // toggle country dropdown on click 122 selectedFlag.click(function(e) { 123 // prevent the click-off-to-close listener from firing 124 e.stopPropagation(); 125 // toggle dropdown 126 if (that.countryList.hasClass("hide")) { 127 // update highlighting and scroll to active list item 128 that.countryListItems.removeClass("highlight"); 129 var activeListItem = that.countryList.children(".active").addClass("highlight"); 130 // show it 131 that.countryList.removeClass("hide"); 132 that._scrollTo(activeListItem); 133 // listen for typing 134 $(document).bind("keydown.intlTelInput", function(e) { 135 // up (38) and down (40) to navigate 136 if (e.which == 38 || e.which == 40) { 137 var current = that.countryList.children(".highlight").first(); 138 var next = e.which == 38 ? current.prev() : current.next(); 139 if (next) { 140 // skip the divider 141 if (next.hasClass("divider")) { 142 next = e.which == 38 ? next.prev() : next.next(); 143 } 144 that.countryListItems.removeClass("highlight"); 145 next.addClass("highlight"); 146 that._scrollTo(next); 147 } 148 } else if (e.which == 13) { 149 var currentCountry = that.countryList.children(".highlight").first(); 150 if (currentCountry.length) { 151 that._selectListItem(currentCountry); 152 } 153 } else if (e.which == 9 || e.which == 27) { 154 that._closeDropdown(); 155 } else if (e.which >= 97 && e.which <= 122 || e.which >= 65 && e.which <= 90) { 156 var letter = String.fromCharCode(e.which); 157 // filter out the countries beginning with that letter 158 var countries = that.countryListItems.filter(function() { 159 return $(this).text().charAt(0) == letter && !$(this).hasClass("preferred"); 160 }); 161 if (countries.length) { 162 // if one is already highlighted, then we want the next one 163 var highlightedCountry = countries.filter(".highlight").first(); 164 var listItem; 165 // if the next country in the list also starts with that letter 166 if (highlightedCountry && highlightedCountry.next() && highlightedCountry.next().text().charAt(0) == letter) { 167 listItem = highlightedCountry.next(); 168 } else { 169 listItem = countries.first(); 170 } 171 // update highlighting and scroll 172 that.countryListItems.removeClass("highlight"); 173 listItem.addClass("highlight"); 174 that._scrollTo(listItem); 175 } 176 } 177 }); 178 } else { 179 // close it 180 that._closeDropdown(); 181 } 182 }); 183 // when mouse over a list item, remove any highlighting from any other items 184 this.countryListItems.mouseover(function() { 185 that.countryListItems.removeClass("highlight"); 186 $(this).addClass("highlight"); 187 }); 188 // listen for country selection 189 this.countryListItems.click(function(e) { 190 var listItem = $(e.currentTarget); 191 that._selectListItem(listItem); 192 }); 193 // click off to close 194 $("html").click(function(e) { 195 if (!$(e.target).closest(".country-list").length) { 196 // close it 197 that._closeDropdown(); 198 } 199 }); 200 }, 201 // find the country data for the given country code 202 _getCountryData: function(countryCode) { 203 for (var i = 0; i < intlTelInput.countries.length; i++) { 204 if (intlTelInput.countries[i].cca2 == countryCode) { 205 return intlTelInput.countries[i];
206 } 207 } 208 }, 209 // update the selected flag and the active list item 210 _selectFlag: function(countryCode) { 211 this.selectedFlagInner.attr("class", "flag " + countryCode); 212 // and the active list item 213 this.countryListItems.removeClass("active"); 214 var listItem = this.countryListItems.children(".flag." + countryCode).parent(); 215 listItem.addClass("active"); 216 return listItem; 217 }, 218 // update the selected flag, and insert the dial code 219 selectCountry: function(countryCode) { 220 // check if already selected 221 if (!this.selectedFlagInner.hasClass(countryCode)) { 222 var listItem = this._selectFlag(countryCode); 223 var dialCode = listItem.attr("data-dial-code"); 224 this.telInput.val("+" + dialCode + " "); 225 } 226 }, 227 // called when the user selects a list item from the dropdown 228 _selectListItem: function(listItem) { 229 var countryCode = listItem.attr("data-country-code"); 230 // update selected flag 231 this.selectedFlagInner.attr("class", "flag " + countryCode); 232 // update input value 233 var newNumber = this._updateNumber(this.telInput.val(), listItem.attr("data-dial-code")); 234 this.telInput.val(newNumber); 235 // hide dropdown again 236 this._closeDropdown(); 237 // focus the input 238 this.telInput.focus(); 239 // mark the list item as active (incase they open the dropdown again) 240 this.countryListItems.removeClass("active highlight"); 241 listItem.addClass("active"); 242 }, 243 // close the dropdown and unbind any listeners 244 _closeDropdown: function() { 245 this.countryList.addClass("hide"); 246 $(document).unbind("keydown.intlTelInput"); 247 }, 248 // check if an element is visible within it's container, else scroll until it is 249 _scrollTo: function(element) { 250 var container = this.countryList; 251 var containerHeight = container.height(); 252 var containerTop = container.offset().top; 253 var containerBottom = containerTop + containerHeight; 254 var elementHeight = element.outerHeight(); 255 var elementTop = element.offset().top; 256 var elementBottom = elementTop + elementHeight; 257 var newScrollTop = elementTop - containerTop + container.scrollTop(); 258 if (elementTop < containerTop) { 259 // scroll up 260 container.scrollTop(newScrollTop); 261 } else if (elementBottom > containerBottom) { 262 // scroll down 263 var heightDifference = containerHeight - elementHeight; 264 container.scrollTop(newScrollTop - heightDifference); 265 } 266 }, 267 // replace any existing dial code with the new one 268 _updateNumber: function(inputVal, dialCode) { 269 var prevDialCode = "+" + this._getDialCode(inputVal); 270 var newDialCode = "+" + dialCode; 271 var newNumber; 272 // if the previous number contained a valid dial code, replace it 273 // (if more than just a plus character) 274 if (prevDialCode.length > 1) { 275 newNumber = inputVal.replace(prevDialCode, newDialCode); 276 // if the old number was just the dial code, 277 // then we will need to add the space again 278 if (inputVal == prevDialCode) { 279 newNumber += " "; 280 } 281 } else if (inputVal.length && inputVal.substr(0, 1) != "+") { 282 // previous number didn't contain a dial code, so persist it 283 newNumber = newDialCode + " " + inputVal.trim(); 284 } else { 285 // previous number contained an invalid dial code, so wipe it 286 newNumber = newDialCode + " "; 287 } 288 // if americaMode is enabled, we dont display the dial code for american numbers 289 if (this.options.americaMode && newNumber.substring(0, 3) == "+1 ") { 290 newNumber = newNumber.substring(3); 291 } 292 return newNumber; 293 }, 294 // try and extract a valid international dial code from a full telephone number 295 _getDialCode: function(inputVal) { 296 var firstPart = inputVal.trim().split(" ")[0]; 297 // only interested in international numbers (starting with a plus) 298 if (firstPart.substring(0, 1) == "+") { 299 // strip out non-numeric chars (e.g. pluses, space
299s, brackets) 300 // and grab the first 4 numbers (max length of a dial code is 4) 301 var dialCode = firstPart.replace(/\D/g, "").substring(0, 4); 302 // try first 4 digits, then 3, then 2, then 1... 303 for (var i = dialCode.length; i > 0; i--) { 304 dialCode = dialCode.substring(0, i); 305 // if we find a match (a valid dial code), then return the dial code 306 if (intlTelInput.countryCodes[dialCode]) { 307 return dialCode; 308 } 309 } 310 } 311 return ""; 312 }, 313 // add a country <li> to the countryList <ul> container 314 _appendListItems: function(countries, className) { 315 // we create so many DOM elements, I decided it was faster to build a temp string 316 // and then add everything to the DOM in one go at the end 317 var tmp = ""; 318 // for each country 319 $.each(countries, function(i, c) { 320 // open the list item 321 tmp += "<li class='country " + className + "' data-dial-code='" + c["calling-code"] + "' data-country-code='" + c.cca2 + "'>"; 322 // add the flag 323 tmp += "<div class='flag " + c.cca2 + "'></div>"; 324 // and the country name and dial code 325 tmp += "<span class='country-name'>" + c.name + "</span>"; 326 tmp += "<span class='dial-code'>+" + c["calling-code"] + "</span>"; 327 // close the list item 328 tmp += "</li>"; 329 }); 330 this.countryList.append(tmp); 331 } 332 }; 333 // adapted to allow public functions 334 // using https://github.com/jquery-boilerplate/jquery-boilerplate/wiki/Extending-jQuery-Boilerplate 335 $.fn[pluginName] = function(options) { 336 var args = arguments; 337 // Is the first parameter an object (options), or was omitted, 338 // instantiate a new instance of the plugin. 339 if (options === undefined || typeof options === "object") { 340 return this.each(function() { 341 if (!$.data(this, "plugin_" + pluginName)) { 342 $.data(this, "plugin_" + pluginName, new Plugin(this, options)); 343 } 344 }); 345 } else if (typeof options === "string" && options[0] !== "_" && options !== "init") { 346 // Cache the method call to make it possible to return a value 347 var returns; 348 this.each(function() { 349 var instance = $.data(this, "plugin_" + pluginName); 350 // Tests that there's already a plugin-instance 351 // and checks that the requested public method exists 352 if (instance instanceof Plugin && typeof instance[options] === "function") { 353 // Call the method of our plugin instance, 354 // and pass it the supplied arguments. 355 returns = instance[options].apply(instance, Array.prototype.slice.call(args, 1)); 356 } 357 }); 358 // If the earlier cached method gives a value back return the value, 359 // otherwise return this to preserve chainability. 360 return returns !== undefined ? returns : this; 361 } 362 }; 363})(jQuery, window, document); 364 365// Namespaced to prevent clashes 366var intlTelInput = { 367 // Array of country objects for the flag dropdown. 368 // Each contains a name, country code (ISO 3166-1 alpha-2) and dial code. 369 // Originally from https://github.com/mledoze/countries 370 // then stripped down by copying the JSON into Chrome dev tools and manipulating it 371 // and then using JSON.stringify to print it out as a string again and copy it here. 372 // Also commented some countries which we dont yet have flags for. 373 countries: [ { 374 name: "Afghanistan", 375 cca2: "af", 376 "calling-code": "93" 377 }, { 378 name: "Albania", 379 cca2: "al", 380 "calling-code": "355" 381 }, { 382 name: "Algeria", 383 cca2: "dz", 384 "calling-code": "213" 385 }, { 386 name: "American Samoa", 387 cca2: "as", 388 "calling-code": "1684" 389 }, { 390 name: "Andorra", 391 cca2: "ad", 392 "calling-code": "376" 393 }, { 394 name: "Angola", 395 cca2: "ao", 396 "calling-code": "244" 397 }, { 398 name: "Anguilla", 399 cca2: "ai",
400 "calling-code": "1264" 401 }, { 402 name: "Antigua and Barbuda", 403 cca2: "ag", 404 "calling-code": "1268" 405 }, { 406 name: "Argentina", 407 cca2: "ar", 408 "calling-code": "54" 409 }, { 410 name: "Armenia", 411 cca2: "am", 412 "calling-code": "374" 413 }, { 414 name: "Aruba", 415 cca2: "aw", 416 "calling-code": "297" 417 }, { 418 name: "Australia", 419 cca2: "au", 420 "calling-code": "61" 421 }, { 422 name: "Austria", 423 cca2: "at", 424 "calling-code": "43" 425 }, { 426 name: "Azerbaijan", 427 cca2: "az", 428 "calling-code": "994" 429 }, { 430 name: "Bahamas", 431 cca2: "bs", 432 "calling-code": "1242" 433 }, { 434 name: "Bahrain", 435 cca2: "bh", 436 "calling-code": "973" 437 }, { 438 name: "Bangladesh", 439 cca2: "bd", 440 "calling-code": "880" 441 }, { 442 name: "Barbados", 443 cca2: "bb", 444 "calling-code": "1246" 445 }, { 446 name: "Belarus", 447 cca2: "by", 448 "calling-code": "375" 449 }, { 450 name: "Belgium", 451 cca2: "be", 452 "calling-code": "32" 453 }, { 454 name: "Belize", 455 cca2: "bz", 456 "calling-code": "501" 457 }, { 458 name: "Benin", 459 cca2: "bj", 460 "calling-code": "229" 461 }, { 462 name: "Bermuda", 463 cca2: "bm", 464 "calling-code": "1441" 465 }, { 466 name: "Bhutan", 467 cca2: "bt", 468 "calling-code": "975" 469 }, { 470 name: "Bolivia", 471 cca2: "bo", 472 "calling-code": "591" 473 }, { 474 name: "Bosnia and Herzegovina", 475 cca2: "ba", 476 "calling-code": "387" 477 }, { 478 name: "Botswana", 479 cca2: "bw", 480 "calling-code": "267" 481 }, { 482 name: "Brazil", 483 cca2: "br", 484 "calling-code": "55" 485 }, { 486 name: "Brunei Darussalam", 487 cca2: "bn", 488 "calling-code": "673" 489 }, { 490 name: "Bulgaria", 491 cca2: "bg", 492 "calling-code": "359" 493 }, { 494 name: "Burkina Faso", 495 cca2: "bf", 496 "calling-code": "226" 497 }, { 498 name: "Burundi", 499 cca2: "bi", 500 "calling-code": "257" 501 }, { 502 name: "Cambodia", 503 cca2: "kh", 504 "calling-code": "855" 505 }, { 506 name: "Cameroon", 507 cca2: "cm", 508 "calling-code": "237" 509 }, { 510 name: "Canada", 511 cca2: "ca", 512 "calling-code": "1" 513 }, { 514 name: "Cape Verde", 515 cca2: "cv", 516 "calling-code": "238" 517 }, { 518 name: "Cayman Islands", 519 cca2: "ky", 520 "calling-code": "1345" 521 }, { 522 name: "Central African Republic", 523 cca2: "cf", 524 "calling-code": "236" 525 }, { 526 name: "Chad", 527 cca2: "td", 528 "calling-code": "235" 529 }, { 530 name: "Chile", 531 cca2: "cl", 532 "calling-code": "56" 533 }, { 534 name: "China", 535 cca2: "cn", 536 "calling-code": "86" 537 }, { 538 name: "Colombia", 539 cca2: "co", 540 "calling-code": "57" 541 }, { 542 name: "Comoros", 543 cca2: "km", 544 "calling-code": "269" 545 }, { 546 name: "Congo (DRC)", 547 cca2: "cd", 548 "calling-code": "243" 549 }, { 550 name: "Congo (Republic)", 551 cca2: "cg", 552 "calling-code": "242" 553 }, { 554 name: "Cook Islands", 555 cca2: "ck", 556 "calling-code": "682" 557 }, { 558 name: "Costa Rica", 559 cca2: "cr", 560 "calling-code": "506" 561 }, { 562 name: "Côte d'Ivoire", 563 cca2: "ci", 564 "calling-code": "225" 565 }, { 566 name: "Croatia", 567 cca2: "hr", 568 "calling-code": "385" 569 }, { 570 name: "Cuba", 571 cca2: "cu", 572 "calling-code": "53" 573 }, { 574 name: "Cyprus", 575 cca2: "cy", 576 "calling-code": "357" 577 }, { 578 name: "Czech Republic", 579 cca2: "cz", 580 "calling-code": "420" 581 }, { 582 name: "Denmark", 583 cca2: "dk", 584 "calling-code": "45" 585 }, { 586 name: "Djibouti", 587 cca2: "dj", 588 "calling-code": "253" 589 }, { 590 name: "Dominica", 591 cca2: "dm", 592 "calling-code": "1767" 593 }, { 594 name: "Dominican Republic", 595 cca2: "do", 596 "calling-code": "1809" 597 }, { 598 name: "Ecuador", 599 cca2: "ec", 600 "calling-code": "593" 601 }, { 602 name: "Egypt", 603 cca2: "eg", 604 "calling-code": "20" 605 }, { 606 name: "El Salvador", 607 cca2: "sv", 608 "calling-code": "503" 609 }, { 610 name: "Equatorial Guinea", 611 cca2: "gq", 612 "calling-code": "240" 613 }, { 614 name: "Eritrea", 615 cca2: "er", 616 "calling-code": "291" 617 }, { 618 name: "Estonia", 619 cca2: "ee", 620 "calling-code": "372" 621 }, { 622 name: "Ethiopia", 623 cca2: "et", 624 "calling-code": "251" 625 }, { 626 name: "Faroe Islands", 627 cca2: "fo", 628 "calling-code": "298" 629 }, { 630 name: "Fiji", 631 cca2: "fj", 632 "calling-code": "679" 633 }, { 634 name: "Finland", 635 cca2: "fi", 636 "calling-code": "358" 637 }, { 638 name: "France", 639 cca2: "fr", 640 "calling-code": "33" 641 }, { 642 name: "French Polynesia", 643 cca2: "pf", 644 "calling-code": "689"
645 }, { 646 name: "Gabon", 647 cca2: "ga", 648 "calling-code": "241" 649 }, { 650 name: "Gambia", 651 cca2: "gm", 652 "calling-code": "220" 653 }, { 654 name: "Georgia", 655 cca2: "ge", 656 "calling-code": "995" 657 }, { 658 name: "Germany", 659 cca2: "de", 660 "calling-code": "49" 661 }, { 662 name: "Ghana", 663 cca2: "gh", 664 "calling-code": "233" 665 }, { 666 name: "Gibraltar", 667 cca2: "gi", 668 "calling-code": "350" 669 }, { 670 name: "Greece", 671 cca2: "gr", 672 "calling-code": "30" 673 }, { 674 name: "Greenland", 675 cca2: "gl", 676 "calling-code": "299" 677 }, { 678 name: "Grenada", 679 cca2: "gd", 680 "calling-code": "1473" 681 }, { 682 name: "Guadeloupe", 683 cca2: "gp", 684 "calling-code": "590" 685 }, { 686 name: "Guam", 687 cca2: "gu", 688 "calling-code": "1671" 689 }, { 690 name: "Guatemala", 691 cca2: "gt", 692 "calling-code": "502" 693 }, { 694 name: "Guernsey", 695 cca2: "gg", 696 "calling-code": "44" 697 }, { 698 name: "Guinea", 699 cca2: "gn", 700 "calling-code": "224" 701 }, { 702 name: "Guinea-Bissau", 703 cca2: "gw", 704 "calling-code": "245" 705 }, { 706 name: "Guyana", 707 cca2: "gy", 708 "calling-code": "592" 709 }, { 710 name: "Haiti", 711 cca2: "ht", 712 "calling-code": "509" 713 }, { 714 name: "Honduras", 715 cca2: "hn", 716 "calling-code": "504" 717 }, { 718 name: "Hong Kong", 719 cca2: "hk", 720 "calling-code": "852" 721 }, { 722 name: "Hungary", 723 cca2: "hu", 724 "calling-code": "36" 725 }, { 726 name: "Iceland", 727 cca2: "is", 728 "calling-code": "354" 729 }, { 730 name: "India", 731 cca2: "in", 732 "calling-code": "91" 733 }, { 734 name: "Indonesia", 735 cca2: "id", 736 "calling-code": "62" 737 }, { 738 name: "Iran", 739 cca2: "ir", 740 "calling-code": "98" 741 }, { 742 name: "Iraq", 743 cca2: "iq", 744 "calling-code": "964" 745 }, { 746 name: "Ireland", 747 cca2: "ie", 748 "calling-code": "353" 749 }, { 750 name: "Isle of Man", 751 cca2: "im", 752 "calling-code": "44" 753 }, { 754 name: "Israel", 755 cca2: "il", 756 "calling-code": "972" 757 }, { 758 name: "Italy", 759 cca2: "it", 760 "calling-code": "39" 761 }, { 762 name: "Jamaica", 763 cca2: "jm", 764 "calling-code": "1876" 765 }, { 766 name: "Japan", 767 cca2: "jp", 768 "calling-code": "81" 769 }, { 770 name: "Jersey", 771 cca2: "je", 772 "calling-code": "44" 773 }, { 774 name: "Jordan", 775 cca2: "jo", 776 "calling-code": "962" 777 }, { 778 name: "Kazakhstan", 779 cca2: "kz", 780 "calling-code": "7" 781 }, { 782 name: "Kenya", 783 cca2: "ke", 784 "calling-code": "254" 785 }, { 786 name: "Kiribati", 787 cca2: "ki", 788 "calling-code": "686" 789 }, { 790 name: "Kuwait", 791 cca2: "kw", 792 "calling-code": "965" 793 }, { 794 name: "Kyrgyzstan", 795 cca2: "kg", 796 "calling-code": "996" 797 }, { 798 name: "Laos", 799 cca2: "la", 800 "calling-code": "856" 801 }, { 802 name: "Latvia", 803 cca2: "lv", 804 "calling-code": "371" 805 }, { 806 name: "Lebanon", 807 cca2: "lb", 808 "calling-code": "961" 809 }, { 810 name: "Lesotho", 811 cca2: "ls", 812 "calling-code": "266" 813 }, { 814 name: "Liberia", 815 cca2: "lr", 816 "calling-code": "231" 817 }, { 818 name: "Libya", 819 cca2: "ly", 820 "calling-code": "218" 821 }, { 822 name: "Liechtenstein", 823 cca2: "li", 824 "calling-code": "423" 825 }, { 826 name: "Lithuania", 827 cca2: "lt", 828 "calling-code": "370" 829 }, { 830 name: "Luxembourg", 831 cca2: "lu", 832 "calling-code": "352" 833 }, { 834 name: "Macao", 835 cca2: "mo", 836 "calling-code": "853" 837 }, { 838 name: "Macedonia", 839 cca2: "mk", 840 "calling-code": "389" 841 }, { 842 name: "Madagascar", 843 cca2: "mg", 844 "calling-code": "261" 845 }, { 846 name: "Malawi", 847 cca2: "mw", 848 "calling-code": "265" 849 }, { 850 name: "Malaysia", 851 cca2: "my", 852 "calling-code": "60" 853 }, { 854 name: "Maldives", 855 cca2: "mv", 856 "calling-code": "960" 857 }, { 858 name: "Mali", 859 cca2: "ml", 860 "calling-code": "223" 861 }, { 862 name: "Malta", 863 cca2: "mt", 864 "calling-code": "356" 865 }, { 866 name: "Marshall Islands", 867 cca2: "mh", 868 "calling-code": "692" 869 }, { 870 name: "Martinique", 871 cca2: "mq", 872 "calling-code": "596" 873 }, { 874 name: "Mauritania", 875 cca2: "mr", 876 "calling-code": "222" 877 }, { 878 name: "Mauritius", 879 cca2: "mu", 880 "calling-code": "230" 881 }, { 882 name: "Mexico", 883 cca2: "mx", 884 "calling-code": "52" 885 }, { 886 name: "Micronesia", 887 cca2: "fm", 888 "calling-code": "691" 889 }, { 890 name: "Moldova", 891 cca2: "md", 892 "calling-code": "373" 893 }, { 894 name: "Monaco", 895 cca2: "mc", 896 "calling-code": "377" 897 }, { 898 name: "Mongolia", 899 cca2: "mn", 900 "calling-code": "976" 901 }, { 902 name: "Montenegro", 903 cca2: "me", 904 "calling-code": "382" 905 }, { 906 name: "Montserrat", 907 cca2: "ms", 908 "calling-code": "1664" 909 }, { 910 name: "Morocco", 911 cca2: "ma", 912 "calling-code": "212" 913 }, { 914 name: "Mozambique", 915 cca2: "mz", 916 "calling-code": "258" 917 }, { 918 name: "Myanmar (Burma)", 919 cca2: "mm", 920 "calling-code": "95" 921 }, { 922 name: "Namibia", 923 cca2: "na", 924 "calling-code": "264" 925 }, { 926 name: "Nauru", 927 cca2: "nr", 928 "calling-code": "674" 929 }, { 930 name: "Nepal", 931 cca2: "np", 932 "calling-code": "977" 933 }, { 934 name: "Netherlands", 935 cca2: "nl", 936 "calling-code": "31" 937 }, { 938 name: "New Caledonia", 939 cca2: "nc", 940 "calling-code": "687" 941 }, { 942 name: "New Zealand", 943 cca2: "nz", 944 "calling-code": "64" 945 }, { 946 name: "Nicaragua", 947 cca2: "ni", 948 "calling-code": "505" 949 }, { 950 name: "Niger", 951 cca2: "ne", 952 "calling-code": "227" 953 }, { 954 name: "Nigeria", 955 cca2: "ng", 956 "calling-code": "234" 957 }, { 958 name: "North Korea", 959 cca2: "kp", 960 "calling-code": "850" 961 }, { 962 name: "Norway", 963 cca2: "no", 964 "calling-code": "47" 965 }, { 966 name: "Oman", 967 cca2: "om", 968 "calling-code": "968" 969 }, { 970 name: "Pakistan", 971 cca2: "pk", 972 "calling-code": "92" 973 }, { 974 name: "Palau", 975 cca2: "pw", 976 "calling-code": "680" 977 }, { 978 name: "Palestinian Territory", 979 cca2: "ps", 980 "calling-code": "970" 981 }, { 982 name: "Panama", 983 cca2: "pa", 984 "calling-code": "507" 985 }, { 986 name: "Papua New Guinea", 987 cca2: "pg", 988 "calling-code": "675" 989 }, { 990 name: "Paraguay", 991 cca2: "py", 992 "calling-code": "595" 993 }, { 994 name: "Peru",
995 cca2: "pe", 996 "calling-code": "51" 997 }, { 998 name: "Philippines", 999 cca2: "ph", 1000 "calling-code": "63" 1001 }, { 1002 name: "Poland", 1003 cca2: "pl", 1004 "calling-code": "48" 1005 }, { 1006 name: "Portugal", 1007 cca2: "pt", 1008 "calling-code": "351" 1009 }, { 1010 name: "Puerto Rico", 1011 cca2: "pr", 1012 "calling-code": "1787" 1013 }, { 1014 name: "Qatar", 1015 cca2: "qa", 1016 "calling-code": "974" 1017 }, { 1018 name: "Réunion", 1019 cca2: "re", 1020 "calling-code": "262" 1021 }, { 1022 name: "Romania", 1023 cca2: "ro", 1024 "calling-code": "40" 1025 }, { 1026 name: "Russian Federation", 1027 cca2: "ru", 1028 "calling-code": "7" 1029 }, { 1030 name: "Rwanda", 1031 cca2: "rw", 1032 "calling-code": "250" 1033 }, { 1034 name: "Saint Kitts and Nevis", 1035 cca2: "kn", 1036 "calling-code": "1869" 1037 }, { 1038 name: "Saint Lucia", 1039 cca2: "lc", 1040 "calling-code": "1758" 1041 }, { 1042 name: "Saint Vincent and the Grenadines", 1043 cca2: "vc", 1044 "calling-code": "1784" 1045 }, { 1046 name: "Samoa", 1047 cca2: "ws", 1048 "calling-code": "685" 1049 }, { 1050 name: "San Marino", 1051 cca2: "sm", 1052 "calling-code": "378" 1053 }, { 1054 name: "São Tomé and PrÃÂncipe", 1055 cca2: "st", 1056 "calling-code": "239" 1057 }, { 1058 name: "Saudi Arabia", 1059 cca2: "sa", 1060 "calling-code": "966" 1061 }, { 1062 name: "Senegal", 1063 cca2: "sn", 1064 "calling-code": "221" 1065 }, { 1066 name: "Serbia", 1067 cca2: "rs", 1068 "calling-code": "381" 1069 }, { 1070 name: "Seychelles", 1071 cca2: "sc", 1072 "calling-code": "248" 1073 }, { 1074 name: "Sierra Leone", 1075 cca2: "sl", 1076 "calling-code": "232" 1077 }, { 1078 name: "Singapore", 1079 cca2: "sg", 1080 "calling-code": "65" 1081 }, { 1082 name: "Slovakia", 1083 cca2: "sk", 1084 "calling-code": "421" 1085 }, { 1086 name: "Slovenia", 1087 cca2: "si", 1088 "calling-code": "386" 1089 }, { 1090 name: "Solomon Islands", 1091 cca2: "sb", 1092 "calling-code": "677" 1093 }, { 1094 name: "Somalia", 1095 cca2: "so", 1096 "calling-code": "252" 1097 }, { 1098 name: "South Africa", 1099 cca2: "za", 1100 "calling-code": "27" 1101 }, { 1102 name: "South Korea", 1103 cca2: "kr", 1104 "calling-code": "82" 1105 }, { 1106 name: "Spain", 1107 cca2: "es", 1108 "calling-code": "34" 1109 }, { 1110 name: "Sri Lanka", 1111 cca2: "lk", 1112 "calling-code": "94" 1113 }, { 1114 name: "Sudan", 1115 cca2: "sd", 1116 "calling-code": "249" 1117 }, { 1118 name: "Suriname", 1119 cca2: "sr", 1120 "calling-code": "597" 1121 }, { 1122 name: "Swaziland", 1123 cca2: "sz", 1124 "calling-code": "268" 1125 }, { 1126 name: "Sweden", 1127 cca2: "se", 1128 "calling-code": "46" 1129 }, { 1130 name: "Switzerland", 1131 cca2: "ch", 1132 "calling-code": "41" 1133 }, { 1134 name: "Syrian Arab Republic", 1135 cca2: "sy", 1136 "calling-code": "963" 1137 }, { 1138 name: "Taiwan, Province of China", 1139 cca2: "tw", 1140 "calling-code": "886" 1141 }, { 1142 name: "Tajikistan", 1143 cca2: "tj", 1144 "calling-code": "992" 1145 }, { 1146 name: "Tanzania", 1147 cca2: "tz", 1148 "calling-code": "255" 1149 }, { 1150 name: "Thailand", 1151 cca2: "th", 1152 "calling-code": "66" 1153 }, { 1154 name: "Timor-Leste", 1155 cca2: "tl", 1156 "calling-code": "670" 1157 }, { 1158 name: "Togo", 1159 cca2: "tg", 1160 "calling-code": "228" 1161 }, { 1162 name: "Tonga", 1163 cca2: "to", 1164 "calling-code": "676" 1165 }, { 1166 name: "Trinidad and Tobago", 1167 cca2: "tt", 1168 "calling-code": "1868" 1169 }, { 1170 name: "Tunisia", 1171 cca2: "tn", 1172 "calling-code": "216" 1173 }, { 1174 name: "Turkey", 1175 cca2: "tr", 1176 "calling-code": "90" 1177 }, { 1178 name: "Turkmenistan", 1179 cca2: "tm", 1180 "calling-code": "993" 1181 }, { 1182 name: "Turks and Caicos Islands", 1183 cca2: "tc", 1184 "calling-code": "1649" 1185 }, { 1186 name: "Tuvalu",
1187 cca2: "tv", 1188 "calling-code": "688" 1189 }, { 1190 name: "Uganda", 1191 cca2: "ug", 1192 "calling-code": "256" 1193 }, { 1194 name: "Ukraine", 1195 cca2: "ua", 1196 "calling-code": "380" 1197 }, { 1198 name: "United Arab Emirates", 1199 cca2: "ae", 1200 "calling-code": "971" 1201 }, { 1202 name: "United Kingdom", 1203 cca2: "gb", 1204 "calling-code": "44" 1205 }, { 1206 name: "United States", 1207 cca2: "us", 1208 "calling-code": "1" 1209 }, { 1210 name: "Uruguay", 1211 cca2: "uy", 1212 "calling-code": "598" 1213 }, { 1214 name: "Uzbekistan", 1215 cca2: "uz", 1216 "calling-code": "998" 1217 }, { 1218 name: "Vanuatu", 1219 cca2: "vu", 1220 "calling-code": "678" 1221 }, { 1222 name: "Vatican City", 1223 cca2: "va", 1224 "calling-code": "379" 1225 }, { 1226 name: "Venezuela", 1227 cca2: "ve", 1228 "calling-code": "58" 1229 }, { 1230 name: "Viet Nam", 1231 cca2: "vn", 1232 "calling-code": "84" 1233 }, { 1234 name: "Virgin Islands (British)", 1235 cca2: "vg", 1236 "calling-code": "1284" 1237 }, { 1238 name: "Virgin Islands (U.S.)", 1239 cca2: "vi", 1240 "calling-code": "1340" 1241 }, { 1242 name: "Western Sahara", 1243 cca2: "eh", 1244 "calling-code": "212" 1245 }, { 1246 name: "Yemen", 1247 cca2: "ye", 1248 "calling-code": "967" 1249 }, { 1250 name: "Zambia", 1251 cca2: "zm", 1252 "calling-code": "260" 1253 }, { 1254 name: "Zimbabwe", 1255 cca2: "zw", 1256 "calling-code": "263" 1257 } ], 1258 // JavaScript object mapping dial code to country code. 1259 // This is used when the user enters a number, 1260 // to quickly look up the corresponding country code. 1261 // Originally from http://libphonenumber.googlecode.com/svn/trunk/javascript/i18n/phonenumbers/metadata.js 1262 // then I commented some weird 001 entries and added some 4-digit country-code 1263 // items at the end e.g. 1246 for Barbados 1264 countryCodes: { 1265 "1": [ "us", "ca" ], 1266 "7": [ "ru", "kz" ], 1267 "20": [ "eg" ], 1268 "27": [ "za" ], 1269 "30": [ "gr" ], 1270 "31": [ "nl" ], 1271 "32": [ "be" ], 1272 "33": [ "fr" ], 1273 "34": [ "es" ], 1274 "36": [ "hu" ], 1275 "39": [ "it" ], 1276 "40": [ "ro" ], 1277 "41": [ "ch" ], 1278 "43": [ "at" ], 1279 "44": [ "gb", "gg", "im", "je" ], 1280 "45": [ "dk" ], 1281 "46": [ "se" ], 1282 "47": [ "no", "sj" ], 1283 "48": [ "pl" ], 1284 "49": [ "de" ], 1285 "51": [ "pe" ], 1286 "52": [ "mx" ], 1287 "53": [ "cu" ], 1288 "54": [ "ar" ], 1289 "55": [ "br" ], 1290 "56": [ "cl" ], 1291 "57": [ "co" ], 1292 "58": [ "ve" ], 1293 "60": [ "my" ], 1294 "61": [ "au", "cc", "cx" ], 1295 "62": [ "id" ], 1296 "63": [ "ph" ], 1297 "64": [ "nz" ], 1298 "65": [ "sg" ], 1299 "66": [ "th" ], 1300 "81": [ "jp" ], 1301 "82": [ "kr" ], 1302 "84": [ "vn" ], 1303 "86": [ "cn" ], 1304 "90": [ "tr" ], 1305 "91": [ "in" ], 1306 "92": [ "pk" ], 1307 "93": [ "af" ], 1308 "94": [ "lk" ], 1309 "95": [ "mm" ], 1310 "98": [ "ir" ], 1311 "211": [ "ss" ], 1312 "212": [ "ma", "eh" ], 1313 "213": [ "dz" ], 1314 "216": [ "tn" ], 1315 "218": [ "ly" ], 1316 "220": [ "gm" ], 1317 "221": [ "sn" ], 1318 "222": [ "mr" ], 1319 "223": [ "ml" ], 1320 "224": [ "gn" ], 1321 "225": [ "ci" ], 1322 "226": [ "bf" ], 1323 "227": [ "ne" ], 1324 "228": [ "tg" ], 1325 "229": [ "bj" ], 1326 "230": [ "mu" ], 1327 "231": [ "lr" ], 1328 "232": [ "sl" ], 1329 "233": [ "gh" ], 1330 "234": [ "ng" ], 1331 "235": [ "td" ], 1332 "236": [ "cf" ], 1333 "237": [ "cm" ], 1334 "238": [ "cv" ], 1335 "239": [ "st" ], 1336 "240": [ "gq" ], 1337 "241": [ "ga" ], 1338 "242": [ "cg" ], 1339 "243": [ "cd" ], 1340 "244": [ "ao" ], 1341 "245": [ "gw" ], 1342 "246": [ "io" ], 1343 "247": [ "ac" ], 1344 "248": [ "sc" ], 1345 "249": [ "sd" ], 1346 "250": [ "rw" ], 1347 "251": [ "et" ], 1348 "252": [ "so" ], 1349 "253": [ "dj" ], 1350 "254": [ "ke" ], 1351 "255": [ "tz" ], 1352 "256": [ "ug" ], 1353 "257": [ "bi" ], 1354 "258": [ "mz" ], 1355 "260": [ "zm" ], 1356 "261": [ "mg" ], 1357 "262": [ "re", "yt" ], 1358 "263": [ "zw" ], 1359 "264": [ "na" ], 1360 "265": [ "mw" ], 1361 "266": [ "ls" ], 1362 "267": [ "bw" ], 1363 "268": [ "sz" ], 1364 "269": [ "km" ], 1365 "290": [ "sh" ], 1366 "291": [ "er" ], 1367 "297": [ "aw" ], 1368 "298": [ "fo" ], 1369 "299": [ "gl" ], 1370 "350": [ "gi" ], 1371 "351": [ "pt" ], 1372 "352": [ "lu" ], 1373 "353": [ "ie" ], 1374 "354": [ "is" ], 1375 "355": [ "al" ], 1376 "356": [ "mt" ], 1377 "357": [ "cy" ], 1378 "358": [ "fi", "ax" ], 1379 "359": [ "bg" ], 1380 "370": [ "lt" ], 1381 "371": [ "lv" ], 1382 "372": [ "ee" ], 1383 "373": [ "md" ], 1384 "374": [ "am" ], 1385 "375": [ "by" ], 1386 "376": [ "ad" ], 1387 "377": [ "mc" ], 1388 "378": [ "sm" ], 1389 "379": [ "va" ], 1390 "380": [ "ua" ], 1391 "381": [ "rs" ], 1392 "382": [ "me" ], 1393 "385": [ "hr" ], 1394 "386": [ "si" ], 1395 "387": [ "ba" ], 1396 "389": [ "mk" ], 1397 "420": [ "cz" ], 1398 "421": [ "sk" ], 1399 "423": [ "li" ], 1400 "500": [ "fk" ], 1401 "501": [ "bz" ], 1402 "502": [ "gt" ], 1403 "503": [ "sv" ], 1404 "504": [ "hn" ], 1405 "505": [ "ni" ], 1406 "506": [ "cr" ], 1407 "507": [ "pa" ], 1408 "508": [ "pm" ], 1409 "509": [ "ht" ], 1410 "590": [ "gp", "bl", "mf" ], 1411 "591": [ "bo" ], 1412 "592": [ "gy" ], 1413 "593": [ "ec" ], 1414 "594": [ "gf" ], 1415 "595": [ "py" ], 1416 "596": [ "mq" ], 1417 "597": [ "sr" ], 1418 "598": [ "uy" ], 1419 "599": [ "cw", "bq" ], 1420 "670": [ "tl" ], 1421 "672": [ "nf" ], 1422 "673": [ "bn" ], 1423 "674": [ "nr" ], 1424 "675": [ "pg" ], 1425 "676": [ "to" ], 1426 "677": [ "sb" ], 1427 "678": [ "vu" ], 1428 "679": [ "fj" ], 1429 "680": [ "pw" ], 1430 "681": [ "wf" ],
1431 "682": [ "ck" ], 1432 "683": [ "nu" ], 1433 "685": [ "ws" ], 1434 "686": [ "ki" ], 1435 "687": [ "nc" ], 1436 "688": [ "tv" ], 1437 "689": [ "pf" ], 1438 "690": [ "tk" ], 1439 "691": [ "fm" ], 1440 "692": [ "mh" ], 1441 "850": [ "kp" ], 1442 "852": [ "hk" ], 1443 "853": [ "mo" ], 1444 "855": [ "kh" ], 1445 "856": [ "la" ], 1446 "880": [ "bd" ], 1447 "886": [ "tw" ], 1448 "960": [ "mv" ], 1449 "961": [ "lb" ], 1450 "962": [ "jo" ], 1451 "963": [ "sy" ], 1452 "964": [ "iq" ], 1453 "965": [ "kw" ], 1454 "966": [ "sa" ], 1455 "967": [ "ye" ], 1456 "968": [ "om" ], 1457 "970": [ "ps" ], 1458 "971": [ "ae" ], 1459 "972": [ "il" ], 1460 "973": [ "bh" ], 1461 "974": [ "qa" ], 1462 "975": [ "bt" ], 1463 "976": [ "mn" ], 1464 "977": [ "np" ], 1465 "992": [ "tj" ], 1466 "993": [ "tm" ], 1467 "994": [ "az" ], 1468 "995": [ "ge" ], 1469 "996": [ "kg" ], 1470 "998": [ "uz" ], 1471 "1242": [ "bs" ], 1472 "1246": [ "bb" ], 1473 "1264": [ "ai" ], 1474 "1268": [ "ag" ], 1475 "1284": [ "vg" ], 1476 "1340": [ "vi" ], 1477 "1345": [ "ky" ], 1478 "1441": [ "bm" ], 1479 "1473": [ "gd" ], 1480 "1649": [ "tc" ], 1481 "1664": [ "ms" ], 1482 "1671": [ "gu" ], 1483 "1684": [ "as" ], 1484 "1758": [ "lc" ], 1485 "1767": [ "dm" ], 1486 "1784": [ "vc" ], 1487 "1787": [ "pr" ], 1488 "1809": [ "do" ], 1489 "1868": [ "tt" ], 1490 "1869": [ "kn" ], 1491 "1876": [ "jm" ] 1492 } 1493};
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.