diff --git a/Makefile b/Makefile index bf2ef7b67..7b6ba7766 100644 --- a/Makefile +++ b/Makefile @@ -27,15 +27,13 @@ data/data.js: $(DATA_FILES) js/lib/d3.curtain.js \ js/lib/jxon.js \ js/lib/lodash.js \ - js/lib/ohauth.js \ + js/lib/osmauth.js \ js/lib/rtree.js \ - js/lib/sha.js \ js/lib/togeojson.js \ js/lib/marked.js \ js/id/start.js \ js/id/id.js \ js/id/connection.js \ - js/id/oauth.js \ js/id/services/*.js \ data/data.js \ js/id/util.js \ diff --git a/data/core.yaml b/data/core.yaml index 85f4716fb..c33d61880 100644 --- a/data/core.yaml +++ b/data/core.yaml @@ -111,6 +111,7 @@ en: view_on_osm: "View on OSM →" zoom_in_edit: zoom in to edit the map logout: logout + loading_auth: "Connecting to OpenStreetMap..." report_a_bug: report a bug commit: title: Save Changes diff --git a/data/locales.js b/data/locales.js index d842ead31..125ea57db 100644 --- a/data/locales.js +++ b/data/locales.js @@ -142,6 +142,7 @@ locale.en = { "view_on_osm": "View on OSM →", "zoom_in_edit": "zoom in to edit the map", "logout": "logout", + "loading_auth": "Connecting to OpenStreetMap...", "report_a_bug": "report a bug", "commit": { "title": "Save Changes", @@ -1690,6 +1691,7 @@ locale.zh = { "reset": "重置" }, "restore": { + "heading": "您有未保存的更改", "description": "上次您有未保存的更改。你想恢复这些更改吗?", "restore": "恢复", "reset": "重置" @@ -1704,10 +1706,13 @@ locale.zh = { }, "splash": { "welcome": "欢迎使用OpenStreetMap编辑器iD", - "text": "这是开发版本{version}。欲了解更多信息,请参阅{website},在{github}报告bug。" + "text": "这是开发版本{version}。欲了解更多信息,请参阅{website},在{github}报告bug。", + "walkthrough": "开始练习", + "start": "现在编辑" }, "source_switch": { "live": "live", + "lose_changes": "您有未保存的更改。切换地图服务器会丢弃他们。你确定要切换服务器吗?", "dev": "dev" }, "tag_reference": { @@ -1731,6 +1736,9 @@ locale.zh = { "local_layer": "本地GPX文件", "drag_drop": "把GPX文件拖到页面上。" }, + "help": { + "title": "帮助" + }, "presets": { "fields": { "access": { @@ -4214,6 +4222,7 @@ locale.fr = { "reset": "réinitialiser" }, "restore": { + "heading": "Vous avez des changements non sauvés.", "description": "Vous avez des changements non sauvegardés d'une précédente édition. Souhaitez-vous restaurer ces changements?", "restore": "Restaurer", "reset": "Annuler" @@ -4228,7 +4237,8 @@ locale.fr = { }, "splash": { "welcome": "Bienvenue sur ID l'editeur en ligne d'OpenStreetMap", - "text": "Cette version {version}, est une version de développement. Si vous souhaitez plus d'informations, veuillez consulter {website} ou pour signaler un bug {github}." + "text": "Cette version {version}, est une version de développement. Si vous souhaitez plus d'informations, veuillez consulter {website} ou pour signaler un bug {github}.", + "start": "Editer" }, "source_switch": { "live": "live", @@ -4255,6 +4265,9 @@ locale.fr = { "local_layer": "Fichier GPX personnel", "drag_drop": "Glisser et déposer un fichier .gpx sur la page" }, + "help": { + "title": "Aide" + }, "presets": { "fields": { "address": { @@ -4800,7 +4813,8 @@ locale.de = { }, "splash": { "welcome": "Willkommen beim iD OpenStreetMap-Editor", - "text": "Dies ist eine Entwicklungsversion {version}. Für weitere Informationen besuche {website} und melde Fehler unter {github}." + "text": "Dies ist eine Entwicklungsversion {version}. Für weitere Informationen besuche {website} und melde Fehler unter {github}.", + "start": "Jetzt bearbeiten" }, "source_switch": { "live": "live", @@ -4869,32 +4883,99 @@ locale.de = { "capacity": { "label": "Kapazität" }, + "collection_times": { + "label": "Leerungszeiten" + }, + "country": { + "label": "Land" + }, + "cuisine": { + "label": "Küche" + }, + "denomination": { + "label": "Glaubensrichtung" + }, + "entrance": { + "label": "Art" + }, "fax": { "label": "Fax" }, + "fee": { + "label": "Gebühr" + }, + "highway": { + "label": "Art" + }, + "historic": { + "label": "Art" + }, "internet_access": { "label": "Internetzugang", "options": { - "wlan": "Wifi" + "wlan": "Wifi", + "wired": "Kabelgebunden" } }, + "landuse": { + "label": "Art" + }, + "layer": { + "label": "Ebene" + }, + "leisure": { + "label": "Art" + }, "levels": { "label": "Etagen" }, + "man_made": { + "label": "Art" + }, "maxspeed": { "label": "Höchstgeschwindigkeit" }, + "network": { + "label": "Netzwerk" + }, "note": { "label": "Notiz" }, "oneway": { "label": "Einbahnstraße" }, + "opening_hours": { + "label": "Öffnungszeiten" + }, + "operator": { + "label": "Betreiber" + }, "phone": { "label": "Telefon" }, + "place": { + "label": "Art" + }, + "railway": { + "label": "Art" + }, "religion": { - "label": "Religion" + "label": "Religion", + "options": { + "christian": "Christlich", + "muslim": "Muslimisch", + "buddhist": "Buddhistisch", + "jewish": "Jüdisch" + } + }, + "service": { + "label": "Art" + }, + "shelter": { + "label": "Unterstand" + }, + "shop": { + "label": "Art" }, "source": { "label": "Quelle" @@ -4902,23 +4983,50 @@ locale.de = { "sport": { "label": "Sport" }, + "structure": { + "options": { + "bridge": "Brücke", + "tunnel": "Tunnel" + } + }, "surface": { "label": "Oberfläche" }, + "tourism": { + "label": "Art" + }, + "water": { + "label": "Art" + }, + "waterway": { + "label": "Art" + }, "website": { "label": "Webseite" }, + "wetland": { + "label": "Art" + }, "wikipedia": { "label": "Wikipedia" + }, + "wood": { + "label": "Art" } }, "presets": { + "aeroway": { + "name": "Luftfahrt" + }, "aeroway/aerodrome": { "name": "Flughafen" }, "aeroway/helipad": { "name": "Hubschrauberlandeplatz" }, + "amenity": { + "name": "Einrichtungen" + }, "amenity/bank": { "name": "Bank" }, @@ -4934,9 +5042,24 @@ locale.de = { "amenity/bicycle_rental": { "name": "Fahrradverleih" }, + "amenity/cafe": { + "name": "Café" + }, "amenity/cinema": { "name": "Kino" }, + "amenity/courthouse": { + "name": "Gericht" + }, + "amenity/embassy": { + "name": "Botschaft" + }, + "amenity/fast_food": { + "name": "Fast Food" + }, + "amenity/fire_station": { + "name": "Feuerwehrhaus" + }, "amenity/fuel": { "name": "Tankstelle" }, @@ -4955,9 +5078,15 @@ locale.de = { "amenity/pharmacy": { "name": "Apotheke" }, + "amenity/place_of_worship": { + "name": "Gebetsort" + }, "amenity/place_of_worship/christian": { "name": "Kirche" }, + "amenity/place_of_worship/jewish": { + "name": "Sy­n­a­go­ge" + }, "amenity/place_of_worship/muslim": { "name": "Moschee" }, @@ -4967,6 +5096,9 @@ locale.de = { "amenity/post_box": { "name": "Briefkasten" }, + "amenity/post_office": { + "name": "Poststelle" + }, "amenity/pub": { "name": "Pub" }, @@ -4976,9 +5108,15 @@ locale.de = { "amenity/school": { "name": "Schule" }, + "amenity/swimming_pool": { + "name": "Schwimmbecken" + }, "amenity/telephone": { "name": "Telefon" }, + "amenity/theatre": { + "name": "The­a­ter" + }, "amenity/toilets": { "name": "Toilette" }, @@ -4988,6 +5126,9 @@ locale.de = { "amenity/university": { "name": "Universität" }, + "building": { + "name": "Gebäude" + }, "entrance": { "name": "Eingang" }, @@ -5006,18 +5147,39 @@ locale.de = { "highway/footway": { "name": "Fußweg" }, + "highway/motorway": { + "name": "Autobahn" + }, "highway/path": { "name": "Pfad" }, + "highway/primary": { + "name": "Hauptverbindungsstraße" + }, + "highway/residential": { + "name": "Wohngebietsstraße" + }, + "highway/secondary": { + "name": "Landstraße" + }, + "highway/service": { + "name": "Erschließungsweg" + }, "highway/steps": { "name": "Treppen" }, + "highway/tertiary": { + "name": "Kreisstraße" + }, "highway/track": { "name": "Feld-/Waldweg" }, "highway/traffic_signals": { "name": "Ampeln" }, + "highway/trunk": { + "name": "Kraftfahrstraße" + }, "highway/turning_circle": { "name": "Wendestelle" }, @@ -5027,9 +5189,21 @@ locale.de = { "historic/monument": { "name": "Monument" }, + "landuse": { + "name": "Landnutzung" + }, "landuse/allotments": { "name": "Kleigartenanlage" }, + "landuse/basin": { + "name": "Becken" + }, + "landuse/cemetery": { + "name": "Friedhof" + }, + "landuse/farm": { + "name": "Bauernhof" + }, "landuse/forest": { "name": "Wald" }, @@ -5045,12 +5219,18 @@ locale.de = { "landuse/residential": { "name": "Wohngebiet" }, + "leisure/garden": { + "name": "Garten" + }, "leisure/golf_course": { "name": "Golfplatz" }, "leisure/park": { "name": "Park" }, + "leisure/pitch": { + "name": "Sportplatz" + }, "leisure/pitch/american_football": { "name": "American Football Feld" }, @@ -5066,6 +5246,21 @@ locale.de = { "leisure/playground": { "name": "Spieplatz" }, + "leisure/stadium": { + "name": "Stadium" + }, + "leisure/swimming_pool": { + "name": "Schwimmbecken" + }, + "man_made/lighthouse": { + "name": "Leuchtturm" + }, + "man_made/pier": { + "name": "Steg" + }, + "man_made/survey_point": { + "name": "Vermessungspunkt" + }, "natural/beach": { "name": "Strand" }, @@ -5114,6 +5309,9 @@ locale.de = { "railway/subway": { "name": "U-Bahn" }, + "shop": { + "name": "Laden" + }, "shop/butcher": { "name": "Fleischer" }, @@ -5138,6 +5336,9 @@ locale.de = { "tourism/information": { "name": "Information" }, + "tourism/motel": { + "name": "Motel" + }, "tourism/museum": { "name": "Museum" }, @@ -5147,6 +5348,9 @@ locale.de = { "tourism/theme_park": { "name": "Themenpark" }, + "tourism/viewpoint": { + "name": "Aussichtspunkt" + }, "tourism/zoo": { "name": "Zoo" }, @@ -6714,7 +6918,17 @@ locale.pl = { "point": "Przesunięto punkt.", "vertex": "Przesunięto węzeł drogi.", "line": "Przesunięto linię.", - "area": "Przesunięto obszar." + "area": "Przesunięto obszar.", + "multiple": "Przesunięto wiele obiektów." + } + }, + "rotate": { + "title": "Obróć", + "description": "Obróć ten obiekt względem jego środka.", + "key": "R", + "annotation": { + "line": "Obrócono linię.", + "area": "Obrócono obszar." } }, "reverse": { @@ -6741,6 +6955,7 @@ locale.pl = { "commit": { "title": "Zapisz zmiany", "description_placeholder": "Krótki opis twoich zmian", + "message_label": "Opis zmian", "upload_explanation": "Zmiany które wyślesz jako {user} będą widoczne na wszystkich mapach używających danych OpenStreetMap.", "save": "Zapisz", "cancel": "Anuluj", @@ -6764,8 +6979,13 @@ locale.pl = { "inspector": { "no_documentation_combination": "Nie ma dokumentacji dla tej kombinacji tagu.", "no_documentation_key": "Nie ma dokumentacji dla tego klucza", + "show_more": "Pokaż więcej", "new_tag": "Nowy tag", - "view_on_osm": "Zobacz w OSM" + "view_on_osm": "Zobacz w OSM", + "editing_feature": "Edytujesz {feature}", + "additional": "Dodatkowe znaczniki", + "results": "{n} wyników dla {search}", + "reference": "Zobacz na OpenStreetMap Wiki →" }, "background": { "title": "Tło", @@ -6775,6 +6995,7 @@ locale.pl = { "reset": "resetuj" }, "restore": { + "heading": "Masz niezapisane zmiany", "description": "Masz niezapisane zmiany z poprzedniej sesji. Chcesz je przywrócić?", "restore": "Przywróć", "reset": "Resetuj" @@ -6782,6 +7003,7 @@ locale.pl = { "save": { "title": "Zapisz", "help": "Zapisz zmiany na OpenStreetMap, aby były one widoczne dla innych", + "no_changes": "Brak zmian do zapisania.", "error": "Wystąpił błąd podczas próby zapisu.", "uploading": "Wysyłanie zmian do OpenStreetMap.", "unsaved_changes": "Masz niezapisane zmiany." @@ -6810,6 +7032,440 @@ locale.pl = { "zoom": { "in": "Powiększ", "out": "Zmniejsz" + }, + "gpx": { + "local_layer": "Lokalny plik GPX", + "drag_drop": "Przeciągnij i upuść plik .gpx na stronę" + }, + "help": { + "title": "Pomoc" + }, + "presets": { + "fields": { + "access": { + "label": "Dostęp" + }, + "address": { + "label": "Adres", + "placeholders": { + "housename": "Nazwa budynku", + "number": "123", + "street": "Ulica", + "city": "Miasto" + } + }, + "aeroway": { + "label": "Typ" + }, + "amenity": { + "label": "Typ" + }, + "atm": { + "label": "Bankomat" + }, + "bicycle_parking": { + "label": "Typ" + }, + "building": { + "label": "Budynek" + }, + "building_area": { + "label": "Budynek" + }, + "building_yes": { + "label": "Budynek" + }, + "capacity": { + "label": "Pojemność" + }, + "construction": { + "label": "Typ" + }, + "crossing": { + "label": "Typ" + }, + "cuisine": { + "label": "Kuchnia" + }, + "denomination": { + "label": "Wyznanie" + }, + "entrance": { + "label": "Typ" + }, + "fax": { + "label": "Faks" + }, + "fee": { + "label": "Opłata" + }, + "highway": { + "label": "Typ" + }, + "historic": { + "label": "Typ" + }, + "internet_access": { + "label": "Dostęp do internetu", + "options": { + "wlan": "Bezprzewodowy", + "wired": "Przewodowy" + } + }, + "landuse": { + "label": "Typ" + }, + "layer": { + "label": "Warstwa" + }, + "leisure": { + "label": "Typ" + }, + "levels": { + "label": "Poziomy" + }, + "man_made": { + "label": "Typ" + }, + "maxspeed": { + "label": "Ograniczenie prędkości" + }, + "network": { + "label": "Sieć" + }, + "note": { + "label": "Notatka" + }, + "office": { + "label": "Typ" + }, + "oneway": { + "label": "Jednokierunkowa" + }, + "opening_hours": { + "label": "Godziny" + }, + "phone": { + "label": "Telefon" + }, + "place": { + "label": "Typ" + }, + "railway": { + "label": "Typ" + }, + "religion": { + "label": "Religia", + "options": { + "christian": "Chrześcijaństwo", + "muslim": "Islam", + "buddhist": "Buddyzm", + "jewish": "Judaizm", + "hindu": "Hinduizm", + "shinto": "Szintoizm", + "taoist": "Taoizm" + } + }, + "service": { + "label": "Typ" + }, + "shelter": { + "label": "Schronienie" + }, + "shop": { + "label": "Typ" + }, + "source": { + "label": "Źródło" + }, + "sport": { + "label": "Sport" + }, + "surface": { + "label": "Nawierzchnia" + }, + "tourism": { + "label": "Typ" + }, + "water": { + "label": "Typ" + }, + "waterway": { + "label": "Typ" + }, + "website": { + "label": "Strona WWW" + }, + "wetland": { + "label": "Typ" + }, + "wikipedia": { + "label": "Wikipedia" + }, + "wood": { + "label": "Typ" + } + }, + "presets": { + "aeroway/aerodrome": { + "name": "Lotnisko" + }, + "aeroway/helipad": { + "name": "Lądowisko dla helikopterów" + }, + "amenity/bank": { + "name": "Bank" + }, + "amenity/bar": { + "name": "Bar" + }, + "amenity/bicycle_parking": { + "name": "Parking dla rowerów" + }, + "amenity/bicycle_rental": { + "name": "Wypożyczalnia rowerów" + }, + "amenity/cafe": { + "name": "Kawiarnia" + }, + "amenity/cinema": { + "name": "Kino" + }, + "amenity/fast_food": { + "name": "Fast food" + }, + "amenity/fire_station": { + "name": "Straż pożarna" + }, + "amenity/grave_yard": { + "name": "Cmentarz" + }, + "amenity/hospital": { + "name": "Szpital" + }, + "amenity/library": { + "name": "Biblioteka" + }, + "amenity/parking": { + "name": "Parking" + }, + "amenity/pharmacy": { + "name": "Apteka" + }, + "amenity/place_of_worship": { + "name": "Miejsce kultu religijnego" + }, + "amenity/place_of_worship/christian": { + "name": "Kościół" + }, + "amenity/place_of_worship/jewish": { + "name": "Synagoga" + }, + "amenity/place_of_worship/muslim": { + "name": "Meczet" + }, + "amenity/police": { + "name": "Policja" + }, + "amenity/post_box": { + "name": "Skrzynka pocztowa" + }, + "amenity/post_office": { + "name": "Poczta" + }, + "amenity/pub": { + "name": "Pub" + }, + "amenity/restaurant": { + "name": "Restauracja" + }, + "amenity/school": { + "name": "Szkoła" + }, + "amenity/toilets": { + "name": "Toalety" + }, + "amenity/townhall": { + "name": "Ratusz" + }, + "amenity/university": { + "name": "Uniwersytet" + }, + "building": { + "name": "Budynek" + }, + "entrance": { + "name": "Wejście" + }, + "highway": { + "name": "Droga" + }, + "highway/bus_stop": { + "name": "Przystanek autobusowy" + }, + "highway/crossing": { + "name": "Przejście dla pieszych" + }, + "highway/cycleway": { + "name": "Ścieżka rowerowa" + }, + "highway/footway": { + "name": "Ścieżka dla pieszych" + }, + "highway/motorway": { + "name": "Autostrada" + }, + "highway/path": { + "name": "Ścieżka" + }, + "highway/primary": { + "name": "Droga krajowa" + }, + "highway/residential": { + "name": "Droga lokalna" + }, + "highway/secondary": { + "name": "Droga wojewódzka" + }, + "highway/service": { + "name": "Droga serwisowa" + }, + "highway/steps": { + "name": "Schody" + }, + "highway/tertiary": { + "name": "Droga powiatowa" + }, + "highway/track": { + "name": "Droga gruntowa" + }, + "highway/traffic_signals": { + "name": "Sygnalizacja świetlna" + }, + "highway/trunk": { + "name": "Droga ekspresowa" + }, + "highway/turning_circle": { + "name": "Miejsce do zawracania" + }, + "highway/unclassified": { + "name": "Droga niesklasyfikowana" + }, + "historic": { + "name": "Miejsce historyczne" + }, + "historic/monument": { + "name": "Pomnik" + }, + "landuse": { + "name": "Użytkowanie gruntów" + }, + "landuse/allotments": { + "name": "Działki" + }, + "landuse/basin": { + "name": "Zbiornik wodny" + }, + "landuse/cemetery": { + "name": "Cmentarz" + }, + "landuse/commercial": { + "name": "Biura i usługi" + }, + "landuse/construction": { + "name": "Budowa" + }, + "landuse/farm": { + "name": "Teren rolny" + }, + "landuse/farmyard": { + "name": "Podwórze gospodarskie" + }, + "landuse/forest": { + "name": "Las" + }, + "landuse/grass": { + "name": "Trawa" + }, + "landuse/industrial": { + "name": "Obszar przemysłowy" + }, + "landuse/meadow": { + "name": "Łąka" + }, + "landuse/orchard": { + "name": "Sad" + }, + "landuse/quarry": { + "name": "Kamieniołom" + }, + "landuse/residential": { + "name": "Zabudowa mieszkaniowa" + }, + "landuse/vineyard": { + "name": "Winnica" + }, + "leisure": { + "name": "Rozrywka i wypoczynek" + }, + "leisure/golf_course": { + "name": "Pole golfowe" + }, + "leisure/park": { + "name": "Park" + }, + "leisure/pitch": { + "name": "Boisko" + }, + "leisure/pitch/american_football": { + "name": "Boisko do futbolu amerykańskiego" + }, + "leisure/pitch/baseball": { + "name": "Boisko do baseballu" + }, + "leisure/pitch/basketball": { + "name": "Boisko do koszykówki" + }, + "leisure/pitch/soccer": { + "name": "Boisko do piłki nożnej" + }, + "leisure/pitch/tennis": { + "name": "Kort tenisowy" + }, + "leisure/playground": { + "name": "Plac zabaw" + }, + "man_made": { + "name": "Obiekty sztuczne" + }, + "man_made/lighthouse": { + "name": "Latarnia morska" + }, + "man_made/pier": { + "name": "Molo" + }, + "man_made/water_tower": { + "name": "Wieża ciśnień" + }, + "natural": { + "name": "Natura" + }, + "natural/bay": { + "name": "Zatoka" + }, + "natural/beach": { + "name": "Plaża" + }, + "natural/cliff": { + "name": "Klif" + }, + "natural/coastline": { + "name": "Wybrzeże" + }, + "natural/glacier": { + "name": "Lodowiec" + } + } } }; locale.pt = { @@ -9700,7 +10356,9 @@ locale.vi = { "drag_drop": "Kéo thả một tập tin .gpx vào trang" }, "help": { - "title": "Trợ giúp" + "title": "Trợ giúp", + "help": "# Trợ giúp\n\nĐây là trình vẽ của [OpenStreetMap](http://www.openstreetmap.org/), bản đồ có mã nguồn mở và dữ liệu mở cho phép mọi người cùng sửa đổi. Bạn có thể sử dụng chương trình này để bổ sung và cập nhật dữ liệu bản đồ tại khu vực của bạn. Bạn có thể cải tiến bản đồ thế giới mở để cho mọi người sử dụng.\n\nCác sửa đổi của bạn trên bản đồ này sẽ xuất hiện cho mọi người dùng OpenStreetMap. Để sửa bản đồ, bạn cần có một [tài khoản OpenStreetMap miễn phí](https://www.openstreetmap.org/user/new).\n\n[Tình vẽ iD](http://ideditor.com/) là một dự án cộng tác và xuất bản [tất cả mã nguồn tại GitHub](https://github.com/systemed/iD).\n", + "addresses": "# Địa chỉ\n\nĐịa chỉ là những thông tin rất cần thiết trên bản đồ.\n\nTuy bản đồ thường trình bày các địa chỉ như một thuộc tính của đường sá, nhưng OpenStreetMap liên kết các địa chỉ với các tòa nhà hoặc miếng đất dọc đường.\n\nBạn có thể thêm thông tin địa chỉ vào các hình dạng tòa nhà hoặc các địa điểm quan tâm. Tốt nhất là lấy thông tin địa chỉ từ kinh nghiệm cá nhân, thí dụ đi dạo trên phố và ghi chép các địa chỉ hoặc nhớ lại những chi tiết từ hoạt động hàng ngày của bạn. Cũng như bất cứ chi tiết nào, dự án này hoàn toàn cấm sao chép từ các nguồn thương mại như Bản đồ Google.\n" }, "presets": { "fields": { diff --git a/index.html b/index.html index fefcd1b72..33f8eb4a0 100644 --- a/index.html +++ b/index.html @@ -15,8 +15,7 @@ - - + @@ -35,7 +34,6 @@ - diff --git a/js/id/connection.js b/js/id/connection.js index 8f690e127..cae450222 100644 --- a/js/id/connection.js +++ b/js/id/connection.js @@ -7,7 +7,12 @@ iD.Connection = function(context) { keys, inflight = {}, loadedTiles = {}, - oauth = iD.OAuth(context).url(url), + loadingModal, + oauth = osmAuth({ + url: url, + loading: authLoading, + done: authDone + }), ndStr = 'nd', tagStr = 'tag', memberStr = 'member', @@ -27,6 +32,15 @@ iD.Connection = function(context) { return d3.xml(url).get().on('load', done); }; + function authLoading() { + loadingModal = iD.ui.loading(context.container(), + t('loading_auth')); + } + + function authDone() { + if (loadingModal) loadingModal.remove(); + } + function getNodes(obj) { var elems = obj.getElementsByTagName(ndStr), nodes = new Array(elems.length); diff --git a/js/id/oauth.js b/js/id/oauth.js deleted file mode 100644 index b4bcd4716..000000000 --- a/js/id/oauth.js +++ /dev/null @@ -1,147 +0,0 @@ -iD.OAuth = function(context) { - var baseurl = 'http://www.openstreetmap.org', - o = {}, - keys, - oauth = {}, - oauth_secret; - - function timenonce(o) { - o.oauth_timestamp = ohauth.timestamp(); - o.oauth_nonce = ohauth.nonce(); - return o; - } - - // token getter/setter, namespaced to the current `apibase` value. - function token() { - return context.storage.apply(context, arguments); - } - - if (token('oauth_token')) { - o.oauth_token = token('oauth_token'); - } - - oauth.authenticated = function() { - return token('oauth_token') && token('oauth_token_secret'); - }; - - oauth.logout = function() { - token('oauth_token', ''); - token('oauth_token_secret', ''); - token('oauth_request_token_secret', ''); - return oauth; - }; - - oauth.xhr = function(options, callback) { - if (token('oauth_token')) { - o.oauth_token = token('oauth_token'); - } - o = timenonce(o); - var url = baseurl + options.path; - var oauth_token_secret = token('oauth_token_secret'); - o.oauth_signature = ohauth.signature(oauth_secret, oauth_token_secret, - ohauth.baseString(options.method, url, o)); - function done(err, xhr) { - if (err) return callback(err); - if (xhr.responseXML) return callback(err, xhr.responseXML); - else return callback(err, xhr.response); - } - ohauth.xhr(options.method, - url, o, options.content, options.options, done); - }; - - oauth.authenticate = function(callback) { - if (oauth.authenticated()) return callback(); - - oauth.logout(); - - setAuth(); - o = timenonce(o); - - var url = baseurl + '/oauth/request_token'; - o.oauth_signature = ohauth.signature(oauth_secret, '', - ohauth.baseString('POST', url, o)); - - var l = iD.ui.loading(context.container(), 'contacting openstreetmap...'); - - // it would make more sense to have this code within the callback - // to oauth.xhr below. however, it needs to be directly within a - // browser event handler in order to open a popup without it being - // blocked. - var w = 600, h = 550, - settings = [ - ['width', w], ['height', h], - ['left', screen.width / 2 - w / 2], - ['top', screen.height / 2 - h / 2]].map(function(x) { - return x.join('='); - }).join(','), - popup = window.open("about:blank", 'oauth_window', settings); - - window.authComplete = function(token) { - var oauth_token = ohauth.stringQs(token); - get_access_token(oauth_token); - delete window.authComplete; - }; - - function reqTokenDone(err, xhr) { - if (err) callback(err); - l.remove(); - - var resp = ohauth.stringQs(xhr.response); - token('oauth_request_token_secret', resp.oauth_token_secret); - - popup.location = baseurl + '/oauth/authorize?' + ohauth.qsString({ - oauth_token: resp.oauth_token, - oauth_callback: location.href.replace('index.html', '') - .replace(/#.+/, '') + 'land.html' - }); - } - - ohauth.xhr('POST', url, o, null, {}, reqTokenDone); - - function get_access_token(oauth_token) { - var url = baseurl + '/oauth/access_token'; - o = timenonce(o); - - o.oauth_token = oauth_token.oauth_token; - var request_token_secret = token('oauth_request_token_secret'); - o.oauth_signature = ohauth.signature(oauth_secret, request_token_secret, - ohauth.baseString('POST', url, o)); - var l = iD.ui.loading(context.container(), 'contacting openstreetmap...'); - - function accessTokenDone(err, xhr) { - if (err) return callback(err); - l.remove(); - var access_token = ohauth.stringQs(xhr.response); - token('oauth_token', access_token.oauth_token); - token('oauth_token_secret', access_token.oauth_token_secret); - callback(); - } - - ohauth.xhr('POST', url, o, null, {}, accessTokenDone); - } - - }; - - function setAuth() { - if (baseurl && keys && keys[baseurl]) { - o = _.assign({}, _.omit(keys[baseurl], 'oauth_secret')); - oauth_secret = keys[baseurl].oauth_secret; - } - } - - oauth.url = function(_) { - if (!arguments.length) return baseurl; - baseurl = _; - setAuth(); - return oauth; - }; - - oauth.keys = function(_) { - if (!arguments.length) return keys; - keys = _; - setAuth(); - return oauth; - }; - - return oauth; -}; diff --git a/js/id/ui/background.js b/js/id/ui/background.js index bcd17eee3..cd8c87bea 100644 --- a/js/id/ui/background.js +++ b/js/id/ui/background.js @@ -238,8 +238,13 @@ iD.ui.Background = function(context) { .on('click', function() { d3.event.preventDefault(); d3.event.stopPropagation(); - context.map() - .extent(d3.geo.bounds(context.map().layers[1].geojson())) + if (context.map().layers[1].geojson().type) { + context.map() + .extent(d3.geo.bounds(context + .map() + .layers[1] + .geojson())); + } }) .append('span') .attr('class', 'icon geocode' ); diff --git a/js/lib/ohauth.js b/js/lib/ohauth.js deleted file mode 100644 index 1d6852268..000000000 --- a/js/lib/ohauth.js +++ /dev/null @@ -1,80 +0,0 @@ -(function(context) { - -var ohauth = {}; - -ohauth.qsString = function(obj) { - return Object.keys(obj).sort().map(function(key) { - return encodeURIComponent(key) + '=' + encodeURIComponent(obj[key]); - }).join('&'); -}; - -ohauth.sha = sha1(); - -ohauth.stringQs = function(str) { - return str.split('&').reduce(function(obj, pair){ - var parts = pair.split('='); - obj[parts[0]] = (null === parts[1]) ? '' : decodeURIComponent(parts[1]); - return obj; - }, {}); -}; - -ohauth.xhr = function(method, url, auth, data, options, callback) { - var xhr = new XMLHttpRequest(), - twoHundred = /^20\d$/; - xhr.onreadystatechange = function() { - if (4 == xhr.readyState && 0 !== xhr.status) { - if (twoHundred.test(xhr.status)) { - callback(null, xhr); - } else { - callback(xhr, null); - } - } - }; - xhr.onerror = function(e) { return callback(e, null); }; - var headers = (options && options.header) || { 'Content-Type': 'application/x-www-form-urlencoded' }; - xhr.open(method, url, true); - xhr.setRequestHeader('Authorization', 'OAuth ' + ohauth.authHeader(auth)); - for (var h in headers) xhr.setRequestHeader(h, headers[h]); - xhr.send(data); -}; - -ohauth.nonce = function() { - for (var o = ''; o.length < 6;) { - o += '0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz'[Math.floor(Math.random() * 61)]; - } - return o; -}; - -ohauth.authHeader = function(obj) { - return Object.keys(obj).sort().map(function(key) { - return encodeURIComponent(key) + '="' + encodeURIComponent(obj[key]) + '"'; - }).join(', '); -}; - -ohauth.timestamp = function() { return ~~((+new Date()) / 1000); }; - -ohauth.percentEncode = function(s) { - return encodeURIComponent(s) - .replace(/\!/g, '%21').replace(/\'/g, '%27') - .replace(/\*/g, '%2A').replace(/\(/g, '%28').replace(/\)/g, '%29'); -}; - -ohauth.baseString = function(method, url, params) { - if (params.oauth_signature) delete params.oauth_signature; - return [ - method, - ohauth.percentEncode(url), - ohauth.percentEncode(ohauth.qsString(params))].join('&'); -}; - -ohauth.signature = function(oauth_secret, token_secret, baseString) { - return ohauth.sha.b64_hmac_sha1( - ohauth.percentEncode(oauth_secret) + '&' + - ohauth.percentEncode(token_secret), - baseString); -}; - -context.ohauth = ohauth; - -})(this); - diff --git a/js/lib/osmauth.js b/js/lib/osmauth.js new file mode 100644 index 000000000..4511aa8bf --- /dev/null +++ b/js/lib/osmauth.js @@ -0,0 +1,2074 @@ +(function(e){if("function"==typeof bootstrap)bootstrap("osmauth",e);else if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else if("undefined"!=typeof ses){if(!ses.ok())return;ses.makeOsmAuth=e}else"undefined"!=typeof window?window.osmAuth=e():global.osmAuth=e()})(function(){var define,ses,bootstrap,module,exports; +return (function(e,t,n){function r(n,i){if(!t[n]){if(!e[n]){var s=typeof require=="function"&&require;if(!i&&s)return s(n,!0);throw new Error("Cannot find module '"+n+"'")}var o=t[n]={exports:{}};e[n][0](function(t){var i=e[n][1][t];return r(i?i:t)},o,o.exports)}return t[n].exports}for(var i=0;idocument.w=window