Sha256: 689bc17c265c14db66072555f6e3b10818f9383b8fc8f1ce49dd86b248c763bc

Contents?: true

Size: 1.16 KB

Versions: 85

Compression:

Stored size: 1.16 KB

Contents

function onFilesSelected(e) {
  var button = e.srcElement;
  button.disabled = true;
  var progress = document.querySelector('div#progress');
  progress.innerHTML = '0%';
  var files = e.target.files;
  var totalFiles = files.length;
  var filesSent = 0;
  if (totalFiles) {
    var uploader = new Uploader('ws://localhost:8080', function () {
      Array.prototype.slice.call(files, 0).forEach(function(file) {
        if (file.name == '.') {
          --totalFiles;
          return;
        }
        uploader.sendFile(file, function(error) {
          if (error) {
            console.log(error);
            return;
          }
          ++filesSent;
          progress.innerHTML = ~~(filesSent / totalFiles * 100) + '%';
          console.log('Sent: ' + file.name);
        });
      });
    });
  }
  uploader.ondone = function() {
    uploader.close();
    progress.innerHTML = '100% done, ' + totalFiles + ' files sent.';
  }
}

window.onload = function() {
  var importButtons = document.querySelectorAll('[type="file"]');
  Array.prototype.slice.call(importButtons, 0).forEach(function(importButton) {
    importButton.addEventListener('change', onFilesSelected, false);
  });
}

Version data entries

85 entries across 85 versions & 1 rubygems

Version Path
flok-0.0.105 spec/iface/driver/assets/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/ws/examples/fileapi/public/app.js
flok-0.0.103 spec/iface/driver/assets/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/ws/examples/fileapi/public/app.js
flok-0.0.102 spec/iface/driver/assets/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/ws/examples/fileapi/public/app.js
flok-0.0.101 spec/iface/driver/assets/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/ws/examples/fileapi/public/app.js
flok-0.0.100 spec/iface/driver/assets/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/ws/examples/fileapi/public/app.js
flok-0.0.99 spec/iface/driver/assets/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/ws/examples/fileapi/public/app.js
flok-0.0.98 spec/iface/driver/assets/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/ws/examples/fileapi/public/app.js
flok-0.0.97 spec/iface/driver/assets/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/ws/examples/fileapi/public/app.js
flok-0.0.96 spec/iface/driver/assets/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/ws/examples/fileapi/public/app.js
flok-0.0.95 spec/iface/driver/assets/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/ws/examples/fileapi/public/app.js
flok-0.0.94 spec/iface/driver/assets/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/ws/examples/fileapi/public/app.js
flok-0.0.93 spec/iface/driver/assets/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/ws/examples/fileapi/public/app.js
flok-0.0.92 spec/iface/driver/assets/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/ws/examples/fileapi/public/app.js
flok-0.0.91 spec/iface/driver/assets/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/ws/examples/fileapi/public/app.js
flok-0.0.90 spec/iface/driver/assets/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/ws/examples/fileapi/public/app.js
flok-0.0.89 spec/iface/driver/assets/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/ws/examples/fileapi/public/app.js
flok-0.0.88 spec/iface/driver/assets/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/ws/examples/fileapi/public/app.js
flok-0.0.87 spec/iface/driver/assets/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/ws/examples/fileapi/public/app.js
flok-0.0.86 spec/iface/driver/assets/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/ws/examples/fileapi/public/app.js
flok-0.0.85 spec/iface/driver/assets/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/ws/examples/fileapi/public/app.js