~dylanmccall/harvest/gsoc-client-stuff

« back to all changes in this revision

Viewing changes to harvest/media/js/harvest.js

  • Committer: Dylan McCall
  • Date: 2010-07-08 17:57:20 UTC
  • Revision ID: dylanmccall@gmail.com-20100708175720-f4shj8xnou5jxw9x
Fixed bug where future_query was not properly merged with current_query in harvest.js.

Show diffs side-by-side

added added

removed removed

Lines of Context:
285
285
                /* Perform bits of setup with a new list of sourcepackages */
286
286
                var sourcepkgs = this.results_pane.find('li.sourcepackage');
287
287
                
288
 
                /* update current_query to match current set of results */
289
 
                if ( this.future_query ) {
290
 
                        this.current_query = this.future_query; /* TODO: make this better */
291
 
                } else {
292
 
                        this.current_query = {};
293
 
                }
294
 
                this.future_query = {};
295
 
                
296
288
                this.expanded_pkgs = Array();
297
289
                
298
290
                sourcepkgs.each(function () {
370
362
        }
371
363
        
372
364
        
373
 
        this.load_results = function (load_query) {
374
 
                /* Begins loading results for this.future_query */
 
365
        this.load_results = function () {
 
366
                /* Begins loading results for future_query */
375
367
                
376
 
                load_query = $.extend({}, this.current_query, load_query);
 
368
                var load_query = $.extend({}, this.current_query, this.future_query);
377
369
                
378
370
                if ( this.running_xhr != null ) {
379
371
                        this.running_xhr.abort();
385
377
                                
386
378
                                /* display the (plain html) results we have receieved */
387
379
                                results.results_pane.html(data);
 
380
                                
 
381
                                results.current_query = load_query;
 
382
                                results.future_query = {};
 
383
                                
388
384
                                results.setup_results_pkgs();
389
385
                                
390
386
                                /* display statistics in the footer */
399
395
        }
400
396
        
401
397
        
402
 
        this.reset_timer = function (future_query) {
403
 
                /* starts, or restarts, the query countdown timer.
404
 
                   The next query will be run in 1.5 seconds. */
 
398
        this.reset_timer = function () {
 
399
                /* Sets the query countdown timer for 1.5s.
 
400
                   When the timer ends, we load the results for future_query. */
405
401
                
406
402
                this.stop_timer();
407
403
                
408
404
                this.query_countdown = setTimeout(
409
405
                        function (results) {
410
 
                                results.load_results(future_query);
 
406
                                results.load_results();
411
407
                        }, 1500, this);
412
408
        }
413
409
        
420
416
        
421
417
        
422
418
        this.post_query = function (key, value) {
 
419
                /* Adds the given key/value pair to future_query. If it is
 
420
                   necessary, a timer is started to get the results for
 
421
                   future_query. */
 
422
                
423
423
                if ( this.current_query[key] == value ) {
424
424
                        /* the user has reverted a change; value is the same as before */
425
425
                        delete this.future_query[key];
430
430
                        }
431
431
                } else {
432
432
                        this.future_query[key] = value;
433
 
                        /* start the timer from 0, waiting to apply the new query */
434
 
                        this.reset_timer(this.future_query);
 
433
                        /* start the timer from 0, waiting to apply the new future_query */
 
434
                        this.reset_timer();
435
435
                }
436
436
        }
437
437
        
440
440
        /* Object initialization */
441
441
        
442
442
        this.setup_results_pkgs();
 
443
        /* TODO: initialize this.current_query based on current state of results and filters */
443
444
}
444
445
 
445
446