Commits

Akash Sinha  committed 3919445

ajax file upload script updated, now only unique files could be uploaded during a upload

  • Participants
  • Parent commits 201150d

Comments (0)

Files changed (1)

File MoinMoin/static/js/jfu.js

  *
  * Copyright 2010, Sebastian Tschan, https://blueimp.net
  * Copyright 2011, Thomas Waldmann (adapted for MoinMoin)
+ * Copyright 2011, Akash Sinha (modified further for MoinMoin)
  *
  * Licensed under the MIT license:
  * http://creativecommons.org/licenses/MIT/
     UploadHandler = function (container, options) {
         var uploadHandler = this;
 
+        this.fileArray = new Array();
         this.url = container.find('form:first').attr('action');
         this.dropZone = container.find('form:first');
         this.uploadTable = container.find('.files:first');
             });
         };
 
+        this.fileExist = function (fileName, fileArray) {
+            for(var i=0; i<fileArray.length; i++) {
+                  if (fileArray[i] == fileName) return true;
+            }
+            fileArray.push(fileName);
+            return false;
+        };
+
         this.buildMultiUploadRow = function (files, handler) {
             var rows = $('<tbody style="display:none;"/>');
             $.each(files, function (index, file) {
                 fileName = handler.formatFileName(file.name),
                 uploadRow = handler.uploadTemplate
                     .clone().removeAttr('id');
+            if(!handler.fileExist(fileName, handler.fileArray)) {
             uploadRow.find('.file_name')
                 .text(fileName);
             uploadRow.find('.file_upload_start button')
             uploadRow.find('.file_upload_cancel button')
                 .button({icons: {primary: 'ui-icon-cancel'}, text: false});
             return uploadRow;
+            }
+            return null;
+            
         };
 
         this.buildMultiDownloadRow = function (files, handler) {
                 uploadHandler.downloadTable.find("h3:first").fadeIn();
                 $(".moin-index-separator").fadeIn();
             }
+            uploadHandler.fileArray.length = 0;
         };
 
         this.initEventHandlers = function () {