From 1e297c33c694bf7ef5700f8276da368c002c4056 Mon Sep 17 00:00:00 2001 From: Neeraj Baid Date: Wed, 25 Feb 2015 17:55:33 -0800 Subject: [PATCH] Remove a comment. Add bundle.js. --- client/bundle.js | 77 ++++++++++++++++++++++++++++++++++++++++++++++++ client/index.js | 2 -- 2 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 client/bundle.js diff --git a/client/bundle.js b/client/bundle.js new file mode 100644 index 0000000..03cab03 --- /dev/null +++ b/client/bundle.js @@ -0,0 +1,77 @@ +(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o', escape(file.name), ' (', file.type || 'n/a', ') - ', + file.size, ' bytes, last modified: ', + file.lastModifiedDate ? file.lastModifiedDate.toLocaleDateString() : 'n/a', + ''); + var metadaton = {"name":escape(file.name), + "size":file.size, + "type":file.type || 'n/a', + "crc" :""} + metadata.push(metadaton) + } + document.getElementById('list').innerHTML = ''; + var firebase = new Firebase("https://webdrop.firebaseio.com/"); + // firebase.set({ + // "id" : createID(), + // "file_metadata" : metadata + // }) + // post metadata to server +} + +function send() { // perhaps need params for peer id or something + for (var i = 0, file; f = files[i]; i++) { + for (var bytes = 0; bytes <= file.size; bytes += 1200) { + endingByte = bytes+1200 + if (endingByte > file.size) { + endingByte = file.size + } + var blob = file.slice(bytes, endingByte); + // send blob + } + } +} + +function handleDragOver(evt) { + evt.stopPropagation(); + evt.preventDefault(); + evt.dataTransfer.dropEffect = 'copy'; +} + +function createID() { + var timestamp = Date.now() + var alphabet = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "a", "b", "c", "d", "e", "f", "g", "h", "i", + "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", + "C", "D", "E", "F", "G", "H", "I", "K", "L", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", + "Y", "Z"] + var arr = [] + var base = alphabet.length + while (timestamp > 0) { + var rem = parseInt(timestamp % base) + timestamp = parseInt(timestamp / base) + arr.push(alphabet[rem]) + } + arr = arr.reverse() + id = arr.join("") + // add two random characters to ensure uniqueness between identical milliseconds + id += (alphabet[Math.floor(Math.random() * alphabet.length)]) + id += (alphabet[Math.floor(Math.random() * alphabet.length)]) + return id +} + +var dropZone = document.getElementById('drop_zone'); +dropZone.addEventListener('dragover', handleDragOver, false); +dropZone.addEventListener('drop', handleFileSelect, false); + +},{}]},{},[1]); diff --git a/client/index.js b/client/index.js index 6889d85..3a15b02 100644 --- a/client/index.js +++ b/client/index.js @@ -5,8 +5,6 @@ function handleFileSelect(evt) { evt.preventDefault(); files = evt.dataTransfer.files; // FileList object. - - // files is a FileList of File objects. List some properties. var output = []; metadata = []; for (var i = 0, file; file = files[i]; i++) {