From 6322e245140d5011bafa0210b6371c4d44b470f7 Mon Sep 17 00:00:00 2001 From: miker Date: Sat, 28 Nov 2009 23:15:21 +0000 Subject: [PATCH] defer turning chunks of xml or marc-breaker into actual records until next() is called git-svn-id: svn://svn.open-ils.org/ILS/trunk@15036 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/js/dojo/MARC/Batch.js | 47 +++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/Open-ILS/web/js/dojo/MARC/Batch.js b/Open-ILS/web/js/dojo/MARC/Batch.js index 83027a58ed..88f0c241fd 100644 --- a/Open-ILS/web/js/dojo/MARC/Batch.js +++ b/Open-ILS/web/js/dojo/MARC/Batch.js @@ -24,13 +24,28 @@ if(!dojo._hasResource["MARC.Batch"]) { dojo.declare('MARC.Batch', null, { constructor : function(kwargs) { - this.current_record = 0; + this.ready = false; this.records = []; - this.type = kwargs.type || 'xml'; this.source = kwargs.source; + this.current_record = 0; - if (kwargs.url) this.fetchURL( kwargs.url ); - this.parse(); + if (this.source) this.ready = true; + if (!this.ready && kwargs.url) this.fetchURL( kwargs.url ); + + if (this.ready) this.parse(); + }, + + parse : function () { + if (dojo.isObject( this.source )) { // assume an xml collection document + this.source = dojo.query('record', this.source); + this.type = 'xml'; + } else if (this.source.match(/^\s*