polling_request 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/src/polling_request.coffee +3 -0
 - data/src/polling_request.js +9 -3
 - metadata +1 -1
 
    
        data/src/polling_request.coffee
    CHANGED
    
    
    
        data/src/polling_request.js
    CHANGED
    
    | 
         @@ -4,7 +4,7 @@ 
     | 
|
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
              PollingRequest = (function() {
         
     | 
| 
       6 
6 
     | 
    
         
             
                function PollingRequest(options) {
         
     | 
| 
       7 
     | 
    
         
            -
                  var _base, _base1, _base2, _base3;
         
     | 
| 
      
 7 
     | 
    
         
            +
                  var _base, _base1, _base2, _base3, _base4;
         
     | 
| 
       8 
8 
     | 
    
         
             
                  this.options = options;
         
     | 
| 
       9 
9 
     | 
    
         
             
                  this.progress = 0;
         
     | 
| 
       10 
10 
     | 
    
         
             
                  this.status = 'pending';
         
     | 
| 
         @@ -12,6 +12,7 @@ 
     | 
|
| 
       12 
12 
     | 
    
         
             
                  (_base1 = this.options).success || (_base1.success = function() {});
         
     | 
| 
       13 
13 
     | 
    
         
             
                  (_base2 = this.options).progress || (_base2.progress = function() {});
         
     | 
| 
       14 
14 
     | 
    
         
             
                  (_base3 = this.options).error || (_base3.error = function() {});
         
     | 
| 
      
 15 
     | 
    
         
            +
                  (_base4 = this.options).stopped || (_base4.stopped = function() {});
         
     | 
| 
       15 
16 
     | 
    
         
             
                }
         
     | 
| 
       16 
17 
     | 
    
         | 
| 
       17 
18 
     | 
    
         
             
                PollingRequest.prototype.start = function() {
         
     | 
| 
         @@ -27,7 +28,8 @@ 
     | 
|
| 
       27 
28 
     | 
    
         
             
                PollingRequest.prototype.stop = function() {
         
     | 
| 
       28 
29 
     | 
    
         
             
                  this.status = 'stopped';
         
     | 
| 
       29 
30 
     | 
    
         
             
                  clearInterval(this.timer);
         
     | 
| 
       30 
     | 
    
         
            -
                   
     | 
| 
      
 31 
     | 
    
         
            +
                  this.timer = null;
         
     | 
| 
      
 32 
     | 
    
         
            +
                  return this.options.stopped();
         
     | 
| 
       31 
33 
     | 
    
         
             
                };
         
     | 
| 
       32 
34 
     | 
    
         | 
| 
       33 
35 
     | 
    
         
             
                PollingRequest.prototype.status = function() {
         
     | 
| 
         @@ -42,6 +44,10 @@ 
     | 
|
| 
       42 
44 
     | 
    
         
             
                  var _this = this;
         
     | 
| 
       43 
45 
     | 
    
         
             
                  return $.ajax({
         
     | 
| 
       44 
46 
     | 
    
         
             
                    url: this.options.url,
         
     | 
| 
      
 47 
     | 
    
         
            +
                    cached: false,
         
     | 
| 
      
 48 
     | 
    
         
            +
                    accepts: {
         
     | 
| 
      
 49 
     | 
    
         
            +
                      json: 'application/json'
         
     | 
| 
      
 50 
     | 
    
         
            +
                    },
         
     | 
| 
       45 
51 
     | 
    
         
             
                    beforeSend: function(jqXHR, settings) {
         
     | 
| 
       46 
52 
     | 
    
         
             
                      return _this.status = 'running';
         
     | 
| 
       47 
53 
     | 
    
         
             
                    },
         
     | 
| 
         @@ -53,7 +59,7 @@ 
     | 
|
| 
       53 
59 
     | 
    
         
             
                      },
         
     | 
| 
       54 
60 
     | 
    
         
             
                      202: function(data, textStatus, jqXHR) {
         
     | 
| 
       55 
61 
     | 
    
         
             
                        _this.progress = data.progress || 0;
         
     | 
| 
       56 
     | 
    
         
            -
                        return _this.options.progress( 
     | 
| 
      
 62 
     | 
    
         
            +
                        return _this.options.progress(_this.progress);
         
     | 
| 
       57 
63 
     | 
    
         
             
                      }
         
     | 
| 
       58 
64 
     | 
    
         
             
                    },
         
     | 
| 
       59 
65 
     | 
    
         
             
                    error: function(jqXHR, textStatus, errorThrown) {
         
     |