This file is indexed.

/usr/share/javascript/yui3/uploader-queue/uploader-queue.js is in libjs-yui3-full 3.5.1-1ubuntu3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
/*
YUI 3.5.1 (build 22)
Copyright 2012 Yahoo! Inc. All rights reserved.
Licensed under the BSD License.
http://yuilibrary.com/license/
*/
YUI.add('uploader-queue', function(Y) {


    /**
     * The class manages a queue of files that should be uploaded to the server.
     * It initializes the required number of uploads, tracks them as they progress,
     * and automatically advances to the next upload when a preceding one has completed.
     * @module uploader-queue
     */     

    var Lang = Y.Lang,
        Bind = Y.bind,
        Win = Y.config.win,
        queuedFiles,
        numberOfUploads,        
        currentUploadedByteValues,
        currentFiles,
        totalBytesUploaded,
        totalBytes;

    /**
     * This class manages a queue of files to be uploaded to the server.
     * @class Uploader.Queue
     * @extends Base
     * @constructor
     * @param {Object} config Configuration object
     */
    var UploaderQueue = function(o) {
        this.queuedFiles = [];
        this.numberOfUploads = 0;
        this.currentUploadedByteValues = {};
        this.currentFiles = {};
        this.totalBytesUploaded = 0;
        this.totalBytes = 0;      
  
        UploaderQueue.superclass.constructor.apply(this, arguments);
    };


    Y.extend(UploaderQueue, Y.Base, {

       /**
        * Stored value of the current queue state
        * @property _currentState
        * @type {String}
        * @protected
        * @default UploaderQueue.STOPPED
        */
        _currentState: UploaderQueue.STOPPED,

       /**
        * Construction logic executed during UploaderQueue instantiation.
        *
        * @method initializer
        * @protected
        */
        initializer : function (cfg) {

        },

       /**
        * Handles and retransmits upload start event.
        * 
        * @method _uploadStartHandler
        * @param event The event dispatched during the upload process.
        * @private
        */
        _uploadStartHandler : function (event) {
           var updatedEvent = event;
           updatedEvent.file = event.target;
           updatedEvent.originEvent = event;
           
           this.fire("uploadstart", updatedEvent);          
        },

       /**
        * Handles and retransmits upload error event.
        * 
        * @method _uploadErrorHandler
        * @param event The event dispatched during the upload process.
        * @private
        */
        _uploadErrorHandler : function (event) {
           var errorAction = this.get("errorAction");
           var updatedEvent = event;
           updatedEvent.file = event.target;
           updatedEvent.originEvent = event;

           this.numberOfUploads-=1;
           delete this.currentFiles[event.target.get("id")];
           
           event.target.cancelUpload();

           if (errorAction === UploaderQueue.STOP) {
             this.pauseUpload();
           }

           else if (errorAction === UploaderQueue.RESTART_ASAP) {
             this.queuedFiles.unshift(event.target);
             this._startNextFile();
           }
           else if (errorAction === UploaderQueue.RESTART_AFTER) {
            this.queuedFiles.push(event.target);
            this._startNextFile();
           }

           this.fire("uploaderror", updatedEvent);  
        },

       /**
        * Launches the upload of the next file in the queue.
        * 
        * @method _startNextFile
        * @private
        */
        _startNextFile : function () {
          if (this.queuedFiles.length > 0) {
            var currentFile = this.queuedFiles.shift(),
               fileId = currentFile.get("id"),
               parameters = this.get("perFileParameters"),
               fileParameters = parameters.hasOwnProperty(fileId) ? parameters[fileId] : parameters;

               this.currentUploadedByteValues[fileId] = 0;

               currentFile.on("uploadstart", this._uploadStartHandler, this);
               currentFile.on("uploadprogress", this._uploadProgressHandler, this);
               currentFile.on("uploadcomplete", this._uploadCompleteHandler, this);
               currentFile.on("uploaderror", this._uploadErrorHandler, this);

               currentFile.startUpload(this.get("uploadURL"), fileParameters, this.get("fileFieldName"));

               this._registerUpload(currentFile);
          }
        },

       /**
        * Register a new upload process.
        * 
        * @method _registerUpload
        * @private
        */
        _registerUpload : function (file) {
          this.numberOfUploads += 1;
          this.currentFiles[file.get("id")] = file;
        },

       /**
        * Unregisters a new upload process.
        * 
        * @method _unregisterUpload
        * @private
        */
        _unregisterUpload : function (file) {
          if (this.numberOfUploads > 0) {
            this.numberOfUploads -=1;
          }
          delete this.currentFiles[file.get("id")];
        },

       /**
        * Handles and retransmits upload complete event.
        * 
        * @method _uploadCompleteHandler
        * @param event The event dispatched during the upload process.
        * @private
        */
        _uploadCompleteHandler : function (event) {

           this._unregisterUpload(event.target);

           this.totalBytesUploaded += event.target.get("size");
           delete this.currentUploadedByteValues[event.target.get("id")];


           if (this.queuedFiles.length > 0 && this._currentState === UploaderQueue.UPLOADING) {
               this._startNextFile();
           }
           
           var updatedEvent = event;
           updatedEvent.file = event.target;
           updatedEvent.originEvent = event;

           var uploadedTotal = this.totalBytesUploaded;

           Y.each(this.currentUploadedByteValues, function (value) {
              uploadedTotal += value; 
           });
           
           var percentLoaded = Math.min(100, Math.round(10000*uploadedTotal/this.totalBytes) / 100); 
           
           this.fire("totaluploadprogress", {bytesLoaded: uploadedTotal, 
                                             bytesTotal: this.totalBytes,
                                             percentLoaded: percentLoaded});

           this.fire("uploadcomplete", updatedEvent);

           if (this.queuedFiles.length === 0 && this.numberOfUploads <= 0) {
               this.fire("alluploadscomplete");
               this._currentState = UploaderQueue.STOPPED;
           }


        },

       /**
        * Handles and retransmits upload progress event.
        * 
        * @method _uploadProgressHandler
        * @param event The event dispatched during the upload process.
        * @private
        */
        _uploadProgressHandler : function (event) {
          
          this.currentUploadedByteValues[event.target.get("id")] = event.bytesLoaded;
          
          var updatedEvent = event;
          updatedEvent.originEvent = event;
          updatedEvent.file = event.target;

          this.fire("uploadprogress", updatedEvent);
          
          var uploadedTotal = this.totalBytesUploaded;

          Y.each(this.currentUploadedByteValues, function (value) {
             uploadedTotal += value; 
          });
          
          var percentLoaded = Math.min(100, Math.round(10000*uploadedTotal/this.totalBytes) / 100);

          this.fire("totaluploadprogress", {bytesLoaded: uploadedTotal, 
                                            bytesTotal: this.totalBytes,
                                            percentLoaded: percentLoaded});
        },

       /**
        * Starts uploading the queued up file list.
        * 
        * @method startUpload
        */
        startUpload: function() {
           
           this.queuedFiles = this.get("fileList").slice(0);
           this.numberOfUploads = 0;
           this.currentUploadedByteValues = {};
           this.currentFiles = {};
           this.totalBytesUploaded = 0;
           
           this._currentState = UploaderQueue.UPLOADING;

           while (this.numberOfUploads < this.get("simUploads") && this.queuedFiles.length > 0) {
                this._startNextFile();
           }
        },

       /**
        * Pauses the upload process. The ongoing file uploads
        * will complete after this method is called, but no
        * new ones will be launched.
        * 
        * @method pauseUpload
        */
        pauseUpload: function () {
            this._currentState = UploaderQueue.STOPPED;
        },

       /**
        * Restarts a paused upload process.
        * 
        * @method restartUpload
        */
        restartUpload: function () {
            this._currentState = UploaderQueue.UPLOADING;
            while (this.numberOfUploads < this.get("simUploads")) {
               this._startNextFile();
            }
        },

       /**
        * If a particular file is stuck in an ongoing upload without
        * any progress events, this method allows to force its reupload
        * by cancelling its upload and immediately relaunching it.
        * 
        * @method forceReupload
        * @param file {Y.File} The file to force reupload on.
        */
        forceReupload : function (file) {
            var id = file.get("id");
            if (this.currentFiles.hasOwnProperty(id)) {
              file.cancelUpload();
              this._unregisterUpload(file);
              this.queuedFiles.unshift(file);
              this._startNextFile();
            }
        },

       /**
        * Add a new file to the top of the queue (the upload will be
        * launched as soon as the current number of uploading files
        * drops below the maximum permissible value).
        * 
        * @method addToQueueTop
        * @param file {Y.File} The file to add to the top of the queue.
        */
        addToQueueTop: function (file) {
            this.queuedFiles.unshift(file);
        },

       /**
        * Add a new file to the bottom of the queue (the upload will be
        * launched after all the other queued files are uploaded.)
        * 
        * @method addToQueueBottom
        * @param file {Y.File} The file to add to the bottom of the queue.
        */
        addToQueueBottom: function (file) {
            this.queuedFiles.push(file);
        },

       /**
        * Cancels a specific file's upload. If no argument is passed,
        * all ongoing uploads are cancelled and the upload process is
        * stopped.
        * 
        * @method cancelUpload
        * @param file {Y.File} An optional parameter - the file whose upload
        * should be cancelled.
        */
        cancelUpload: function (file) {

          if (file) {
            var id = file.get("id");
            if (this.currentFiles[id]) {
              this.currentFiles[id].cancelUpload();
              this._unregisterUpload(this.currentFiles[id]);
            }
            else {
              for (var i = 0, len = this.queuedFiles.length; i < len; i++) {
                if (this.queuedFiles[i].get("id") === id) {
                  this.queuedFiles.splice(i, 1);
                  break;
                }
              }
            }
          }
          else {
            for (var fid in this.currentFiles) {
              this.currentFiles[fid].cancelUpload();
              this._unregisterUpload(this.currentFiles[fid]);
            }

            this.currentUploadedByteValues = {};
            this.currentFiles = {};
            this.totalBytesUploaded = 0;
            this.fire("alluploadscancelled");
            this._currentState = UploaderQueue.STOPPED;
          }
        }
    }, 

    {
      /** 
       * Static constant for the value of the `errorAction` attribute:
       * prescribes the queue to continue uploading files in case of 
       * an error.
       * @property CONTINUE
       * @readOnly
       * @type {String}
       * @static
       */
        CONTINUE: "continue",

      /** 
       * Static constant for the value of the `errorAction` attribute:
       * prescribes the queue to stop uploading files in case of 
       * an error.
       * @property STOP
       * @readOnly
       * @type {String}
       * @static
       */
        STOP: "stop",

      /** 
       * Static constant for the value of the `errorAction` attribute:
       * prescribes the queue to restart a file upload immediately in case of 
       * an error.
       * @property RESTART_ASAP
       * @readOnly
       * @type {String}
       * @static
       */
        RESTART_ASAP: "restartasap",

      /** 
       * Static constant for the value of the `errorAction` attribute:
       * prescribes the queue to restart an errored out file upload after 
       * other files have finished uploading.
       * @property RESTART_AFTER
       * @readOnly
       * @type {String}
       * @static
       */
        RESTART_AFTER: "restartafter",

      /** 
       * Static constant for the value of the `_currentState` property:
       * implies that the queue is currently not uploading files.
       * @property STOPPED
       * @readOnly
       * @type {String}
       * @static
       */
        STOPPED: "stopped",

      /** 
       * Static constant for the value of the `_currentState` property:
       * implies that the queue is currently uploading files.
       * @property UPLOADING
       * @readOnly
       * @type {String}
       * @static
       */
        UPLOADING: "uploading",

       /**
        * The identity of the class.
        *
        * @property NAME
        * @type String
        * @default 'uploaderqueue'
        * @readOnly
        * @protected
        * @static
        */
        NAME: 'uploaderqueue',

       /**
        * Static property used to define the default attribute configuration of
        * the class.
        *
        * @property ATTRS
        * @type {Object}
        * @protected
        * @static
        */
        ATTRS: {
       
          /**
           * Maximum number of simultaneous uploads; must be in the
           * range between 1 and 5. The value of `2` is default. It
           * is recommended that this value does not exceed 3.
           * @property simUploads
           * @type Number
           * @default 2
           */
           simUploads: {
               value: 2,
               validator: function (val, name) {
                   return (val >= 1 && val <= 5);
               }
           },
   
          /**
           * The action to take in case of error. The valid values for this attribute are: 
           * `Y.Uploader.Queue.CONTINUE` (the upload process should continue on other files, 
           * ignoring the error), `Y.Uploader.Queue.STOP` (the upload process 
           * should stop completely), `Y.Uploader.Queue.RESTART_ASAP` (the upload 
           * should restart immediately on the errored out file and continue as planned), or
           * Y.Uploader.Queue.RESTART_AFTER (the upload of the errored out file should restart
           * after all other files have uploaded)
           * @property errorAction
           * @type String
           * @default Y.Uploader.Queue.CONTINUE
           */
           errorAction: {
               value: "continue",
               validator: function (val, name) {
                   return (val === UploaderQueue.CONTINUE || val === UploaderQueue.STOP || val === UploaderQueue.RESTART_ASAP || val === UploaderQueue.RESTART_AFTER);
               }
           },

          /**
           * The total number of bytes that has been uploaded.
           * @property bytesUploaded
           * @type Number
           */   
           bytesUploaded: {
               readOnly: true,
               value: 0
           },
   
          /**
           * The total number of bytes in the queue.
           * @property bytesTotal
           * @type Number
           */ 
           bytesTotal: {
               readOnly: true,
               value: 0
           },

          /**
           * The queue file list. This file list should only be modified
           * before the upload has been started; modifying it after starting
           * the upload has no effect, and `addToQueueTop` or `addToQueueBottom` methods
           * should be used instead.
           * @property fileList
           * @type Number
           */    
           fileList: {
               value: [],
               lazyAdd: false,
               setter: function (val) {
                   var newValue = val;
                   Y.Array.each(newValue, function (value) {
                       this.totalBytes += value.get("size");
                   }, this);
    
                   return val;
               }   
           },

          /**
           * A String specifying what should be the POST field name for the file
           * content in the upload request.
           *
           * @attribute fileFieldName
           * @type {String}
           * @default Filedata
           */   
           fileFieldName: {
              value: "Filedata"
           },

           /**
           * The URL to POST the file upload requests to.
           *
           * @attribute uploadURL
           * @type {String}
           * @default ""
           */  
           uploadURL: {
             value: ""
           },
          /**
           * An object, keyed by `fileId`, containing sets of key-value pairs
           * that should be passed as POST variables along with each corresponding
           * file.
           *
           * @attribute perFileParameters
           * @type {Object}
           * @default {}
           */   
           perFileParameters: {
             value: {}
           }

        }
    });


    Y.namespace('Uploader');
    Y.Uploader.Queue = UploaderQueue;


}, '3.5.1' ,{requires:['base']});