MAPG-133 replace XHRs to MapGuesser.httpRequest
This commit is contained in:
		
							parent
							
								
									25262fb5fe
								
							
						
					
					
						commit
						e4c7aadc64
					
				| @ -25,9 +25,7 @@ | ||||
|             }); | ||||
|             Game.map.fitBounds(mapBounds); | ||||
| 
 | ||||
|             var xhr = new XMLHttpRequest(); | ||||
|             xhr.responseType = 'json'; | ||||
|             xhr.onload = function () { | ||||
|             MapGuesser.httpRequest('GET', '/game/' + mapId + '/newPlace.json', function () { | ||||
|                 document.getElementById('loading').style.visibility = 'hidden'; | ||||
|                 document.getElementById('cover').style.visibility = 'hidden'; | ||||
| 
 | ||||
| @ -51,10 +49,7 @@ | ||||
|                 } | ||||
| 
 | ||||
|                 Game.startNewRound(); | ||||
|             }; | ||||
| 
 | ||||
|             xhr.open('GET', '/game/' + mapId + '/newPlace.json', true); | ||||
|             xhr.send(); | ||||
|             }); | ||||
|         }, | ||||
| 
 | ||||
|         reset: function () { | ||||
| @ -127,16 +122,11 @@ | ||||
|         handleErrorResponse: function (error) { | ||||
|             // for the time being we only handle the "no_session_found" error and reset the game
 | ||||
| 
 | ||||
|             var xhr = new XMLHttpRequest(); | ||||
|             xhr.responseType = 'json'; | ||||
|             xhr.onload = function () { | ||||
|             MapGuesser.httpRequest('GET', '/game/' + mapId + '/json', function () { | ||||
|                 mapBounds = this.response.bounds; | ||||
| 
 | ||||
|                 Game.reset(); | ||||
|             }; | ||||
| 
 | ||||
|             xhr.open('GET', '/game/' + mapId + '/json', true); | ||||
|             xhr.send(); | ||||
|             }); | ||||
|         }, | ||||
| 
 | ||||
|         loadPano: function (panoId) { | ||||
| @ -168,9 +158,7 @@ | ||||
|             data.append('lat', String(guessPosition.lat)); | ||||
|             data.append('lng', String(guessPosition.lng)); | ||||
| 
 | ||||
|             var xhr = new XMLHttpRequest(); | ||||
|             xhr.responseType = 'json'; | ||||
|             xhr.onload = function () { | ||||
|             MapGuesser.httpRequest('POST', '/game/' + mapId + '/guess.json', function () { | ||||
|                 if (this.response.error) { | ||||
|                     Game.handleErrorResponse(this.response.error); | ||||
|                     return; | ||||
| @ -211,10 +199,7 @@ | ||||
|                 } | ||||
| 
 | ||||
|                 Game.panoId = this.response.panoId; | ||||
|             }; | ||||
| 
 | ||||
|             xhr.open('POST', '/game/' + mapId + '/guess.json', true); | ||||
|             xhr.send(data); | ||||
|             }, data); | ||||
|         }, | ||||
| 
 | ||||
|         addRealGuessPair: function (position, guessPosition, hidden) { | ||||
|  | ||||
| @ -8,9 +8,7 @@ | ||||
| 
 | ||||
|         var formData = new FormData(form); | ||||
| 
 | ||||
|         var xhr = new XMLHttpRequest(); | ||||
|         xhr.responseType = 'json'; | ||||
|         xhr.onload = function () { | ||||
|         MapGuesser.httpRequest('POST', form.action, function () { | ||||
|             if (this.response.error) { | ||||
|                 var errorText; | ||||
|                 switch (this.response.error) { | ||||
| @ -34,9 +32,6 @@ | ||||
|             } | ||||
| 
 | ||||
|             window.location.replace('/'); | ||||
|         }; | ||||
| 
 | ||||
|         xhr.open('POST', form.action, true); | ||||
|         xhr.send(formData); | ||||
|         }, formData); | ||||
|     }; | ||||
| })(); | ||||
|  | ||||
| @ -28,9 +28,7 @@ | ||||
|         }, | ||||
| 
 | ||||
|         getPlace: function (placeId, marker) { | ||||
|             var xhr = new XMLHttpRequest(); | ||||
|             xhr.responseType = 'json'; | ||||
|             xhr.onload = function () { | ||||
|             MapGuesser.httpRequest('GET', '/admin/place.json/' + placeId, function () { | ||||
|                 document.getElementById('loading').style.visibility = 'hidden'; | ||||
| 
 | ||||
|                 if (!this.response.panoId) { | ||||
| @ -46,10 +44,7 @@ | ||||
|                 places[marker.placeId].noPano = false; | ||||
| 
 | ||||
|                 MapEditor.loadPano(this.response.panoId, places[marker.placeId].pov); | ||||
|             }; | ||||
| 
 | ||||
|             xhr.open('GET', '/admin/place.json/' + placeId, true); | ||||
|             xhr.send(); | ||||
|             }); | ||||
|         }, | ||||
| 
 | ||||
|         loadPano: function (panoId, pov) { | ||||
| @ -284,9 +279,7 @@ | ||||
|                 data.append('deleted[]', JSON.stringify(MapEditor.deleted[placeId])); | ||||
|             } | ||||
| 
 | ||||
|             var xhr = new XMLHttpRequest(); | ||||
|             xhr.responseType = 'json'; | ||||
|             xhr.onload = function () { | ||||
|             MapGuesser.httpRequest('POST', '/admin/saveMap/' + mapId + '/json', function () { | ||||
|                 document.getElementById('loading').style.visibility = 'hidden'; | ||||
| 
 | ||||
|                 if (this.response.error) { | ||||
| @ -310,10 +303,7 @@ | ||||
|                 document.getElementById('deleted').innerHTML = '0'; | ||||
| 
 | ||||
|                 document.getElementById('saveButton').disabled = true; | ||||
|             }; | ||||
| 
 | ||||
|             xhr.open('POST', '/admin/saveMap/' + mapId + '/json', true); | ||||
|             xhr.send(data); | ||||
|             }, data); | ||||
|         }, | ||||
| 
 | ||||
|         replacePlaceIdsToReal: function (addedPlaces) { | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user