summaryrefslogtreecommitdiffstats
path: root/pyload/web/app
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-12-15 14:00:42 +0100
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-12-15 14:00:42 +0100
commit8fbde7a43b4f838df0379fdb4acd791713b639b7 (patch)
treebb7e78afc6a34823e078ab64c6965321c6866e85 /pyload/web/app
parentadded new file states (diff)
downloadpyload-8fbde7a43b4f838df0379fdb4acd791713b639b7.tar.xz
more options to get webUI through proxy working
Diffstat (limited to 'pyload/web/app')
-rw-r--r--pyload/web/app/index.html8
-rw-r--r--pyload/web/app/scripts/app.js7
-rw-r--r--pyload/web/app/scripts/views/headerView.js36
3 files changed, 30 insertions, 21 deletions
diff --git a/pyload/web/app/index.html b/pyload/web/app/index.html
index 98e1bf233..08366f665 100644
--- a/pyload/web/app/index.html
+++ b/pyload/web/app/index.html
@@ -22,7 +22,7 @@
// Use value set by templateEngine or default val
function configValue(string, defaultValue) {
- if (string.indexOf('{{') > -1)
+ if (string.indexOf('{{') > -1 && string !== 'None' && string !== '')
return defaultValue;
return string;
}
@@ -38,10 +38,10 @@
window.hostProtocol = window.location.protocol + '//';
window.hostAddress = window.location.hostname;
window.hostPort = configValue('{{web}}', '8001');
- // TODO
- window.pathPrefix = '/';
+ window.external = configValue('{{external}}', 'true').toLowerCase();
+ window.pathPrefix = configValue('{{prefix}}', '');
window.wsAddress = configValue('{{ws}}', 'ws://%s:7227');
- window.setup = configValue('{{setup}}', 'false');
+ window.setup = configValue('{{setup}}', 'false').toLowerCase();
require(['config'], function(Config) {
require(['default'], function(App) {
diff --git a/pyload/web/app/scripts/app.js b/pyload/web/app/scripts/app.js
index af5c50b14..68a20666d 100644
--- a/pyload/web/app/scripts/app.js
+++ b/pyload/web/app/scripts/app.js
@@ -41,8 +41,11 @@ define([
};
App.apiUrl = function(path) {
- var url = window.hostProtocol + window.hostAddress + ':' + window.hostPort + window.pathPrefix + path;
- return url;
+ var prefix = window.pathPrefix;
+ if (window.external !== 'false')
+ prefix = window.hostProtocol + window.hostAddress + ':' + window.hostPort + prefix;
+
+ return prefix + '/' + path;
};
// Add Global Helper functions
diff --git a/pyload/web/app/scripts/views/headerView.js b/pyload/web/app/scripts/views/headerView.js
index 49298d450..7d892bf01 100644
--- a/pyload/web/app/scripts/views/headerView.js
+++ b/pyload/web/app/scripts/views/headerView.js
@@ -62,21 +62,27 @@ define(['jquery', 'underscore', 'backbone', 'app', 'models/ServerStatus', 'colle
});
// TODO: button to start stop refresh
- var ws = App.openWebSocket('/async');
- ws.onopen = function() {
- ws.send(JSON.stringify('start'));
- };
- // TODO compare with polling
- ws.onmessage = _.bind(this.onData, this);
- ws.onerror = function(error) {
- console.log(error);
- alert('WebSocket error' + error);
- };
- ws.onclose = function() {
- alert('WebSocket was closed');
- };
-
- this.ws = ws;
+ // TODO: catch ws errors / switch into ws less mode
+ try {
+ var ws = App.openWebSocket('/async');
+ ws.onopen = function() {
+ ws.send(JSON.stringify('start'));
+ };
+ // TODO compare with polling
+ ws.onmessage = _.bind(this.onData, this);
+ ws.onerror = function(error) {
+ console.log(error);
+ alert('WebSocket error ' + error);
+ };
+ ws.onclose = function() {
+ alert('WebSocket was closed');
+ };
+
+ this.ws = ws;
+
+ } catch (e) {
+ alert('Could not open WebSocket: ' + e);
+ }
},
gotoDashboard: function() {