PK
886{ ajax.arcUT ܐH#HUx (defop auto_complete req
(let prefix (downcase (arg req "prefix"))
(prn (to-html-list (cut (startselts prefix keylist) 0 10)))))
(defop getcontents req
(with (field (arg req "field") name (arg req "name"))
(if (is field "population") (prn ((database name) 1))
(is field "area") (prn ((database name) 2))
(is field "capital") (prn ((database name) 3)))))
; Returns a list of elements that start with prefix
(def startselts (prefix seq) (rem [no (begins (downcase _) prefix)] seq))
; Wraps elts in HTML list tags
(def to-html-list (elts) (tostring
(prall elts "
")))
; Read the data, converting from a list into a table
; (database "United States") is
; ("United States" "301,139,947" "9,826,630" "Washington, DC")
(= database (table))
(w/infile inf "data.arc"
(let datalist (sread inf nil)
(each elt datalist
(= (database (elt 0)) elt))))
(= keylist (mergesort < (keys database)))
; Patch srv.arc to allow .js files
(= (srv-header* 'text/javascript)
"HTTP/1.0 200 OK
Content-Type: text/javascript; charset=UTF-8
Connection: close")
(def static-filetype (sym)
(let fname (string sym)
(and (~find #\/ fname)
(case (last (check (tokens fname #\.) ~single))
"gif" 'gif
"jpg" 'jpg
"css" 'text/css
"txt" 'text/html
"html" 'text/html
"js" 'text/javascript
))))
PK
,8@pV, V, data.arcUT T? H#HUx (("Afghanistan" "31,889,923" "647,500" "Kabul") ("Akrotiri" "15,700" "123" "Episkopi Cantonment (base administrative center for Akrotiri and Dhekelia)") ("Albania" "3,600,523" "28,748" "Tirana (Tirane)") ("Algeria" "33,333,216" "2,381,740" "Algiers") ("American Samoa" "57,663" "199" "Pago Pago") ("Andorra" "71,822" "468" "Andorra la Vella") ("Angola" "12,263,596" "1,246,700" "Luanda") ("Anguilla" "13,677" "102" "The Valley") ("Antigua and Barbuda" "69,481" "443" "Saint John's") ("Argentina" "40,301,927" "2,766,890" "Buenos Aires") ("Armenia" "2,971,650" "29,800" "Yerevan") ("Aruba" "100,018" "193" "Oranjestad") ("Australia" "20,434,176" "7,686,850" "Canberra") ("Austria" "8,199,783" "83,870" "Vienna") ("Azerbaijan" "8,120,247" "86,600" "Baku (Baki, Baky)") ("Bahamas, The" "305,655" "13,940" "Nassau") ("Bahrain" "708,573" "665" "Manama") ("Bangladesh" "150,448,339" "144,000" "Dhaka") ("Barbados" "280,946" "431" "Bridgetown") ("Belarus" "9,724,723" "207,600" "Minsk") ("Belgium" "10,392,226" "30,528" "Brussels") ("Belize" "294,385" "22,966" "Belmopan") ("Benin" "8,078,314" "112,620" "Porto-Novo (official capital)") ("Bermuda" "66,163" "53" "Hamilton") ("Bhutan" "2,327,849" "47,000" "Thimphu") ("Bolivia" "9,119,152" "1,098,580" "La Paz (administrative capital)") ("Bosnia and Herzegovina" "4,552,198" "51,129" "Sarajevo") ("Botswana" "1,815,508" "600,370" "Gaborone") ("Brazil" "190,010,647" "8,511,965" "Brasilia") ("British Virgin Islands" "23,552" "153" "Road Town") ("Brunei" "374,577" "5,770" "Bandar Seri Begawan") ("Bulgaria" "7,322,858" "110,910" "Sofia") ("Burkina Faso" "14,326,203" "274,200" "Ouagadougou") ("Burma" "47,373,958" "678,500" "Rangoon (Yangon)") ("Burundi" "8,390,505" "27,830" "Bujumbura") ("Cambodia" "13,995,904" "181,040" "Phnom Penh") ("Cameroon" "18,060,382" "475,440" "Yaounde") ("Canada" "33,390,141" "9,984,670" "Ottawa") ("Cape Verde" "423,613" "4,033" "Praia") ("Cayman Islands" "46,600" "262" "George Town (on Grand Cayman)") ("Central African Republic" "4,369,038" "622,984" "Bangui") ("Chad" "9,885,661" "1,284,000" "N'Djamena") ("Chile" "16,284,741" "756,950" "Santiago") ("China" "1,321,851,888" "9,596,960" "Beijing") ("Christmas Island" "1,402" "135" "The Settlement") ("Cocos (Keeling) Islands" "596" "14" "West Island") ("Colombia" "44,379,598" "1,138,910" "Bogota") ("Comoros" "711,417" "2,170" "Moroni") ("Congo, Democratic Republic of the" "65,751,512" "2,345,410" "Kinshasa") ("Congo, Republic of the" "3,800,610" "342,000" "Brazzaville") ("Cook Islands" "21,750" "237" "Avarua") ("Costa Rica" "4,133,884" "51,100" "San Jose") ("Cote d'Ivoire" "18,013,409" "322,460" "Yamoussoukro") ("Croatia" "4,493,312" "56,542" "Zagreb") ("Cuba" "11,394,043" "110,860" "Havana") ("Cyprus" "788,457" "9,250" "Nicosia (Lefkosia)") ("Czech Republic" "10,228,744" "78,866" "Prague") ("Denmark" "5,468,120" "43,094" "Copenhagen") ("Dhekelia" "15,700" "131" "Episkopi Cantonment (base administrative center for Akrotiri and Dhekelia); located in Akrotiri") ("Djibouti" "496,374" "23,000" "Djibouti") ("Dominica" "72,386" "754" "Roseau") ("Dominican Republic" "9,365,818" "48,730" "Santo Domingo") ("Ecuador" "13,755,680" "283,560" "Quito") ("Egypt" "80,335,036" "1,001,450" "Cairo") ("El Salvador" "6,948,073" "21,040" "San Salvador") ("Equatorial Guinea" "551,201" "28,051" "Malabo") ("Eritrea" "4,906,585" "121,320" "Asmara (Asmera)") ("Estonia" "1,315,912" "45,226" "Tallinn") ("Ethiopia" "76,511,887" "1,127,127" "Addis Ababa") ("European Union" "490,426,060" "4,324,782" "Brussels (Belgium), Strasbourg (France), Luxembourg") ("Falkland Islands (Islas Malvinas)" "3,105" "12,173" "Stanley") ("Faroe Islands" "47,511" "1,399" "Torshavn") ("Fiji" "918,675" "18,270" "Suva (on Viti Levu)") ("Finland" "5,238,460" "338,145" "Helsinki") ("France" "64,057,790" "643,427" "Paris") ("French Polynesia" "278,963" "4,167" "Papeete") ("Gabon" "1,454,867" "267,667" "Libreville") ("Gambia, The" "1,688,359" "11,300" "Banjul") ("Gaza Strip" "1,482,405" "360" "") ("Georgia" "4,646,003" "69,700" "T'bilisi") ("Germany" "82,400,996" "357,021" "Berlin") ("Ghana" "22,931,299" "239,460" "Accra") ("Gibraltar" "27,967" "7" "Gibraltar") ("Greece" "10,706,290" "131,940" "Athens") ("Greenland" "56,344" "2,166,086" "Nuuk (Godthab)") ("Grenada" "89,971" "344" "Saint George's") ("Guam" "173,456" "541" "Hagatna (Agana)") ("Guatemala" "12,728,111" "108,890" "Guatemala") ("Guernsey" "65,573" "78" "Saint Peter Port") ("Guinea" "9,947,814" "245,857" "Conakry") ("Guinea-Bissau" "1,472,780" "36,120" "Bissau") ("Guyana" "769,095" "214,970" "Georgetown") ("Haiti" "8,706,497" "27,750" "Port-au-Prince") ("Holy See (Vatican City)" "821" "0" "Vatican City") ("Honduras" "7,483,763" "112,090" "Tegucigalpa") ("Hong Kong" "6,980,412" "1,092" "") ("Hungary" "9,956,108" "93,030" "Budapest") ("Iceland" "301,931" "103,000" "Reykjavik") ("India" "1,129,866,154" "3,287,590" "New Delhi") ("Indonesia" "234,693,997" "1,919,440" "Jakarta") ("Iran" "65,397,521" "1,648,000" "Tehran") ("Iraq" "27,499,638" "437,072" "Baghdad") ("Ireland" "4,109,086" "70,280" "Dublin") ("Isle of Man" "75,831" "572" "Douglas") ("Israel" "6,426,679" "20,770" "Jerusalem") ("Italy" "58,147,733" "301,230" "Rome") ("Jamaica" "2,780,132" "10,991" "Kingston") ("Japan" "127,433,494" "377,835" "Tokyo") ("Jersey" "91,321" "116" "Saint Helier") ("Jordan" "6,053,193" "92,300" "Amman") ("Kazakhstan" "15,284,929" "2,717,300" "Astana") ("Kenya" "36,913,721" "582,650" "Nairobi") ("Kiribati" "107,817" "811" "Tarawa") ("Korea, North" "23,301,725" "120,540" "Pyongyang") ("Korea, South" "49,044,790" "98,480" "Seoul") ("Kosovo" "2,126,708" "10,887" "Pristina (Prishtine)") ("Kuwait" "2,505,559" "17,820" "Kuwait") ("Kyrgyzstan" "5,284,149" "198,500" "Bishkek") ("Laos" "6,521,998" "236,800" "Vientiane") ("Latvia" "2,259,810" "64,589" "Riga") ("Lebanon" "3,925,502" "10,400" "Beirut") ("Lesotho" "2,125,262" "30,355" "Maseru") ("Liberia" "3,195,931" "111,370" "Monrovia") ("Libya" "6,036,914" "1,759,540" "Tripoli") ("Liechtenstein" "34,247" "160" "Vaduz") ("Lithuania" "3,575,439" "65,200" "Vilnius") ("Luxembourg" "480,222" "2,586" "Luxembourg") ("Macau" "456,989" "28" "") ("Macedonia" "2,055,915" "25,333" "Skopje") ("Madagascar" "19,448,815" "587,040" "Antananarivo") ("Malawi" "13,603,181" "118,480" "Lilongwe") ("Malaysia" "24,821,286" "329,750" "Kuala Lumpur") ("Maldives" "369,031" "300" "Male") ("Mali" "11,995,402" "1,240,000" "Bamako") ("Malta" "401,880" "316" "Valletta") ("Marshall Islands" "61,815" "181" "Majuro") ("Mauritania" "3,270,065" "1,030,700" "Nouakchott") ("Mauritius" "1,250,882" "2,040" "Port Louis") ("Mayotte" "208,783" "374" "Mamoudzou") ("Mexico" "108,700,891" "1,972,550" "Mexico (Distrito Federal)") ("Micronesia, Federated States of" "107,862" "702" "Palikir") ("Moldova" "4,320,490" "33,843" "Chisinau (Kishinev)") ("Monaco" "32,671" "2" "Monaco") ("Mongolia" "2,951,786" "1,564,116" "Ulaanbaatar") ("Montenegro" "684,736" "14,026" "Podgorica") ("Montserrat" "9,538" "102" "Plymouth") ("Morocco" "33,757,175" "446,550" "Rabat") ("Mozambique" "20,905,585" "801,590" "Maputo") ("Namibia" "2,055,080" "825,418" "Windhoek") ("Nauru" "13,528" "21" "") ("Nepal" "28,901,790" "147,181" "Kathmandu") ("Netherlands" "16,570,613" "41,526" "Amsterdam") ("Netherlands Antilles" "223,652" "960" "Willemstad (on Curacao)") ("New Caledonia" "221,943" "19,060" "Noumea") ("New Zealand" "4,115,771" "268,680" "Wellington") ("Nicaragua" "5,675,356" "129,494" "Managua") ("Niger" "12,894,865" "1,267,000" "Niamey") ("Nigeria" "135,031,164" "923,768" "Abuja") ("Niue" "1,492" "260" "Alofi") ("Norfolk Island" "2,114" "35" "Kingston") ("Northern Mariana Islands" "84,546" "477" "Saipan") ("Norway" "4,627,926" "323,802" "Oslo") ("Oman" "3,204,897" "212,460" "Muscat") ("Pakistan" "164,741,924" "803,940" "Islamabad") ("Palau" "20,842" "458" "Melekeok") ("Panama" "3,242,173" "78,200" "Panama") ("Papua New Guinea" "5,795,887" "462,840" "Port Moresby") ("Paraguay" "6,669,086" "406,750" "Asuncion") ("Peru" "28,674,757" "1,285,220" "Lima") ("Philippines" "91,077,287" "300,000" "Manila") ("Pitcairn Islands" "48" "47" "Adamstown") ("Poland" "38,518,241" "312,685" "Warsaw") ("Portugal" "10,642,836" "92,391" "Lisbon") ("Puerto Rico" "3,944,259" "13,790" "San Juan") ("Qatar" "907,229" "11,437" "Doha") ("Romania" "22,276,056" "237,500" "Bucharest") ("Russia" "141,377,752" "17,075,200" "Moscow") ("Rwanda" "9,907,509" "26,338" "Kigali") ("Saint Helena" "7,543" "413" "Jamestown") ("Saint Kitts and Nevis" "39,349" "261" "Basseterre") ("Saint Lucia" "170,649" "616" "Castries") ("Saint Martin" "33,102" "54" "Marigot") ("Saint Pierre and Miquelon" "7,036" "242" "Saint-Pierre") ("Saint Vincent and the Grenadines" "118,149" "389" "Kingstown") ("Samoa" "214,265" "2,944" "Apia") ("San Marino" "29,615" "61" "San Marino") ("Sao Tome and Principe" "199,579" "1,001" "Sao Tome") ("Saudi Arabia" "27,601,038" "2,149,690" "Riyadh") ("Senegal" "12,521,851" "196,190" "Dakar") ("Serbia" "10,150,265" "77,474" "Belgrade") ("Seychelles" "81,895" "455" "Victoria") ("Sierra Leone" "6,144,562" "71,740" "Freetown") ("Singapore" "4,553,009" "693" "Singapore") ("Slovakia" "5,447,502" "48,845" "Bratislava") ("Slovenia" "2,009,245" "20,273" "Ljubljana") ("Solomon Islands" "566,842" "28,450" "Honiara") ("Somalia" "9,118,773" "637,657" "Mogadishu") ("South Africa" "43,997,828" "1,219,912" "Pretoria (administrative capital)") ("Spain" "40,448,191" "504,782" "Madrid") ("Sri Lanka" "20,926,315" "65,610" "Colombo") ("Sudan" "39,379,358" "2,505,810" "Khartoum") ("Suriname" "470,784" "163,270" "Paramaribo") ("Svalbard" "2,214" "61,020" "Longyearbyen") ("Swaziland" "1,133,066" "17,363" "Mbabane") ("Sweden" "9,031,088" "449,964" "Stockholm") ("Switzerland" "7,554,661" "41,290" "Bern") ("Syria" "19,314,747" "185,180" "Damascus") ("Taiwan" "22,858,872" "35,980" "Taipei") ("Tajikistan" "7,076,598" "143,100" "Dushanbe") ("Tanzania" "39,384,223" "945,087" "Dar es Salaam") ("Thailand" "65,068,149" "514,000" "Bangkok") ("Timor-Leste" "1,084,971" "15,007" "Dili") ("Togo" "5,701,579" "56,785" "Lome") ("Tokelau" "1,449" "10" "") ("Tonga" "116,921" "748" "Nuku'alofa") ("Trinidad and Tobago" "1,056,608" "5,128" "Port-of-Spain") ("Tunisia" "10,276,158" "163,610" "Tunis") ("Turkey" "71,158,647" "780,580" "Ankara") ("Turkmenistan" "5,097,028" "488,100" "Ashgabat (Ashkhabad)") ("Turks and Caicos Islands" "21,746" "430" "Grand Turk (Cockburn Town)") ("Tuvalu" "11,992" "26" "Funafuti") ("Uganda" "30,262,610" "236,040" "Kampala") ("Ukraine" "46,299,862" "603,700" "Kyiv (Kiev)") ("United Arab Emirates" "4,444,011" "83,600" "Abu Dhabi") ("United Kingdom" "60,776,238" "244,820" "London") ("United States" "301,139,947" "9,826,630" "Washington, DC") ("Uruguay" "3,460,607" "176,220" "Montevideo") ("Uzbekistan" "27,780,059" "447,400" "Tashkent (Toshkent)") ("Vanuatu" "211,971" "12,200" "Port-Vila (on Efate)") ("Venezuela" "26,023,528" "912,050" "Caracas") ("Vietnam" "85,262,356" "329,560" "Hanoi") ("Virgin Islands" "108,448" "1,910" "Charlotte Amalie") ("Wallis and Futuna" "16,309" "274" "Mata-Utu (on Ile Uvea)") ("West Bank" "2,535,927" "5,860" "") ("Western Sahara" "382,617" "266,000" "") ("World" "6,602,224,175" "510,072,000" "") ("Yemen" "22,230,531" "527,970" "Sanaa") ("Zambia" "11,477,447" "752,614" "Lusaka") ("Zimbabwe" "12,311,143" "390,580" "Harare"))PK D8]~a ajax.htmlUT ϒHHUx SM0WЀ#MREl=j:bֱ- DK@EEvyc$o\+$oapVL;j\-)e{zy6ne^(o$\AQm