fix urls for when we aren't running on the root

This commit is contained in:
root 2019-11-25 20:17:11 +01:00
parent 147c108570
commit b774e75f2c
5 changed files with 15 additions and 11 deletions

View File

@ -1,6 +1,6 @@
$(function(){ $(function(){
var converter = new showdown.Converter(); var converter = new showdown.Converter();
$.ajax('/api/features').done(function(data){ $.ajax('api/features').done(function(data){
var $table = $('table.features'); var $table = $('table.features');
$.each(data, function(name, details) { $.each(data, function(name, details) {
var requirements = $.map(details.requirements, function(r, name){ var requirements = $.map(details.requirements, function(r, name){

View File

@ -18,7 +18,7 @@
<li data-toggle-panel="openwebrx-panel-status"><img src="static/gfx/openwebrx-panel-status.png" /><br/>Status</li> <li data-toggle-panel="openwebrx-panel-status"><img src="static/gfx/openwebrx-panel-status.png" /><br/>Status</li>
<li data-toggle-panel="openwebrx-panel-log"><img src="static/gfx/openwebrx-panel-log.png" /><br/>Log</li> <li data-toggle-panel="openwebrx-panel-log"><img src="static/gfx/openwebrx-panel-log.png" /><br/>Log</li>
<li data-toggle-panel="openwebrx-panel-receiver"><img src="static/gfx/openwebrx-panel-receiver.png" /><br/>Receiver</li> <li data-toggle-panel="openwebrx-panel-receiver"><img src="static/gfx/openwebrx-panel-receiver.png" /><br/>Receiver</li>
<li><a href="/map" target="_blank"><img src="static/gfx/openwebrx-panel-map.png" /><br/>Map</a></li> <li><a href="map" target="_blank"><img src="static/gfx/openwebrx-panel-map.png" /><br/>Map</a></li>
</ul> </ul>
</section> </section>
</div> </div>

View File

@ -9,7 +9,7 @@ AprsMarker.prototype.draw = function() {
if (this.symbol) { if (this.symbol) {
var tableId = this.symbol.table === '/' ? 0 : 1; var tableId = this.symbol.table === '/' ? 0 : 1;
div.style.background = 'url(/aprs-symbols/aprs-symbols-24-' + tableId + '@2x.png)'; div.style.background = 'url(aprs-symbols/aprs-symbols-24-' + tableId + '@2x.png)';
div.style['background-size'] = '384px 144px'; div.style['background-size'] = '384px 144px';
div.style['background-position-x'] = -(this.symbol.index % 16) * 24 + 'px'; div.style['background-position-x'] = -(this.symbol.index % 16) * 24 + 'px';
div.style['background-position-y'] = -Math.floor(this.symbol.index / 16) * 24 + 'px'; div.style['background-position-y'] = -Math.floor(this.symbol.index / 16) * 24 + 'px';
@ -63,7 +63,7 @@ AprsMarker.prototype.onAdd = function() {
var overlay = this.overlay = document.createElement('div'); var overlay = this.overlay = document.createElement('div');
overlay.style.width = '24px'; overlay.style.width = '24px';
overlay.style.height = '24px'; overlay.style.height = '24px';
overlay.style.background = 'url(/aprs-symbols/aprs-symbols-24-2@2x.png)'; overlay.style.background = 'url(aprs-symbols/aprs-symbols-24-2@2x.png)';
overlay.style['background-size'] = '384px 144px'; overlay.style['background-size'] = '384px 144px';
overlay.style.display = 'none'; overlay.style.display = 'none';

View File

@ -18,8 +18,10 @@
var expectedLocator; var expectedLocator;
if (query.locator) expectedLocator = query.locator; if (query.locator) expectedLocator = query.locator;
var ws_url = protocol + "://" + (window.location.origin.split("://")[1]) + "/ws/"; var base = protocol + "://" + (window.location.href.split("://")[1]);
if (!("WebSocket" in window)) return; base = base.replace(/\/map$/, '');
if (!base.endsWith('/')) base += '/';
var ws_url = base + "ws/"; //guess automatically -> now default behaviour
var map; var map;
var markers = {}; var markers = {};
@ -216,11 +218,11 @@
}, },
zoom: 5 zoom: 5
}); });
$.getScript("/static/lib/nite-overlay.js").done(function(){ $.getScript("static/lib/nite-overlay.js").done(function(){
nite.init(map); nite.init(map);
setInterval(function() { nite.refresh() }, 10000); // every 10s setInterval(function() { nite.refresh() }, 10000); // every 10s
}); });
$.getScript('/static/lib/AprsMarker.js').done(function(){ $.getScript('static/lib/AprsMarker.js').done(function(){
processUpdates(updateQueue); processUpdates(updateQueue);
updateQueue = []; updateQueue = [];
}); });

View File

@ -1532,7 +1532,9 @@ function open_websocket() {
protocol = 'wss'; protocol = 'wss';
} }
var ws_url = protocol + "://" + (window.location.origin.split("://")[1]) + "/ws/"; //guess automatically -> now default behaviour var base = protocol + "://" + (window.location.href.split("://")[1]);
if (!base.endsWith('/')) base += '/';
var ws_url = base + "ws/"; //guess automatically -> now default behaviour
if (!("WebSocket" in window)) if (!("WebSocket" in window))
divlog("Your browser does not support WebSocket, which is required for WebRX to run. Please upgrade to a HTML5 compatible browser."); divlog("Your browser does not support WebSocket, which is required for WebRX to run. Please upgrade to a HTML5 compatible browser.");
ws = new WebSocket(ws_url); ws = new WebSocket(ws_url);