From 61721dc4baf7fdebd2c74e6d6c9010012d184541 Mon Sep 17 00:00:00 2001
From: Angela Ko <ako926@berkeley.edu>
Date: Sat, 6 Aug 2016 08:57:26 -0700
Subject: [PATCH 1/3] modified button and sent blob

---
 js/photonic3d.js | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/js/photonic3d.js b/js/photonic3d.js
index e6a1907..e7949f9 100644
--- a/js/photonic3d.js
+++ b/js/photonic3d.js
@@ -42,6 +42,7 @@ function initializeValues() {
 	$slicerSpeedYes[0].checked = true;
 	$slicerSpeedNo[0].checked = false;
 	$slicerSpeedDelay.val(0);
+	makeButton();
 
 	// Update global javascript object with slicer settings
     settings.set('slicer.speed', $slicerSpeedYes[0].checked);
@@ -61,8 +62,43 @@ function initializeValues() {
 		// Error handling
 	}
 
+	
+
 	// loader.load(/*insert file here*/);
 }
 
+function makeZip() {
+	if (zipFile) {
+        var name = 'SLAcer';
+        if (loadedFile && loadedFile.name) {
+            name = loadedFile.name;
+        }
+        uploadZip(zipFile.generate({type: 'blob'}), name + '.zip');
+        $location.path('/printables');
+    }
+}
+
+function uploadZip(zipFile) {
+	var blob = zipFile,
+    form = new FormData(),
+    request = new XMLHttpRequest();
+	form.append("blob",blob);
+	request.open(
+	            "POST",
+	            "/services/printerables//uploadPrintableFile",
+	            true
+	        );
+	request.send(form);
+}
+
+function makeButton() {
+	var btn	= document.getElementById("zip-button");
+	btn.onclick = function () {
+	    makeZip();
+	};
+	btn.id = "new-zip-button";
+	btn.innerHTML = "New Zip";	
+}
+
 $(document).ready(initializeValues);
 

From 35789f46bf4eff062c5aca8d679824a71e901d21 Mon Sep 17 00:00:00 2001
From: Angela Ko <ako926@berkeley.edu>
Date: Sat, 6 Aug 2016 12:15:41 -0700
Subject: [PATCH 2/3] Upload Zip File Directly To Server + Button

---
 js/photonic3d.js | 32 +++++++++++++++++---------------
 1 file changed, 17 insertions(+), 15 deletions(-)

diff --git a/js/photonic3d.js b/js/photonic3d.js
index e7949f9..25ec5d3 100644
--- a/js/photonic3d.js
+++ b/js/photonic3d.js
@@ -74,30 +74,32 @@ function makeZip() {
             name = loadedFile.name;
         }
         uploadZip(zipFile.generate({type: 'blob'}), name + '.zip');
-        $location.path('/printables');
+        window.location = "/printablesPage";
     }
 }
 
-function uploadZip(zipFile) {
-	var blob = zipFile,
-    form = new FormData(),
-    request = new XMLHttpRequest();
-	form.append("blob",blob);
-	request.open(
-	            "POST",
-	            "/services/printerables//uploadPrintableFile",
-	            true
-	        );
+function uploadZip(zipFile, fileName) {
+	var blob = zipFile;
+    form = new FormData();
+	form.append("file",blob,fileName);
+	request = new XMLHttpRequest();
+	request.open("POST", "/services/printables/uploadPrintableFile");
 	request.send(form);
 }
 
 function makeButton() {
+	//rename original zip button
 	var btn	= document.getElementById("zip-button");
-	btn.onclick = function () {
+	btn.innerHTML = "Download Zip";	
+	//create new zip button
+	var newbtn = document.createElement("BUTTON");
+	newbtn.onclick = function () {
 	    makeZip();
-	};
-	btn.id = "new-zip-button";
-	btn.innerHTML = "New Zip";	
+	}
+	newbtn.id = "new-zip-button";
+	newbtn.className = "btn btn-primary";
+	newbtn.innerHTML = "Upload ZIP To Printables";
+	btn.parentNode.insertBefore(newbtn, btn);
 }
 
 $(document).ready(initializeValues);

From 7527834e7b0ffcd9d1852ce4119c699992ecbdf3 Mon Sep 17 00:00:00 2001
From: Angela Ko <ako926@berkeley.edu>
Date: Sat, 6 Aug 2016 12:30:31 -0700
Subject: [PATCH 3/3] Removed auto redirect back to printables page after
 upload complete

---
 js/photonic3d.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/js/photonic3d.js b/js/photonic3d.js
index 25ec5d3..823846a 100644
--- a/js/photonic3d.js
+++ b/js/photonic3d.js
@@ -74,7 +74,7 @@ function makeZip() {
             name = loadedFile.name;
         }
         uploadZip(zipFile.generate({type: 'blob'}), name + '.zip');
-        window.location = "/printablesPage";
+        //window.location = "/printablesPage";
     }
 }
 
