world info display
This commit is contained in:
parent
d1a71d3a2a
commit
c4c8c7699a
@ -27,6 +27,7 @@
|
||||
<script src="js/WebSocketChannel.js"></script>
|
||||
<script src="js/RealtimeTileLayer.js"></script>
|
||||
<script src="js/CoordinatesDisplay.js"></script>
|
||||
<script src="js/WorldInfoDisplay.js"></script>
|
||||
|
||||
<!-- overlays -->
|
||||
<script src="js/overlays/TravelnetOverlay.js"></script>
|
||||
|
22
server/static/js/WorldInfoDisplay.js
Normal file
22
server/static/js/WorldInfoDisplay.js
Normal file
@ -0,0 +1,22 @@
|
||||
'use strict';
|
||||
|
||||
// coord display
|
||||
var WorldInfoDisplay = L.Control.extend({
|
||||
initialize: function(wsChannel, opts) {
|
||||
L.Control.prototype.initialize.call(this, opts);
|
||||
this.wsChannel = wsChannel;
|
||||
},
|
||||
|
||||
onAdd: function(map) {
|
||||
var div = L.DomUtil.create('div', 'leaflet-bar leaflet-custom-display');
|
||||
|
||||
this.wsChannel.addListener("minetest-info", function(info){
|
||||
div.innerHTML = "Lag: " + parseInt(info.max_lag*10)/10 + " Time: " + parseInt(info.time)/1000;
|
||||
});
|
||||
|
||||
return div;
|
||||
},
|
||||
|
||||
onRemove: function(map) {
|
||||
}
|
||||
});
|
@ -41,6 +41,9 @@ api.getConfig().then(function(cfg){
|
||||
var el = new CoordinatesDisplay({ position: 'bottomleft' });
|
||||
el.addTo(map);
|
||||
|
||||
el = new WorldInfoDisplay(wsChannel, { position: 'bottomright' });
|
||||
el.addTo(map);
|
||||
|
||||
}).catch(function(e){
|
||||
console.error(e);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user