home *** CD-ROM | disk | FTP | other *** search
/ PC Advisor 2006 January / PCA126_DVD.iso / internet / nsb-setup.exe / chrome / toolkit.jar / content / mozapps / autofill / countryList.js < prev    next >
Encoding:
Text File  |  2005-04-15  |  4.1 KB  |  244 lines

  1. const countryListUS = 'United States';
  2. const countryListDefault = countryListUS;
  3. const countryList = [
  4. "Afghanistan",
  5. "Albania",
  6. "Algeria",
  7. "American Samoa",
  8. "Andorra",
  9. "Angola",
  10. "Anguilla",
  11. "Antigua and Barbuda",
  12. "Argentina",
  13. "Armenia",
  14. "Australia",
  15. "Austria",
  16. "Azerbaijan Republic",
  17. "Bahamas",
  18. "Bahrain",
  19. "Bangladesh",
  20. "Barbados",
  21. "Belarus",
  22. "Belgium",
  23. "Belize",
  24. "Benin",
  25. "Bermuda",
  26. "Bhutan",
  27. "Bolivia",
  28. "Bosnia and Herzegovina",
  29. "Botswana",
  30. "Brazil",
  31. "British Virgin Islands",
  32. "Brunei Darussalam",
  33. "Bulgaria",
  34. "Burkina Faso",
  35. "Burma",
  36. "Burundi",
  37. "Cambodia",
  38. "Cameroon",
  39. "Canada",
  40. "Cape Verde Islands",
  41. "Cayman Islands",
  42. "Central African Republic",
  43. "Chad",
  44. "Chile",
  45. "China",
  46. "Colombia",
  47. "Congo",
  48. "Cook Islands",
  49. "Costa Rica",
  50. "Cote d Ivoire (Ivory Coast)",
  51. "Croatia, Republic of",
  52. "Cyprus",
  53. "Czech Republic",
  54. "Denmark",
  55. "Djibouti",
  56. "Dominica",
  57. "Dominican Republic",
  58. "Ecuador",
  59. "Egypt",
  60. "El Salvador",
  61. "Equatorial Guinea",
  62. "Eritrea",
  63. "Falkland Islands (Islas Malvinas)",
  64. "Fiji",
  65. "Finland",
  66. "France",
  67. "French Guiana",
  68. "French Polynesia",
  69. "Gabon Republic",
  70. "Gambia",
  71. "Georgia",
  72. "Germany",
  73. "Ghana",
  74. "Gibraltar",
  75. "Greece",
  76. "Greenland",
  77. "Grenada",
  78. "Guadeloupe",
  79. "Guam",
  80. "Guatemala",
  81. "Guernsey",
  82. "Guinea",
  83. "Guinea-Bissau",
  84. "Guyana",
  85. "Haiti",
  86. "Honduras",
  87. "Hong Kong",
  88. "Hungary",
  89. "Iceland",
  90. "India",
  91. "Indonesia",
  92. "Ireland",
  93. "Jersey",
  94. "Jordan",
  95. "Kazakhstan",
  96. "Kenya Coast Republic",
  97. "Kiribati",
  98. "Korea, South",
  99. "Kuwait",
  100. "Kyrgyzstan",
  101. "Laos",
  102. "Latvia",
  103. "Lebanon",
  104. "Liechtenstein",
  105. "Lithuania",
  106. "Luxembourg",
  107. "Macau",
  108. "Macedonia",
  109. "Madagascar",
  110. "Malawi",
  111. "Malaysia",
  112. "Maldives",
  113. "Mali",
  114. "Malta",
  115. "Marshall Islands",
  116. "Martinique",
  117. "Mauritania",
  118. "Mauritius",
  119. "Mayotte",
  120. "Mexico",
  121. "Micronesia",
  122. "Moldova",
  123. "Monaco",
  124. "Mongolia",
  125. "Montserrat",
  126. "Morocco",
  127. "Mozambique",
  128. "Namibia",
  129. "Nauru",
  130. "Nepal",
  131. "Netherlands",
  132. "Netherlands Antilles",
  133. "New Caledonia",
  134. "New Zealand",
  135. "Nicaragua",
  136. "Niger",
  137. "Nigeria",
  138. "Niue",
  139. "Norway",
  140. "Oman",
  141. "Pakistan",
  142. "Palau",
  143. "Panama",
  144. "Papua New Guinea",
  145. "Paraguay",
  146. "Peru",
  147. "Philippines",
  148. "Poland",
  149. "Portugal",
  150. "Puerto Rico",
  151. "Qatar",
  152. "Romania",
  153. "Russian Federation",
  154. "Rwanda",
  155. "Saint Helena",
  156. "Saint Kitts-Nevis",
  157. "Saint Lucia",
  158. "Saint Pierre and Miquelon",
  159. "Saint Vincent and the Grenadines",
  160. "San Marino",
  161. "Saudi Arabia",
  162. "Senegal",
  163. "Seychelles",
  164. "Sierra Leone",
  165. "Singapore",
  166. "Slovakia",
  167. "Slovenia",
  168. "Solomon Islands",
  169. "Somalia",
  170. "South Africa",
  171. "Spain",
  172. "Sri Lanka",
  173. "Suriname",
  174. "Svalbard",
  175. "Swaziland",
  176. "Sweden",
  177. "Switzerland",
  178. "Syria",
  179. "Tahiti",
  180. "Taiwan",
  181. "Tajikistan",
  182. "Tanzania",
  183. "Thailand",
  184. "Togo",
  185. "Tonga",
  186. "Trinidad and Tobago",
  187. "Tunisia",
  188. "Turkey",
  189. "Turkmenistan",
  190. "Turks and Caicos Islands",
  191. "Tuvalu",
  192. "Uganda",
  193. "Ukraine",
  194. "United Arab Emirates",
  195. "United Kingdom",
  196. countryListUS,
  197. "Uruguay",
  198. "Uzbekistan",
  199. "Vanuatu",
  200. "Vatican City State",
  201. "Venezuela",
  202. "Vietnam",
  203. "Virgin Islands (U.S.)",
  204. "Wallis and Futuna",
  205. "Western Sahara",
  206. "Western Samoa",
  207. "Yemen",
  208. "Yugoslavia",
  209. "Zambia",
  210. "Zimbabwe"
  211. ];
  212.  
  213. function findClosestCountryMatch(dubiousCountry) {
  214.     dubiousCountry = dubiousCountry.toLowerCase();
  215.     // First the trivial cases
  216.     if (!dubiousCountry || (dubiousCountry == ''))
  217.         return countryListUS;
  218.     // Next check for exact matches (case insensitive)
  219.     for (var i = 0; i < countryList.length; i++) {
  220.         var candidateMatchCountry = countryList[i].toLowerCase();
  221.         if (dubiousCountry == candidateMatchCountry)
  222.             return countryList[i];
  223.     }
  224.     // Next check for specific variations
  225.     if ((dubiousCountry == 'us') ||
  226.         (dubiousCountry == 'usa') ||
  227.         (dubiousCountry == 'u.s.') ||
  228.         (dubiousCountry == 'u.s.a.') ||
  229.         (dubiousCountry == 'united states of america'))
  230.     {
  231.         return countryListUS;
  232.     }
  233.     // Next check for substring matches
  234.     for (var i = 0; i < countryList.length; i++) {
  235.         var candidateMatchCountry = countryList[i].toLowerCase();
  236.         if ((dubiousCountry.indexOf(candidateMatchCountry) > -1) ||
  237.             (candidateMatchCountry.indexOf(dubiousCountry) > -1))
  238.         {
  239.             return countryList[i];
  240.         }
  241.     }
  242.     // Default to United States
  243.     return countryListUS;
  244. }