Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add gcode tab #60

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions frontend/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,58 @@ <h3>Recent Jobs</h3>
</div>
</div> <!-- end of log tab -->

<!-- START CUSTOM GCODE TAB -->
<div id='tab_gcode' class='tab-pane'>
<div id='gcode_content'>
<textarea id='gcode_edit' style='clear:both; width: 900px;' rows=20></textarea>
<button id="gcode_submit" class="btn btn-large btn-primary">Send to Lasersaur</button>
</div>
</div>

<script>
var chunksize = 5000;
var gqueue = Array();
function queue_gcode(gcode){
var tmp = gcode.split("\n");
var chunk = "";
var lc = 0;
for (var i=0; i<tmp.length; i++){
lc++;
chunk += tmp[i]+"\n";
if (lc>=chunksize){
gqueue.push(chunk);
lc=0;
chunk=""
}
}
if (chunk.length>0){ gqueue.push(chunk); }
}

function process_gcode_queue(){

if (progress_not_yet_done_flag==false && gqueue.length > 0){
gcode = gqueue.shift();
progress_not_yet_done_flag=true;
send_gcode(gcode, "New Chunk from Queue Sent.", true);
}
setTimeout("process_gcode_queue()",5000);
}
setTimeout("process_gcode_queue()",5000);

$("#cancel_btn").click(function(e){
gqueue = Array();
});

$('.tabs-left ul').append('<li><a href="#tab_gcode" id="tab_gcode_button" data-toggle="tab"><i class="icon-exclamation-sign" style="margin-right:2px"></i> Gcode</a></li>');
$("#gcode_submit").click(function(e) {
var gcode = $('#gcode_edit').val();
if (gcode){
//send_gcode(gcode, "G-Code sent to backend.", true);
queue_gcode(gcode);
}
});
</script>
<!-- END CUSTOM GCODE TAB -->
<!--content end-->
</div>
</div>
Expand Down