diff options
author | Jo-Philipp Wich <jo@mein.io> | 2019-04-01 16:36:30 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2019-07-07 15:36:24 +0200 |
commit | 3bc73a7d0533902ca762c0fc39a66de7a9878a94 (patch) | |
tree | 256fefa27dc1b0370519e27a3370ba065d07dc2c /modules | |
parent | b839ee87f2df52d5445bd668352adbca6d2c906b (diff) |
luci-base: luci.js: catch base class loading errors
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules')
-rw-r--r-- | modules/luci-base/htdocs/luci-static/resources/luci.js | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/modules/luci-base/htdocs/luci-static/resources/luci.js b/modules/luci-base/htdocs/luci-static/resources/luci.js index 767d013d7..61c3e8274 100644 --- a/modules/luci-base/htdocs/luci-static/resources/luci.js +++ b/modules/luci-base/htdocs/luci-static/resources/luci.js @@ -431,6 +431,14 @@ LuCI = Class.extend({ __name__: 'LuCI', __init__: function(env) { + + document.querySelectorAll('script[src$="/luci.js"]').forEach(function(s) { + env.base_url = s.getAttribute('src').replace(/\/luci\.js$/, ''); + }); + + if (env.base_url == null) + this.error('InternalError', 'Cannot find url of luci.js'); + Object.assign(this.env, env); document.addEventListener('poll-start', function(ev) { @@ -453,9 +461,7 @@ domReady, this.require('ui'), this.require('form') - ]).then(this.setupDOM.bind(this)).catch(function(error) { - alert('LuCI class loading error:\n' + error); - }); + ]).then(this.setupDOM.bind(this)).catch(this.error); originalCBIInit = window.cbi_init; window.cbi_init = function() {}; @@ -527,15 +533,7 @@ return classes[name]; } - document.querySelectorAll('script[src$="/luci.js"]').forEach(function(s) { - url = '%s/%s.js'.format( - s.getAttribute('src').replace(/\/luci\.js$/, ''), - name.replace(/\./g, '/')); - }); - - if (url == null) - L.error('InternalError', 'Cannot find url of luci.js'); - + url = '%s/%s.js'.format(L.env.base_url, name.replace(/\./g, '/')); from = [ name ].concat(from); var compileClass = function(res) { |