14 lines
788 B
JavaScript
14 lines
788 B
JavaScript
(function (ns, $) {
|
|
'use strict';
|
|
function request(path) {
|
|
return $.ajax({ url: ns.Config.apiBase + path, method: 'GET', dataType: 'json', cache: false });
|
|
}
|
|
ns.Api = {
|
|
health: () => request('/health'),
|
|
routes: position => request('/routes' + (position ? `?lat=${encodeURIComponent(position.lat)}&lon=${encodeURIComponent(position.lon)}&radiusKm=${ns.Config.routeRadiusKm}` : '')),
|
|
route: id => request(`/routes/${encodeURIComponent(id)}`),
|
|
pictureUrl: (routeId, pictureId) => `${ns.Config.apiBase}/routes/${encodeURIComponent(routeId)}/pictures/${encodeURIComponent(pictureId)}`,
|
|
audioUrl: (routeId, poiId) => `${ns.Config.apiBase}/routes/${encodeURIComponent(routeId)}/audio?poiId=${encodeURIComponent(poiId)}`
|
|
};
|
|
}(window.Wegwichtel, window.jQuery));
|