summaryrefslogtreecommitdiffstats
path: root/deluge/ui/web/js/ext-extensions-debug.js
diff options
context:
space:
mode:
authorDamien Churchill <damoc@gmail.com>2009-09-14 16:32:23 +0000
committerDamien Churchill <damoc@gmail.com>2009-09-14 16:32:23 +0000
commit45840727e987279de875e903a859821d69463c7e (patch)
tree2fd6c4e1daeb06869edf93f81a692f0bf6afbb3e /deluge/ui/web/js/ext-extensions-debug.js
parent137be4c8f1821527aadac13c9e461313f6eb3cf4 (diff)
downloaddeluge-45840727e987279de875e903a859821d69463c7e.tar.gz
deluge-45840727e987279de875e903a859821d69463c7e.tar.bz2
deluge-45840727e987279de875e903a859821d69463c7e.zip
add a js loader class, taken from http://www.extjs.com/forum/showthread.php?p=272104
Diffstat (limited to 'deluge/ui/web/js/ext-extensions-debug.js')
-rw-r--r--deluge/ui/web/js/ext-extensions-debug.js48
1 files changed, 47 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..3050ed683 100644
--- a/deluge/ui/web/js/ext-extensions-debug.js
+++ b/deluge/ui/web/js/ext-extensions-debug.js
@@ -993,4 +993,50 @@ 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
+ };
+
+ Ext.Ajax.request({
+ url: options.url,
+ params: options.params,
+ scriptIndex: Ext.ux.JSLoader.index,
+ success: function(response, options) {
+ var script = Ext.ux.JSLoader.scripts[options.scriptIndex];
+ try {
+ script.jsLoadObj = Ext.decode(response.responseText);
+ Ext.applyIf(script.jsLoadObj,{jsLoad: function(){return Ext.ComponentMgr.create(script.jsLoadObj);}});
+ var comp = script.jsLoadObj.jsLoad();
+ if (comp.remoteInit){
+ comp.remoteInit();
+ }
+ } catch(e) {
+ script.success = false;
+ script.onError(script.options, e);
+ }
+ if (script.success) script.onLoad(comp,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