Make sure we only render the most recent request to the canvas, so a laggy network...
authorMike Rylander <mrylander@gmail.com>
Wed, 14 Sep 2011 19:43:55 +0000 (15:43 -0400)
committerMike Rylander <mrylander@gmail.com>
Wed, 14 Sep 2011 19:43:55 +0000 (15:43 -0400)
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/web/js/dojo/openils/BibTemplate.js

index 5941388..8c81447 100644 (file)
@@ -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) {