Skip to content

Commit 6c5d3c2

Browse files
author
Eric W. Greene
committed
cleaned up ui
1 parent 4b82cff commit 6c5d3c2

File tree

6 files changed

+43
-10
lines changed

6 files changed

+43
-10
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,11 @@
11
# file_uploads
22
File Upload Demonstrations using a HTML5 and Node.js.
3+
4+
To run,
5+
6+
1. Clone this repository to your local computer.
7+
2. Open a terminal, change to the local folder where the repository was cloned to.
8+
3. Type **npm install**, then press **enter**.
9+
4. Then either, type **grunt**, and press **enter**. Or, type **node app/index.js**, and press **enter**.
10+
5. Then open a web browser, and navigate to **http://localhost:8080**
11+
6. Select a demo, and follow the instructions.

app/www/css/site.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ footer {
33
}
44

55
#drop-zone {
6-
float:left;
76
width:200px;
87
height:200px;
98
background-color: white;
109
box-sizing: border-box;
1110
border: 2px dashed #999999;
11+
text-align:center;
1212
}
1313

14-
#drop-zone .active {
14+
#drop-zone.active {
1515
border: 3px dashed black;
1616
}

app/www/index_socketio_upload.html

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,14 @@
1515
<h1>Drag & Drop Socket IO File Upload Demo</h1>
1616
</header>
1717

18-
<div id="drop-zone">Drop a File Here</div>
18+
<main class="row">
19+
<div class="col-xs-6">
20+
<div id="drop-zone">Drop a File Here</div>
21+
</div>
22+
<div class="col-xs-6">
23+
<pre id="status-log">Status:</pre>
24+
</div>
25+
</main>
1926

2027
<footer>
2128
<small><a href='http://www.training4developers.com' target='_blank'>

app/www/index_websockets_upload.html

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,14 @@
1515
<h1>Drag & Drop Web Socket File Upload Demo</h1>
1616
</header>
1717

18-
<div id="drop-zone">Drop a File Here</div>
18+
<main class="row">
19+
<div class="col-xs-6">
20+
<div id="drop-zone">Drop a File Here</div>
21+
</div>
22+
<div class="col-xs-6">
23+
<pre id="status-log">Status:</pre>
24+
</div>
25+
</main>
1926

2027
<footer>
2128
<small><a href='http://www.training4developers.com' target='_blank'>

app/www/js/socket_io_file_upload.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
(function(document) {
22

3-
var socket = io();
3+
var socket = io(), statusLog;
44

55
socket.on("upload result", function(result) {
6-
console.log(result);
6+
statusLog.innerText += result + "\n";
7+
});
8+
9+
document.addEventListener("DOMContentLoaded", function() {
10+
11+
statusLog = document.getElementById("status-log");
12+
statusLog.innerText += "\n";
13+
714
});
815

916
document.addEventListener("dragenter", function(e) {
@@ -32,7 +39,7 @@
3239
fr = new FileReader();
3340

3441
fr.addEventListener("loadend", function() {
35-
console.log("sending " + fr.result.byteLength + " bytes");
42+
statusLog.innerText += "sending " + fr.result.byteLength + " bytes\n";
3643
socket.emit("upload file", fr.result);
3744
});
3845

app/www/js/web_socket_file_upload.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
(function(window, document) {
22

3-
var socket;
3+
var socket, statusLog;
44

55
document.addEventListener("DOMContentLoaded", function() {
66

7+
statusLog = document.getElementById("status-log");
8+
statusLog.innerText += "\n";
9+
710
socket = new WebSocket("ws://localhost:8081");
811
socket.addEventListener("open", function() {
912
console.log("connection open");
1013
});
1114

1215
socket.addEventListener("message", function(msg) {
13-
console.log(msg.data);
16+
statusLog.innerText += msg.data + "\n";
1417
});
1518

1619
});
@@ -41,7 +44,7 @@
4144
fr = new FileReader();
4245

4346
fr.addEventListener("loadend", function() {
44-
console.log("sending " + fr.result.byteLength + " bytes");
47+
statusLog.innerText += "sending " + fr.result.byteLength + " bytes" + "\n";
4548
socket.send(fr.result);
4649
});
4750

0 commit comments

Comments
 (0)