Browse Source

added future ideas and implementation comments, minor reworking

Josh Bicking 7 years ago
parent
commit
700f2d13a4
2 changed files with 31 additions and 22 deletions
  1. 9 0
      README.md
  2. 22 22
      public/javascripts/index.js

+ 9 - 0
README.md

@@ -19,3 +19,12 @@ Or build and run the docker container at:
 
 Connect to the server (by default) at localhost:3000. Port 9000 must also be open for the peer server to communicate with clients.
 
+#TODO:
+Progression indicator
+SSL support
+Distributed system support (many outlets supporting one ID source)
+UI improvements
+Mobile support, either through an app or easier web access
+Standalone Desktop client?
+QR codes, rather than ID numbers
+Words for ID names, rather than ID numbers (suggested by Adelphius)

+ 22 - 22
public/javascripts/index.js

@@ -9,39 +9,36 @@ var peer = new Peer({host: 'localhost', port: 9000, path: '/node_modules/peerjs'
 // Send a file
 function send() {
     // Check that all fields are filled
-    var valid = true;
     var file_to_send = document.getElementById("file_to_send").files[0];
     var dest_id = document.getElementById("dest_id").value;
-    if(!file_to_send) {
-        valid = false;
+    if(!file_to_send && !dest_id) {
+        alert("Please select a file and previde a Destination ID.");
+    }
+    else if(!file_to_send) {
         alert("Please select a file.");
     }
-    if(!dest_id) {
-        valid = false;
+    else if(!dest_id) {
         alert("Please provide a Destination ID.");
     }
     else if (dest_id === peer.id) {
-        valid = false;
         alert("You can't send a file to yourself!");
     }
-    if(!valid){
-        return;
-    }
-
-    // Build blob from file and file type
-    var blob = new Blob([file_to_send], {type: file_to_send.type});
+    else {
+	// Build blob from file and file type
+	var blob = new Blob([file_to_send], {type: file_to_send.type});
 
-    // Connect to the desired peer
-    var con = peer.connect(dest_id, { label: 'file', reliable: true}); 
+	// Connect to the desired peer
+	var con = peer.connect(dest_id, { label: 'file', reliable: true}); 
 
-    con.on('open', function() {
-        // Send arr of blob and file data
-        con.send({
-            name: document.getElementById("file_to_send").files[0].name,
-            file: blob,
-            type: document.getElementById("file_to_send").files[0].type
-        });
-    });
+	con.on('open', function() {
+	    // Send arr of blob and file data
+	    con.send({
+		name: document.getElementById("file_to_send").files[0].name,
+		file: blob,
+		type: document.getElementById("file_to_send").files[0].type
+	    });
+	});
+    }
 }
 
 // Display ID
@@ -53,6 +50,9 @@ peer.on('open', function(id) {
 peer.on('connection', function(conn) {
     conn.on('open', function() {
         conn.on('data', function(data) {
+	    // TODO consider sending a size blob beforehand, or a size field in the blob
+	    // A good starting point would be to continuously update the entry with how
+	    // much data was downloaded
             var blob = new Blob([data.file], {type: data.type});
             var url = window.URL.createObjectURL(blob);