Best JavaScript code snippet using wpt
generator.js
Source:generator.js
1(function() {2 'use strict';3 var app = angular.module('WonderfulWorld');4 app.controller('GeneratorController', ['$scope', 'utilityService', 'PlacesDatabase',5 function($scope, util, PlacesDatabase) {6 $scope.countries = [7 {8 "name": "Afghanistan",9 "alpha-2": "AF",10 "country-code": "004"11 }, {12 "name": "Ã
land Islands",13 "alpha-2": "AX",14 "country-code": "248"15 }, {16 "name": "Albania",17 "alpha-2": "AL",18 "country-code": "008"19 }, {20 "name": "Algeria",21 "alpha-2": "DZ",22 "country-code": "012"23 }, {24 "name": "American Samoa",25 "alpha-2": "AS",26 "country-code": "016"27 }, {28 "name": "Andorra",29 "alpha-2": "AD",30 "country-code": "020"31 }, {32 "name": "Angola",33 "alpha-2": "AO",34 "country-code": "024"35 }, {36 "name": "Anguilla",37 "alpha-2": "AI",38 "country-code": "660"39 }, {40 "name": "Antarctica",41 "alpha-2": "AQ",42 "country-code": "010"43 }, {44 "name": "Antigua and Barbuda",45 "alpha-2": "AG",46 "country-code": "028"47 }, {48 "name": "Argentina",49 "alpha-2": "AR",50 "country-code": "032"51 }, {52 "name": "Armenia",53 "alpha-2": "AM",54 "country-code": "051"55 }, {56 "name": "Aruba",57 "alpha-2": "AW",58 "country-code": "533"59 }, {60 "name": "Australia",61 "alpha-2": "AU",62 "country-code": "036"63 }, {64 "name": "Austria",65 "alpha-2": "AT",66 "country-code": "040"67 }, {68 "name": "Azerbaijan",69 "alpha-2": "AZ",70 "country-code": "031"71 }, {72 "name": "Bahamas",73 "alpha-2": "BS",74 "country-code": "044"75 }, {76 "name": "Bahrain",77 "alpha-2": "BH",78 "country-code": "048"79 }, {80 "name": "Bangladesh",81 "alpha-2": "BD",82 "country-code": "050"83 }, {84 "name": "Barbados",85 "alpha-2": "BB",86 "country-code": "052"87 }, {88 "name": "Belarus",89 "alpha-2": "BY",90 "country-code": "112"91 }, {92 "name": "Belgium",93 "alpha-2": "BE",94 "country-code": "056"95 }, {96 "name": "Belize",97 "alpha-2": "BZ",98 "country-code": "084"99 }, {100 "name": "Benin",101 "alpha-2": "BJ",102 "country-code": "204"103 }, {104 "name": "Bermuda",105 "alpha-2": "BM",106 "country-code": "060"107 }, {108 "name": "Bhutan",109 "alpha-2": "BT",110 "country-code": "064"111 }, {112 "name": "Bolivia",113 "alpha-2": "BO",114 "country-code": "068"115 }, {116 "name": "Bonaire, Sint Eustatius and Saba",117 "alpha-2": "BQ",118 "country-code": "535"119 }, {120 "name": "Bosnia and Herzegovina",121 "alpha-2": "BA",122 "country-code": "070"123 }, {124 "name": "Botswana",125 "alpha-2": "BW",126 "country-code": "072"127 }, {128 "name": "Bouvet Island",129 "alpha-2": "BV",130 "country-code": "074"131 }, {132 "name": "Brazil",133 "alpha-2": "BR",134 "country-code": "076"135 }, {136 "name": "British Indian Ocean Territory",137 "alpha-2": "IO",138 "country-code": "086"139 }, {140 "name": "Brunei Darussalam",141 "alpha-2": "BN",142 "country-code": "096"143 }, {144 "name": "Bulgaria",145 "alpha-2": "BG",146 "country-code": "100"147 }, {148 "name": "Burkina Faso",149 "alpha-2": "BF",150 "country-code": "854"151 }, {152 "name": "Burundi",153 "alpha-2": "BI",154 "country-code": "108"155 }, {156 "name": "Cambodia",157 "alpha-2": "KH",158 "country-code": "116"159 }, {160 "name": "Cameroon",161 "alpha-2": "CM",162 "country-code": "120"163 }, {164 "name": "Canada",165 "alpha-2": "CA",166 "country-code": "124"167 }, {168 "name": "Cabo Verde",169 "alpha-2": "CV",170 "country-code": "132"171 }, {172 "name": "Cayman Islands",173 "alpha-2": "KY",174 "country-code": "136"175 }, {176 "name": "Central African Republic",177 "alpha-2": "CF",178 "country-code": "140"179 }, {180 "name": "Chad",181 "alpha-2": "TD",182 "country-code": "148"183 }, {184 "name": "Chile",185 "alpha-2": "CL",186 "country-code": "152"187 }, {188 "name": "China",189 "alpha-2": "CN",190 "country-code": "156"191 }, {192 "name": "Christmas Island",193 "alpha-2": "CX",194 "country-code": "162"195 }, {196 "name": "Cocos Islands",197 "alpha-2": "CC",198 "country-code": "166"199 }, {200 "name": "Colombia",201 "alpha-2": "CO",202 "country-code": "170"203 }, {204 "name": "Comoros",205 "alpha-2": "KM",206 "country-code": "174"207 }, {208 "name": "Congo",209 "alpha-2": "CG",210 "country-code": "178"211 }, {212 "name": "Congo DR",213 "alpha-2": "CD",214 "country-code": "180"215 }, {216 "name": "Cook Islands",217 "alpha-2": "CK",218 "country-code": "184"219 }, {220 "name": "Costa Rica",221 "alpha-2": "CR",222 "country-code": "188"223 }, {224 "name": "Côte d'Ivoire",225 "alpha-2": "CI",226 "country-code": "384"227 }, {228 "name": "Croatia",229 "alpha-2": "HR",230 "country-code": "191"231 }, {232 "name": "Cuba",233 "alpha-2": "CU",234 "country-code": "192"235 }, {236 "name": "Curaçao",237 "alpha-2": "CW",238 "country-code": "531"239 }, {240 "name": "Cyprus",241 "alpha-2": "CY",242 "country-code": "196"243 }, {244 "name": "Czech Republic",245 "alpha-2": "CZ",246 "country-code": "203"247 }, {248 "name": "Denmark",249 "alpha-2": "DK",250 "country-code": "208"251 }, {252 "name": "Djibouti",253 "alpha-2": "DJ",254 "country-code": "262"255 }, {256 "name": "Dominica",257 "alpha-2": "DM",258 "country-code": "212"259 }, {260 "name": "Dominican Republic",261 "alpha-2": "DO",262 "country-code": "214"263 }, {264 "name": "Ecuador",265 "alpha-2": "EC",266 "country-code": "218"267 }, {268 "name": "Egypt",269 "alpha-2": "EG",270 "country-code": "818"271 }, {272 "name": "El Salvador",273 "alpha-2": "SV",274 "country-code": "222"275 }, {276 "name": "Equatorial Guinea",277 "alpha-2": "GQ",278 "country-code": "226"279 }, {280 "name": "Eritrea",281 "alpha-2": "ER",282 "country-code": "232"283 }, {284 "name": "Estonia",285 "alpha-2": "EE",286 "country-code": "233"287 }, {288 "name": "Ethiopia",289 "alpha-2": "ET",290 "country-code": "231"291 }, {292 "name": "Falkland Islands",293 "alpha-2": "FK",294 "country-code": "238"295 }, {296 "name": "Faroe Islands",297 "alpha-2": "FO",298 "country-code": "234"299 }, {300 "name": "Fiji",301 "alpha-2": "FJ",302 "country-code": "242"303 }, {304 "name": "Finland",305 "alpha-2": "FI",306 "country-code": "246"307 }, {308 "name": "France",309 "alpha-2": "FR",310 "country-code": "250"311 }, {312 "name": "French Guiana",313 "alpha-2": "GF",314 "country-code": "254"315 }, {316 "name": "French Polynesia",317 "alpha-2": "PF",318 "country-code": "258"319 }, {320 "name": "French Southern Territories",321 "alpha-2": "TF",322 "country-code": "260"323 }, {324 "name": "Gabon",325 "alpha-2": "GA",326 "country-code": "266"327 }, {328 "name": "Gambia",329 "alpha-2": "GM",330 "country-code": "270"331 }, {332 "name": "Georgia",333 "alpha-2": "GE",334 "country-code": "268"335 }, {336 "name": "Germany",337 "alpha-2": "DE",338 "country-code": "276"339 }, {340 "name": "Ghana",341 "alpha-2": "GH",342 "country-code": "288"343 }, {344 "name": "Gibraltar",345 "alpha-2": "GI",346 "country-code": "292"347 }, {348 "name": "Greece",349 "alpha-2": "GR",350 "country-code": "300"351 }, {352 "name": "Greenland",353 "alpha-2": "GL",354 "country-code": "304"355 }, {356 "name": "Grenada",357 "alpha-2": "GD",358 "country-code": "308"359 }, {360 "name": "Guadeloupe",361 "alpha-2": "GP",362 "country-code": "312"363 }, {364 "name": "Guam",365 "alpha-2": "GU",366 "country-code": "316"367 }, {368 "name": "Guatemala",369 "alpha-2": "GT",370 "country-code": "320"371 }, {372 "name": "Guernsey",373 "alpha-2": "GG",374 "country-code": "831"375 }, {376 "name": "Guinea",377 "alpha-2": "GN",378 "country-code": "324"379 }, {380 "name": "Guinea-Bissau",381 "alpha-2": "GW",382 "country-code": "624"383 }, {384 "name": "Guyana",385 "alpha-2": "GY",386 "country-code": "328"387 }, {388 "name": "Haiti",389 "alpha-2": "HT",390 "country-code": "332"391 }, {392 "name": "Heard Island and McDonald Islands",393 "alpha-2": "HM",394 "country-code": "334"395 }, {396 "name": "Holy See",397 "alpha-2": "VA",398 "country-code": "336"399 }, {400 "name": "Honduras",401 "alpha-2": "HN",402 "country-code": "340"403 }, {404 "name": "Hong Kong",405 "alpha-2": "HK",406 "country-code": "344"407 }, {408 "name": "Hungary",409 "alpha-2": "HU",410 "country-code": "348"411 }, {412 "name": "Iceland",413 "alpha-2": "IS",414 "country-code": "352"415 }, {416 "name": "India",417 "alpha-2": "IN",418 "country-code": "356"419 }, {420 "name": "Indonesia",421 "alpha-2": "ID",422 "country-code": "360"423 }, {424 "name": "Iran",425 "alpha-2": "IR",426 "country-code": "364"427 }, {428 "name": "Iraq",429 "alpha-2": "IQ",430 "country-code": "368"431 }, {432 "name": "Ireland",433 "alpha-2": "IE",434 "country-code": "372"435 }, {436 "name": "Isle of Man",437 "alpha-2": "IM",438 "country-code": "833"439 }, {440 "name": "Israel",441 "alpha-2": "IL",442 "country-code": "376"443 }, {444 "name": "Italy",445 "alpha-2": "IT",446 "country-code": "380"447 }, {448 "name": "Jamaica",449 "alpha-2": "JM",450 "country-code": "388"451 }, {452 "name": "Japan",453 "alpha-2": "JP",454 "country-code": "392"455 }, {456 "name": "Jersey",457 "alpha-2": "JE",458 "country-code": "832"459 }, {460 "name": "Jordan",461 "alpha-2": "JO",462 "country-code": "400"463 }, {464 "name": "Kazakhstan",465 "alpha-2": "KZ",466 "country-code": "398"467 }, {468 "name": "Kenya",469 "alpha-2": "KE",470 "country-code": "404"471 }, {472 "name": "Kiribati",473 "alpha-2": "KI",474 "country-code": "296"475 }, {476 "name": "North Korea",477 "alpha-2": "KP",478 "country-code": "408"479 }, {480 "name": "South Korea",481 "alpha-2": "KR",482 "country-code": "410"483 }, {484 "name": "Kuwait",485 "alpha-2": "KW",486 "country-code": "414"487 }, {488 "name": "Kyrgyzstan",489 "alpha-2": "KG",490 "country-code": "417"491 }, {492 "name": "Laos",493 "alpha-2": "LA",494 "country-code": "418"495 }, {496 "name": "Latvia",497 "alpha-2": "LV",498 "country-code": "428"499 }, {500 "name": "Lebanon",501 "alpha-2": "LB",502 "country-code": "422"503 }, {504 "name": "Lesotho",505 "alpha-2": "LS",506 "country-code": "426"507 }, {508 "name": "Liberia",509 "alpha-2": "LR",510 "country-code": "430"511 }, {512 "name": "Libya",513 "alpha-2": "LY",514 "country-code": "434"515 }, {516 "name": "Liechtenstein",517 "alpha-2": "LI",518 "country-code": "438"519 }, {520 "name": "Lithuania",521 "alpha-2": "LT",522 "country-code": "440"523 }, {524 "name": "Luxembourg",525 "alpha-2": "LU",526 "country-code": "442"527 }, {528 "name": "Macao",529 "alpha-2": "MO",530 "country-code": "446"531 }, {532 "name": "Macedonia",533 "alpha-2": "MK",534 "country-code": "807"535 }, {536 "name": "Madagascar",537 "alpha-2": "MG",538 "country-code": "450"539 }, {540 "name": "Malawi",541 "alpha-2": "MW",542 "country-code": "454"543 }, {544 "name": "Malaysia",545 "alpha-2": "MY",546 "country-code": "458"547 }, {548 "name": "Maldives",549 "alpha-2": "MV",550 "country-code": "462"551 }, {552 "name": "Mali",553 "alpha-2": "ML",554 "country-code": "466"555 }, {556 "name": "Malta",557 "alpha-2": "MT",558 "country-code": "470"559 }, {560 "name": "Marshall Islands",561 "alpha-2": "MH",562 "country-code": "584"563 }, {564 "name": "Martinique",565 "alpha-2": "MQ",566 "country-code": "474"567 }, {568 "name": "Mauritania",569 "alpha-2": "MR",570 "country-code": "478"571 }, {572 "name": "Mauritius",573 "alpha-2": "MU",574 "country-code": "480"575 }, {576 "name": "Mayotte",577 "alpha-2": "YT",578 "country-code": "175"579 }, {580 "name": "Mexico",581 "alpha-2": "MX",582 "country-code": "484"583 }, {584 "name": "Micronesia",585 "alpha-2": "FM",586 "country-code": "583"587 }, {588 "name": "Moldova",589 "alpha-2": "MD",590 "country-code": "498"591 }, {592 "name": "Monaco",593 "alpha-2": "MC",594 "country-code": "492"595 }, {596 "name": "Mongolia",597 "alpha-2": "MN",598 "country-code": "496"599 }, {600 "name": "Montenegro",601 "alpha-2": "ME",602 "country-code": "499"603 }, {604 "name": "Montserrat",605 "alpha-2": "MS",606 "country-code": "500"607 }, {608 "name": "Morocco",609 "alpha-2": "MA",610 "country-code": "504"611 }, {612 "name": "Mozambique",613 "alpha-2": "MZ",614 "country-code": "508"615 }, {616 "name": "Myanmar",617 "alpha-2": "MM",618 "country-code": "104"619 }, {620 "name": "Namibia",621 "alpha-2": "NA",622 "country-code": "516"623 }, {624 "name": "Nauru",625 "alpha-2": "NR",626 "country-code": "520"627 }, {628 "name": "Nepal",629 "alpha-2": "NP",630 "country-code": "524"631 }, {632 "name": "Netherlands",633 "alpha-2": "NL",634 "country-code": "528"635 }, {636 "name": "New Caledonia",637 "alpha-2": "NC",638 "country-code": "540"639 }, {640 "name": "New Zealand",641 "alpha-2": "NZ",642 "country-code": "554"643 }, {644 "name": "Nicaragua",645 "alpha-2": "NI",646 "country-code": "558"647 }, {648 "name": "Niger",649 "alpha-2": "NE",650 "country-code": "562"651 }, {652 "name": "Nigeria",653 "alpha-2": "NG",654 "country-code": "566"655 }, {656 "name": "Niue",657 "alpha-2": "NU",658 "country-code": "570"659 }, {660 "name": "Norfolk Island",661 "alpha-2": "NF",662 "country-code": "574"663 }, {664 "name": "Northern Mariana Islands",665 "alpha-2": "MP",666 "country-code": "580"667 }, {668 "name": "Norway",669 "alpha-2": "NO",670 "country-code": "578"671 }, {672 "name": "Oman",673 "alpha-2": "OM",674 "country-code": "512"675 }, {676 "name": "Pakistan",677 "alpha-2": "PK",678 "country-code": "586"679 }, {680 "name": "Palau",681 "alpha-2": "PW",682 "country-code": "585"683 }, {684 "name": "Palestine, State of",685 "alpha-2": "PS",686 "country-code": "275"687 }, {688 "name": "Panama",689 "alpha-2": "PA",690 "country-code": "591"691 }, {692 "name": "Papua New Guinea",693 "alpha-2": "PG",694 "country-code": "598"695 }, {696 "name": "Paraguay",697 "alpha-2": "PY",698 "country-code": "600"699 }, {700 "name": "Peru",701 "alpha-2": "PE",702 "country-code": "604"703 }, {704 "name": "Philippines",705 "alpha-2": "PH",706 "country-code": "608"707 }, {708 "name": "Pitcairn",709 "alpha-2": "PN",710 "country-code": "612"711 }, {712 "name": "Poland",713 "alpha-2": "PL",714 "country-code": "616"715 }, {716 "name": "Portugal",717 "alpha-2": "PT",718 "country-code": "620"719 }, {720 "name": "Puerto Rico",721 "alpha-2": "PR",722 "country-code": "630"723 }, {724 "name": "Qatar",725 "alpha-2": "QA",726 "country-code": "634"727 }, {728 "name": "Réunion",729 "alpha-2": "RE",730 "country-code": "638"731 }, {732 "name": "Romania",733 "alpha-2": "RO",734 "country-code": "642"735 }, {736 "name": "Russian Federation",737 "alpha-2": "RU",738 "country-code": "643"739 }, {740 "name": "Rwanda",741 "alpha-2": "RW",742 "country-code": "646"743 }, {744 "name": "Saint Barthélemy",745 "alpha-2": "BL",746 "country-code": "652"747 }, {748 "name": "Saint Helena, Ascension and Tristan da Cunha",749 "alpha-2": "SH",750 "country-code": "654"751 }, {752 "name": "Saint Kitts and Nevis",753 "alpha-2": "KN",754 "country-code": "659"755 }, {756 "name": "Saint Lucia",757 "alpha-2": "LC",758 "country-code": "662"759 }, {760 "name": "Saint Martin",761 "alpha-2": "MF",762 "country-code": "663"763 }, {764 "name": "Saint Pierre and Miquelon",765 "alpha-2": "PM",766 "country-code": "666"767 }, {768 "name": "Saint Vincent and the Grenadines",769 "alpha-2": "VC",770 "country-code": "670"771 }, {772 "name": "Samoa",773 "alpha-2": "WS",774 "country-code": "882"775 }, {776 "name": "San Marino",777 "alpha-2": "SM",778 "country-code": "674"779 }, {780 "name": "Sao Tome and Principe",781 "alpha-2": "ST",782 "country-code": "678"783 }, {784 "name": "Saudi Arabia",785 "alpha-2": "SA",786 "country-code": "682"787 }, {788 "name": "Senegal",789 "alpha-2": "SN",790 "country-code": "686"791 }, {792 "name": "Serbia",793 "alpha-2": "RS",794 "country-code": "688"795 }, {796 "name": "Seychelles",797 "alpha-2": "SC",798 "country-code": "690"799 }, {800 "name": "Sierra Leone",801 "alpha-2": "SL",802 "country-code": "694"803 }, {804 "name": "Singapore",805 "alpha-2": "SG",806 "country-code": "702"807 }, {808 "name": "Sint Maarten",809 "alpha-2": "SX",810 "country-code": "534"811 }, {812 "name": "Slovakia",813 "alpha-2": "SK",814 "country-code": "703"815 }, {816 "name": "Slovenia",817 "alpha-2": "SI",818 "country-code": "705"819 }, {820 "name": "Solomon Islands",821 "alpha-2": "SB",822 "country-code": "090"823 }, {824 "name": "Somalia",825 "alpha-2": "SO",826 "country-code": "706"827 }, {828 "name": "South Africa",829 "alpha-2": "ZA",830 "country-code": "710"831 }, {832 "name": "South Georgia and the South Sandwich Islands",833 "alpha-2": "GS",834 "country-code": "239"835 }, {836 "name": "South Sudan",837 "alpha-2": "SS",838 "country-code": "728"839 }, {840 "name": "Spain",841 "alpha-2": "ES",842 "country-code": "724"843 }, {844 "name": "Sri Lanka",845 "alpha-2": "LK",846 "country-code": "144"847 }, {848 "name": "Sudan",849 "alpha-2": "SD",850 "country-code": "729"851 }, {852 "name": "Suriname",853 "alpha-2": "SR",854 "country-code": "740"855 }, {856 "name": "Svalbard and Jan Mayen",857 "alpha-2": "SJ",858 "country-code": "744"859 }, {860 "name": "Swaziland",861 "alpha-2": "SZ",862 "country-code": "748"863 }, {864 "name": "Sweden",865 "alpha-2": "SE",866 "country-code": "752"867 }, {868 "name": "Switzerland",869 "alpha-2": "CH",870 "country-code": "756"871 }, {872 "name": "Syrian Arab Republic",873 "alpha-2": "SY",874 "country-code": "760"875 }, {876 "name": "Taiwan",877 "alpha-2": "TW",878 "country-code": "158"879 }, {880 "name": "Tajikistan",881 "alpha-2": "TJ",882 "country-code": "762"883 }, {884 "name": "Tanzania",885 "alpha-2": "TZ",886 "country-code": "834"887 }, {888 "name": "Thailand",889 "alpha-2": "TH",890 "country-code": "764"891 }, {892 "name": "Timor-Leste",893 "alpha-2": "TL",894 "country-code": "626"895 }, {896 "name": "Togo",897 "alpha-2": "TG",898 "country-code": "768"899 }, {900 "name": "Tokelau",901 "alpha-2": "TK",902 "country-code": "772"903 }, {904 "name": "Tonga",905 "alpha-2": "TO",906 "country-code": "776"907 }, {908 "name": "Trinidad and Tobago",909 "alpha-2": "TT",910 "country-code": "780"911 }, {912 "name": "Tunisia",913 "alpha-2": "TN",914 "country-code": "788"915 }, {916 "name": "Turkey",917 "alpha-2": "TR",918 "country-code": "792"919 }, {920 "name": "Turkmenistan",921 "alpha-2": "TM",922 "country-code": "795"923 }, {924 "name": "Turks and Caicos Islands",925 "alpha-2": "TC",926 "country-code": "796"927 }, {928 "name": "Tuvalu",929 "alpha-2": "TV",930 "country-code": "798"931 }, {932 "name": "Uganda",933 "alpha-2": "UG",934 "country-code": "800"935 }, {936 "name": "Ukraine",937 "alpha-2": "UA",938 "country-code": "804"939 }, {940 "name": "United Arab Emirates",941 "alpha-2": "AE",942 "country-code": "784"943 }, {944 "name": "United Kingdom",945 "alpha-2": "GB",946 "country-code": "826"947 }, {948 "name": "United States of America",949 "alpha-2": "US",950 "country-code": "840"951 }, {952 "name": "United States Minor Outlying Islands",953 "alpha-2": "UM",954 "country-code": "581"955 }, {956 "name": "Uruguay",957 "alpha-2": "UY",958 "country-code": "858"959 }, {960 "name": "Uzbekistan",961 "alpha-2": "UZ",962 "country-code": "860"963 }, {964 "name": "Vanuatu",965 "alpha-2": "VU",966 "country-code": "548"967 }, {968 "name": "Venezuela",969 "alpha-2": "VE",970 "country-code": "862"971 }, {972 "name": "Vietnam",973 "alpha-2": "VN",974 "country-code": "704"975 }, {976 "name": "Virgin Islands (British)",977 "alpha-2": "VG",978 "country-code": "092"979 }, {980 "name": "Virgin Islands (U.S.)",981 "alpha-2": "VI",982 "country-code": "850"983 }, {984 "name": "Wallis and Futuna",985 "alpha-2": "WF",986 "country-code": "876"987 }, {988 "name": "Western Sahara",989 "alpha-2": "EH",990 "country-code": "732"991 }, {992 "name": "Yemen",993 "alpha-2": "YE",994 "country-code": "887"995 }, {996 "name": "Zambia",997 "alpha-2": "ZM",998 "country-code": "894"999 }, {1000 "name": "Zimbabwe",1001 "alpha-2": "ZW",1002 "country-code": "716"1003 }1004 ];1005 var autocomplete = new google.maps.places.Autocomplete(document.getElementById("placeName"));1006 autocomplete.addListener('place_changed', function() {1007 var place = autocomplete.getPlace();1008 if (!place.geometry) {1009 window.alert("Autocomplete's returned place contains no geometry");1010 return;1011 }1012 else{1013 $scope.place.properties.name = place.name;1014 $scope.place.geometry.coordinates[0] = place.geometry.location.lng();1015 $scope.place.geometry.coordinates[1] = place.geometry.location.lat();1016 $scope.friendlyLon = util.getDD2DMS(place.geometry.location.lng(),'lon');1017 $scope.friendlyLat = util.getDD2DMS(place.geometry.location.lat(),'lat');1018 $scope.updateModel();1019 $scope.remapCoords();1020 $scope.place.properties.countryCode = getAddressComponent(place, "country", "short");1021 $scope.$apply();1022 var elevationService = new google.maps.ElevationService;1023 elevationService.getElevationForLocations({1024 'locations': [place.geometry.location]1025 }, function(results, status) {1026 if (status === google.maps.ElevationStatus.OK) {1027 // Retrieve the first result1028 if (results[0]) {1029 $scope.place.geometry.coordinates[2]= results[0].elevation;1030 $scope.$apply();1031 }1032 } else {1033 console.log('Elevation service failed due to: ' + status);1034 }1035 });1036 }1037 });1038 // restrictions1039 $scope.onlyDecimalCoordinate = /-?\d+(.\d+)?/;1040 // load map1041 var po = org.polymaps;1042 var map = po.map()1043 .container(document.getElementById("map").appendChild(po.svg("svg")))1044 .zoom(2)1045 .add(po.image().url("http://s3.amazonaws.com/com.modestmaps.bluemarble/{Z}-r{Y}-c{X}.jpg"));1046 var mapMarkerObject;1047 $scope.place = {1048 'type': 'Feature',1049 'geometry': {1050 'type': 'Point',1051 'coordinates': [0, 0, 0]1052 },1053 'properties': {1054 'name': '',1055 'countryCode': 'CA',1056 'tags': [],1057 'image': [],1058 'link': '',1059 'contributedBy': '',1060 'description': ''1061 }1062 };1063 $scope.tags = [];1064 PlacesDatabase.data().then(function(db) {1065 $scope.tagSuggestions = db[1].tags;1066 });1067 $scope.toggleTag = function(tag) {1068 if(_.contains($scope.place.properties.tags,tag)) {1069 $scope.place.properties.tags = _.without($scope.place.properties.tags, tag);1070 } else {1071 $scope.place.properties.tags.push(tag);1072 }1073 $scope.updateModel();1074 };1075 $scope.addTag = function() {1076 if($scope.addTagText === '') {1077 return;1078 }1079 if(_.every($scope.tagSuggestions, function(existingTag) { return existingTag.tag.toLowerCase() !== $scope.addTagText.toLowerCase(); })) {1080 $scope.tagSuggestions.push({1081 tag: $scope.addTagText,1082 quantity: 0,1083 alreadyChecked: true1084 });1085 $scope.toggleTag($scope.addTagText, true);1086 } else {1087 alert('Tag is already in the checklist above.');1088 }1089 $scope.addTagText = '';1090 };1091 $scope.$watch('place.geometry.coordinates[0]', function() {1092 $scope.friendlyLon = util.getDD2DMS($scope.place.geometry.coordinates[0],'lon');1093 $scope.updateModel();1094 $scope.remapCoords();1095 });1096 $scope.$watch('place.geometry.coordinates[1]', function() {1097 $scope.friendlyLat = util.getDD2DMS($scope.place.geometry.coordinates[1],'lat');1098 $scope.updateModel();1099 $scope.remapCoords();1100 });1101 $scope.$watch('place.geometry.coordinates[2]', function() {1102 $scope.updateModel();1103 });1104 $scope.$watchCollection('place.properties', function() { $scope.updateModel() });1105 $scope.remapCoords = function() {1106 if(mapMarkerObject) map.remove(mapMarkerObject);1107 mapMarkerObject = po.geoJson().features([$scope.place]).on("load", util.convertMarkers(po));1108 map.add(mapMarkerObject);1109 map.center({1110 lat:$scope.place.geometry.coordinates[1],1111 lon:$scope.place.geometry.coordinates[0]1112 });1113 };1114 var downloadButton = document.getElementById('downloadBlobButton');1115 // Based on the place's name, get the suggested file name that it should be saved as1116 $scope.getSuggestedPlaceFileName = function() {1117 return $scope.place.properties.name.toLowerCase().replace(/\s+/g,'-');1118 };1119 // returns a shadow copy of $scope.place with all variables adjusted for 'niceness'1120 $scope.shadowCopy = function() {1121 var pl = angular.copy($scope.place);1122 // strip elevation if it is zero1123 if(pl.geometry.coordinates[2] === 0) {1124 pl.geometry.coordinates = pl.geometry.coordinates.splice(0,2);1125 }1126 // strip contributedBy if it is empty1127 if(!pl.properties.contributedBy) {1128 delete pl.properties.contributedBy;1129 }1130 // set image name to something based on the location name1131 pl.properties.image = [$scope.getSuggestedPlaceFileName() + '.jpg'];1132 return pl;1133 };1134 $scope.updateModel = function() {1135 $scope.placeGeoJson = JSON.stringify($scope.shadowCopy(), null, 2);1136 var toDownload = new Blob([$scope.placeGeoJson],{type:'application/octet-stream'});1137 var link = window.URL.createObjectURL(toDownload);1138 downloadButton.href = link;1139 downloadButton.download = ($scope.getSuggestedPlaceFileName() || 'unnamed')+'.geojson';1140 };1141 $scope.updateModel();1142 <!-- From stackoverflow http://stackoverflow.com/a/31544361 -->1143 function getAddressComponent(address, component, type) {1144 var element = null;1145 angular.forEach(address.address_components, function (address_component) {1146 if (address_component.types[0] == component) {1147 element = (type == 'short') ? address_component.short_name : address_component.long_name;1148 }1149 });1150 return element;1151}1152 }1153 ]);...
country-codes.js
Source:country-codes.js
1// https://github.com/lukes/ISO-3166-Countries-with-Regional-Codes2// slightly modified3module.exports = [{4 "name": "Afghanistan",5 "alpha-2": "AF",6 "country-code": "004"7}, {8 "name": "Ã
land Islands",9 "alpha-2": "AX",10 "country-code": "248"11}, {12 "name": "Albania",13 "alpha-2": "AL",14 "country-code": "008"15}, {16 "name": "Algeria",17 "alpha-2": "DZ",18 "country-code": "012"19}, {20 "name": "American Samoa",21 "alpha-2": "AS",22 "country-code": "016"23}, {24 "name": "Andorra",25 "alpha-2": "AD",26 "country-code": "020"27}, {28 "name": "Angola",29 "alpha-2": "AO",30 "country-code": "024"31}, {32 "name": "Anguilla",33 "alpha-2": "AI",34 "country-code": "660"35}, {36 "name": "Antarctica",37 "alpha-2": "AQ",38 "country-code": "010"39}, {40 "name": "Antigua and Barbuda",41 "alpha-2": "AG",42 "country-code": "028"43}, {44 "name": "Argentina",45 "alpha-2": "AR",46 "country-code": "032"47}, {48 "name": "Armenia",49 "alpha-2": "AM",50 "country-code": "051"51}, {52 "name": "Aruba",53 "alpha-2": "AW",54 "country-code": "533"55}, {56 "name": "Australia",57 "alpha-2": "AU",58 "country-code": "036"59}, {60 "name": "Austria",61 "alpha-2": "AT",62 "country-code": "040"63}, {64 "name": "Azerbaijan",65 "alpha-2": "AZ",66 "country-code": "031"67}, {68 "name": "Bahamas",69 "alpha-2": "BS",70 "country-code": "044"71}, {72 "name": "Bahrain",73 "alpha-2": "BH",74 "country-code": "048"75}, {76 "name": "Bangladesh",77 "alpha-2": "BD",78 "country-code": "050"79}, {80 "name": "Barbados",81 "alpha-2": "BB",82 "country-code": "052"83}, {84 "name": "Belarus",85 "alpha-2": "BY",86 "country-code": "112"87}, {88 "name": "Belgium",89 "alpha-2": "BE",90 "country-code": "056"91}, {92 "name": "Belize",93 "alpha-2": "BZ",94 "country-code": "084"95}, {96 "name": "Benin",97 "alpha-2": "BJ",98 "country-code": "204"99}, {100 "name": "Bermuda",101 "alpha-2": "BM",102 "country-code": "060"103}, {104 "name": "Bhutan",105 "alpha-2": "BT",106 "country-code": "064"107}, {108 "name": "Bolivia",109 "alpha-2": "BO",110 "country-code": "068"111}, {112 "name": "Bonaire, Sint Eustatius and Saba",113 "alpha-2": "BQ",114 "country-code": "535"115}, {116 "name": "Bosnia and Herzegovina",117 "alpha-2": "BA",118 "country-code": "070"119}, {120 "name": "Botswana",121 "alpha-2": "BW",122 "country-code": "072"123}, {124 "name": "Bouvet Island",125 "alpha-2": "BV",126 "country-code": "074"127}, {128 "name": "Brazil",129 "alpha-2": "BR",130 "country-code": "076"131}, {132 "name": "British Indian Ocean Territory",133 "alpha-2": "IO",134 "country-code": "086"135}, {136 "name": "Brunei Darussalam",137 "alpha-2": "BN",138 "country-code": "096"139}, {140 "name": "Bulgaria",141 "alpha-2": "BG",142 "country-code": "100"143}, {144 "name": "Burkina Faso",145 "alpha-2": "BF",146 "country-code": "854"147}, {148 "name": "Burundi",149 "alpha-2": "BI",150 "country-code": "108"151}, {152 "name": "Cambodia",153 "alpha-2": "KH",154 "country-code": "116"155}, {156 "name": "Cameroon",157 "alpha-2": "CM",158 "country-code": "120"159}, {160 "name": "Canada",161 "alpha-2": "CA",162 "country-code": "124"163}, {164 "name": "Cabo Verde",165 "alpha-2": "CV",166 "country-code": "132"167}, {168 "name": "Cayman Islands",169 "alpha-2": "KY",170 "country-code": "136"171}, {172 "name": "Central African Republic",173 "alpha-2": "CF",174 "country-code": "140"175}, {176 "name": "Chad",177 "alpha-2": "TD",178 "country-code": "148"179}, {180 "name": "Chile",181 "alpha-2": "CL",182 "country-code": "152"183}, {184 "name": "China",185 "alpha-2": "CN",186 "country-code": "156"187}, {188 "name": "Christmas Island",189 "alpha-2": "CX",190 "country-code": "162"191}, {192 "name": "Cocos Islands",193 "alpha-2": "CC",194 "country-code": "166"195}, {196 "name": "Colombia",197 "alpha-2": "CO",198 "country-code": "170"199}, {200 "name": "Comoros",201 "alpha-2": "KM",202 "country-code": "174"203}, {204 "name": "Congo",205 "alpha-2": "CG",206 "country-code": "178"207}, {208 "name": "Congo DR",209 "alpha-2": "CD",210 "country-code": "180"211}, {212 "name": "Cook Islands",213 "alpha-2": "CK",214 "country-code": "184"215}, {216 "name": "Costa Rica",217 "alpha-2": "CR",218 "country-code": "188"219}, {220 "name": "Côte d'Ivoire",221 "alpha-2": "CI",222 "country-code": "384"223}, {224 "name": "Croatia",225 "alpha-2": "HR",226 "country-code": "191"227}, {228 "name": "Cuba",229 "alpha-2": "CU",230 "country-code": "192"231}, {232 "name": "Curaçao",233 "alpha-2": "CW",234 "country-code": "531"235}, {236 "name": "Cyprus",237 "alpha-2": "CY",238 "country-code": "196"239}, {240 "name": "Czech Republic",241 "alpha-2": "CZ",242 "country-code": "203"243}, {244 "name": "Denmark",245 "alpha-2": "DK",246 "country-code": "208"247}, {248 "name": "Djibouti",249 "alpha-2": "DJ",250 "country-code": "262"251}, {252 "name": "Dominica",253 "alpha-2": "DM",254 "country-code": "212"255}, {256 "name": "Dominican Republic",257 "alpha-2": "DO",258 "country-code": "214"259}, {260 "name": "Ecuador",261 "alpha-2": "EC",262 "country-code": "218"263}, {264 "name": "Egypt",265 "alpha-2": "EG",266 "country-code": "818"267}, {268 "name": "El Salvador",269 "alpha-2": "SV",270 "country-code": "222"271}, {272 "name": "Equatorial Guinea",273 "alpha-2": "GQ",274 "country-code": "226"275}, {276 "name": "Eritrea",277 "alpha-2": "ER",278 "country-code": "232"279}, {280 "name": "Estonia",281 "alpha-2": "EE",282 "country-code": "233"283}, {284 "name": "Ethiopia",285 "alpha-2": "ET",286 "country-code": "231"287}, {288 "name": "Falkland Islands",289 "alpha-2": "FK",290 "country-code": "238"291}, {292 "name": "Faroe Islands",293 "alpha-2": "FO",294 "country-code": "234"295}, {296 "name": "Fiji",297 "alpha-2": "FJ",298 "country-code": "242"299}, {300 "name": "Finland",301 "alpha-2": "FI",302 "country-code": "246"303}, {304 "name": "France",305 "alpha-2": "FR",306 "country-code": "250"307}, {308 "name": "French Guiana",309 "alpha-2": "GF",310 "country-code": "254"311}, {312 "name": "French Polynesia",313 "alpha-2": "PF",314 "country-code": "258"315}, {316 "name": "French Southern Territories",317 "alpha-2": "TF",318 "country-code": "260"319}, {320 "name": "Gabon",321 "alpha-2": "GA",322 "country-code": "266"323}, {324 "name": "Gambia",325 "alpha-2": "GM",326 "country-code": "270"327}, {328 "name": "Georgia",329 "alpha-2": "GE",330 "country-code": "268"331}, {332 "name": "Germany",333 "alpha-2": "DE",334 "country-code": "276"335}, {336 "name": "Ghana",337 "alpha-2": "GH",338 "country-code": "288"339}, {340 "name": "Gibraltar",341 "alpha-2": "GI",342 "country-code": "292"343}, {344 "name": "Greece",345 "alpha-2": "GR",346 "country-code": "300"347}, {348 "name": "Greenland",349 "alpha-2": "GL",350 "country-code": "304"351}, {352 "name": "Grenada",353 "alpha-2": "GD",354 "country-code": "308"355}, {356 "name": "Guadeloupe",357 "alpha-2": "GP",358 "country-code": "312"359}, {360 "name": "Guam",361 "alpha-2": "GU",362 "country-code": "316"363}, {364 "name": "Guatemala",365 "alpha-2": "GT",366 "country-code": "320"367}, {368 "name": "Guernsey",369 "alpha-2": "GG",370 "country-code": "831"371}, {372 "name": "Guinea",373 "alpha-2": "GN",374 "country-code": "324"375}, {376 "name": "Guinea-Bissau",377 "alpha-2": "GW",378 "country-code": "624"379}, {380 "name": "Guyana",381 "alpha-2": "GY",382 "country-code": "328"383}, {384 "name": "Haiti",385 "alpha-2": "HT",386 "country-code": "332"387}, {388 "name": "Heard Island and McDonald Islands",389 "alpha-2": "HM",390 "country-code": "334"391}, {392 "name": "Holy See",393 "alpha-2": "VA",394 "country-code": "336"395}, {396 "name": "Honduras",397 "alpha-2": "HN",398 "country-code": "340"399}, {400 "name": "Hong Kong",401 "alpha-2": "HK",402 "country-code": "344"403}, {404 "name": "Hungary",405 "alpha-2": "HU",406 "country-code": "348"407}, {408 "name": "Iceland",409 "alpha-2": "IS",410 "country-code": "352"411}, {412 "name": "India",413 "alpha-2": "IN",414 "country-code": "356"415}, {416 "name": "Indonesia",417 "alpha-2": "ID",418 "country-code": "360"419}, {420 "name": "Iran",421 "alpha-2": "IR",422 "country-code": "364"423}, {424 "name": "Iraq",425 "alpha-2": "IQ",426 "country-code": "368"427}, {428 "name": "Ireland",429 "alpha-2": "IE",430 "country-code": "372"431}, {432 "name": "Isle of Man",433 "alpha-2": "IM",434 "country-code": "833"435}, {436 "name": "Israel",437 "alpha-2": "IL",438 "country-code": "376"439}, {440 "name": "Italy",441 "alpha-2": "IT",442 "country-code": "380"443}, {444 "name": "Jamaica",445 "alpha-2": "JM",446 "country-code": "388"447}, {448 "name": "Japan",449 "alpha-2": "JP",450 "country-code": "392"451}, {452 "name": "Jersey",453 "alpha-2": "JE",454 "country-code": "832"455}, {456 "name": "Jordan",457 "alpha-2": "JO",458 "country-code": "400"459}, {460 "name": "Kazakhstan",461 "alpha-2": "KZ",462 "country-code": "398"463}, {464 "name": "Kenya",465 "alpha-2": "KE",466 "country-code": "404"467}, {468 "name": "Kiribati",469 "alpha-2": "KI",470 "country-code": "296"471}, {472 "name": "North Korea",473 "alpha-2": "KP",474 "country-code": "408"475}, {476 "name": "South Korea",477 "alpha-2": "KR",478 "country-code": "410"479}, {480 "name": "Kuwait",481 "alpha-2": "KW",482 "country-code": "414"483}, {484 "name": "Kyrgyzstan",485 "alpha-2": "KG",486 "country-code": "417"487}, {488 "name": "Laos",489 "alpha-2": "LA",490 "country-code": "418"491}, {492 "name": "Latvia",493 "alpha-2": "LV",494 "country-code": "428"495}, {496 "name": "Lebanon",497 "alpha-2": "LB",498 "country-code": "422"499}, {500 "name": "Lesotho",501 "alpha-2": "LS",502 "country-code": "426"503}, {504 "name": "Liberia",505 "alpha-2": "LR",506 "country-code": "430"507}, {508 "name": "Libya",509 "alpha-2": "LY",510 "country-code": "434"511}, {512 "name": "Liechtenstein",513 "alpha-2": "LI",514 "country-code": "438"515}, {516 "name": "Lithuania",517 "alpha-2": "LT",518 "country-code": "440"519}, {520 "name": "Luxembourg",521 "alpha-2": "LU",522 "country-code": "442"523}, {524 "name": "Macao",525 "alpha-2": "MO",526 "country-code": "446"527}, {528 "name": "Macedonia",529 "alpha-2": "MK",530 "country-code": "807"531}, {532 "name": "Madagascar",533 "alpha-2": "MG",534 "country-code": "450"535}, {536 "name": "Malawi",537 "alpha-2": "MW",538 "country-code": "454"539}, {540 "name": "Malaysia",541 "alpha-2": "MY",542 "country-code": "458"543}, {544 "name": "Maldives",545 "alpha-2": "MV",546 "country-code": "462"547}, {548 "name": "Mali",549 "alpha-2": "ML",550 "country-code": "466"551}, {552 "name": "Malta",553 "alpha-2": "MT",554 "country-code": "470"555}, {556 "name": "Marshall Islands",557 "alpha-2": "MH",558 "country-code": "584"559}, {560 "name": "Martinique",561 "alpha-2": "MQ",562 "country-code": "474"563}, {564 "name": "Mauritania",565 "alpha-2": "MR",566 "country-code": "478"567}, {568 "name": "Mauritius",569 "alpha-2": "MU",570 "country-code": "480"571}, {572 "name": "Mayotte",573 "alpha-2": "YT",574 "country-code": "175"575}, {576 "name": "Mexico",577 "alpha-2": "MX",578 "country-code": "484"579}, {580 "name": "Micronesia",581 "alpha-2": "FM",582 "country-code": "583"583}, {584 "name": "Moldova",585 "alpha-2": "MD",586 "country-code": "498"587}, {588 "name": "Monaco",589 "alpha-2": "MC",590 "country-code": "492"591}, {592 "name": "Mongolia",593 "alpha-2": "MN",594 "country-code": "496"595}, {596 "name": "Montenegro",597 "alpha-2": "ME",598 "country-code": "499"599}, {600 "name": "Montserrat",601 "alpha-2": "MS",602 "country-code": "500"603}, {604 "name": "Morocco",605 "alpha-2": "MA",606 "country-code": "504"607}, {608 "name": "Mozambique",609 "alpha-2": "MZ",610 "country-code": "508"611}, {612 "name": "Myanmar",613 "alpha-2": "MM",614 "country-code": "104"615}, {616 "name": "Namibia",617 "alpha-2": "NA",618 "country-code": "516"619}, {620 "name": "Nauru",621 "alpha-2": "NR",622 "country-code": "520"623}, {624 "name": "Nepal",625 "alpha-2": "NP",626 "country-code": "524"627}, {628 "name": "Netherlands",629 "alpha-2": "NL",630 "country-code": "528"631}, {632 "name": "New Caledonia",633 "alpha-2": "NC",634 "country-code": "540"635}, {636 "name": "New Zealand",637 "alpha-2": "NZ",638 "country-code": "554"639}, {640 "name": "Nicaragua",641 "alpha-2": "NI",642 "country-code": "558"643}, {644 "name": "Niger",645 "alpha-2": "NE",646 "country-code": "562"647}, {648 "name": "Nigeria",649 "alpha-2": "NG",650 "country-code": "566"651}, {652 "name": "Niue",653 "alpha-2": "NU",654 "country-code": "570"655}, {656 "name": "Norfolk Island",657 "alpha-2": "NF",658 "country-code": "574"659}, {660 "name": "Northern Mariana Islands",661 "alpha-2": "MP",662 "country-code": "580"663}, {664 "name": "Norway",665 "alpha-2": "NO",666 "country-code": "578"667}, {668 "name": "Oman",669 "alpha-2": "OM",670 "country-code": "512"671}, {672 "name": "Pakistan",673 "alpha-2": "PK",674 "country-code": "586"675}, {676 "name": "Palau",677 "alpha-2": "PW",678 "country-code": "585"679}, {680 "name": "Palestine, State of",681 "alpha-2": "PS",682 "country-code": "275"683}, {684 "name": "Panama",685 "alpha-2": "PA",686 "country-code": "591"687}, {688 "name": "Papua New Guinea",689 "alpha-2": "PG",690 "country-code": "598"691}, {692 "name": "Paraguay",693 "alpha-2": "PY",694 "country-code": "600"695}, {696 "name": "Peru",697 "alpha-2": "PE",698 "country-code": "604"699}, {700 "name": "Philippines",701 "alpha-2": "PH",702 "country-code": "608"703}, {704 "name": "Pitcairn",705 "alpha-2": "PN",706 "country-code": "612"707}, {708 "name": "Poland",709 "alpha-2": "PL",710 "country-code": "616"711}, {712 "name": "Portugal",713 "alpha-2": "PT",714 "country-code": "620"715}, {716 "name": "Puerto Rico",717 "alpha-2": "PR",718 "country-code": "630"719}, {720 "name": "Qatar",721 "alpha-2": "QA",722 "country-code": "634"723}, {724 "name": "Réunion",725 "alpha-2": "RE",726 "country-code": "638"727}, {728 "name": "Romania",729 "alpha-2": "RO",730 "country-code": "642"731}, {732 "name": "Russian Federation",733 "alpha-2": "RU",734 "country-code": "643"735}, {736 "name": "Rwanda",737 "alpha-2": "RW",738 "country-code": "646"739}, {740 "name": "Saint Barthélemy",741 "alpha-2": "BL",742 "country-code": "652"743}, {744 "name": "Saint Helena, Ascension and Tristan da Cunha",745 "alpha-2": "SH",746 "country-code": "654"747}, {748 "name": "Saint Kitts and Nevis",749 "alpha-2": "KN",750 "country-code": "659"751}, {752 "name": "Saint Lucia",753 "alpha-2": "LC",754 "country-code": "662"755}, {756 "name": "Saint Martin",757 "alpha-2": "MF",758 "country-code": "663"759}, {760 "name": "Saint Pierre and Miquelon",761 "alpha-2": "PM",762 "country-code": "666"763}, {764 "name": "Saint Vincent and the Grenadines",765 "alpha-2": "VC",766 "country-code": "670"767}, {768 "name": "Samoa",769 "alpha-2": "WS",770 "country-code": "882"771}, {772 "name": "San Marino",773 "alpha-2": "SM",774 "country-code": "674"775}, {776 "name": "Sao Tome and Principe",777 "alpha-2": "ST",778 "country-code": "678"779}, {780 "name": "Saudi Arabia",781 "alpha-2": "SA",782 "country-code": "682"783}, {784 "name": "Senegal",785 "alpha-2": "SN",786 "country-code": "686"787}, {788 "name": "Serbia",789 "alpha-2": "RS",790 "country-code": "688"791}, {792 "name": "Seychelles",793 "alpha-2": "SC",794 "country-code": "690"795}, {796 "name": "Sierra Leone",797 "alpha-2": "SL",798 "country-code": "694"799}, {800 "name": "Singapore",801 "alpha-2": "SG",802 "country-code": "702"803}, {804 "name": "Sint Maarten",805 "alpha-2": "SX",806 "country-code": "534"807}, {808 "name": "Slovakia",809 "alpha-2": "SK",810 "country-code": "703"811}, {812 "name": "Slovenia",813 "alpha-2": "SI",814 "country-code": "705"815}, {816 "name": "Solomon Islands",817 "alpha-2": "SB",818 "country-code": "090"819}, {820 "name": "Somalia",821 "alpha-2": "SO",822 "country-code": "706"823}, {824 "name": "South Africa",825 "alpha-2": "ZA",826 "country-code": "710"827}, {828 "name": "South Georgia and the South Sandwich Islands",829 "alpha-2": "GS",830 "country-code": "239"831}, {832 "name": "South Sudan",833 "alpha-2": "SS",834 "country-code": "728"835}, {836 "name": "Spain",837 "alpha-2": "ES",838 "country-code": "724"839}, {840 "name": "Sri Lanka",841 "alpha-2": "LK",842 "country-code": "144"843}, {844 "name": "Sudan",845 "alpha-2": "SD",846 "country-code": "729"847}, {848 "name": "Suriname",849 "alpha-2": "SR",850 "country-code": "740"851}, {852 "name": "Svalbard and Jan Mayen",853 "alpha-2": "SJ",854 "country-code": "744"855}, {856 "name": "Swaziland",857 "alpha-2": "SZ",858 "country-code": "748"859}, {860 "name": "Sweden",861 "alpha-2": "SE",862 "country-code": "752"863}, {864 "name": "Switzerland",865 "alpha-2": "CH",866 "country-code": "756"867}, {868 "name": "Syrian Arab Republic",869 "alpha-2": "SY",870 "country-code": "760"871}, {872 "name": "Taiwan",873 "alpha-2": "TW",874 "country-code": "158"875}, {876 "name": "Tajikistan",877 "alpha-2": "TJ",878 "country-code": "762"879}, {880 "name": "Tanzania",881 "alpha-2": "TZ",882 "country-code": "834"883}, {884 "name": "Thailand",885 "alpha-2": "TH",886 "country-code": "764"887}, {888 "name": "Timor-Leste",889 "alpha-2": "TL",890 "country-code": "626"891}, {892 "name": "Togo",893 "alpha-2": "TG",894 "country-code": "768"895}, {896 "name": "Tokelau",897 "alpha-2": "TK",898 "country-code": "772"899}, {900 "name": "Tonga",901 "alpha-2": "TO",902 "country-code": "776"903}, {904 "name": "Trinidad and Tobago",905 "alpha-2": "TT",906 "country-code": "780"907}, {908 "name": "Tunisia",909 "alpha-2": "TN",910 "country-code": "788"911}, {912 "name": "Turkey",913 "alpha-2": "TR",914 "country-code": "792"915}, {916 "name": "Turkmenistan",917 "alpha-2": "TM",918 "country-code": "795"919}, {920 "name": "Turks and Caicos Islands",921 "alpha-2": "TC",922 "country-code": "796"923}, {924 "name": "Tuvalu",925 "alpha-2": "TV",926 "country-code": "798"927}, {928 "name": "Uganda",929 "alpha-2": "UG",930 "country-code": "800"931}, {932 "name": "Ukraine",933 "alpha-2": "UA",934 "country-code": "804"935}, {936 "name": "United Arab Emirates",937 "alpha-2": "AE",938 "country-code": "784"939}, {940 "name": "United Kingdom",941 "alpha-2": "GB",942 "country-code": "826"943}, {944 "name": "United States of America",945 "alpha-2": "US",946 "country-code": "840"947}, {948 "name": "United States Minor Outlying Islands",949 "alpha-2": "UM",950 "country-code": "581"951}, {952 "name": "Uruguay",953 "alpha-2": "UY",954 "country-code": "858"955}, {956 "name": "Uzbekistan",957 "alpha-2": "UZ",958 "country-code": "860"959}, {960 "name": "Vanuatu",961 "alpha-2": "VU",962 "country-code": "548"963}, {964 "name": "Venezuela",965 "alpha-2": "VE",966 "country-code": "862"967}, {968 "name": "Vietnam",969 "alpha-2": "VN",970 "country-code": "704"971}, {972 "name": "Virgin Islands (British)",973 "alpha-2": "VG",974 "country-code": "092"975}, {976 "name": "Virgin Islands (U.S.)",977 "alpha-2": "VI",978 "country-code": "850"979}, {980 "name": "Wallis and Futuna",981 "alpha-2": "WF",982 "country-code": "876"983}, {984 "name": "Western Sahara",985 "alpha-2": "EH",986 "country-code": "732"987}, {988 "name": "Yemen",989 "alpha-2": "YE",990 "country-code": "887"991}, {992 "name": "Zambia",993 "alpha-2": "ZM",994 "country-code": "894"995}, {996 "name": "Zimbabwe",997 "alpha-2": "ZW",998 "country-code": "716"...
Alpha.js
Source:Alpha.js
1/**2 * @author Richard Davey <rich@photonstorm.com>3 * @copyright 2019 Photon Storm Ltd.4 * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}5 */6var Clamp = require('../../math/Clamp');7// bitmask flag for GameObject.renderMask8var _FLAG = 2; // 00109/**10 * Provides methods used for setting the alpha properties of a Game Object.11 * Should be applied as a mixin and not used directly.12 *13 * @namespace Phaser.GameObjects.Components.Alpha14 * @since 3.0.015 */16var Alpha = {17 /**18 * Private internal value. Holds the global alpha value.19 *20 * @name Phaser.GameObjects.Components.Alpha#_alpha21 * @type {number}22 * @private23 * @default 124 * @since 3.0.025 */26 _alpha: 1,27 /**28 * Private internal value. Holds the top-left alpha value.29 *30 * @name Phaser.GameObjects.Components.Alpha#_alphaTL31 * @type {number}32 * @private33 * @default 134 * @since 3.0.035 */36 _alphaTL: 1,37 /**38 * Private internal value. Holds the top-right alpha value.39 *40 * @name Phaser.GameObjects.Components.Alpha#_alphaTR41 * @type {number}42 * @private43 * @default 144 * @since 3.0.045 */46 _alphaTR: 1,47 /**48 * Private internal value. Holds the bottom-left alpha value.49 *50 * @name Phaser.GameObjects.Components.Alpha#_alphaBL51 * @type {number}52 * @private53 * @default 154 * @since 3.0.055 */56 _alphaBL: 1,57 /**58 * Private internal value. Holds the bottom-right alpha value.59 *60 * @name Phaser.GameObjects.Components.Alpha#_alphaBR61 * @type {number}62 * @private63 * @default 164 * @since 3.0.065 */66 _alphaBR: 1,67 /**68 * Clears all alpha values associated with this Game Object.69 *70 * Immediately sets the alpha levels back to 1 (fully opaque).71 *72 * @method Phaser.GameObjects.Components.Alpha#clearAlpha73 * @since 3.0.074 *75 * @return {this} This Game Object instance.76 */77 clearAlpha: function ()78 {79 return this.setAlpha(1);80 },81 /**82 * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders.83 * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque.84 *85 * If your game is running under WebGL you can optionally specify four different alpha values, each of which86 * correspond to the four corners of the Game Object. Under Canvas only the `topLeft` value given is used.87 *88 * @method Phaser.GameObjects.Components.Alpha#setAlpha89 * @since 3.0.090 *91 * @param {number} [topLeft=1] - The alpha value used for the top-left of the Game Object. If this is the only value given it's applied across the whole Game Object.92 * @param {number} [topRight] - The alpha value used for the top-right of the Game Object. WebGL only.93 * @param {number} [bottomLeft] - The alpha value used for the bottom-left of the Game Object. WebGL only.94 * @param {number} [bottomRight] - The alpha value used for the bottom-right of the Game Object. WebGL only.95 *96 * @return {this} This Game Object instance.97 */98 setAlpha: function (topLeft, topRight, bottomLeft, bottomRight)99 {100 if (topLeft === undefined) { topLeft = 1; }101 // Treat as if there is only one alpha value for the whole Game Object102 if (topRight === undefined)103 {104 this.alpha = topLeft;105 }106 else107 {108 this._alphaTL = Clamp(topLeft, 0, 1);109 this._alphaTR = Clamp(topRight, 0, 1);110 this._alphaBL = Clamp(bottomLeft, 0, 1);111 this._alphaBR = Clamp(bottomRight, 0, 1);112 }113 return this;114 },115 /**116 * The alpha value of the Game Object.117 *118 * This is a global value, impacting the entire Game Object, not just a region of it.119 *120 * @name Phaser.GameObjects.Components.Alpha#alpha121 * @type {number}122 * @since 3.0.0123 */124 alpha: {125 get: function ()126 {127 return this._alpha;128 },129 set: function (value)130 {131 var v = Clamp(value, 0, 1);132 this._alpha = v;133 this._alphaTL = v;134 this._alphaTR = v;135 this._alphaBL = v;136 this._alphaBR = v;137 if (v === 0)138 {139 this.renderFlags &= ~_FLAG;140 }141 else142 {143 this.renderFlags |= _FLAG;144 }145 }146 },147 /**148 * The alpha value starting from the top-left of the Game Object.149 * This value is interpolated from the corner to the center of the Game Object.150 *151 * @name Phaser.GameObjects.Components.Alpha#alphaTopLeft152 * @type {number}153 * @webglOnly154 * @since 3.0.0155 */156 alphaTopLeft: {157 get: function ()158 {159 return this._alphaTL;160 },161 set: function (value)162 {163 var v = Clamp(value, 0, 1);164 this._alphaTL = v;165 if (v !== 0)166 {167 this.renderFlags |= _FLAG;168 }169 }170 },171 /**172 * The alpha value starting from the top-right of the Game Object.173 * This value is interpolated from the corner to the center of the Game Object.174 *175 * @name Phaser.GameObjects.Components.Alpha#alphaTopRight176 * @type {number}177 * @webglOnly178 * @since 3.0.0179 */180 alphaTopRight: {181 get: function ()182 {183 return this._alphaTR;184 },185 set: function (value)186 {187 var v = Clamp(value, 0, 1);188 this._alphaTR = v;189 if (v !== 0)190 {191 this.renderFlags |= _FLAG;192 }193 }194 },195 /**196 * The alpha value starting from the bottom-left of the Game Object.197 * This value is interpolated from the corner to the center of the Game Object.198 *199 * @name Phaser.GameObjects.Components.Alpha#alphaBottomLeft200 * @type {number}201 * @webglOnly202 * @since 3.0.0203 */204 alphaBottomLeft: {205 get: function ()206 {207 return this._alphaBL;208 },209 set: function (value)210 {211 var v = Clamp(value, 0, 1);212 this._alphaBL = v;213 if (v !== 0)214 {215 this.renderFlags |= _FLAG;216 }217 }218 },219 /**220 * The alpha value starting from the bottom-right of the Game Object.221 * This value is interpolated from the corner to the center of the Game Object.222 *223 * @name Phaser.GameObjects.Components.Alpha#alphaBottomRight224 * @type {number}225 * @webglOnly226 * @since 3.0.0227 */228 alphaBottomRight: {229 get: function ()230 {231 return this._alphaBR;232 },233 set: function (value)234 {235 var v = Clamp(value, 0, 1);236 this._alphaBR = v;237 if (v !== 0)238 {239 this.renderFlags |= _FLAG;240 }241 }242 }243};...
Using AI Code Generation
1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3 if (err) return console.error(err);4 console.log('Test submitted to WebPagetest for %s', data.data.testUrl);5 console.log('Test ID: %s', data.data.testId);6 console.log('Poll results every %d ms', data.data.pollResults);7 console.log('Test status: %s', data.data.statusText);8});9var wpt = require('webpagetest');10var wpt = new WebPageTest('www.webpagetest.org');11 if (err) return console.error(err);12 console.log('Test submitted to WebPagetest for %s', data.data.testUrl);13 console.log('Test ID: %s', data.data.testId);14 console.log('Poll results every %d ms', data.data.pollResults);15 console.log('Test status: %s', data.data.statusText);16});17var wpt = require('webpagetest');18var wpt = new WebPageTest('www.webpagetest.org');19wpt.getTestResults('141115_1W_8a0e9c0a2e2e2f8b8f1b0d1f7c6c1d6b', function(err, data) {20 if (err) return console.error(err);21 console.log('Test results for %s', data.data.testUrl);22 console.log('First view (load time): %d ms', data.data.average.firstView.loadTime);23 console.log('Repeat view (load time): %d ms', data.data.average.repeatView.loadTime);24});25var wpt = require('webpagetest');26var wpt = new WebPageTest('www.webpagetest.org');27wpt.getTestResults('141115_1W_8a0e9c0a2e2e2f8b8f1b0d1f7c6c1d6b', function(err, data) {28 if (err) return console.error(err);29 console.log('Test results for %
Using AI Code Generation
1var wptools = require('wptools');2var wp = wptools.page('Barack Obama');3wp.get(function(err, resp) {4 if (err) {5 console.log(err);6 } else {7 console.log(resp);8 }9});10{ [Error: ENOENT, no such file or directory '/Users/abhinav/Documents/Projects/NodeJS/NodeJS-Projects/wikipedia-tools/node_modules/wptools/node_modules/cheerio/node_modules/css-select/node_modules/domutils/node_modules/dom-serializer/node_modules/domelementtype/lib/elementtype.js']11 path: '/Users/abhinav/Documents/Projects/NodeJS/NodeJS-Projects/wikipedia-tools/node_modules/wptools/node_modules/cheerio/node_modules/css-select/node_modules/domutils/node_modules/dom-serializer/node_modules/domelementtype/lib/elementtype.js' }12var fs = require('fs');13var otherModule = require('./otherModule.js');14exports.readFile = function() {15 fs.readFile('test.txt', 'utf8', function(err, data) {16 if (err) throw err;17 otherModule.someFunction(data, function(err, data) {18 if (err) throw err;19 console.log(data);20 });21 });22};23exports.someFunction = function(data, callback) {24 var x = data;25 callback(null, x);26};27When I call readFile() from test.js, I get the following error:
Using AI Code Generation
1var wptools = require('wptools');2var options = {3};4wptools.page('Barack Obama').get(options, function(err, resp) {5 if (err) {6 console.log(err);7 }8 console.log(resp);9});10var wptools = require('wptools');11var options = {12};13wptools.page('Barack Obama').get(options, function(err, resp) {14 if (err) {15 console.log(err);16 }17 console.log(resp);18});19TypeError: wptools.page(...).get is not a function
Using AI Code Generation
1var wptools = require('wptools');2var page = wptools.page('Albert Einstein');3page.get(function(err, resp){4 console.log(resp);5});6var wptools = require('wptools');7var page = wptools.page('Albert Einstein');8page.get(function(err, resp){9 console.log(resp);10});
Using AI Code Generation
1const wptools = require('wptools');2wptools.page('Albert Einstein').then(page => {3 return page.get();4}).then(data => {5 console.log(data);6});7const wptools = require('wptools');8wptools.page('Albert Einstein').then(page => {9 return page.get();10}).then(data => {11 console.log(data);12});
Using AI Code Generation
1var wptools = require('wptools');2wptools.page('Barack Obama').then(function(page){3 return page.alpha();4}).then(function(page){5 console.log(page.data);6});7var wptools = require('wptools');8wptools.page('Barack Obama').then(function(page){9 return page.alpha();10}).then(function(page){11 console.log(page.data);12});13var wptools = require('wptools');14wptools.page('Barack Obama').then(function(page){15 return page.alpha();16}).then(function(page){17 console.log(page.data);18});19var wptools = require('wptools');20wptools.page('Barack Obama').then(function(page){21 return page.alpha();22}).then(function(page){23 console.log(page.data);24});25var wptools = require('wptools');26wptools.page('Barack Obama').then(function(page){27 return page.alpha();28}).then(function(page){29 console.log(page.data);30});31var wptools = require('wptools');32wptools.page('Barack Obama').then(function(page){33 return page.alpha();34}).then(function(page){35 console.log(page.data);36});37var wptools = require('wptools');38wptools.page('Barack Obama').then(function(page){39 return page.alpha();40}).then(function(page){41 console.log(page.data);42});43var wptools = require('wptools');44wptools.page('Barack Obama').then(function(page){45 return page.alpha();46}).then(function(page){47 console.log(page.data);48});49var wptools = require('wptools');50wptools.page('Barack Obama').then(function(page){51 return page.alpha();52}).then(function(page
Using AI Code Generation
1var wptools = require('wptools');2var options = {3};4wptools.page(options).then(function(response) {5 console.log(response);6}).catch(function(err) {7 console.log(err);8});9var wptools = require('wptools');10var options = {11};12wptools.page(options).then(function(response) {13 console.log(response);14}).catch(function(err) {15 console.log(err);16});17var wptools = require('wptools');18var options = {19};20wptools.page(options).then(function(response) {21 console.log(response);22}).catch(function(err) {23 console.log(err);24});25var wptools = require('wptools');26var options = {27};28wptools.page(options).then(function(response) {29 console.log(response);30}).catch(function(err) {31 console.log(err);32});33var wptools = require('wptools');34var options = {35};36wptools.page(options).then(function(response) {37 console.log(response);38}).catch(function(err) {39 console.log(err);40});41var wptools = require('
Using AI Code Generation
1const wptools = require('wptools');2wptools.page('Barack Obama').then(function(page) {3 page.alpha().then(function(alpha) {4 console.log(alpha);5 });6});7{ title: 'Barack Obama',8 height: 275 },9 height: 3750 },10 [ { lang: 'af',11 { lang: 'ar',12 { lang: 'az',13 { lang: 'be',
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!