From fd70fb824fd606ee8b2d1d2870f89e5c117f9e60 Mon Sep 17 00:00:00 2001 From: Mike Rylander Date: Wed, 14 Sep 2011 15:43:55 -0400 Subject: [PATCH] Make sure we only render the most recent request to the canvas, so a laggy network does not cause double rendering or stale display Signed-off-by: Mike Rylander --- Open-ILS/web/js/dojo/openils/BibTemplate.js | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/Open-ILS/web/js/dojo/openils/BibTemplate.js b/Open-ILS/web/js/dojo/openils/BibTemplate.js index 5941388ec6..8c81447c0a 100644 --- a/Open-ILS/web/js/dojo/openils/BibTemplate.js +++ b/Open-ILS/web/js/dojo/openils/BibTemplate.js @@ -242,6 +242,7 @@ if(!dojo._hasResource["openils.BibTemplate"]) { constructor : function(kwargs) { this.place = kwargs.place; + this.empty = kwargs.empty; this.root = kwargs.root; this.xml = kwargs.xml; this.feed_uri = kwargs.uri; @@ -253,19 +254,30 @@ if(!dojo._hasResource["openils.BibTemplate"]) { this.relativePosition = 'last'; if (this.reverseSort) this.relativePosition = 'first'; + this.horizon = new Date().getTime(); + var horiz = parseInt(this.root.getAttribute('horizon')); + + if (isNaN(horiz) || this.horizon >= horiz) + this.root.setAttribute('horizon', this.horizon); + if (this.nodelay) this.render(); }, render : function () { var me = this; + var process_feed = function (xmldoc) { - dojo.query( me.item_query, xmldoc ).forEach( - function (item) { - var template = me.root.cloneNode(true); - dojo.place( template, me.place, me.relativePosition ); - new openils.BibTemplate({ delay : false, xml : item, root : template }); - } - ); + if (parseInt(me.horizon) >= parseInt(me.root.getAttribute('horizon'))) { + if (me.empty == true) dojo.empty(me.place); + me.root.setAttribute('horizon', this.horizon); + dojo.query( me.item_query, xmldoc ).forEach( + function (item) { + var template = me.root.cloneNode(true); + dojo.place( template, me.place, me.relativePosition ); + new openils.BibTemplate({ delay : false, xml : item, root : template }); + } + ); + } }; if (this.xml) { -- 2.11.0