Skip to content

Commit

Permalink
[#1506][editresources][m]: Throttle AJAX requests & escape URIs.
Browse files Browse the repository at this point in the history
  • Loading branch information
teajaymars committed Feb 24, 2012
1 parent 0cb5a47 commit f4dd3b9
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions ckan/public/scripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -811,13 +811,20 @@ CKAN.View.Resource = Backbone.View.extend({
*/
updateIcon: function() {
var self = this;
// AJAX to server API
$.getJSON('/api/2/util/format_icon?format='+this.formatBox.val(), function(data) {
if (data.icon) {
self.li.find('.js-resource-icon').attr('src',data.icon);
self.table.find('.js-resource-icon').attr('src',data.icon);
}
});
if (self.updateIconTimer) {
clearTimeout(self.updateIconTimer);
}
self.updateIconTimer = setTimeout(function() {
// AJAX to server API
$.getJSON('/api/2/util/format_icon?format='+encodeURIComponent(self.formatBox.val()), function(data) {
if (data && data.icon && data.format==self.formatBox.val()) {
self.li.find('.js-resource-icon').attr('src',data.icon);
self.table.find('.js-resource-icon').attr('src',data.icon);
}
});
delete self.updateIconTimer;
},
100);
},
/*
* Closes all other panels on the right and opens my editor panel.
Expand Down

0 comments on commit f4dd3b9

Please sign in to comment.