Sha256: 2b5f0253a85a2da8d528fc345082d0b0670f255beab659ffdaba0800824c4c34

Contents?: true

Size: 1.94 KB

Versions: 1

Compression:

Stored size: 1.94 KB

Contents

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = {}.hasOwnProperty,
    __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };

  WebSocketRails.UploadEvent = (function(_super) {

    __extends(UploadEvent, _super);

    function UploadEvent(eventName, file, data, connectionId, successCallback, failureCallback, _conn) {
      this.file = file;
      this.successCallback = successCallback;
      this.failureCallback = failureCallback;
      this._conn = _conn;
      this.storeBinaryData = __bind(this.storeBinaryData, this);

      this.attributes = __bind(this.attributes, this);

      UploadEvent.__super__.constructor.call(this, [eventName, data, connectionId], this.successCallback, this.failureCallback);
      this.fileReader = new FileReader;
      this.fileReader.onloadend = this.storeBinaryData;
      this.fileReader.readAsArrayBuffer(this.file);
    }

    UploadEvent.prototype.isFileUpload = function() {
      return true;
    };

    UploadEvent.prototype.attributes = function() {
      return {
        id: this.id,
        channel: this.channel,
        data: this.data,
        upload_event: true,
        raw_file_data: {
          filename: this.file.name,
          file_size: this.file.size,
          type: this.file.type,
          array_buffer: this.bufferView
        }
      };
    };

    UploadEvent.prototype.storeBinaryData = function(event) {
      this.arrayBuffer = event.target.result;
      this.bufferView = new Uint8Array(this.arrayBuffer);
      window.buffer = this.bufferView;
      console.log(this.arrayBuffer);
      return this._conn.trigger(this);
    };

    return UploadEvent;

  })(WebSocketRails.Event);

}).call(this);

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
websocket-rails-0.4.7 spec/javascripts/generated/assets/upload_event.js