-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathlocory.js
71 lines (59 loc) · 1.45 KB
/
locory.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
var Locory = {};
$(function()
{
var menuItem = $('.nav').find("[data-nav-for-page='" + Locory.ContentPage + "']");
menuItem.addClass('active');
Locory.DefaultFrom = moment().subtract(1, "days");
Locory.DefaultTo = moment().subtract(1, "days");
$.timeago.settings.allowFuture = true;
$('time.timeago').timeago();
});
Locory.FetchJson = function(url, success, error)
{
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function()
{
if (xhr.readyState === XMLHttpRequest.DONE)
{
if (xhr.status === 200)
{
if (success)
{
success(JSON.parse(xhr.responseText));
}
}
else
{
if (error)
{
error(xhr);
}
}
}
};
xhr.open("GET", url, true);
xhr.send();
}
Locory.SetupMap = function(mapElementId)
{
Locory.Map = L.map(mapElementId);
L.tileLayer("https://osm-tile-cache.berrnd.org/{z}/{x}/{y}.png", {
attribution: 'Map data © <a target="_blank" href="https://www.openstreetmap.org">OpenStreetMap</a> contributors',
maxZoom: 18
}).addTo(Locory.Map);
Locory.LocationPointsLayer = new L.FeatureGroup();
Locory.Map.addLayer(Locory.LocationPointsLayer);
}
Locory.GetUriParam = function(key)
{
var currentUri = decodeURIComponent(window.location.search.substring(1));
var vars = currentUri.split('&');
for (i = 0; i < vars.length; i++)
{
var currentParam = vars[i].split('=');
if (currentParam[0] === key)
{
return currentParam[1] === undefined ? true : currentParam[1];
}
}
};