Skip to content

Commit c97bb73

Browse files
committed
Added countries codes
1 parent 14297c1 commit c97bb73

File tree

5 files changed

+270
-2
lines changed

5 files changed

+270
-2
lines changed

projects/whatsapp_direct/index.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<div class="card">
3535
<div class="card-header">Прямая связь</div>
3636
<div class="card-body">
37-
<label>Номер телефона:</label>
37+
<label>Номер телефона: {{country}}</label>
3838
<div class="input-group mb-3">
3939
<input type="tel" class="form-control" v-model="tel" v-on:input="saveTel()">
4040
<div class="input-group-append">
@@ -69,7 +69,9 @@
6969
</div>
7070
</div>
7171

72-
<script src="script.js"></script>
72+
<script src="scripts/libphonenumber-js.min.js"></script>
73+
<script src="scripts/countries.js"></script>
74+
<script src="scripts/script.js"></script>
7375
<script src="serviceworker.js"></script>
7476
</body>
7577

Lines changed: 255 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,255 @@
1+
var isoCountries = {
2+
'AF' : 'Afghanistan',
3+
'AX' : 'Aland Islands',
4+
'AL' : 'Albania',
5+
'DZ' : 'Algeria',
6+
'AS' : 'American Samoa',
7+
'AD' : 'Andorra',
8+
'AO' : 'Angola',
9+
'AI' : 'Anguilla',
10+
'AQ' : 'Antarctica',
11+
'AG' : 'Antigua And Barbuda',
12+
'AR' : 'Argentina',
13+
'AM' : 'Armenia',
14+
'AW' : 'Aruba',
15+
'AU' : 'Australia',
16+
'AT' : 'Austria',
17+
'AZ' : 'Azerbaijan',
18+
'BS' : 'Bahamas',
19+
'BH' : 'Bahrain',
20+
'BD' : 'Bangladesh',
21+
'BB' : 'Barbados',
22+
'BY' : 'Belarus',
23+
'BE' : 'Belgium',
24+
'BZ' : 'Belize',
25+
'BJ' : 'Benin',
26+
'BM' : 'Bermuda',
27+
'BT' : 'Bhutan',
28+
'BO' : 'Bolivia',
29+
'BA' : 'Bosnia And Herzegovina',
30+
'BW' : 'Botswana',
31+
'BV' : 'Bouvet Island',
32+
'BR' : 'Brazil',
33+
'IO' : 'British Indian Ocean Territory',
34+
'BN' : 'Brunei Darussalam',
35+
'BG' : 'Bulgaria',
36+
'BF' : 'Burkina Faso',
37+
'BI' : 'Burundi',
38+
'KH' : 'Cambodia',
39+
'CM' : 'Cameroon',
40+
'CA' : 'Canada',
41+
'CV' : 'Cape Verde',
42+
'KY' : 'Cayman Islands',
43+
'CF' : 'Central African Republic',
44+
'TD' : 'Chad',
45+
'CL' : 'Chile',
46+
'CN' : 'China',
47+
'CX' : 'Christmas Island',
48+
'CC' : 'Cocos (Keeling) Islands',
49+
'CO' : 'Colombia',
50+
'KM' : 'Comoros',
51+
'CG' : 'Congo',
52+
'CD' : 'Congo, Democratic Republic',
53+
'CK' : 'Cook Islands',
54+
'CR' : 'Costa Rica',
55+
'CI' : 'Cote D\'Ivoire',
56+
'HR' : 'Croatia',
57+
'CU' : 'Cuba',
58+
'CY' : 'Cyprus',
59+
'CZ' : 'Czech Republic',
60+
'DK' : 'Denmark',
61+
'DJ' : 'Djibouti',
62+
'DM' : 'Dominica',
63+
'DO' : 'Dominican Republic',
64+
'EC' : 'Ecuador',
65+
'EG' : 'Egypt',
66+
'SV' : 'El Salvador',
67+
'GQ' : 'Equatorial Guinea',
68+
'ER' : 'Eritrea',
69+
'EE' : 'Estonia',
70+
'ET' : 'Ethiopia',
71+
'FK' : 'Falkland Islands (Malvinas)',
72+
'FO' : 'Faroe Islands',
73+
'FJ' : 'Fiji',
74+
'FI' : 'Finland',
75+
'FR' : 'France',
76+
'GF' : 'French Guiana',
77+
'PF' : 'French Polynesia',
78+
'TF' : 'French Southern Territories',
79+
'GA' : 'Gabon',
80+
'GM' : 'Gambia',
81+
'GE' : 'Georgia',
82+
'DE' : 'Germany',
83+
'GH' : 'Ghana',
84+
'GI' : 'Gibraltar',
85+
'GR' : 'Greece',
86+
'GL' : 'Greenland',
87+
'GD' : 'Grenada',
88+
'GP' : 'Guadeloupe',
89+
'GU' : 'Guam',
90+
'GT' : 'Guatemala',
91+
'GG' : 'Guernsey',
92+
'GN' : 'Guinea',
93+
'GW' : 'Guinea-Bissau',
94+
'GY' : 'Guyana',
95+
'HT' : 'Haiti',
96+
'HM' : 'Heard Island & Mcdonald Islands',
97+
'VA' : 'Holy See (Vatican City State)',
98+
'HN' : 'Honduras',
99+
'HK' : 'Hong Kong',
100+
'HU' : 'Hungary',
101+
'IS' : 'Iceland',
102+
'IN' : 'India',
103+
'ID' : 'Indonesia',
104+
'IR' : 'Iran, Islamic Republic Of',
105+
'IQ' : 'Iraq',
106+
'IE' : 'Ireland',
107+
'IM' : 'Isle Of Man',
108+
'IL' : 'Israel',
109+
'IT' : 'Italy',
110+
'JM' : 'Jamaica',
111+
'JP' : 'Japan',
112+
'JE' : 'Jersey',
113+
'JO' : 'Jordan',
114+
'KZ' : 'Kazakhstan',
115+
'KE' : 'Kenya',
116+
'KI' : 'Kiribati',
117+
'KR' : 'Korea',
118+
'KW' : 'Kuwait',
119+
'KG' : 'Kyrgyzstan',
120+
'LA' : 'Lao People\'s Democratic Republic',
121+
'LV' : 'Latvia',
122+
'LB' : 'Lebanon',
123+
'LS' : 'Lesotho',
124+
'LR' : 'Liberia',
125+
'LY' : 'Libyan Arab Jamahiriya',
126+
'LI' : 'Liechtenstein',
127+
'LT' : 'Lithuania',
128+
'LU' : 'Luxembourg',
129+
'MO' : 'Macao',
130+
'MK' : 'Macedonia',
131+
'MG' : 'Madagascar',
132+
'MW' : 'Malawi',
133+
'MY' : 'Malaysia',
134+
'MV' : 'Maldives',
135+
'ML' : 'Mali',
136+
'MT' : 'Malta',
137+
'MH' : 'Marshall Islands',
138+
'MQ' : 'Martinique',
139+
'MR' : 'Mauritania',
140+
'MU' : 'Mauritius',
141+
'YT' : 'Mayotte',
142+
'MX' : 'Mexico',
143+
'FM' : 'Micronesia, Federated States Of',
144+
'MD' : 'Moldova',
145+
'MC' : 'Monaco',
146+
'MN' : 'Mongolia',
147+
'ME' : 'Montenegro',
148+
'MS' : 'Montserrat',
149+
'MA' : 'Morocco',
150+
'MZ' : 'Mozambique',
151+
'MM' : 'Myanmar',
152+
'NA' : 'Namibia',
153+
'NR' : 'Nauru',
154+
'NP' : 'Nepal',
155+
'NL' : 'Netherlands',
156+
'AN' : 'Netherlands Antilles',
157+
'NC' : 'New Caledonia',
158+
'NZ' : 'New Zealand',
159+
'NI' : 'Nicaragua',
160+
'NE' : 'Niger',
161+
'NG' : 'Nigeria',
162+
'NU' : 'Niue',
163+
'NF' : 'Norfolk Island',
164+
'MP' : 'Northern Mariana Islands',
165+
'NO' : 'Norway',
166+
'OM' : 'Oman',
167+
'PK' : 'Pakistan',
168+
'PW' : 'Palau',
169+
'PS' : 'Palestinian Territory, Occupied',
170+
'PA' : 'Panama',
171+
'PG' : 'Papua New Guinea',
172+
'PY' : 'Paraguay',
173+
'PE' : 'Peru',
174+
'PH' : 'Philippines',
175+
'PN' : 'Pitcairn',
176+
'PL' : 'Poland',
177+
'PT' : 'Portugal',
178+
'PR' : 'Puerto Rico',
179+
'QA' : 'Qatar',
180+
'RE' : 'Reunion',
181+
'RO' : 'Romania',
182+
'RU' : 'Russian Federation',
183+
'RW' : 'Rwanda',
184+
'BL' : 'Saint Barthelemy',
185+
'SH' : 'Saint Helena',
186+
'KN' : 'Saint Kitts And Nevis',
187+
'LC' : 'Saint Lucia',
188+
'MF' : 'Saint Martin',
189+
'PM' : 'Saint Pierre And Miquelon',
190+
'VC' : 'Saint Vincent And Grenadines',
191+
'WS' : 'Samoa',
192+
'SM' : 'San Marino',
193+
'ST' : 'Sao Tome And Principe',
194+
'SA' : 'Saudi Arabia',
195+
'SN' : 'Senegal',
196+
'RS' : 'Serbia',
197+
'SC' : 'Seychelles',
198+
'SL' : 'Sierra Leone',
199+
'SG' : 'Singapore',
200+
'SK' : 'Slovakia',
201+
'SI' : 'Slovenia',
202+
'SB' : 'Solomon Islands',
203+
'SO' : 'Somalia',
204+
'ZA' : 'South Africa',
205+
'GS' : 'South Georgia And Sandwich Isl.',
206+
'ES' : 'Spain',
207+
'LK' : 'Sri Lanka',
208+
'SD' : 'Sudan',
209+
'SR' : 'Suriname',
210+
'SJ' : 'Svalbard And Jan Mayen',
211+
'SZ' : 'Swaziland',
212+
'SE' : 'Sweden',
213+
'CH' : 'Switzerland',
214+
'SY' : 'Syrian Arab Republic',
215+
'TW' : 'Taiwan',
216+
'TJ' : 'Tajikistan',
217+
'TZ' : 'Tanzania',
218+
'TH' : 'Thailand',
219+
'TL' : 'Timor-Leste',
220+
'TG' : 'Togo',
221+
'TK' : 'Tokelau',
222+
'TO' : 'Tonga',
223+
'TT' : 'Trinidad And Tobago',
224+
'TN' : 'Tunisia',
225+
'TR' : 'Turkey',
226+
'TM' : 'Turkmenistan',
227+
'TC' : 'Turks And Caicos Islands',
228+
'TV' : 'Tuvalu',
229+
'UG' : 'Uganda',
230+
'UA' : 'Ukraine',
231+
'AE' : 'United Arab Emirates',
232+
'GB' : 'United Kingdom',
233+
'US' : 'United States',
234+
'UM' : 'United States Outlying Islands',
235+
'UY' : 'Uruguay',
236+
'UZ' : 'Uzbekistan',
237+
'VU' : 'Vanuatu',
238+
'VE' : 'Venezuela',
239+
'VN' : 'Viet Nam',
240+
'VG' : 'Virgin Islands, British',
241+
'VI' : 'Virgin Islands, U.S.',
242+
'WF' : 'Wallis And Futuna',
243+
'EH' : 'Western Sahara',
244+
'YE' : 'Yemen',
245+
'ZM' : 'Zambia',
246+
'ZW' : 'Zimbabwe'
247+
};
248+
249+
function getCountryName (countryCode) {
250+
if (isoCountries.hasOwnProperty(countryCode)) {
251+
return isoCountries[countryCode];
252+
} else {
253+
return countryCode;
254+
}
255+
}

projects/whatsapp_direct/scripts/libphonenumber-js.min.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

projects/whatsapp_direct/scripts/libphonenumber-js.min.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

projects/whatsapp_direct/script.js renamed to projects/whatsapp_direct/scripts/script.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ var app = new Vue({
1818
},
1919
whatsapp_link: function () {
2020
return 'https://api.whatsapp.com/send?phone=' + this.tel_numeric + '&text=' + this.message_encoded
21+
},
22+
country: function () {
23+
var data = new libphonenumber.parse('+' + this.tel_numeric)
24+
25+
if (data.country == undefined)
26+
return ''
27+
28+
return data.country + ' - ' + getCountryName(data.country)
2129
}
2230
},
2331
methods: {

0 commit comments

Comments
 (0)