apiKey support for last/index.html

This commit is contained in:
Jan-Piet Mens
2016-07-14 18:28:52 +02:00
parent 44cf65add7
commit 834530a1f5
5 changed files with 30 additions and 8 deletions

View File

@@ -1 +1,2 @@
config.js
apikey.js

View File

@@ -0,0 +1 @@
var apiKey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";

View File

@@ -33,6 +33,8 @@ function initialize() {
buttonControlDiv.index = 1;
map.controls[google.maps.ControlPosition.BOTTOM_LEFT].push(buttonControlDiv);
ws_go(); // Connect to websocket and start listening
}
function ButtonControl(controlDiv, map) {
@@ -215,4 +217,4 @@ function map_marker(loc)
}
}
google.maps.event.addDomListener(window, 'load', initialize);
// google.maps.event.addDomListener(window, 'load', initialize);

View File

@@ -32,18 +32,35 @@
.latlon { color: gray; }
</style>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&signed_in=true"></script>
<script src="apikey.js"></script>
<script src="functions.js"></script>
<script src="websock.js"></script>
<script src="config.js"></script>
<script src="../static/js/moment.min.js"></script>
<script src="../static/js/mustache.js"></script>
<script>
function loadMapsAPI() {
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'https://maps.googleapis.com/maps/api/js?v=3' +
'&signed_in=true&key=' + apiKey +'&callback=initialize';
document.body.appendChild(script);
}
document.addEventListener("DOMContentLoaded", function(event) {
loadMapsAPI();
});
</script>
</head>
<body>
<div id="output"></div>
<div id="wrapper">
<div id="map-canvas"></div>
<div id="maplabel"></div>
</div>
<div id="output"></div>
<div id="wrapper">
<div id="map-canvas"></div>
<div id="maplabel"></div>
</div>
</body>
</html>

View File

@@ -56,7 +56,7 @@ function ws_connect() {
};
}
window.onload = function() {
function ws_go() {
// var url = 'ws://' + location.host + '/ws/last';
// console.log(JSON.stringify(location));
@@ -68,6 +68,7 @@ window.onload = function() {
url = url + "ws/last";
console.log("Websocket URI: " + url);
ws_url = url;
ws_connect();