Permalink
Browse files

Initial pass on Print-Button setup. Requires testing.

  • Loading branch information...
1 parent 52f6623 commit ca92d450cd6f4eca6e8981c7210b60c51e89eca8 @WGAndrew WGAndrew committed Nov 24, 2016
Showing with 13 additions and 33 deletions.
  1. +3 −8 index.html
  2. +10 −25 js/photonic3d.js
View
@@ -15,17 +15,14 @@
<div id="sidebar">
<div class="form-group">
- <button id="open-viewer-2d" class="btn btn-primary" type="button">
- <span class="glyphicon glyphicon-picture"></span> 2D viewer
- </button>
<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="zip-button" class="btn btn-info" type="button" disabled="disabled">
- <span class="glyphicon glyphicon-compressed"></span> ZIP
+ <button id="print-button" class="btn btn-success" type="button" disabled="disabled">
+ <span class="glyphicon glyphicon-print"></span> Print
</button>
</div>
@@ -164,8 +161,7 @@ <h3 class="panel-title">Slicer</h3>
</div>
<div class="verbergen">
<hr />
-
-
+
<div class="form-group">
<label for="slicer-image-extension">Output type</label>
<input type="radio" name="slicer-image-extension" id="slicer-image-extension-png" value="png" checked="checked" /> png
@@ -193,7 +189,6 @@ <h3 class="panel-title">Slicer</h3>
<label for="slicer-speed-delay">Speed mode<br />delay <small>(ms)</small></label>
<input type="number" id="slicer-speed-delay" class="form-control input-sm" placeholder="100" min="1" />
</div>
- </div>
</div>
</div><!-- #slicer -->
View
@@ -55,8 +55,11 @@ function setPrinterCalibrationSettings(printer) {
// Initialize values
function initializeValues() {
- makeButton();
+ var btn = document.getElementById("print-button");
+ btn.onclick= function(){
+ makeZip();
+ }
// settings.set('#slicer.panel.collapsed', true);
// $slicerBody.collapse('hide');
@@ -85,11 +88,11 @@ function makeZip() {
if (loadedFile && loadedFile.name) {
name = loadedFile.name;
}
- uploadZip(zipFile.generate({type: 'blob'}), name + '.zip');
+ printZip(zipFile.generate({type: 'blob'}), name + '.zip');
}
}
-function uploadZip(zipFile, fileName) {
+function printZip(zipFile, fileName) {
var blob = zipFile;
form = new FormData();
form.append("file",blob,fileName);
@@ -100,37 +103,19 @@ function uploadZip(zipFile, fileName) {
if (request.readyState == 4 && request.status == 200) {
// window.open('/printablesPage', '_self');
$('#uploadzip-icon').prop('class', 'glyphicon glyphicon-upload');
- alert("Upload successful! Refresh printables page on Photonic3D to see the file.");
+ $.post("/services/printables/print/"+fileName, function(data){
+ alert(fileName+" is now printing!");
+ });
}
}
request.send(form);
}
-function makeButton() {
- //rename original zip button
- var btn = document.getElementById("zip-button");
- btn.innerHTML = '<span class="glyphicon glyphicon-compressed"></span> ZIP';
-
- //create new zip button
- var newbtn = document.createElement("BUTTON");
- $(newbtn).css({
- 'margin-top' : '10px'
- });
- btn.parentNode.insertBefore(newbtn, btn.nextSibling);
- newbtn.onclick = function () {
- makeZip();
- }
- newbtn.id = "new-zip-button";
- newbtn.className = "btn btn-primary";
- newbtn.disabled = true;
- newbtn.innerHTML = '<i class="glyphicon glyphicon-upload" id="uploadzip-icon"></i> Upload ZIP To Photonic3D';
-}
-
var oldEndSlicing = endSlicing;
endSlicing = function() {
oldEndSlicing();
- $('#new-zip-button').prop('disabled', !zipFile);
+ $('#print-button').prop('disabled', !zipFile);
}
$(document).ready(initializeValues);

0 comments on commit ca92d45

Please sign in to comment.