diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-10 21:38:38 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-10 21:38:38 +0000 |
commit | 2e2851dc13d73352530dd4495c7e05603b2e520d (patch) | |
tree | 622b9cd8e5d32091c9aa9e4937b533975a40356c /deluge/ui/web/js/extjs/ext-extensions/JSLoader.js | |
parent | Initial commit. (diff) | |
download | deluge-upstream/2.1.2_dev0+20240219.tar.xz deluge-upstream/2.1.2_dev0+20240219.zip |
Adding upstream version 2.1.2~dev0+20240219.upstream/2.1.2_dev0+20240219upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'deluge/ui/web/js/extjs/ext-extensions/JSLoader.js')
-rw-r--r-- | deluge/ui/web/js/extjs/ext-extensions/JSLoader.js | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/deluge/ui/web/js/extjs/ext-extensions/JSLoader.js b/deluge/ui/web/js/extjs/ext-extensions/JSLoader.js new file mode 100644 index 0000000..e4691b0 --- /dev/null +++ b/deluge/ui/web/js/extjs/ext-extensions/JSLoader.js @@ -0,0 +1,40 @@ +Ext.ux.JSLoader = function (options) { + Ext.ux.JSLoader.scripts[++Ext.ux.JSLoader.index] = { + url: options.url, + success: true, + jsLoadObj: null, + options: options, + onLoad: options.onLoad || Ext.emptyFn, + onError: options.onError || Ext.ux.JSLoader.stdError, + scope: options.scope || this, + }; + + Ext.Ajax.request({ + url: options.url, + scriptIndex: Ext.ux.JSLoader.index, + success: function (response, options) { + var script = Ext.ux.JSLoader.scripts[options.scriptIndex]; + try { + eval(response.responseText); + } catch (e) { + script.success = false; + script.onError(script.options, e); + } + if (script.success) { + script.onLoad.call(script.scope, script.options); + } + }, + failure: function (response, options) { + var script = Ext.ux.JSLoader.scripts[options.scriptIndex]; + script.success = false; + script.onError(script.options, response.status); + }, + }); +}; +Ext.ux.JSLoader.index = 0; +Ext.ux.JSLoader.scripts = []; +Ext.ux.JSLoader.stdError = function (options, e) { + window.alert( + 'Error loading script:\n\n' + options.url + '\n\nstatus: ' + e + ); +}; |