create a simple html escape method and escape the fields in the details tab

This commit is contained in:
Damien Churchill 2009-10-27 10:26:59 +00:00
commit de82302c67
2 changed files with 88 additions and 82 deletions

View file

@ -33,56 +33,57 @@ Copyright:
*/ */
Ext.deluge.details.DetailsTab = Ext.extend(Ext.Panel, { Ext.deluge.details.DetailsTab = Ext.extend(Ext.Panel, {
title: _('Details'), title: _('Details'),
bodyStyle: 'padding 5px', bodyStyle: 'padding 5px',
onRender: function(ct, position) { onRender: function(ct, position) {
Ext.deluge.details.DetailsTab.superclass.onRender.call(this, ct, position); Ext.deluge.details.DetailsTab.superclass.onRender.call(this, ct, position);
this.load({ this.load({
url: '/render/tab_details.html', url: '/render/tab_details.html',
text: _('Loading') + '...' text: _('Loading') + '...'
}); });
this.body.setStyle('padding', '5px'); this.body.setStyle('padding', '5px');
this.getUpdater().on('update', this.onPanelUpdate, this); this.getUpdater().on('update', this.onPanelUpdate, this);
}, },
clear: function() { clear: function() {
if (!this.fields) return; if (!this.fields) return;
for (var k in this.fields) { for (var k in this.fields) {
this.fields[k].innerHTML = ''; this.fields[k].innerHTML = '';
}
},
update: function(torrentId) {
Deluge.Client.core.get_torrent_status(torrentId, Deluge.Keys.Details, {
success: this.onRequestComplete,
scope: this,
torrentId: torrentId
});
},
onPanelUpdate: function(el, response) {
this.fields = {};
Ext.each(Ext.query('dd', this.body.dom), function(field) {
this.fields[field.className] = field;
}, this);
},
onRequestComplete: function(torrent, options) {
var data = {
torrent_name: torrent.name,
hash: options.torrentId,
path: torrent.save_path,
size: fsize(torrent.total_size),
files: torrent.num_files,
status: torrent.tracker_status,
tracker: torrent.tracker,
comment: torrent.comment
};
for (var field in this.fields) {
this.fields[field].innerHTML = data[field];
}
} }
},
update: function(torrentId) {
Deluge.Client.core.get_torrent_status(torrentId, Deluge.Keys.Details, {
success: this.onRequestComplete,
scope: this,
torrentId: torrentId
});
},
onPanelUpdate: function(el, response) {
this.fields = {};
Ext.each(Ext.query('dd', this.body.dom), function(field) {
this.fields[field.className] = field;
}, this);
},
onRequestComplete: function(torrent, options) {
var data = {
torrent_name: torrent.name,
hash: options.torrentId,
path: torrent.save_path,
size: fsize(torrent.total_size),
files: torrent.num_files,
status: torrent.tracker_status,
tracker: torrent.tracker,
comment: torrent.comment
};
for (var field in this.fields) {
//this.fields[field].innerHTML = Ext.escapeHTML(data[field]);
this.fields[field].innerHTML = data[field];
}
}
}); });
Deluge.Details.add(new Ext.deluge.details.DetailsTab()); Deluge.Details.add(new Ext.deluge.details.DetailsTab());

View file

@ -38,39 +38,44 @@ Ext.namespace('Ext.deluge');
Ext.state.Manager.setProvider(new Ext.state.CookieProvider()); Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
(function() { (function() {
/* Add some helper functions to Ext */ /* Add some helper functions to Ext */
Ext.apply(Function.prototype, { Ext.apply(Function.prototype, {
bind: function(scope) { bind: function(scope) {
var self = this; var self = this;
return function() { return function() {
return self.apply(scope, arguments); return self.apply(scope, arguments);
} }
} }
}); });
Ext.apply(Ext, { Ext.apply(Ext, {
isObjectEmpty: function(obj) { escapeHTML: function(text) {
for(var i in obj) { return false; } text = String(text);
return true; return text.replace('&', '&');
}, },
keys: function(obj) { isObjectEmpty: function(obj) {
var keys = []; for(var i in obj) { return false; }
for (i in obj) if (obj.hasOwnProperty(i)) return true;
{ },
keys.push(i);
}
return keys;
},
splat: function(obj) { keys: function(obj) {
var type = Ext.type(obj); var keys = [];
return (type) ? ((type != 'array') ? [obj] : obj) : []; for (i in obj) if (obj.hasOwnProperty(i))
} {
}); keys.push(i);
Ext.getKeys = Ext.keys; }
return keys;
},
Ext.BLANK_IMAGE_URL = '/images/s.gif'; splat: function(obj) {
var type = Ext.type(obj);
return (type) ? ((type != 'array') ? [obj] : obj) : [];
}
});
Ext.getKeys = Ext.keys;
Ext.BLANK_IMAGE_URL = '/images/s.gif';
})(); })();
(function() { (function() {