// Used by the Screen::Report::render method var EPrints_Screen_Report_Loader = Class.create({ has_problems: 0, count: 0, runs: 0, progress: null, ids: Array(), step: 20, prefix: '', onProblems: function() {}, onFinish: function() {}, url: "", parameters: "", container: null, // to show a pretty progress bar (% compliance): total_dataobjs: 0, total_noncompliant: 0, initialize: function(opts) { if( opts.ids ) this.ids = opts.ids; if( opts.step ) this.step = opts.step; if( opts.prefix ) this.prefix = opts.prefix; if( opts.onFinish ) this.onFinish = opts.onFinish; if( opts.onProblems ) this.onProblems = opts.onProblems; if( opts.url ) this.url = opts.url; if( opts.parameters ) this.parameters = opts.parameters; if( opts.container_id ) this.container = $( opts.container_id ); // should fail if container doesn't exist... }, execute: function() { // progress-bar this.container.insert( new Element( 'div', { 'class': 'ep_report_progress_bar', 'id': this.prefix + "_progress_bar" } ) ); var current_grouping = null; // might not be set in the returned value but that's allowed/OK var dataobjs = {}; for(var i = 0; i < this.ids.length; i+=this.step) { // arguments for Ajax query AND creates the HTML placeholders
's (that will receive the content of the Ajax query...) var args = '&ajax='+this.prefix; for(var j = 0; j < this.step && i+j < this.ids.length; j++) { args += '&' + this.prefix + '=' + this.ids[i+j]; this.container.insert( new Element( 'div', { 'class': 'ep_report_row', 'id': this.prefix + '_' + this.ids[i+j] } ), { 'position': 'after' } ); } new Ajax.Request( this.url, { method: 'get', parameters: this.parameters + args, onSuccess: (function(transport) { var json = transport.responseText.evalJSON(); var data = json.data; if( data == null ) data = new Array(); for( var i=0; i