diff options
author | Damien Churchill <damoc@gmail.com> | 2009-09-16 09:02:26 +0000 |
---|---|---|
committer | Damien Churchill <damoc@gmail.com> | 2009-09-16 09:02:26 +0000 |
commit | e4fb98bd024ef0144bab9a9a3bd80d16a48dd503 (patch) | |
tree | e4bb0ed520786aa98d3f95c08da5268edb073e67 /deluge/ui/web/js/ext-extensions-debug.js | |
parent | b2390b8ff4ce8d21987c253b27c4547ccb4c0da5 (diff) | |
download | deluge-e4fb98bd024ef0144bab9a9a3bd80d16a48dd503.tar.gz deluge-e4fb98bd024ef0144bab9a9a3bd80d16a48dd503.tar.bz2 deluge-e4fb98bd024ef0144bab9a9a3bd80d16a48dd503.zip |
add a working javascript loader
implement the core code for disabling/enabling plugins on the fly
Diffstat (limited to 'deluge/ui/web/js/ext-extensions-debug.js')
-rw-r--r-- | deluge/ui/web/js/ext-extensions-debug.js | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/deluge/ui/web/js/ext-extensions-debug.js b/deluge/ui/web/js/ext-extensions-debug.js index 1270308f2..b7df07ecd 100644 --- a/deluge/ui/web/js/ext-extensions-debug.js +++ b/deluge/ui/web/js/ext-extensions-debug.js @@ -993,4 +993,42 @@ Ext.override(Ext.form.TriggerField, { actionMode: 'wrap', onShow: Ext.form.TriggerField.superclass.onShow, onHide: Ext.form.TriggerField.superclass.onHide -});
\ No newline at end of file +}); + +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) { + // throw(e); + window.alert('Error loading script:\n\n' + options.url + '\n\nstatus: ' + e); +}
\ No newline at end of file |