Permalink
Browse files

Readding Save button and handling the code for it slightly differentl…

…y to the old implementation.
  • Loading branch information...
1 parent 649fae1 commit 83e275f9ed6d8f94958baf3ad323b2497c30ee71 @WGAndrew WGAndrew committed Nov 28, 2016
Showing with 36 additions and 11 deletions.
  1. +11 −6 index.html
  2. +25 −5 js/photonic3d.js
View
@@ -1,4 +1,4 @@
-<!DOCTYPE html>
+<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
@@ -13,17 +13,22 @@
<body>
<div class="body container-fluid">
<div id="sidebar">
-
- <div class="form-group">
+ <div class="form-group" style="display:inline-block;">
<button id="slice-button" class="btn btn-success" type="button">
<span class="glyphicon glyphicon-align-center"></span> Slice
</button>
<button id="abort-button" class="btn btn-danger hidden" type="button">
<span class="glyphicon glyphicon-off"></span> Abort
</button>
- <button id="print-button" class="btn btn-success" type="button" disabled="disabled">
- <span class="glyphicon glyphicon-print"></span> Print
- </button>
+
+ <div class=" btn-group" style="display:inline-block;">
+ <button id="upload-button" class="btn btn-success" type="button" disabled="disa$
+ <span class="glyphicon glyphicon-upload"> </span> Save
+ </button>
+ <button id="print-button" class="btn btn-success" type="button" disabled="disab$
+ <span class="glyphicon glyphicon-print"></span> Print
+ </button>
+ y</div>
</div>
<div id="transform" class="panel panel-default">
View
@@ -57,9 +57,11 @@ function setPrinterCalibrationSettings(printer) {
function initializeValues() {
var btn = document.getElementById("print-button");
- btn.onclick= function(){
- makeZip();
- }
+ btn.onclick= function(){makeZip(printZip);};
+
+ btn = document.getElementById("print-button");
+ btn.onclick= function(){makeZip(saveZip);};
+
// settings.set('#slicer.panel.collapsed', true);
// $slicerBody.collapse('hide');
@@ -79,7 +81,7 @@ function initializeValues() {
}
-function makeZip() {
+function makeZip(action) {
$('#uploadzip-icon').prop('class', 'glyphicon glyphicon-refresh glyphicon-spin');
if (zipFile === null || zipFile === undefined) {
alert("You must first slice images to generate a zip file.");
@@ -88,7 +90,7 @@ function makeZip() {
if (loadedFile && loadedFile.name) {
name = loadedFile.name;
}
- printZip(zipFile.generate({type: 'blob'}), name + '.zip');
+ action(zipFile.generate({type: 'blob'}), name + '.zip');
}
}
@@ -111,11 +113,29 @@ function printZip(zipFile, fileName) {
request.send(form);
}
+function saveZip(zipFile, fileName) {
+ var blob = zipFile;
+ form = new FormData();
+ form.append("file",blob,fileName);
+ request = new XMLHttpRequest();
+ request.open("POST", "/services/printables/uploadPrintableFile");
+ // When the request is successfully sent, alert the user
+ request.onreadystatechange = function () {
+ if (request.readyState == 4 && request.status == 200) {
+ // window.open('/printablesPage', '_self');
+ $('#uploadzip-icon').prop('class', 'glyphicon glyphicon-upload');
+ }
+ }
+ request.send(form);
+}
+
+
var oldEndSlicing = endSlicing;
endSlicing = function() {
oldEndSlicing();
$('#print-button').prop('disabled', !zipFile);
+ $('#upload-button').prop('disabled', !zipFile);
}
$(document).ready(initializeValues);

0 comments on commit 83e275f

Please sign in to comment.