Skip to content

Commit 8211e43

Browse files
author
Tomas Kirda
committed
Add working demo.
1 parent 930393c commit 8211e43

File tree

5 files changed

+322
-0
lines changed

5 files changed

+322
-0
lines changed

content/countries.txt

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

content/styles.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
body { font-family: sans-serif; font-size: 14px; line-height: 1.6em; margin: 0; padding: 0; }
2+
.container { width: 800px; margin: 0 auto; }
3+
4+
.autocomplete-w1 { position: absolute; top: 0px; left: 0px; }
5+
.autocomplete { border: 1px solid #999; background: #FFF; cursor: default; text-align: left; max-height: 350px; overflow: auto; /* IE6 specific: */ _height: 350px; _margin: 0; _overflow-x: hidden; }
6+
.autocomplete .selected { background: #F0F0F0; }
7+
.autocomplete div { padding: 2px 5px; white-space: nowrap; overflow: hidden; }
8+
.autocomplete strong { font-weight: normal; color: #3399FF; }
9+
10+
#query { font-size: 28px; padding: 10px; border: 1px solid #CCC; display: block; margin: 40px; }

demo.htm

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!DOCTYPE html>
2+
<html xmlns="http://www.w3.org/1999/xhtml">
3+
<head>
4+
<title>DevBridge Autocomplete Demo</title>
5+
<link href="content/styles.css" rel="stylesheet" />
6+
</head>
7+
<body>
8+
<div class="container">
9+
<h1>Ajax Autocomplete Demo</h1>
10+
<p>Type country name in english:</p>
11+
<div>
12+
<input type="text" name="query" id="query"/>
13+
</div>
14+
<div id="selection"></div>
15+
</div>
16+
17+
<script type="text/javascript" src="scripts/jquery-1.8.2.min.js"></script>
18+
<script type="text/javascript" src="src/jquery.autocomplete.js"></script>
19+
<script type="text/javascript" src="scripts/demo.js"></script>
20+
</body>
21+
</html>

scripts/demo.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*jslint browser: true, white: true, plusplus: true */
2+
/*global $: true */
3+
4+
$(function () {
5+
'use strict';
6+
7+
$.ajax({
8+
url: 'content/countries.txt',
9+
dataType: 'json'
10+
}).done(function (data) {
11+
var status = $('#selection'),
12+
countries = $.map(data, function (value) {
13+
return value;
14+
});
15+
16+
$('#query').autocomplete({
17+
lookup: countries,
18+
onSelect: function (suggestion) {
19+
status.html('You selected: ' + suggestion);
20+
}
21+
});
22+
});
23+
});

scripts/jquery-1.8.2.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.

0 commit comments

Comments
 (0)