implement the core...
Content-type: text/plain
Author: damoxc
Revision: 5756
Log:
add a working javascript loader
implement the core code for disabling/enabling plugins on the fly
Diff:
Modified: trunk/deluge/ui/web/js/Deluge.Preferences.js
===================================================================
--- trunk/deluge/ui/web/js/Deluge.Preferences.js 2009-09-16 08:42:39 UTC
(rev 5755)
+++ trunk/deluge/ui/web/js/Deluge.Preferences.js 2009-09-16 09:02:26 UTC
(rev 5756)
@@ -129,9 +129,22 @@
store.loadData([[name]], true);
page['bodyStyle'] = 'margin: 5px';
this.pages[name] = this.configPanel.add(page);
+ return this.pages[name];
},
/**
+ * Removes a preferences page from the window.
+ * @param {mixed} name
+ */
+ removePage: function(page) {
+ var name = page.title;
+ var store = this.categoriesGrid.getStore();
+ store.removeAt(store.find('name', name));
+ this.configPanel.remove(page);
+ delete this.pages[page.title];
+ },
+
+ /**
* Return the options manager for the preferences window.
* @returns {Deluge.OptionsManager} the options manager
*/
Modified: trunk/deluge/ui/web/js/Deluge.UI.js
===================================================================
--- trunk/deluge/ui/web/js/Deluge.UI.js 2009-09-16 08:42:39 UTC (rev 5755)
+++ trunk/deluge/ui/web/js/Deluge.UI.js 2009-09-16 09:02:26 UTC (rev 5756)
@@ -162,16 +162,28 @@
},
onGotPluginResources: function(resources) {
- var scripts = (Deluge.debug) ? resources['debug_scripts'] :
resources['scripts'];
+ var scripts = (Deluge.debug) ? resources.debug_scripts :
resources.scripts;
Ext.each(scripts, function(script) {
-
+ Ext.ux.JSLoader({
+ url: script,
+ onLoad: this.onPluginLoaded,
+ pluginName: resources.name
+ });
}, this);
},
onPluginDisabled: function(pluginName) {
- //alert('D: ' + pluginName);
+ Deluge.Plugins[pluginName].disable();
},
+ onPluginLoaded: function(options) {
+ // This could happen if the plugin has multiple scripts
+ if (!Deluge.Plugins[options.pluginName]) return;
+
+ // Enable the plugin
+ Deluge.Plugins[options.pluginName].enable();
+ },
+
/**
* @static
* Stop the Deluge UI polling the server and clear the interface.
Modified: trunk/deluge/ui/web/js/ext-extensions-debug.js
===================================================================
--- trunk/deluge/ui/web/js/ext-extensions-debug.js 2009-09-16 08:42:39 UTC
(rev 5755)
+++ trunk/deluge/ui/web/js/ext-extensions-debug.js 2009-09-16 09:02:26 UTC
(rev 5756)
@@ -993,4 +993,42 @@
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
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"deluge-commit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/deluge-commit?hl=en
-~----------~----~----~----~------~----~------~--~---