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
parent 81949449ae
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, {
title: _('Details'),
bodyStyle: 'padding 5px',
onRender: function(ct, position) {
Ext.deluge.details.DetailsTab.superclass.onRender.call(this, ct, position);
this.load({
url: '/render/tab_details.html',
text: _('Loading') + '...'
});
this.body.setStyle('padding', '5px');
this.getUpdater().on('update', this.onPanelUpdate, this);
},
clear: function() {
if (!this.fields) return;
for (var k in this.fields) {
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];
}
title: _('Details'),
bodyStyle: 'padding 5px',
onRender: function(ct, position) {
Ext.deluge.details.DetailsTab.superclass.onRender.call(this, ct, position);
this.load({
url: '/render/tab_details.html',
text: _('Loading') + '...'
});
this.body.setStyle('padding', '5px');
this.getUpdater().on('update', this.onPanelUpdate, this);
},
clear: function() {
if (!this.fields) return;
for (var k in this.fields) {
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 = Ext.escapeHTML(data[field]);
this.fields[field].innerHTML = data[field];
}
}
});
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());
(function() {
/* Add some helper functions to Ext */
Ext.apply(Function.prototype, {
bind: function(scope) {
var self = this;
return function() {
return self.apply(scope, arguments);
}
}
});
/* Add some helper functions to Ext */
Ext.apply(Function.prototype, {
bind: function(scope) {
var self = this;
return function() {
return self.apply(scope, arguments);
}
}
});
Ext.apply(Ext, {
escapeHTML: function(text) {
text = String(text);
return text.replace('&', '&');
},
Ext.apply(Ext, {
isObjectEmpty: function(obj) {
for(var i in obj) { return false; }
return true;
},
keys: function(obj) {
var keys = [];
for (i in obj) if (obj.hasOwnProperty(i))
{
keys.push(i);
}
return keys;
},
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';
isObjectEmpty: function(obj) {
for(var i in obj) { return false; }
return true;
},
keys: function(obj) {
var keys = [];
for (i in obj) if (obj.hasOwnProperty(i))
{
keys.push(i);
}
return keys;
},
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() {