forked from chilipeppr/widget-gcodelist
-
Notifications
You must be signed in to change notification settings - Fork 1
/
auto-generated-widget.html
4364 lines (3841 loc) · 218 KB
/
auto-generated-widget.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Widget / Gcode v8</title>
<!-- ChiliPeppr is based on bootstrap CSS. -->
<link rel="stylesheet" type="text/css" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
<!-- Customized version of require.js for ChiliPeppr. Please see require.js docs for how
ChiliPeppr's dependency system works as it's based on require.js. -->
<script type='text/javascript' src="//i2dcui.appspot.com/js/require.js"></script>
<style type='text/css'>
#root .btn:active, #root .btn.active {
box-shadow: inset 0 3px 5px rgba(0,0,0,0.425);
}
#com-chilipeppr-widget-gcodeviewer {
}
.gcode-sent {
color: #E6D8BB; /* #faebcc; */
background-color: #fcf8e3;
}
.gcode-queued {
color: #BED0D9; /* #faebcc; */
background-color: #d9edf7;
}
.gcode-written {
color: #BBCCAD; /* #d6e9c6; */
background-color: #dff0d8;
}
.gcode-completed {
color: #000000;
}
.gcode-error{
color: #000000;
background-color: pink;
}
.gcode-executed {
color: #000000;
background-color: silver;
}
#com-chilipeppr-widget-gcodeviewer-popover-steps {
font-size:10px;
/* min-width:300px; */
}
#com-chilipeppr-widget-gcodeviewer-popover-steps tr {
vertical-align: top;
}
.com-chilipeppr-widget-gcodeviewer-coords-wrapper {
position:relative;
/* z-index:998; */
}
#com-chilipeppr-ws-gcode-wrapper #com-chilipeppr-widget-gcode-body.gcode-short-mode {
height:80px;
}
.com-chilipeppr-widget-gcodeviewer-coords {
position: absolute;
/* left: 0; */
background: white;
box-shadow: 0 0 6px 0 rgba(0,0,0,0.2);
border-radius:4px;
z-index:999;
}
.com-chilipeppr-widget-gcodeviewer-coords span {
display: inline-block;
padding:0 6px;
}
.com-chilipeppr-widget-gcodeviewer-coords .coords-lbl {
width:45px;
background:#d5d5d5;
padding:0 3px;
}
.com-chilipeppr-widget-gcodeviewer-coords .coords-axis {
width:15px;
background:#f5f5f5;
padding:0 3px;
}
.com-chilipeppr-widget-gcodeviewer-coords-start {
border-radius:4px;
border:1px solid #adadad;
border-bottom-left-radius:0;
border-bottom-right-radius:0;
}
.com-chilipeppr-widget-gcodeviewer-coords-end {
border-radius:4px;
border:1px solid #adadad;
border-top-width:0;
border-top-left-radius:0;
border-top-right-radius:0;
}
#com-chilipeppr-widget-gcodeviewer .btn-group {
padding-left:0;
}
#com-chilipeppr-widget-gcodeviewer .panel-heading {
/* overflow-x: hidden; */
}
#com-chilipeppr-widget-gcode-body {
padding:0;
margin:0;
height: 200px;
overflow: scroll;
overflow-x: hidden;
position:inherit;
}
#com-chilipeppr-widget-gcode-feedrate {
padding:0;
padding-top:10px;
}
#com-chilipeppr-widget-gcode-tbl tr.gcode-rowhilite {
background-color: #f5f5f5;
}
#com-chilipeppr-widget-gcode-tbl .gtools {
position:relative;
}
#com-chilipeppr-widget-gcode-tbl tr.gcode-rowhilite:hover {
background-color: #d5d5d5;
}
#com-chilipeppr-widget-gcode-tbl .feedrate-adjust {
color: blue;
}
#com-chilipeppr-widget-gcode-body .popover {
max-width: 450px;
width: 450px;
}
.com-chilipeppr-widget-gcode .btn-group {
padding-left: 6px;
}
.com-chilipeppr-widget-gcode .popover .popover-content {
font-size: 10px;
}
.com-chilipeppr-widget-gcode .g {
word-wrap: break-word;
word-break: break-all;
}
.com-chilipeppr-widget-gcode .gcode-comment {
color: silver;
/* max-width:150px; */
word-wrap: break-word;
word-break: break-all;
/* display: block; */
text-overflow: ellipsis;
}
.com-chilipeppr-gcode-tip {
background-color: #e9e9e9;
padding: 3px;
border-radius: 6px;
}
.com-chilipeppr-widget-gcode .btn .glyphicon-play {
/* width: 50px; */
}
.com-chilipeppr-widget-gcode .btn .glyphicon-stop {
/* width: 30px; */
}
#com-chilipeppr-widget-gcode-tbl .glyphicon-ok {
color: #dddddd;
}
#com-chilipeppr-widget-gcode-feedrate .glyphicon {
padding:0;
margin:0;
}
#com-chilipeppr-widget-gcode-feedrate .btn {
/* padding:2px; */
/* margin:0; */
}
#com-chilipeppr-widget-gcode-footer .stats-hdr {
font-size:10px;
/* font-weight:bold; */
}
#com-chilipeppr-widget-gcode-footer .stats-val {
font-size:10px;
font-weight:bold;
}
#com-chilipeppr-widget-gcode-body-wrapper {
position:relative;
/* border:1px solid green; */
/* height:100%; */
}
#com-chilipeppr-widget-gcode-body-jumpscroll-wrapper {
/* position:relative; */
/* border: 1px solid red; */
/* background-color:green; */
/* height:100%; */
/* width:100%; */
/* display: table-cell; */
}
#com-chilipeppr-widget-gcode-body-jumpscroll {
/* position: absolute; */
border: 1px solid red;
/* display: table-cell; */
right:0;
/* top:0; */
height:100%;
width:20px;
background-color:silver;
}
.paginator {
/* position: absolute; */
/* min-height:25px; */
/* display: table-cell; */
/* height:10px; */
width:20px;
height:20%;
/* background-color: rgba(0,0,255,0.5); */
/* border-bottom:1px solid silver; */
/* margin-bottom:1px; */
/* padding-bottom:1px; */
padding:0;
margin:0;
overflow:hidden;
}
.paginator-first, .paginator-last {
position:absolute;
height:24px;
}
.paginator-first {
top:0;
}
.paginator-last {
bottom:0;
}
.jumpbtn {
padding:0;
margin:0;
}
.com-chilipeppr-gcode-jumpscroll .btn {
border-radius:0;
padding:0;
margin:0;
/* padding:1px 8px; */
width:20px;
background-color: none;
/* background-color: rgba(255,255,255,0.5); */
border:0;
height:100%;
}
.com-chilipeppr-gcode-jumpscroll .glyphicon-minus {
/* color: #fdfdfd; */
color: rgba(255,255,255,0);
}
#com-chilipeppr-widget-gcode-footer {
overflow-x: hidden;
}
#com-chilipeppr-widget-gcodeviewer .btnIconBlue {
color: #428bca;
}
#com-chilipeppr-widget-gcodeviewer .btnIconWarning {
color: #f0ad4e;
}
#com-chilipeppr-widget-gcodeviewer .plannerpauseindicator {
cursor:none;
}
#com-chilipeppr-widget-gcode-modal .options-heading {
font-size: larger;
padding:10px 0 0 0;
margin-bottom:0;
}
</style>
<script type='text/javascript'>
//<![CDATA[
// Load additional files via Chilipeppr's require.js
requirejs.config({
paths: {
//jqueryui: '//chilipeppr.com/js/jquery-ui-1.10.4/ui/minified/jquery.ui.core.min',
//jqueryuiResizeable: '//chilipeppr.com/js/jquery-ui-1.10.4/ui/minified/jquery.ui.resizable.min',
jqueryui: '//i2dcui.appspot.com/js/jquery-ui-1.10.4/ui/jquery.ui.core',
jqueryuiWidget: '//i2dcui.appspot.com/js/jquery-ui-1.10.4/ui/jquery.ui.widget',
jqueryuiMouse: '//i2dcui.appspot.com/js/jquery-ui-1.10.4/ui/jquery.ui.mouse',
jqueryuiResizeable: '//i2dcui.appspot.com/js/jquery-ui-1.10.4/ui/jquery.ui.resizable',
waypoints: '//cdnjs.cloudflare.com/ajax/libs/waypoints/2.0.4/waypoints.min',
//jqueryWaypointsInfinite: '//cdnjs.cloudflare.com/ajax/libs/waypoints/2.0.4/waypoints-infinite.min'
},
shim: {
//jqueryWaypointsInfinite: ['waypoints']
//jqueryui: ['jquery'],
jqueryuiWidget: ['jqueryui'],
jqueryuiMouse: ['jqueryuiWidget'],
jqueryuiResizeable: ['jqueryui', 'jqueryuiMouse']
}
});
// Test this element. This code is auto-removed by the chilipeppr.load()
cprequire_test(["inline:com-chilipeppr-widget-gcode"], function (gcode) {
console.log("test running of " + gcode.id);
//console.log(gcode);
/*
gcode.gcodeLoad(function() {
console.log("done loading gcode data...");
//console.log(gcode.gcodeData);
});
*/
/*
cprequire(["inline:com-chilipeppr-elem-gcodedata"], function (gcd) {
console.log("inside the cprequire which i think is getting called too fast.");
console.log(gcd.gcode);
//console.log(gcode);
//console.log(gcode.gcode());
});
*/
// add flash msg
chilipeppr.load(
"http://fiddle.jshell.net/chilipeppr/90698kax/show/light",
function() {
cprequire(
['inline:com-chilipeppr-elem-flashmsg'],
function(flash) {
flash.init();
//chilipeppr.publish("/com-chilipeppr-elem-flashmsg/flashmsg", "title from pub no dismiss", "body from pub", 1000, true);
}
);
}
);
// create a div to hold dragdrop
// Element / Drag Drop
// http://jsfiddle.net/jlauer/Q654J/
chilipeppr.load("dragdrop",
"http://fiddle.jshell.net/jlauer/Z9F6G/show/light/", function () {
require(["inline:com-chilipeppr-elem-dragdrop"], function (dd) {
console.log("inside require of dragdrop");
dd.init();
dd.bind("body", null);
//$(".com-chilipeppr-elem-dragdrop").popover('show');
//dd.bind("#pnlWorkspace", null);
console.log(dd);
});
});
var testPlannerPause = function() {
setTimeout(function() {chilipeppr.publish('/com-chilipeppr-interface-cnccontroller/plannerpause', "");}, 5000);
setTimeout(function() {chilipeppr.publish('/com-chilipeppr-interface-cnccontroller/plannerresume', "");}, 10000);
setTimeout(function() {chilipeppr.publish('/com-chilipeppr-interface-cnccontroller/plannerpause', "");}, 15000);
setTimeout(function() {chilipeppr.publish('/com-chilipeppr-interface-cnccontroller/plannerresume', "");}, 20000);
setTimeout(function() {chilipeppr.publish('/com-chilipeppr-interface-cnccontroller/plannerpause', "");}, 25000);
setTimeout(function() {chilipeppr.publish('/com-chilipeppr-interface-cnccontroller/plannerresume', "");}, 30000);
}
//testPlannerPause();
// mimic recving 3dobject
chilipeppr.subscribe("/com-chilipeppr-widget-3dviewer/request3dObject", function() {
var obj = {
userData: {
lines: [
{"p2":{"x":0,"y":234.234245,"z":0,"e":0,"f":0,"g0":true},"args":{"cmd":"G0","text":"G0 X0 Y2","origtext":"G0 X0Y2","indx":0,"isComment":false,"x":0,"y":2}
},
{"p2":{"x":2,"y":0,"z":0,"e":0,"f":0,"arci":null,"arcj":-2,"arck":null,"arcr":null,"arc":true,"clockwise":true,"g2":true},"args":{"cmd":"G2","text":"G2 X2 Y0 I0 J-2.0","origtext":"G02 X2Y0 I0J-2.0","indx":1,"isComment":false,"x":2,"y":0,"i":0,"j":-2}},
{"p2":{"x":0,"y":234.234245,"z":0,"e":0,"f":0,"g0":true},"args":{"cmd":"G0","text":"G0 X0 Y2","origtext":"G0 X0Y2","indx":0,"isComment":false,"x":0,"y":2}},
{"p2":{"x":0,"y":234.234245,"z":0,"e":0,"f":0,"g0":true},"args":{"cmd":"G0","text":"G0 X0 Y2","origtext":"G0 X0Y2","indx":0,"isComment":false,"x":0,"y":2}},
{"p2":{"x":0,"y":234.234245,"z":0,"e":0,"f":0,"g0":true},"args":{"cmd":"G0","text":"G0 X0 Y2","origtext":"G0 X0Y2","indx":0,"isComment":false,"x":0,"y":2}},
{"p2":{"x":0,"y":234.234245,"z":0,"e":0,"f":0,"g0":true},"args":{"cmd":"G0","text":"G0 X0 Y2","origtext":"G0 X0Y2","indx":0,"isComment":false,"x":0,"y":2}},
{"p2":{"x":0,"y":234.234245,"z":0,"e":0,"f":0,"g0":true},"args":{"cmd":"G0","text":"G0 X0 Y2","origtext":"G0 X0Y2","indx":0,"isComment":false,"x":0,"y":2}},
{"p2":{"x":0,"y":234.234245,"z":0,"e":0,"f":0,"g0":true},"args":{"cmd":"G0","text":"G0 X0 Y2","origtext":"G0 X0Y2","indx":0,"isComment":false,"x":0,"y":2}},
{"p2":{"x":0,"y":234.234245,"z":0,"e":0,"f":0,"g0":true},"args":{"cmd":"G0","text":"G0 X0 Y2","origtext":"G0 X0Y2","indx":0,"isComment":false,"x":0,"y":2}},
{"p2":{"x":0,"y":234.234245,"z":0,"e":0,"f":0,"g0":true, timeMinsSum: 68.42445},"args":{"cmd":"G0","text":"G0 X0 Y2","origtext":"G0 X0Y2","indx":0,"isComment":false,"x":0,"y":2}}
]
}
};
chilipeppr.publish("/com-chilipeppr-widget-3dviewer/recv3dObject", obj);
});
gcode.init();
//gcode.init({lineNumbersOnByDefault: true});
//gcode.showOptionsModal();
//gcode.setupInfiniteScroll();
//var txt = gcode.fileLines.join('\n');
//window.open('data:text/csv;charset=utf-8,' + escape(txt));
// test a fake receiving of an onQueue msg
var testOnQueue = function() {
setTimeout(function() {
chilipeppr.publish("/com-chilipeppr-widget-serialport/onQueue", { Id: "g2" });
}, 2000);
};
var testOnWrite = function() {
setTimeout(function() {
chilipeppr.publish("/com-chilipeppr-widget-serialport/onWrite", { Id: "g2" });
}, 3000);
};
var testOnComplete = function() {
setTimeout(function() {
chilipeppr.publish("/com-chilipeppr-widget-serialport/onComplete", { Id: "g2" });
}, 4000);
};
var testOnExecute = function() {
setTimeout(function() {
chilipeppr.publish("/com-chilipeppr-interface-cnccontroller/onExecute", { line: 2 });
}, 5000);
setTimeout(function() {
chilipeppr.publish("/com-chilipeppr-interface-cnccontroller/onExecute", { line: 4 });
}, 6000);
setTimeout(function() {
chilipeppr.publish("/com-chilipeppr-widget-serialport/onComplete", { Id: "g3" });
}, 7000);
};
var testOnError = function() {
setTimeout(function() {
chilipeppr.publish("/com-chilipeppr-widget-serialport/onError", { Id: "g3" });
}, 7000);
}
// testOnQueue();
// testOnWrite();
// testOnComplete();
// testOnExecute();
//testOnError();
var testPublishGcode = function() {
setTimeout(function() {
chilipeppr.publish("/com-chilipeppr-widget-gcode/requestGcode", "");
}, 5000);
}
//testPublishGcode();
var testJumpToLine = function() {
setTimeout(function() {
chilipeppr.publish("/com-chilipeppr-widget-gcode/jumpToLine", 5);
}, 6000);
}
//testJumpToLine();
// force widget to set width to test css
$('#com-chilipeppr-widget-gcodeviewer').css('width', '350px');
$('body').css('padding', '20px');
// test out the /onPlay and interrupting it
var testOnPlayInterrupt = function() {
var isDoInterrupt = true;
chilipeppr.subscribe("/com-chilipeppr-widget-gcode/onplay", this, function(event) {
console.log("got onPlay pubsub test for interrupt. event: ", event);
if (isDoInterrupt) {
console.log("onPlay pubsub test. CANCELLING EVENT.");
// then send a new /play about 5 seconds later to mimic an async interrupt
setTimeout(function() {
// pretend we threw up a dialog box, let the user choose stuff, and then they move along
// we have to mimic the user is hitting play to start the process again
chilipeppr.publish("/com-chilipeppr-widget-gcode/play", event);
}, 5000);
// set to false so next time in, we don't cancel
isDoInterrupt = false;
// return false to cancel all subsequent calls
return false;
} else {
// we get here after we resend the /play signal to the Gcode widget. when it gets that
// it starts the process again of a play and we should let it continue on since we already
// did our important work
console.log("onPlay pubsub test. Now allowing play to continue on.")
return true;
}
});
};
// testOnPlayInterrupt();
} /*end_test*/ );
cpdefine("inline:com-chilipeppr-widget-gcode", ["chilipeppr_ready", "waypoints", "jqueryuiResizeable", "jquerycookie"], function () {
return {
id: "com-chilipeppr-widget-gcode",
url: "http://raw.githubusercontent.com/jeruick/widget-gcodelist/master/auto-generated-widget.html", // The final URL of the working widget as a single HTML file with CSS and Javascript inlined. You can let runme.js auto fill this if you are using Cloud9.
fiddleurl: "http://ide.c9.io/eaclaya/widget-gcode-list", // The edit URL. This can be auto-filled by runme.js in Cloud9 if you'd like, or just define it on your own to help people know where they can edit/fork your widget
githuburl: "http://github.com/jeruick/widget-gcodelist", // The backing github repo
testurl: "http://widget-gcode-list-eaclaya.c9users.io/widget.html", // The standalone working widget so can view it working by itself
name: "Widget / Gcode v8",
desc: "The Gcode widget shows you the Gcode loaded into your workspace, lets you send it to the serial port, get back per line status, see an estimated length of time to execute the Gcode, navigate to the XYZ position of a specific line, and much more.",
publish: {
// '/onplay': "When user hits play button",
'/onplay': "When user hits play button. This is fired before this widget starts playing to give subscribers a chance to cancel the play, or delay it, or interrupt it. Payload contains {gcodeLines:(array of gcode lines)}. For example, the Cayenn widget listens for this signal and interrupts you if there are Cayenn commands in your Gcode so it can send a ResetCtr to all Cayenn devices. The Cayenn widget needs to send all the resets before ChiliPeppr is allowed to play to make sure everything is in sync. Return a false from your subscribe callback to cancel the play.",
'/onpause': "When user hits pause button. The payload is a true/false boolean indicating whether it is a pause or an unpause. This event also fires if a pause is triggered for a different reason like from an M6 command. In that case the 2nd paramater of the payload contains a string of \"m6\".",
'/onstop': "When user hits stop button",
'/resize' : "When we resize in case any other widget wants to listen to that so it can resize itself.",
'/done' : "When we are done sending all gcode. We send a payload of how many lines sent and time for job.",
'/recvGcode' : 'We publish this signal after you send in a /requestGcode signal. We will send you the Gcode in this widget including metadata. The payload contains { lines: [(your lines as a 0-based array)], metadata: [{isSent: bool, isQueued: bool, isWritten: bool, isComplete: bool}] }. The lines are a 0-based array so if you are trying to line them up with the numbers in the Gcode widget, line 1 corresponds to lines[0] in the array. The metadata is an array that matches the lines array but contains data on the send state of each line. You are being sent an exact reference to that array so if you modify it, you are modifying the actual Gcode and Metadata in this widget. You have been warned.',
'/onChiliPepprPause' : 'This event is published during the play operation when the chilipeppr_pause string is found inside the Gcode. You can place a chilipeppr_pause string anywhere in the Gcode inside a comment and it will tell ChiliPeppr to pause sending when it hits that line. <br><br>The pause acts much like the M6 tool change pause but it is a pause just for ChiliPeppr to interpret and not the CNC controller. This technique was implemented for synchronizing a secondary microcontroller that could trigger an out-of-band event like a laser solderer, or a solder paste dispenser, or some other control that had to trigger at a specific Gcode line. This specific event is not very helpful to subscribe to because it does not have as much meaning as onChiliPepprPauseOnComplete or onChiliPepprPauseOnExecute. Those two events are triggered when the CNC controller actually gets to the specifically paused line and that is where you would synchronize from. <br><br>The onChiliPepprPauseOnComplete is triggered by all CNC controllers but is not a very accurate event as most controllers have a planner buffer which means this line is not really what is being executed but will be executed in the very near future at an unknown time. The onChiliPepprPauseOnExecute is a highly accurate event currently only available from TinyG that tells you the CNC controller is exactly executing this line at this moment.<br><br>A sample macro is available that shows how to use the onChiliPepprPause events.',
'/onChiliPepprPauseOnExecute' : 'This event is published when the line that contained the chilipeppr_pause command inside a comment has actually executed in the CNC controller. This is currently supported by TinyG. Grbl does not support this.<br><br>The payload of the event includes the line number and the line of gcode that was just executed like { line: 8, gcode: "(chilipeppr_pause solder drop 4)" }',
'/onChiliPepprPauseOnComplete' : 'This event is published when the line that contained the chilipeppr_pause command inside a comment has been actually sent to the CNC controller. If your controller supports onExecute events then it is recommended you use onChiliPepprPauseOnExecute instead because it is much more accurate.<br><br>To help explain the difference between onChiliPepprPauseOnExecute and onChiliPepprPauseOnComplete, for the onChiliPepprPauseOnComplete event if 1000 lines were buffered to SPJS and this is the 1000th line that this event will only trigger as the 1000th line is dished up to the CNC controller. This gives an event that can be pivoted off of. If the CNC controller has a planner buffer that can hold around 8 moves, you will get this event only when this line of gcode enters the planner buffer. So you are getting the event 8 moves ahead. To make this work in the real world you should likely pause by a length of time to ensure all commands are done or issue a double check command to your CNC controller that sends you back a response where you can ensure the controller is in the correct state.<br><br>The payload of the event includes the line number and the line of gcode that was just completed like { line: 8, gcode: "(chilipeppr_pause solder drop 4)" }'
},
subscribe: {
'/requestGcode' : 'Send in this signal and we will publish back out a /recvGcode signal. See /recvGcode for further info.',
'/stop' : 'Send in this signal to stop the gcode playing. Equivalent to hitting the stop button.',
'/play' : 'Send in this signal to play the gcode. Equivalent to hitting the play button.',
'/pause' : 'Send in this signal to pause/unpause the gcode. Equivalent to hitting the pause button.',
'/jumpToLine' : "Send in an integer of what line to jump to in the Gcode widget. The index you send it should match what visually shows in the Gcode widget, i.e. line 1 should be sent as a 1 (even though the backing array is index 0).",
},
foreignSubscribe: {
"/com-chilipeppr-elem-dragdrop/ondropped" : "We watch for a drag drop event of the Gcode file. The payload of the signal contains the localStorage object which is just the string representing the entire Gcode file.",
'/com-chilipeppr-interface-cnccontroller/plannerpause' : "We need to pause when planner tells us.",
'/com-chilipeppr-interface-cnccontroller/plannerresume' : "We need to resume when planner tells us.",
"/com-chilipeppr-interface-cnccontroller/feedhold" : "We need to place a manual pause if we see the e-stop hit. That way user can start where they left off.",
"/com-chilipeppr-interface-cnccontroller/onExecute" : "This signal is sent to us by the CNC controller widget. The payload looks like { line: 234 }. It is ONLY sent if the CNC controller widget is able to determine an executed state. Please refer to your CNC controller's publish documenation to determine if this signal will be published and thus whether this Gcode widget will see these events."
},
foreignPublish: {
'/com-chilipeppr-widget-3dviewer/gcodeline': "When a user clicks a line of gcode. We'll send the gcode and the line number so the subscriber can sync to what we're sending, i.e. a 3D viewer that wants to hilite the line representing this command. The format of the signal data is something like {line: 12, gcode: \"G1 F300.0 Z0.0\"}.",
"/com-chilipeppr-elem-flashmsg/flashmsg" : "Send a flash message on certain events. In particular, we send a flash message when a comment line is hit. We also send a flash message when the gcode is done sending."
},
fileLines: [], // contains the gcode file as array per line
metaLines: [], // stores meta data related to each line in fileLines
metaObj: { // Default meta data object
isSent: false,
isQueued: false,
isWritten: false,
isCompleted: false, // whether onComplete has processed it
isError: false,
isExecuted: false, // whether onExecute has processed it
isDisplayed: false // whether onComplete or onExecute has reacted to it
},
linesComplete: [],
linesToShow: 50, // how many lines to show in the infinite scroll area
linesToShowMax: 200, // how many max before we start unloading
delayPerLine: 1000, // ms delay between the send of each line to serial port
lineNumbersOnByDefault: false,
isDirtyUnits: false, //track if user had to specify a unit of measurement and whether we need to reload the gcode file to add a UOM.
init: function (settings) {
console.log("init called. settings:", settings);
// You can pass in a settings object. Supported settings are:
/*
{lineNumbersOnByDefault: true})
*/
if (settings && 'lineNumbersOnByDefault' in settings) {
console.log("init called. we were passed in settings");
// the workspace wants lineNumbersOnByDefault
this.lineNumbersOnByDefault = settings.lineNumbersOnByDefault;
if (this.lineNumbersOnByDefault) {
console.log("init called. showing default msg. el:", $('.com-chilipeppr-widget-gcode-option-addlinenums-default'));
$('.com-chilipeppr-widget-gcode-option-addlinenums-default').removeClass('hidden');
}
}
// Added on 1/2/17 by JLauer so we can allow onPlay to get interrupted
// subscribe to our own /onPlay event at lowest priority so we get it last
// setting priority to 11 because default is 10 and lower values have higher priority
chilipeppr.subscribe("/com-chilipeppr-widget-gcode/onplay", this, this.onPlayAfter, 11);
this.setupOptionsModal();
// this is async, so hopefully it completes before the user drags a file
// this loads all our tooltip popout info
// to describe the g commands
this.gcodeLoad();
// subscribe to all callback events from serial port widget
// so we know when our gcode is executed by spjs
this.setupOnQueueWriteCompletePubSub();
// load jquery-ui css, but make sure nobody else loaded it
if (!$("link[href='//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css']").length)
$('<link>')
.appendTo('head')
.attr({type : 'text/css', rel : 'stylesheet'})
.attr('href', '//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css');
// load local file
//localStorage.removeItem('last-imported');
var lastImported = localStorage.getItem('last-imported');
var lastLoaded = localStorage.getItem('last-loaded');
if (lastImported) {
console.log("loading text from local storage");
this.onFileLoaded(lastImported);
} else {
console.log("gcode viewer loading from path lastLoaded or 15mm_cube.gcode");
var that = this;
if (!lastLoaded) lastLoaded = 'http://www.chilipeppr.com/3d/chilipepprlogo.nc';
$.get(lastLoaded, null, function (data) {
localStorage.setItem('last-loaded', lastLoaded);
localStorage.removeItem('last-imported');
// load gcode file, true: skip local store cuz i want a path
// stored instead for default file so it reloads when i change it
that.onFileLoaded(data, null, true);
}, 'text')
.error(function () {
console.log("error loading default file");
});
}
// subscribe to file load events
// do it a a stronger priority than default so we get this first
// before the 3d viewser since we modify gcode and may have
// to re-issue it
chilipeppr.subscribe("/com-chilipeppr-elem-dragdrop/ondropped", this, this.onFileLoaded, 9);
// subscribe to pause/resume events
chilipeppr.subscribe("/com-chilipeppr-interface-cnccontroller/plannerpause", this, this.onPlannerPause);
chilipeppr.subscribe("/com-chilipeppr-interface-cnccontroller/plannerresume", this, this.onPlannerResume);
chilipeppr.subscribe("/com-chilipeppr-interface-cnccontroller/feedhold", this, this.onFeedhold);
// setup buttons in top toolbar
this.btnSetup();
// get a trigger per row so we can hilite it
this.setupRowTrigger();
//this.createGcodeDesc();
//console.log(gcode);
this.parseGcode();
//console.log(window.location);
// Make widget resizeable
this.setupResizeable();
this.setupFeedrateAdjust();
this.forkSetup();
this.setupToolChangeModal();
// setup pubsub for sending users our gcode
this.setupSendGcodePubSub();
//this.showToolChangeModal();
// setup play/pause/stop subscribe signals so other code
// can control the playing/pausing/stopping of gcode
this.setupPlayPauseStopPubSub();
// setup subscribe to jumpToLine
chilipeppr.subscribe("/" + this.id + "/jumpToLine", this, this.gotoLine);
// setup popover for status items
this.setupStatusSteps();
this.setupJumpToLine();
this.setupSecondaryButtons();
// get estimated time duration. request this after a few
// seconds to give best chance of 3d viewer being loaded
setTimeout(this.getEstimates.bind(this), 5000);
console.log(this.name + " done loading.");
},
/**
* Configure the "Feed Rate Override" button and the "Tool Changes" pulldown
*/
setupSecondaryButtons: function() {
// setup Feed Rate Override to toggle the actual region
$('.com-chilipeppr-widget-gcode-showfr').click(this.onToggleShowFeedRateOverride.bind(this));
},
onToggleShowFeedRateOverride: function() {
var btnEl = $('.com-chilipeppr-widget-gcode-showfr');
var regionEl = $('#com-chilipeppr-widget-gcode-feedrate');
if (btnEl.hasClass("active")) {
// it's showing, so hide it
regionEl.addClass("hidden");
// remove our active tag
btnEl.removeClass("active");
} else {
// it's hidden, so show it
regionEl.removeClass("hidden");
// show us as pressed in
btnEl.addClass("active");
}
},
/**
* This method scans the Gcode for tool changes and then populates the pulldown menu so
* you can easily jump to the changes in the file and continue where you left off.
*/
toolChanges: {},
toolChangesKeys: [], // need to store keys in own array cuz keys in javascript are strings and we wants ints
toolComments: {},
setupToolChanges: function() {
// scan gcode for tool change info
console.log("about to look for tool changes in this.fileLines. lines:", this.fileLines.length);
this.toolComments = {};
this.toolChanges = {};
this.toolChangesKeys = [];
for (var i = 0; i < this.fileLines.length; i++) {
var line = this.fileLines[i];
// see if we have line where comment starts with
// look for something like:
// (T1 D=3.175 CR=0. - ZMIN=-4.2 - FLAT END MILL)
if (line.match(/\(T(\d+)\s+(.*)\)/i)) {
var toolNum = parseInt(RegExp.$1);
var toolComment = "T" + toolNum + " " + RegExp.$2;
console.log("found tool comment. lineNum:", i, "toolNum:", toolNum, "comment:", toolComment, "line:", line);
this.toolComments[toolNum] = {
lineNum: i+1,
toolNum: toolNum,
toolComment: toolComment,
}
}
// look for M6 line
if (line.match(/M6|M06|M006/i)) {
var toolNum;
if (line.match(/T(\d+)/i)) {
toolNum = parseInt(RegExp.$1);
}
this.toolChanges[(i+1)] = {
lineNum: i+1,
toolNum: toolNum,
};
this.toolChangesKeys.push(i+1);
console.log("found tool change. lineNum:", i, "line:", line);
}
}
console.log("this.toolComments:", this.toolComments);
console.log("this.toolChanges:", this.toolChanges);
// now look for a comment up to 10 lines above the M6 tool change line to see if any comments are there
var keys = this.toolChangesKeys; //Object.keys(this.toolChanges).sort();
console.log("looking for comments above m6 to get a label for this tool change. keys:", keys);
for (var i = 0; i < keys.length; i++) {
var toolChangeLineNum = keys[i];
var lookBackToLineNum = toolChangeLineNum - 10;
if (lookBackToLineNum < 1) lookBackToLineNum = 1; // first line
// now look backwards until we've seen just 1 comment
for (var lineNum = toolChangeLineNum; lineNum >= lookBackToLineNum; lineNum--) {
var line = this.fileLines[lineNum - 1]; // index of array is 1 less than lineNum
console.log("looking at lineNum:", lineNum, "line:", line);
// see if comment
if ( line.match(/\((.*?)\)/) || line.match(/;(.*)/) ) {
var comment = RegExp.$1;
console.log("found comment:", comment);
// stick comment into toolChanges
this.toolChanges[toolChangeLineNum].sectionComment = comment;
// break since we found one
break;
}
}
}
console.log("after adding section comments. this.toolChanges:", this.toolChanges);
// now populate the pulldown
var keys = this.toolChangesKeys; //Object.keys(this.toolChanges).sort();
var ddEl = $('.com-chilipeppr-widget-gcode-menuToolChange');
// wipe menu
ddEl.html('<li role="presentation" class="dropdown-header com-chilipeppr-widget-gcode-toolchanges-hdr">Click the item below to jump to the line in the Gcode so you can start playing from there.</li>');
if (keys.length == 0) {
// insert that no tool changes
var menuEl = $('<li role="presentation" class="dropdown-header com-chilipeppr-widget-gcode-toolchanges-hdr">(No Tool Changes in Gcode)</li>');
ddEl.append(menuEl);
}
for (var i = 0; i < keys.length; i++) {
var toolChange = this.toolChanges[keys[i]];
var tool = this.toolComments[toolChange.toolNum];
var str = "";
if ('sectionComment' in toolChange) {
str = str + '<span class="small" style="font-weight:bold;">' + toolChange.sectionComment + '</span><br>';
}
str = str + "Tool " + toolChange.toolNum + " on line " + toolChange.lineNum;
if (tool != null) {
str = str + "<br>" + tool.toolComment;
}
var menuEl = $('<li><a class="" style="cursor:pointer;">' + str + '</a></li>');
menuEl.click(toolChange, this.onToolChangesSelectMenu.bind(this));
ddEl.append(menuEl);
console.log("added Tool Changes menu item:", menuEl);
}
},
/**
* Called when user clicks a Tool Changes menu item. They want to jump to that line.
*/
onToolChangesSelectMenu: function(data) {
console.log("got click on Tool Changes menu. data:", data.data);
var toolInfo = data.data;
// u get data like: {lineNum: 11, toolNum: 1}
this.jumpToLine(toolInfo.lineNum);
},
/**
* This method is called after the Gcode file is loaded so you can do some post-processing.
*/
onAfterGcodeFileLoaded: function() {
this.setupToolChanges();
},
setupJumpToLine: function() {
$('#com-chilipeppr-widget-gcode-jumptoline').click(this.onJumpToLine.bind(this));
},
onJumpToLine: function(evt) {
console.log("got onJumpToLine. evt:", evt);
console.log("this.lastLineMarkedExecuted:", this.lastLineMarkedExecuted);
var lastLine = "";
if (this.lastLineMarkedExecuted && this.lastLineMarkedExecuted > 0)
lastLine = this.lastLineMarkedExecuted;
var line = prompt("Please enter the line number to jump to.", lastLine);
var lineNum = parseInt(line);
if (lineNum > 0)
chilipeppr.publish("/com-chilipeppr-widget-gcode/jumpToLine", lineNum);
else
chilipeppr.publish("/com-chilipeppr-elem-flashmsg/flashmsg", "Error on Line Jump", "We had a problem parsing the line number you gave us.", 1000, true);
},
getEstimates: function() {
var that = this;
this.get3dObj(function() {
// when we get this callback, we should have a 3dobj
console.log("getEstimates got obj3d:", this.obj3d);
if (this.obj3d && this.obj3d.userData && this.obj3d.userData.lines) {
var lastLine = this.obj3d.userData.lines[this.obj3d.userData.lines.length - 1];
if ('p2' in lastLine && 'timeMinsSum' in lastLine.p2) {
console.log("we got a timeMinsSum:", lastLine.p2.timeMinsSum);
var estDurMins = lastLine.p2.timeMinsSum;
var str = this.toHHMMSS(estDurMins * 60); // expect seconds
$('#com-chilipeppr-widget-gcodeviewer #gcode-time-est').text(str);
}
}
});
},
setupStatusSteps: function() {
var html =
"<div id=\"com-chilipeppr-widget-gcodeviewer-popover-steps\" >Your Gcode moves through 5 steps from ChiliPeppr all the way through execution." +
"<table class=\"table table-condensed table-striped\"><tr><th>Step </th><th>Status</th><th>Description</th></tr>" +
"<tr><td>1</td><td><span class=\"glyphicon glyphicon-ok gcode-sent\"></span> Sent</td><td>Your Gcode has been sent to the Serial Port JSON Server by the Serial Port Widget.</td></tr>" +
"<tr><td>2</td><td><span class=\"glyphicon glyphicon-ok gcode-queued\"></span> Queued</td><td>Gcode is queued inside the Serial Port JSON Server and waiting to be sent to the CNC controller's serial buffer.</td></tr>" +
"<tr><td>3</td><td><span class=\"glyphicon glyphicon-ok gcode-written\"></span> Written</td><td>Gcode has been written to the serial buffer of your CNC controller and removed from SPJS's buffer. </td></tr>" +
"<tr><td>4</td><td><span class=\"glyphicon glyphicon-ok gcode-completed\"></span> Completed </td><td>Gcode is completed when the CNC controller tells us it read the Gcode from its serial buffer and placed the Gcode into its planner buffer (this means the Gcode may only get executed seconds into the future as the planner buffer works its way through lines.) </td></tr>" +
"<tr><td>5</td><td><span class=\"glyphicon glyphicon-ok gcode-executed\"></span> Executed</td><td>Optional. The CNC controller tells us that your Gcode was actually executed. This is the final step. On controllers like TinyG this data only comes back if line numbers are in your Gcode.</td></tr>" +
"<tr><td>6</td><td><span class=\"glyphicon glyphicon-ok gcode-error\"></span> Error/Unsupported Command</td><td>Optional. The CNC controller failed to execute the line of gcode. This could indicate a problem with your gcode syntax, or that your CNC controller does not understand a particular gcode command.</td></tr>" +
"</table></div>";
$("#com-chilipeppr-widget-gcodeviewer .stats-hdr").popover({
content: html
})
.on("show.bs.popover", function(){ $(this).data("bs.popover").tip().css("max-width", "600px"); });
},
setupPlayPauseStopPubSub: function() {
var that = this;
/*chilipeppr.subscribe("/" + this.id + "/play", this, function() { that.onPlay(true); } );
chilipeppr.subscribe("/" + this.id + "/pause", this, function() { that.onPause(true); } );
chilipeppr.subscribe("/" + this.id + "/stop", this, function() { that.onStop(true); } );*/
chilipeppr.subscribe("/" + this.id + "/play", this, function() { that.onPlay({}); } );
chilipeppr.subscribe("/" + this.id + "/pause", this, function() { that.onPause({}); } );
chilipeppr.subscribe("/" + this.id + "/stop", this, function() { that.onStop({}); } );
},
setupSendGcodePubSub: function() {
chilipeppr.subscribe("/" + this.id + "/requestGcode", this, this.publishGcode);
},
publishGcode: function() {
var gcode = {
lines: this.fileLines,
metadata: this.metaLines
}
chilipeppr.publish("/" + this.id + "/recvGcode", gcode);
},
// options: stores the cookie settings for the user
// example: {whenPlay: "serial", perRow: "3d", perRow3dType: "goto"}
// it is set during the setupOptionsModal()
options: null,
setupOptionsModal: function() {
console.log("setupOptionsModal");
// read vals from cookies
var options = $.cookie('com-chilipeppr-widget-gcode-options');
if (true && options) {
options = $.parseJSON(options);
console.log("just evaled options: ", options);
if (!('removeemptylines' in options))
options.removeemptylines = true;
// only addlinenumbs by default if workspace asked us to
if (this.lineNumbersOnByDefault) {
if (!('addlinenums' in options))
options.addlinenums = true;
}
// Default new options for backwards compatibility
if (!('sendOnM6' in options)) {
options.sendOnM6 = "";
}
if (!('sendOffM6' in options)) {
options.sendOffM6 = "";
}
if (!('probeCmd' in options)) {
options.probeCmd = "G28.2 Z0";
}
} else {
options = {whenPlay: "serial", perRow: "3d", perRow3dType: "goto", delayPerLine: this.delayPerLine, pauseOnM6: true, preUpload: 'none', multiLineMode: 'yes', multiLines: 50, ppsOnPlayFlush: false, ppsOnStopFeedhold: false, ppsOnPauseFeedhold: false, ppsOnUnpauseResume: false, removeemptylines: true, addlinenums: true, sendOnM6: "", sendOffM6: "", probeCmd: "G28.2 Z0"};
}
this.options = options;
console.log("options:", options);
// setup the correct radio buttons in dialog
if (this.options.whenPlay == "serial")
$('#com-chilipeppr-widget-gcode-option-whenplay-serial').prop('checked', true);
else
$('#com-chilipeppr-widget-gcode-option-whenplay-3d').prop('checked', true);
if (this.options.perRow == "serial")
$('#com-chilipeppr-widget-gcode-option-perrow-serial').prop('checked', true);
else
$('#com-chilipeppr-widget-gcode-option-perrow-3d').prop('checked', true);
if (this.options.perRow3dType == "goto")
$('#com-chilipeppr-widget-gcode-option-perrow-3d-goto').prop('checked', true);
else
$('#com-chilipeppr-widget-gcode-option-perrow-3d-anim').prop('checked', true);
if (this.options.pauseOnM6) {
$('#com-chilipeppr-widget-gcode-option-pauseOnM6').prop('checked', true);
$('#com-chilipeppr-widget-gcode-option-pauseOnM6-alt').prop('checked', true);
}
$('#com-chilipeppr-widget-gcode-option-sendonM6').val(this.options.sendOnM6);
$('#com-chilipeppr-widget-gcode-option-sendoffM6').val(this.options.sendOffM6);
$('#com-chilipeppr-widget-gcode-option-probe-cmd').val(this.options.probeCmd);
if (this.options.preUpload) {
var opt = ["none", "100", "1000", "10000", "20000"];
var that = this;
opt.forEach(function(item,indx) {
console.log("indx:", indx, "item:", item, "preUpload:", that.options.preUpload);
if (that.options.preUpload == item) {
$('#com-chilipeppr-widget-gcode-option-upload-' + item ).prop('checked', true);
} else {
$('#com-chilipeppr-widget-gcode-option-upload-' + item).prop('checked', false);
}
});
}
if (this.options.multiLineMode) {
if (this.options.multiLineMode == "yes") {
$('#com-chilipeppr-widget-gcode-option-multilinemode-yes').prop('checked', true);
this.isInMultiLineMode = true;
} else {
$('#com-chilipeppr-widget-gcode-option-multilinemode-no').prop('checked', true);
this.isInMultiLineMode = false;
}
this.options.multiLines = parseInt(this.options.multiLines);
if (this.options.multiLines < 1) this.options.multiLines = 1;
$('#com-chilipeppr-widget-gcode-option-multiline').val(this.options.multiLines);
this.multiLines = this.options.multiLines;
}
// setup play/pause/stop options
if (this.options.ppsOnPlayFlush)
$('#com-chilipeppr-widget-gcode-option-ppsOnPlayFlush').prop('checked', true);
if (this.options.ppsOnStopFeedhold)
$('#com-chilipeppr-widget-gcode-option-ppsOnStopFeedhold').prop('checked', true);
if (this.options.ppsOnPauseFeedhold)
$('#com-chilipeppr-widget-gcode-option-ppsOnPauseFeedhold').prop('checked', true);
if (this.options.ppsOnUnpauseResume)
$('#com-chilipeppr-widget-gcode-option-ppsOnUnpauseResume').prop('checked', true);
// setup delay per line
if (this.options.delayPerLine) {
this.delayPerLine = parseInt(this.options.delayPerLine);
$('#com-chilipeppr-widget-gcode-option-delayPerLine').val(this.delayPerLine);
}
if (this.options.removeemptylines) {
$('#com-chilipeppr-widget-gcode-option-removeemptylines').prop('checked', true);
}
if (this.options.addlinenums) {
$('#com-chilipeppr-widget-gcode-option-addlinenums').prop('checked', true);
}
// setup "save changes" button
var that = this;
$("#com-chilipeppr-widget-gcode-modal .optionsbtnsave").click(function(evt) {
console.log("Got save changes on gcode options dialog. evt:", evt);
that.saveOptionsModal();
that.hideOptionsModal();
});
// also, if ANYTHING is clicked, just go ahead and save all options
$("#com-chilipeppr-widget-gcode-modal input").click(function(evt) {
console.log("got click on evt:", evt);
that.saveOptionsModal();
});
$("#com-chilipeppr-widget-gcode-modal #com-chilipeppr-widget-gcode-option-multiline").blur(function(evt) {
console.log("got blur on evt:", evt);
that.saveOptionsModal();
});
$("#com-chilipeppr-widget-gcode-modal #com-chilipeppr-widget-gcode-option-delayPerLine").blur(function(evt) {
console.log("got blur on evt:", evt);