Precompile location example. Requires rename location -> locationRecord to avoid window.location clash.
This commit is contained in:
parent
ddd67540be
commit
9b2ce64300
|
@ -0,0 +1 @@
|
|||
*.expanded.js
|
|
@ -0,0 +1,7 @@
|
|||
all: index.expanded.js
|
||||
|
||||
%.expanded.js: %.js
|
||||
../../bin/syndicatec $< > $@ || (rm -f $@; false)
|
||||
|
||||
clean:
|
||||
rm -f *.expanded.js
|
|
@ -8,9 +8,7 @@
|
|||
<script src="https://cdnjs.cloudflare.com/ajax/libs/mustache.js/2.2.1/mustache.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/blueimp-md5/2.3.0/js/md5.min.js"></script>
|
||||
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAgjLSNu9Cx4V1bNxhSTM4ZzqADbGoYmZ0"></script>
|
||||
<script src="../../dist/syndicatecompiler.js"></script>
|
||||
<script src="../../dist/syndicate.js"></script>
|
||||
<script type="text/syndicate-js" src="index.js"></script>
|
||||
<script src="../../dist/syndicate.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<template id="json">
|
||||
|
@ -48,5 +46,7 @@
|
|||
<button id="findMarker">Find</button>
|
||||
</fieldset>
|
||||
</div>
|
||||
|
||||
<script src="index.expanded.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
assertion type location(id, email, timestamp, lat, lng);
|
||||
assertion type locationRecord(id, email, timestamp, lat, lng) = 'location';
|
||||
message type findMarker(id);
|
||||
|
||||
var brokerConnection = Syndicate.Broker.brokerConnection;
|
||||
|
@ -44,11 +44,11 @@ ground dataspace G {
|
|||
|
||||
var watchId = ('geolocation' in navigator)
|
||||
&& navigator.geolocation.watchPosition(Syndicate.Dataspace.wrap(function (pos) {
|
||||
:: location(id,
|
||||
email_element.value.trim(),
|
||||
+new Date(),
|
||||
pos.coords.latitude,
|
||||
pos.coords.longitude);
|
||||
:: locationRecord(id,
|
||||
email_element.value.trim(),
|
||||
+new Date(),
|
||||
pos.coords.latitude,
|
||||
pos.coords.longitude);
|
||||
if (!mapInitialized && map) {
|
||||
mapInitialized = true;
|
||||
map.setCenter({lat: pos.coords.latitude, lng: pos.coords.longitude});
|
||||
|
@ -78,11 +78,11 @@ ground dataspace G {
|
|||
:: findMarker(document.getElementById('markerList').value);
|
||||
}
|
||||
|
||||
on message ($loc = location(_, _, _, _, _)) {
|
||||
on message ($loc = locationRecord(_, _, _, _, _)) {
|
||||
currentLocation = loc;
|
||||
}
|
||||
|
||||
during fromBroker(wsurl, location($id, $email, _, _, _)) {
|
||||
during fromBroker(wsurl, locationRecord($id, $email, _, _, _)) {
|
||||
var ui = new Syndicate.UI.Anchor();
|
||||
var marker = new google.maps.Marker({
|
||||
map: map,
|
||||
|
@ -123,7 +123,7 @@ ground dataspace G {
|
|||
selectMarker();
|
||||
if (latestPosition) map.panTo(latestPosition);
|
||||
}
|
||||
on asserted fromBroker(wsurl, location(id, email, $timestamp, $lat, $lng)) {
|
||||
on asserted fromBroker(wsurl, locationRecord(id, email, $timestamp, $lat, $lng)) {
|
||||
latestTimestamp = new Date(timestamp);
|
||||
latestPosition = {lat: lat, lng: lng};
|
||||
marker.setPosition(latestPosition);
|
||||
|
|
Loading…
Reference in New Issue