Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Country code conversion review #3

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
251 changes: 251 additions & 0 deletions countrymap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,251 @@
var countryToCodeMap = {
'Afghanistan': 'AF',
'Åland Islands': 'AX',
'Albania': 'AL',
'Algeria': 'DZ',
'American Samoa': 'AS',
'Andorra': 'AD',
'Angola': 'AO',
'Anguilla': 'AI',
'Antarctica': 'AQ',
'Antigua and Barbuda': 'AG',
'Argentina': 'AR',
'Armenia': 'AM',
'Aruba': 'AW',
'Australia': 'AU',
'Austria': 'AT',
'Azerbaijan': 'AZ',
'Bahrain': 'BH',
'Bahamas': 'BS',
'Bangladesh': 'BD',
'Barbados': 'BB',
'Belarus': 'BY',
'Belgium': 'BE',
'Belize': 'BZ',
'Benin': 'BJ',
'Bermuda': 'BM',
'Bhutan': 'BT',
'Bolivia, Plurinational State of': 'BO',
'Bonaire, Sint Eustatius and Saba': 'BQ',
'Bosnia and Herzegovina': 'BA',
'Botswana': 'BW',
'Bouvet Island': 'BV',
'Brazil': 'BR',
'British Indian Ocean Territory': 'IO',
'Brunei Darussalam': 'BN',
'Bulgaria': 'BG',
'Burkina Faso': 'BF',
'Burundi': 'BI',
'Cambodia': 'KH',
'Cameroon': 'CM',
'Canada': 'CA',
'Cape Verde': 'CV',
'Cayman Islands': 'KY',
'Central African Republic': 'CF',
'Chad': 'TD',
'Chile': 'CL',
'China': 'CN',
'Christmas Island': 'CX',
'Cocos (Keeling) Islands': 'CC',
'Colombia': 'CO',
'Comoros': 'KM',
'Congo': 'CG',
'Congo, the Democratic Republic of the': 'CD',
'Cook Islands': 'CK',
'Costa Rica': 'CR',
'Côte d\'Ivoire': 'CI',
'Croatia': 'HR',
'Cuba': 'CU',
'Curaçao': 'CW',
'Cyprus': 'CY',
'Czech Republic': 'CZ',
'Denmark': 'DK',
'Djibouti': 'DJ',
'Dominica': 'DM',
'Dominican Republic': 'DO',
'Ecuador': 'EC',
'Egypt': 'EG',
'El Salvador': 'SV',
'Equatorial Guinea': 'GQ',
'Eritrea': 'ER',
'Estonia': 'EE',
'Ethiopia': 'ET',
'Falkland Islands (Malvinas)': 'FK',
'Faroe Islands': 'FO',
'Fiji': 'FJ',
'Finland': 'FI',
'France': 'FR',
'French Guiana': 'GF',
'French Polynesia': 'PF',
'French Southern Territories': 'TF',
'Gabon': 'GA',
'Gambia': 'GM',
'Georgia': 'GE',
'Germany': 'DE',
'Ghana': 'GH',
'Gibraltar': 'GI',
'Greece': 'GR',
'Greenland': 'GL',
'Grenada': 'GD',
'Guadeloupe': 'GP',
'Guam': 'GU',
'Guatemala': 'GT',
'Guernsey': 'GG',
'Guinea': 'GN',
'Guinea-Bissau': 'GW',
'Guyana': 'GY',
'Haiti': 'HT',
'Heard Island and McDonald Islands': 'HM',
'Holy See (Vatican City State)': 'VA',
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was unsure about the spellings of some countries and if google charts can recognize them - such as Holy See (Vatican City State), Côte d\'Ivoire, Åland Islands etc., but I did verify they work just fine.
Good job!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for review and actual verification. I did not check if they worked myself; just believed that Wikipedia listing will have them named in a proper manner and decided that they countries are not the most popular and can be checked when somebody actually visits them.

'Honduras': 'HN',
'Hong Kong': 'HK',
'Hungary': 'HU',
'Iceland': 'IS',
'India': 'IN',
'Indonesia': 'ID',
'Iran, Islamic Republic of': 'IR',
'Iraq': 'IQ',
'Ireland': 'IE',
'Isle of Man': 'IM',
'Israel': 'IL',
'Italy': 'IT',
'Jamaica': 'JM',
'Japan': 'JP',
'Jersey': 'JE',
'Jordan': 'JO',
'Kazakhstan': 'KZ',
'Kenya': 'KE',
'Kiribati': 'KI',
'Korea, Democratic People\'s Republic of': 'KP',
'Korea, Republic of': 'KR',
'Kuwait': 'KW',
'Kyrgyzstan': 'KG',
'Lao People\'s Democratic Republic': 'LA',
'Latvia': 'LV',
'Lebanon': 'LB',
'Lesotho': 'LS',
'Liberia': 'LR',
'Libya': 'LY',
'Liechtenstein': 'LI',
'Lithuania': 'LT',
'Luxembourg': 'LU',
'Macao': 'MO',
'Macedonia, the Former Yugoslav Republic of': 'MK',
'Madagascar': 'MG',
'Malawi': 'MW',
'Malaysia': 'MY',
'Maldives': 'MV',
'Mali': 'ML',
'Malta': 'MT',
'Marshall Islands': 'MH',
'Martinique': 'MQ',
'Mauritania': 'MR',
'Mauritius': 'MU',
'Mayotte': 'YT',
'Mexico': 'MX',
'Micronesia, Federated States of': 'FM',
'Moldova, Republic of': 'MD',
'Monaco': 'MC',
'Mongolia': 'MN',
'Montenegro': 'ME',
'Montserrat': 'MS',
'Morocco': 'MA',
'Mozambique': 'MZ',
'Myanmar': 'MM',
'Namibia': 'NA',
'Nauru': 'NR',
'Nepal': 'NP',
'Netherlands': 'NL',
'New Caledonia': 'NC',
'New Zealand': 'NZ',
'Nicaragua': 'NI',
'Niger': 'NE',
'Nigeria': 'NG',
'Niue': 'NU',
'Norfolk Island': 'NF',
'Northern Mariana Islands': 'MP',
'Norway': 'NO',
'Oman': 'OM',
'Pakistan': 'PK',
'Palau': 'PW',
'Palestine, State of': 'PS',
'Panama': 'PA',
'Papua New Guinea': 'PG',
'Paraguay': 'PY',
'Peru': 'PE',
'Philippines': 'PH',
'Pitcairn': 'PN',
'Poland': 'PL',
'Portugal': 'PT',
'Puerto Rico': 'PR',
'Qatar': 'QA',
'Réunion': 'RE',
'Romania': 'RO',
'Russian Federation': 'RU',
'Rwanda': 'RW',
'Saint Barthélemy': 'BL',
'Saint Helena, Ascension and Tristan da Cunha': 'SH',
'Saint Kitts and Nevis': 'KN',
'Saint Lucia': 'LC',
'Saint Martin (French part)': 'MF',
'Saint Pierre and Miquelon': 'PM',
'Saint Vincent and the Grenadines': 'VC',
'Samoa': 'WS',
'San Marino': 'SM',
'Sao Tome and Principe': 'ST',
'Saudi Arabia': 'SA',
'Senegal': 'SN',
'Serbia': 'RS',
'Seychelles': 'SC',
'Sierra Leone': 'SL',
'Singapore': 'SG',
'Sint Maarten (Dutch part)': 'SX',
'Slovakia': 'SK',
'Slovenia': 'SI',
'Solomon Islands': 'SB',
'Somalia': 'SO',
'South Africa': 'ZA',
'South Georgia and the South Sandwich Islands': 'GS',
'South Sudan': 'SS',
'Spain': 'ES',
'Sri Lanka': 'LK',
'Sudan': 'SD',
'Suriname': 'SR',
'Svalbard and Jan Mayen': 'SJ',
'Swaziland': 'SZ',
'Sweden': 'SE',
'Switzerland': 'CH',
'Syrian Arab Republic': 'SY',
'Taiwan, Province of China': 'TW',
'Tajikistan': 'TJ',
'Tanzania, United Republic of': 'TZ',
'Thailand': 'TH',
'Timor-Leste': 'TL',
'Togo': 'TG',
'Tokelau': 'TK',
'Tonga': 'TO',
'Trinidad and Tobago': 'TT',
'Tunisia': 'TN',
'Turkey': 'TR',
'Turkmenistan': 'TM',
'Turks and Caicos Islands': 'TC',
'Tuvalu': 'TV',
'Uganda': 'UG',
'Ukraine': 'UA',
'United Arab Emirates': 'AE',
'United Kingdom': 'GB',
'United States': 'US',
'United States Minor Outlying Islands': 'UM',
'Uruguay': 'UY',
'Uzbekistan': 'UZ',
'Vanuatu': 'VU',
'Venezuela, Bolivarian Republic of': 'VE',
'Viet Nam': 'VN',
'Virgin Islands, British': 'VG',
'Virgin Islands, U.S.': 'VI',
'Wallis and Futuna': 'WF',
'Western Sahara': 'EH',
'Yemen': 'YE',
'Zambia': 'ZM',
'Zimbabwe': 'ZW',
}
45 changes: 20 additions & 25 deletions data.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,21 @@
var countries = {
common: [
'BY',
'UA',
'RU',
'PL',
'Germany',
'BG',
'CZ',
'LT',
'LV',
'EE',
'Moldova',
'CH',
'FR',
'LI',
'SE',
'RU-MOW',
'RU-SPE',
'RU-LEN',
'Iran',
'Denmark'
],
ulad: ['GB', 'PT', 'US', 'US-CA', 'US-WA', 'MX', 'CU', 'RU-KDA', 'GE', 'US-NV', 'US-MA', 'US-NY', 'US-OR', 'Canada', 'CA-BC', 'US-HI', 'CA-ON', 'CA-QC', 'RU-MOS'],
marie: ['IT', 'NO', 'TR', 'RU-KR', 'Finland', 'RU-MUR', 'RU-PSK', 'RU-NGR']
var users = {
ulad: {
displayNames: {
en: 'Ulad',
},
countries: ['Belarus', 'Ukraine', 'Poland', 'Germany', 'Bulgaria', 'Czech Republic', 'Lithuania', 'Latvia', 'Estonia',
'Moldova, Republic of', 'Switzerland', 'France', 'Liechtenstein', 'Sweden', 'RU-MOW', 'RU-SPE', 'RU-LEN', 'Iran, Islamic Republic of',
'Denmark', 'United Kingdom', 'Portugal', 'US-CA', 'US-WA', 'Mexico', 'Cuba', 'RU-KDA', 'Georgia',
'US-NV', 'US-MA', 'US-NY', 'US-OR', 'CA-BC', 'US-HI', 'CA-ON',
'CA-QC', 'RU-MOS'],
},
marie: {
displayNames: {
en: 'Marie',
},
countries: ['Belarus', 'Ukraine', 'Poland', 'Germany', 'Bulgaria', 'Czech Republic', 'Lithuania', 'Latvia', 'Estonia',
'Moldova, Republic of', 'Switzerland', 'France', 'Liechtenstein', 'Sweden', 'RU-MOW', 'RU-SPE', 'RU-LEN', 'Iran, Islamic Republic of',
'Denmark', 'Italy', 'Norway', 'Turkey', 'RU-KR', 'Finland', 'RU-MUR', 'RU-PSK',
'RU-NGR'],
},
};
51 changes: 9 additions & 42 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,64 +1,31 @@
<!DOCTYPE html>
<html>
<head>
<title>Marie vs. Ulad</title>
<title>Трэкер краінаў</title>
<meta charset="utf-8"/>
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
<link rel="stylesheet" href="styles.css">
<link href="https://fonts.googleapis.com/css?family=EB+Garamond" rel="stylesheet">

<script type="text/javascript" src="utils.js"></script>
<script type="text/javascript" src="countrymap.js"></script>
<script type="text/javascript" src="data.js"></script>

<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
</head>
<body >
<div class="data">
<br>
<div class="names">Marie vs. Ulad</div>
<div class="names" id="names"></div>
<br>
<div class="numbers">21 vs. 24</div>
<div class="numbers" id="numbers"></div>
<br>
<div class="countries">
<br>
Беларусь <img class="flag" src="flags-iso/BY.png" style="vertical-align: middle; width: 30px;"><br>
<br>
Украіна <img class="flag" src="flags-iso/UA.png"><br>
Расея <img class="flag" src="flags-iso/RU.png"><br>
Польшча <img class="flag" src="flags-iso/PL.png"><br>
Нямеччына <img class="flag" src="flags-iso/DE.png"><br>
Баўгарыя <img class="flag" src="flags-iso/BG.png"><br>
Чэхія <img class="flag" src="flags-iso/CZ.png"><br>
Літва <img class="flag" src="flags-iso/LT.png"><br>
Латвія <img class="flag" src="flags-iso/LV.png"><br>
Эстонія <img class="flag" src="flags-iso/EE.png"><br>
Малдова <img class="flag" src="flags-iso/MD.png"><br>
Швейцарыя <img class="flag" src="flags-iso/CH.png"><br>
Францыя <img class="flag" src="flags-iso/FR.png"><br>
Ліхтэнштэйн <img class="flag" src="flags-iso/LI.png"><br>
Швецыя <img class="flag" src="flags-iso/SE.png"><br>
Іран <img class="flag" src="flags-iso/IR.png"><br>
Данія <img class="flag" src="flags-iso/DK.png"><br>
<br>
<div class="countries marie-countries">
Італія <img class="flag" src="flags-iso/IT.png"><br>
Нарвегія <img class="flag" src="flags-iso/NO.png"><br>
Турэччына <img class="flag" src="flags-iso/TR.png"><br>
Фінляндыя <img class="flag" src="flags-iso/FI.png"><br>
<br>
<br>
<br>
<br>
<br>
<div id="common">
</div>
<div class="countries marie-countries" id="unique_first">
</div>
<div class="countries ulad-countries">
Велікабрытанія <img class="flag" src="flags-iso/GB.png"><br>
Партугалія <img class="flag" src="flags-iso/PT.png"><br>
ЗША <img class="flag" src="flags-iso/US.png"> : <small>CA,WA,NV,MA,NY,OR,HI</small><br>
Мексіка <img class="flag" src="flags-iso/MX.png"><br>
Куба <img class="flag" src="flags-iso/CU.png"><br>
Грузія <img class="flag" src="flags-iso/GE.png"><br>
Канада <img class="flag" src="flags-iso/CA.png"> : <small>BC,ON,QC</small><br>
<br>
<div class="countries ulad-countries" id="unique_second">
</div>
</div>
</div>
Expand Down
Loading