// wrap in UMD - see https://github.com/umdjs/umd/blob/master/jqueryPlugin.js
(function (factory){
if(typeof define==="function"&&define.amd){
define(["jquery"], function ($){
factory($, window, document);
});
}else if(typeof module==="object"&&module.exports){
module.exports=factory(require("jquery"), window, document);
}else{
factory(jQuery, window, document);
}})(function ($, window, document, undefined){
"use strict";
var pluginName="countrySelect", id=1,
defaults={
defaultCountry: "",
defaultStyling: "inside",
excludeCountries: [],
onlyCountries: [],
preferredCountries: ["us", "gb"],
localizedCountries: null,
responsiveDropdown: ($(window).width() < 768 ? true:false),
}, keys={
UP: 38,
DOWN: 40,
ENTER: 13,
ESC: 27,
BACKSPACE: 8,
PLUS: 43,
SPACE: 32,
A: 65,
Z: 90
}, windowLoaded=false;
$(window).on('load', function (){
windowLoaded=true;
});
function Plugin(element, options){
this.element=element;
this.options=$.extend({}, defaults, options);
this._defaults=defaults;
this.ns="." + pluginName + id++;
this._name=pluginName;
this.init();
}
Plugin.prototype={
init: function (){
this._processCountryData();
this._generateMarkup();
this._setInitialState();
this._initListeners();
this.autoCountryDeferred=new $.Deferred();
this._initAutoCountry();
this.typedLetters="";
return this.autoCountryDeferred;
},
_processCountryData: function (){
this._setInstanceCountryData();
this._setPreferredCountries();
if(this.options.localizedCountries) this._translateCountriesByLocale();
if(this.options.onlyCountries.length||this.options.localizedCountries){
this.countries.sort(this._countryNameSort);
}},
_setInstanceCountryData: function (){
var that=this;
if(this.options.onlyCountries.length){
var newCountries=[];
$.each(this.options.onlyCountries, function (i, countryCode){
var countryData=that._getCountryData(countryCode, true);
if(countryData){
newCountries.push(countryData);
}});
this.countries=newCountries;
}else if(this.options.excludeCountries.length){
var lowerCaseExcludeCountries=this.options.excludeCountries.map(function (country){
return country.toLowerCase();
});
this.countries=allCountries.filter(function (country){
return lowerCaseExcludeCountries.indexOf(country.iso2)===-1;
});
}else{
this.countries=allCountries;
}},
_setPreferredCountries: function (){
var that=this;
this.preferredCountries=[];
$.each(this.options.preferredCountries, function (i, countryCode){
var countryData=that._getCountryData(countryCode, false);
if(countryData){
that.preferredCountries.push(countryData);
}});
},
_translateCountriesByLocale(){
for (let i=0; i < this.countries.length; i++){
const iso=this.countries[i].iso2.toLowerCase();
if(this.options.localizedCountries.hasOwnProperty(iso)){
this.countries[i].name=this.options.localizedCountries[iso];
}}
},
_countryNameSort(a, b){
return a.name.localeCompare(b.name);
},
_generateMarkup: function (){
this.countryInput=$(this.element);
var mainClass="country-select";
if(this.options.defaultStyling){
mainClass +=" " + this.options.defaultStyling;
}
this.countryInput.wrap($("<div>", {
"class": mainClass
}));
var flagsContainer=$("<div>", {
"class": "flag-dropdown"
}).insertAfter(this.countryInput);
var selectedFlag=$("<div>", {
"class": "selected-flag"
}).appendTo(flagsContainer);
this.selectedFlagInner=$("<div>", {
"class": "flag"
}).appendTo(selectedFlag);
$("<div>", {
"class": "arrow"
}).appendTo(selectedFlag);
this.countryList=$("<ul>", {
"class": "country-list v-hide"
}).appendTo(flagsContainer);
if(this.preferredCountries.length){
this._appendListItems(this.preferredCountries, "preferred");
$("<li>", {
"class": "divider"
}).appendTo(this.countryList);
}
this._appendListItems(this.countries, "");
this.countryCodeInput=$("#" + this.countryInput.attr("id") + "_code");
if(!this.countryCodeInput){
this.countryCodeInput=$('<input type="hidden" id="' + this.countryInput.attr("id") + '_code" name="' + this.countryInput.attr("name") + '_code" value="" />');
this.countryCodeInput.insertAfter(this.countryInput);
}
this.dropdownHeight=this.countryList.outerHeight();
if(this.options.responsiveDropdown){
$(window).resize(function (){
$('.country-select').each(function (){
var dropdownWidth=this.offsetWidth;
$(this).find('.country-list').css("width", dropdownWidth + "px");
});
}).resize();
}
this.countryList.removeClass("v-hide").addClass("hide");
this.countryListItems=this.countryList.children(".country");
},
_appendListItems: function (countries, className){
var tmp="";
$.each(countries, function (i, c){
tmp +='<li class="country ' + className + '" data-country-code="' + c.iso2 + '">';
tmp +='<div class="flag ' + c.iso2 + '"></div>';
tmp +='<span class="country-name">' + c.name + '</span>';
tmp +='</li>';
});
this.countryList.append(tmp);
},
_setInitialState: function (){
var flagIsSet=false;
if(this.countryInput.val()){
flagIsSet=this._updateFlagFromInputVal();
}
var selectedCode=this.countryCodeInput.val();
if(selectedCode){
this.selectCountry(selectedCode);
}
if(!flagIsSet){
var defaultCountry;
if(this.options.defaultCountry){
defaultCountry=this._getCountryData(this.options.defaultCountry, false);
if(!defaultCountry){
defaultCountry=this.preferredCountries.length ? this.preferredCountries[0]:this.countries[0];
}}else{
defaultCountry=this.preferredCountries.length ? this.preferredCountries[0]:this.countries[0];
}
this.defaultCountry=defaultCountry.iso2;
}},
_initListeners: function (){
var that=this;
this.countryInput.on("keyup" + this.ns, function (){
that._updateFlagFromInputVal();
});
var selectedFlag=this.selectedFlagInner.parent();
selectedFlag.on("click" + this.ns, function (e){
if(that.countryList.hasClass("hide")&&!that.countryInput.prop("disabled")){
that._showDropdown();
}});
this.countryInput.on("blur" + this.ns, function (){
if(that.countryInput.val()!=that.getSelectedCountryData().name){
that.setCountry(that.countryInput.val());
}
that.countryInput.val(that.getSelectedCountryData().name);
});
},
_initAutoCountry: function (){
if(this.options.initialCountry==="auto"){
this._loadAutoCountry();
}else{
if(this.defaultCountry){
this.selectCountry(this.defaultCountry);
}
this.autoCountryDeferred.resolve();
}},
_loadAutoCountry: function (){
var that=this;
if($.fn[pluginName].autoCountry){
this.handleAutoCountry();
}else if(!$.fn[pluginName].startedLoadingAutoCountry){
$.fn[pluginName].startedLoadingAutoCountry=true;
if(typeof this.options.geoIpLookup==='function'){
this.options.geoIpLookup(function (countryCode){
$.fn[pluginName].autoCountry=countryCode.toLowerCase();
setTimeout(function (){
$(".country-select input").countrySelect("handleAutoCountry");
});
});
}}
},
_focus: function (){
this.countryInput.focus();
var input=this.countryInput[0];
if(input.setSelectionRange){
var len=this.countryInput.val().length;
input.setSelectionRange(len, len);
}},
_showDropdown: function (){
this._setDropdownPosition();
var activeListItem=this.countryList.children(".active");
this._highlightListItem(activeListItem);
this.countryList.removeClass("hide");
this._scrollTo(activeListItem);
this._bindDropdownListeners();
this.selectedFlagInner.parent().children(".arrow").addClass("up");
},
_setDropdownPosition: function (){
var inputTop=this.countryInput.offset().top, windowTop=$(window).scrollTop(),
dropdownFitsBelow=inputTop + this.countryInput.outerHeight() + this.dropdownHeight < windowTop + $(window).height(), dropdownFitsAbove=inputTop - this.dropdownHeight > windowTop;
var cssTop = !dropdownFitsBelow&&dropdownFitsAbove ? "-" + (this.dropdownHeight - 1) + "px":"";
this.countryList.css("top", cssTop);
},
_bindDropdownListeners: function (){
var that=this;
this.countryList.on("mouseover" + this.ns, ".country", function (e){
that._highlightListItem($(this));
});
this.countryList.on("click" + this.ns, ".country", function (e){
that._selectListItem($(this));
});
var isOpening=true;
$("html").on("click" + this.ns, function (e){
e.preventDefault();
if(!isOpening){
that._closeDropdown();
}
isOpening=false;
});
$(document).on("keydown" + this.ns, function (e){
e.preventDefault();
if(e.which==keys.UP||e.which==keys.DOWN){
that._handleUpDownKey(e.which);
}else if(e.which==keys.ENTER){
that._handleEnterKey();
}else if(e.which==keys.ESC){
that._closeDropdown();
}else if(e.which >=keys.A&&e.which <=keys.Z||e.which===keys.SPACE){
that.typedLetters +=String.fromCharCode(e.which);
that._filterCountries(that.typedLetters);
}else if(e.which===keys.BACKSPACE){
that.typedLetters=that.typedLetters.slice(0, -1);
that._filterCountries(that.typedLetters);
}});
},
_handleUpDownKey: function (key){
var current=this.countryList.children(".highlight").first();
var next=key==keys.UP ? current.prev():current.next();
if(next.length){
if(next.hasClass("divider")){
next=key==keys.UP ? next.prev():next.next();
}
this._highlightListItem(next);
this._scrollTo(next);
}},
_handleEnterKey: function (){
var currentCountry=this.countryList.children(".highlight").first();
if(currentCountry.length){
this._selectListItem(currentCountry);
}},
_filterCountries: function (letters){
var countries=this.countryListItems.filter(function (){
return $(this).text().toUpperCase().indexOf(letters)===0&&!$(this).hasClass("preferred");
});
if(countries.length){
var highlightedCountry=countries.filter(".highlight").first(), listItem;
if(highlightedCountry&&highlightedCountry.next()&&highlightedCountry.next().text().toUpperCase().indexOf(letters)===0){
listItem=highlightedCountry.next();
}else{
listItem=countries.first();
}
this._highlightListItem(listItem);
this._scrollTo(listItem);
}},
_updateFlagFromInputVal: function (){
var that=this;
var value=this.countryInput.val().replace(/(?=[() ])/g, '\\');
if(value){
var countryCodes=[];
var matcher=new RegExp(value, "i");
if(value.length <=2){
for (var i=0; i < this.countries.length; i++){
if(this.countries[i].iso2.match(matcher)){
countryCodes.push(this.countries[i].iso2);
}}
}
if(countryCodes.length==0){
for (var i=0; i < this.countries.length; i++){
if(this.countries[i].name.match(matcher)){
countryCodes.push(this.countries[i].iso2);
}}
}
var alreadySelected=false;
$.each(countryCodes, function (i, c){
if(that.selectedFlagInner.hasClass(c)){
alreadySelected=true;
}});
if(!alreadySelected){
this._selectFlag(countryCodes[0]);
this.countryCodeInput.val(countryCodes[0]).trigger("change");
}
return true;
}
return false;
},
_highlightListItem: function (listItem){
this.countryListItems.removeClass("highlight");
listItem.addClass("highlight");
},
_getCountryData: function (countryCode, ignoreOnlyCountriesOption){
var countryList=ignoreOnlyCountriesOption ? allCountries:this.countries;
for (var i=0; i < countryList.length; i++){
if(countryList[i].iso2==countryCode){
return countryList[i];
}}
return null;
},
_selectFlag: function (countryCode){
if(!countryCode){
return false;
}
this.selectedFlagInner.attr("class", "flag " + countryCode);
var countryData=this._getCountryData(countryCode);
this.selectedFlagInner.parent().attr("title", countryData.name);
var listItem=this.countryListItems.children(".flag." + countryCode).first().parent();
this.countryListItems.removeClass("active");
listItem.addClass("active");
},
_selectListItem: function (listItem){
var countryCode=listItem.attr("data-country-code");
this._selectFlag(countryCode);
this._closeDropdown();
this._updateName(countryCode);
this.countryInput.trigger("change");
this.countryCodeInput.trigger("change");
this._focus();
},
_closeDropdown: function (){
this.countryList.addClass("hide");
this.selectedFlagInner.parent().children(".arrow").removeClass("up");
$(document).off("keydown" + this.ns);
$("html").off("click" + this.ns);
this.countryList.off(this.ns);
this.typedLetters="";
},
_scrollTo: function (element){
if(!element||!element.offset()){
return;
}
var container=this.countryList, containerHeight=container.height(), containerTop=container.offset().top, containerBottom=containerTop + containerHeight, elementHeight=element.outerHeight(), elementTop=element.offset().top, elementBottom=elementTop + elementHeight, newScrollTop=elementTop - containerTop + container.scrollTop();
if(elementTop < containerTop){
container.scrollTop(newScrollTop);
}else if(elementBottom > containerBottom){
var heightDifference=containerHeight - elementHeight;
container.scrollTop(newScrollTop - heightDifference);
}},
_updateName: function (countryCode){
this.countryCodeInput.val(this._getCountryData(countryCode).name).trigger("change");
this.countryInput.val(this._getCountryData(countryCode).name);
},
handleAutoCountry: function (){
if(this.options.initialCountry==="auto"){
this.defaultCountry=$.fn[pluginName].autoCountry;
if(!this.countryInput.val()){
this.selectCountry(this.defaultCountry);
}
this.autoCountryDeferred.resolve();
}},
getSelectedCountryData: function (){
var countryCode=this.selectedFlagInner.attr("class").split(" ")[1];
return this._getCountryData(countryCode);
},
selectCountry: function (countryCode){
countryCode=countryCode.toLowerCase();
if(!this.selectedFlagInner.hasClass(countryCode)){
this._selectFlag(countryCode);
this._updateName(countryCode);
}},
setCountry: function (country){
this.countryInput.val(country);
this._updateFlagFromInputVal();
},
destroy: function (){
this.countryInput.off(this.ns);
this.selectedFlagInner.parent().off(this.ns);
var container=this.countryInput.parent();
container.before(this.countryInput).remove();
}};
$.fn[pluginName]=function (options){
var args=arguments;
if(options===undefined||typeof options==="object"){
return this.each(function (){
if(!$.data(this, "plugin_" + pluginName)){
$.data(this, "plugin_" + pluginName, new Plugin(this, options));
}});
}else if(typeof options==="string"&&options[0]!=="_"&&options!=="init"){
var returns;
this.each(function (){
var instance=$.data(this, "plugin_" + pluginName);
if(instance instanceof Plugin&&typeof instance[options]==="function"){
returns=instance[options].apply(instance, Array.prototype.slice.call(args, 1));
}
if(options==="destroy"){
$.data(this, "plugin_" + pluginName, null);
}});
return returns!==undefined ? returns:this;
}};
$.fn[pluginName].getCountryData=function (){
return allCountries;
};
$.fn[pluginName].setCountryData=function (obj){
allCountries=obj;
};
var allCountries=$.each([{
n: "Select a country",
i: "bdt"
},{
n: "Afghanistan (‫افغانستان‬‎)",
i: "af"
}, {
n: "Åland Islands (Åland)",
i: "ax"
}, {
n: "Albania (Shqipëri)",
i: "al"
}, {
n: "Algeria (‫الجزائر‬‎)",
i: "dz"
}, {
n: "American Samoa",
i: "as"
}, {
n: "Andorra",
i: "ad"
}, {
n: "Angola",
i: "ao"
}, {
n: "Anguilla",
i: "ai"
}, {
n: "Antarctica",
i: "aq"
}, {
n: "Antigua and Barbuda",
i: "ag"
}, {
n: "Argentina",
i: "ar"
}, {
n: "Armenia (Հայաստան)",
i: "am"
}, {
n: "Aruba",
i: "aw"
}, {
n: "Australia",
i: "au"
}, {
n: "Austria (Österreich)",
i: "at"
}, {
n: "Azerbaijan (Azərbaycan)",
i: "az"
}, {
n: "Bahamas",
i: "bs"
}, {
n: "Bahrain (‫البحرين‬‎)",
i: "bh"
}, {
n: "Bangladesh (বাংলাদেশ)",
i: "bd"
}, {
n: "Barbados",
i: "bb"
}, {
n: "Belarus (Беларусь)",
i: "by"
}, {
n: "Belgium (België)",
i: "be"
}, {
n: "Belize",
i: "bz"
}, {
n: "Benin (Bénin)",
i: "bj"
}, {
n: "Bermuda",
i: "bm"
}, {
n: "Bhutan (འབྲུག)",
i: "bt"
}, {
n: "Bolivia",
i: "bo"
}, {
n: "Bosnia and Herzegovina (Босна и Херцеговина)",
i: "ba"
}, {
n: "Botswana",
i: "bw"
}, {
n: "Bouvet Island (Bouvetøya)",
i: "bv"
}, {
n: "Brazil (Brasil)",
i: "br"
}, {
n: "British Indian Ocean Territory",
i: "io"
}, {
n: "British Virgin Islands",
i: "vg"
}, {
n: "Brunei",
i: "bn"
}, {
n: "Bulgaria (България)",
i: "bg"
}, {
n: "Burkina Faso",
i: "bf"
}, {
n: "Burundi (Uburundi)",
i: "bi"
}, {
n: "Cambodia (កម្ពុជា)",
i: "kh"
}, {
n: "Cameroon (Cameroun)",
i: "cm"
}, {
n: "Canada",
i: "ca"
}, {
n: "Cape Verde (Kabu Verdi)",
i: "cv"
}, {
n: "Caribbean Netherlands",
i: "bq"
}, {
n: "Cayman Islands",
i: "ky"
}, {
n: "Central African Republic (République Centrafricaine)",
i: "cf"
}, {
n: "Chad (Tchad)",
i: "td"
}, {
n: "Chile",
i: "cl"
}, {
n: "China (中国)",
i: "cn"
}, {
n: "Christmas Island",
i: "cx"
}, {
n: "Cocos (Keeling) Islands (Kepulauan Cocos (Keeling))",
i: "cc"
}, {
n: "Colombia",
i: "co"
}, {
n: "Comoros (‫جزر القمر‬‎)",
i: "km"
}, {
n: "Congo (DRC) (Jamhuri ya Kidemokrasia ya Kongo)",
i: "cd"
}, {
n: "Congo (Republic) (Congo-Brazzaville)",
i: "cg"
}, {
n: "Cook Islands",
i: "ck"
}, {
n: "Costa Rica",
i: "cr"
}, {
n: "Côte d’Ivoire",
i: "ci"
}, {
n: "Croatia (Hrvatska)",
i: "hr"
}, {
n: "Cuba",
i: "cu"
}, {
n: "Curaçao",
i: "cw"
}, {
n: "Cyprus (Κύπρος)",
i: "cy"
}, {
n: "Czech Republic (Česká republika)",
i: "cz"
}, {
n: "Denmark (Danmark)",
i: "dk"
}, {
n: "Djibouti",
i: "dj"
}, {
n: "Dominica",
i: "dm"
}, {
n: "Dominican Republic (República Dominicana)",
i: "do"
}, {
n: "Ecuador",
i: "ec"
}, {
n: "Egypt (‫مصر‬‎)",
i: "eg"
}, {
n: "El Salvador",
i: "sv"
}, {
n: "Equatorial Guinea (Guinea Ecuatorial)",
i: "gq"
}, {
n: "Eritrea",
i: "er"
}, {
n: "Estonia (Eesti)",
i: "ee"
}, {
n: "Ethiopia",
i: "et"
}, {
n: "Falkland Islands (Islas Malvinas)",
i: "fk"
}, {
n: "Faroe Islands (Føroyar)",
i: "fo"
}, {
n: "Fiji",
i: "fj"
}, {
n: "Finland (Suomi)",
i: "fi"
}, {
n: "France",
i: "fr"
}, {
n: "French Guiana (Guyane française)",
i: "gf"
}, {
n: "French Polynesia (Polynésie française)",
i: "pf"
}, {
n: "French Southern Territories (Terres australes françaises)",
i: "tf"
}, {
n: "Gabon",
i: "ga"
}, {
n: "Gambia",
i: "gm"
}, {
n: "Georgia (საქართველო)",
i: "ge"
}, {
n: "Germany (Deutschland)",
i: "de"
}, {
n: "Ghana (Gaana)",
i: "gh"
}, {
n: "Gibraltar",
i: "gi"
}, {
n: "Greece (Ελλάδα)",
i: "gr"
}, {
n: "Greenland (Kalaallit Nunaat)",
i: "gl"
}, {
n: "Grenada",
i: "gd"
}, {
n: "Guadeloupe",
i: "gp"
}, {
n: "Guam",
i: "gu"
}, {
n: "Guatemala",
i: "gt"
}, {
n: "Guernsey",
i: "gg"
}, {
n: "Guinea (Guinée)",
i: "gn"
}, {
n: "Guinea-Bissau (Guiné Bissau)",
i: "gw"
}, {
n: "Guyana",
i: "gy"
}, {
n: "Haiti",
i: "ht"
}, {
n: "Heard Island and Mcdonald Islands",
i: "hm"
}, {
n: "Honduras",
i: "hn"
}, {
n: "Hong Kong (香港)",
i: "hk"
}, {
n: "Hungary (Magyarország)",
i: "hu"
}, {
n: "Iceland (Ísland)",
i: "is"
}, {
n: "India (भारत)",
i: "in"
}, {
n: "Indonesia",
i: "id"
}, {
n: "Iran (‫ایران‬‎)",
i: "ir"
}, {
n: "Iraq (‫العراق‬‎)",
i: "iq"
}, {
n: "Ireland",
i: "ie"
}, {
n: "Isle of Man",
i: "im"
}, {
n: "Israel (‫ישראל‬‎)",
i: "il"
}, {
n: "Italy (Italia)",
i: "it"
}, {
n: "Jamaica",
i: "jm"
}, {
n: "Japan (日本)",
i: "jp"
}, {
n: "Jersey",
i: "je"
}, {
n: "Jordan (‫الأردن‬‎)",
i: "jo"
}, {
n: "Kazakhstan (Казахстан)",
i: "kz"
}, {
n: "Kenya",
i: "ke"
}, {
n: "Kiribati",
i: "ki"
}, {
n: "Kosovo (Kosovë)",
i: "xk"
}, {
n: "Kuwait (‫الكويت‬‎)",
i: "kw"
}, {
n: "Kyrgyzstan (Кыргызстан)",
i: "kg"
}, {
n: "Laos (ລາວ)",
i: "la"
}, {
n: "Latvia (Latvija)",
i: "lv"
}, {
n: "Lebanon (‫لبنان‬‎)",
i: "lb"
}, {
n: "Lesotho",
i: "ls"
}, {
n: "Liberia",
i: "lr"
}, {
n: "Libya (‫ليبيا‬‎)",
i: "ly"
}, {
n: "Liechtenstein",
i: "li"
}, {
n: "Lithuania (Lietuva)",
i: "lt"
}, {
n: "Luxembourg",
i: "lu"
}, {
n: "Macau (澳門)",
i: "mo"
}, {
n: "North Macedonia (FYROM) (Северна Македонија)",
i: "mk"
}, {
n: "Madagascar (Madagasikara)",
i: "mg"
}, {
n: "Malawi",
i: "mw"
}, {
n: "Malaysia",
i: "my"
}, {
n: "Maldives",
i: "mv"
}, {
n: "Mali",
i: "ml"
}, {
n: "Malta",
i: "mt"
}, {
n: "Marshall Islands",
i: "mh"
}, {
n: "Martinique",
i: "mq"
}, {
n: "Mauritania (‫موريتانيا‬‎)",
i: "mr"
}, {
n: "Mauritius (Moris)",
i: "mu"
}, {
n: "Mayotte",
i: "yt"
}, {
n: "Mexico (México)",
i: "mx"
}, {
n: "Micronesia",
i: "fm"
}, {
n: "Moldova (Republica Moldova)",
i: "md"
}, {
n: "Monaco",
i: "mc"
}, {
n: "Mongolia (Монгол)",
i: "mn"
}, {
n: "Montenegro (Crna Gora)",
i: "me"
}, {
n: "Montserrat",
i: "ms"
}, {
n: "Morocco (‫المغرب‬‎)",
i: "ma"
}, {
n: "Mozambique (Moçambique)",
i: "mz"
}, {
n: "Myanmar (Burma) (မြန်မာ)",
i: "mm"
}, {
n: "Namibia (Namibië)",
i: "na"
}, {
n: "Nauru",
i: "nr"
}, {
n: "Nepal (नेपाल)",
i: "np"
}, {
n: "Netherlands (Nederland)",
i: "nl"
}, {
n: "New Caledonia (Nouvelle-Calédonie)",
i: "nc"
}, {
n: "New Zealand",
i: "nz"
}, {
n: "Nicaragua",
i: "ni"
}, {
n: "Niger (Nijar)",
i: "ne"
}, {
n: "Nigeria",
i: "ng"
}, {
n: "Niue",
i: "nu"
}, {
n: "Norfolk Island",
i: "nf"
}, {
n: "North Korea (조선 민주주의 인민 공화국)",
i: "kp"
}, {
n: "Northern Mariana Islands",
i: "mp"
}, {
n: "Norway (Norge)",
i: "no"
}, {
n: "Oman (‫عُمان‬‎)",
i: "om"
}, {
n: "Pakistan (‫پاکستان‬‎)",
i: "pk"
}, {
n: "Palau",
i: "pw"
}, {
n: "Palestine (‫فلسطين‬‎)",
i: "ps"
}, {
n: "Panama (Panamá)",
i: "pa"
}, {
n: "Papua New Guinea",
i: "pg"
}, {
n: "Paraguay",
i: "py"
}, {
n: "Peru (Perú)",
i: "pe"
}, {
n: "Philippines",
i: "ph"
}, {
n: "Pitcairn Islands",
i: "pn"
}, {
n: "Poland (Polska)",
i: "pl"
}, {
n: "Portugal",
i: "pt"
}, {
n: "Puerto Rico",
i: "pr"
}, {
n: "Qatar (‫قطر‬‎)",
i: "qa"
}, {
n: "Réunion (La Réunion)",
i: "re"
}, {
n: "Romania (România)",
i: "ro"
}, {
n: "Russia (Россия)",
i: "ru"
}, {
n: "Rwanda",
i: "rw"
}, {
n: "Saint Barthélemy (Saint-Barthélemy)",
i: "bl"
}, {
n: "Saint Helena",
i: "sh"
}, {
n: "Saint Kitts and Nevis",
i: "kn"
}, {
n: "Saint Lucia",
i: "lc"
}, {
n: "Saint Martin (Saint-Martin (partie française))",
i: "mf"
}, {
n: "Saint Pierre and Miquelon (Saint-Pierre-et-Miquelon)",
i: "pm"
}, {
n: "Saint Vincent and the Grenadines",
i: "vc"
}, {
n: "Samoa",
i: "ws"
}, {
n: "San Marino",
i: "sm"
}, {
n: "São Tomé and Príncipe (São Tomé e Príncipe)",
i: "st"
}, {
n: "Saudi Arabia (‫المملكة العربية السعودية‬‎)",
i: "sa"
}, {
n: "Senegal (Sénégal)",
i: "sn"
}, {
n: "Serbia (Србија)",
i: "rs"
}, {
n: "Seychelles",
i: "sc"
}, {
n: "Sierra Leone",
i: "sl"
}, {
n: "Singapore",
i: "sg"
}, {
n: "Sint Maarten",
i: "sx"
}, {
n: "Slovakia (Slovensko)",
i: "sk"
}, {
n: "Slovenia (Slovenija)",
i: "si"
}, {
n: "Solomon Islands",
i: "sb"
}, {
n: "Somalia (Soomaaliya)",
i: "so"
}, {
n: "South Africa",
i: "za"
}, {
n: "South Georgia & South Sandwich Islands",
i: "gs"
}, {
n: "South Korea (대한민국)",
i: "kr"
}, {
n: "South Sudan (‫جنوب السودان‬‎)",
i: "ss"
}, {
n: "Spain (España)",
i: "es"
}, {
n: "Sri Lanka (ශ්‍රී ලංකාව)",
i: "lk"
}, {
n: "Sudan (‫السودان‬‎)",
i: "sd"
}, {
n: "Suriname",
i: "sr"
}, {
n: "Svalbard and Jan Mayen (Svalbard og Jan Mayen)",
i: "sj"
}, {
n: "Swaziland",
i: "sz"
}, {
n: "Sweden (Sverige)",
i: "se"
}, {
n: "Switzerland (Schweiz)",
i: "ch"
}, {
n: "Syria (‫سوريا‬‎)",
i: "sy"
}, {
n: "Taiwan (台灣)",
i: "tw"
}, {
n: "Tajikistan",
i: "tj"
}, {
n: "Tanzania",
i: "tz"
}, {
n: "Thailand (ไทย)",
i: "th"
}, {
n: "Timor-Leste",
i: "tl"
}, {
n: "Togo",
i: "tg"
}, {
n: "Tokelau",
i: "tk"
}, {
n: "Tonga",
i: "to"
}, {
n: "Trinidad and Tobago",
i: "tt"
}, {
n: "Tunisia (‫تونس‬‎)",
i: "tn"
}, {
n: "Turkey (Türkiye)",
i: "tr"
}, {
n: "Turkmenistan",
i: "tm"
}, {
n: "Turks and Caicos Islands",
i: "tc"
}, {
n: "Tuvalu",
i: "tv"
}, {
n: "Uganda",
i: "ug"
}, {
n: "Ukraine (Україна)",
i: "ua"
}, {
n: "United Arab Emirates (‫الإمارات العربية المتحدة‬‎)",
i: "ae"
}, {
n: "United Kingdom",
i: "gb"
}, {
n: "United States",
i: "us"
}, {
n: "U.S. Minor Outlying Islands",
i: "um"
}, {
n: "U.S. Virgin Islands",
i: "vi"
}, {
n: "Uruguay",
i: "uy"
}, {
n: "Uzbekistan (Oʻzbekiston)",
i: "uz"
}, {
n: "Vanuatu",
i: "vu"
}, {
n: "Vatican City (Città del Vaticano)",
i: "va"
}, {
n: "Venezuela",
i: "ve"
}, {
n: "Vietnam (Việt Nam)",
i: "vn"
}, {
n: "Wallis and Futuna",
i: "wf"
}, {
n: "Western Sahara (‫الصحراء الغربية‬‎)",
i: "eh"
}, {
n: "Yemen (‫اليمن‬‎)",
i: "ye"
}, {
n: "Zambia",
i: "zm"
}, {
n: "Zimbabwe",
i: "zw"
}], function (i, c){
c.name=c.n;
c.iso2=c.i;
delete c.n;
delete c.i;
});
});