forked from chilipeppr/workspace-tinyg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
auto-generated-workspace.html
1952 lines (1777 loc) · 90.1 KB
/
auto-generated-workspace.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>Workspace / TinyG / Darkness</title>
<!-- ChiliPeppr is based on bootstrap CSS. -->
<link rel="stylesheet" type="text/css" href="//maxcdn.bootstrapcdn.com/bootswatch/3.3.6/cyborg/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'>
.workspace-dropdown li {
padding: 6px 20px;
}
.btn-ws {
width:100%;
/*margin:6px 20px;*/
}
.zipwhip-button {
/*line-height:0px;*/
/*padding: 1px 2px;*/
}
.zipwhip-recvtext-button {
/*height:22px;*/
}
.zipwhip {
background: url('http://www.zipwhip.com/resources/images/favicon.ico') no-repeat top left;
display: inline-block;
/*margin: 1px 0;*/
margin: -4px 5px;
height: 16px;
width: 16px;
/* line-height:0px; */
background-size: 16px 16px;
/* -webkit-background-size: 50% 50%; Safari
-khtml-background-size: 50% 50%; Konqueror
-moz-background-size: 50% 50%; Firefox */
}
#com-chilipeppr-ws-gcode-wrapper .dropdown-menu {
/* z-index:6; */
/* position:inherit; */
}
#com-chilipeppr-ws-gcode-wrapper .panel-heading {
/* padding: 10px 12px; */
}
#com-chilipeppr-ws-gcode-wrapper .well.com-chilipeppr-ws-hdr {
/* padding: 10px 15px; */
}
#com-chilipeppr-ws-gcode-dragdrop {
/*margin-right:6px;*/
}
#com-chilipeppr-ws-gcode-hdr {
height:64px;
margin-bottom:10px;
}
.panel {
margin-bottom:10px;
}
#com-chilipeppr-ws-gcode-wrapper #com-chilipeppr-widget-gcode-body {
/* max-height:250px; */
height:250px;
}
#com-chilipeppr-ws-gcode-wrapper .com-chilipeppr-widget-spconsole {
margin-bottom:0;
}
#com-chilipeppr-ws-gcode-dragdropoverlay {
position: absolute;
top:0;
bottom:0;
left:0;
right:0;
z-index:10;
background-color: rgba(255, 255, 255, 0.5);
font-size: 20px;
padding:100px;
border: 3px dashed #3276b1;
text-align:center;
pointer-events: none;
}
#com-chilipeppr-ws-gcode-dragdropoverlay .well {
background-color: rgba(127, 127, 127, 0.5);
}
#com-chilipeppr-ws-gcode-wrapper.hover {
/* background-color: blue; */
}
.com-chilipeppr-elem-dragdrop {
/* border: 1px dashed gray; */
/* border-radius: 4px; */
padding:0;
margin-right:6px;
}
.padrt {
padding-right:10px;
padding-left:10px;
}
.zhigh {
/* z-index:5; */
position:relative;
}
#com-chilipeppr-ws-gcode-wrapper .dropdown-menu {
/* z-index:20; */
}
#mainnav {
z-index:5;
}
.nopadding {
padding:0;
}
#com-chilipeppr-widget-3dviewer .panel-heading, #com-chilipeppr-3dviewer-controlpanel .panel-heading {
background:none;
/* border:none; */
padding:10px 15px;
margin-bottom:0;
}
#com-chilipeppr-3dviewer-controlpanel {
/* padding:0 10px; */
float:left;
}
#com-chilipeppr-gcode-list {
/* padding-right: 10px; */
/* z-index:5; */
/* position: relative; */
}
#com-chilipeppr-serialport-ws-hdr {
/* z-index:5; */
}
.well.com-chilipeppr-ws-hdr {
padding:10px 15px;
/* padding:8px; */
/* padding-left:15px; */
/* margin:0; */
/* margin-bottom:10px; */
}
#chilipeppr-3dviewer {
/* z-index: -1; */
padding-right:10px;
}
#com-chilipeppr-widget-3dviewer-renderArea {
/* z-index:0; */
}
.row .widget {
margin:0;
padding:0;
}
.dropArea.hover {
background: #dddddd;
}
#pnlWorkspace.hover {
background: red;
}
body.hover {
background: #5bc0de;
}
#chilipeppr-serialport-wrapper .com-chilipeppr-widget-serialport-spselector {
max-height: none;
}
#chilipeppr-serialport-log {
/*height:200px;*/
/* padding-right:10px; */
/* z-index:5; */
/* position: relative; */
}
.nomargin {
margin:0;
}
.noheight {
height:0;
}
.billboard-content {
padding: 6px 20px;
}
.billboard-title {
margin-bottom:6px;
}
.billboard-url {
/* font-size: 9px; */
padding-top:0px;
margin-bottom:6px;
font-size:12px;
}
.billboard-img {
border:0px solid red;
border-radius: 5px;
position: relative;
width:100%;
height:160px;
background-position: center;
background-size: cover;
}
.billboard-imgcontain {
border:0px solid red;
position: relative;
}
.billboard-stats {
position: absolute;
top: 4px;
left: 10px;
}
.billboard-desc {
/* font-size:11px; */
}
.billboard-detail-title {
font-weight: bold;
}
.billboard-stats2 {
position: absolute;
bottom: 0px;
left: 0px;
right: 0px;
padding: 4px 10px 10px 10px;
background-color: rgba(255, 255, 255, 0.5);
}
#com-chilipeppr-widget-xyz-body .com-chilipeppr-xyz-label-well, #com-chilipeppr-widget-xyz-ftr .btn {
background-color: #232323 !important;
}
.navbar-brand.main-brand>img {
display: inline;
}
.com-chilipeppr-widget-xyz-buttonarray>table {
background-color: transparent;
}
#com-chilipeppr-ws-gcode-hdr {
background-color: #232323
}
#com-chilipeppr-ws-menu .btn {
margin-top: 5px;
}
#com-chilipeppr-ws-gcode-hdr .tabmode-button {
}
.workspace-title, .panel-title {
color: #2a9fd6;
}
#com-chilipeppr-3dviewer-controlpanel .com-chilipeppr-widget-3dviewer-simulator-title {
border-color: rgb(102, 175, 233);
}
::-webkit-scrollbar
{
width: 12px; /* for vertical scrollbars */
height: 12px; /* for horizontal scrollbars */
}
::-webkit-scrollbar-track
{
background: rgba(0, 0, 0, 0.1);
}
::-webkit-scrollbar-thumb
{
background: rgba(0, 0, 0, 0.5);
}
.form-control {
background-color: transparent !important;
}
.com-chilipeppr-xyz-pos-well>input {
background-color: #555555 !important;
}
#com-chilipeppr-widget-xyz-machinecoords .com-chilipeppr-xyz-well {
background-color: #232323 !important;
}
.gcode-sent {
color: #ff8800 !important;
background-color: transparent !important;
}
.gcode-queued {
color: #2a9fd6 !important;
background-color: transparent !important;
}
.gcode-written {
color: #77b300 !important;
background-color: transparent !important;
}
.gcode-completed {
color: #000000 !important;
background-color: #2a9fd6 !important;
}
.gcode-executed {
color: #000000 !important;
background-color: #77b300 !important;
}
.gcode-error{
color: #000000 !important;
background-color: #cc0000 !important;
}
#com-chilipeppr-widget-gcode-tbl .indx {
color: #9933cc;
}
#com-chilipeppr-widget-gcode-tbl .com-chilipeppr-gcode-tip {
background-color: #9933cc;
}
#com-chilipeppr-widget-gcode-body-2col {
width: 100%;
}
.com-chilipeppr-widget-gcodeviewer-coords {
background: black !important;
}
.com-chilipeppr-widget-gcodeviewer-coords-start .coords-lbl, .com-chilipeppr-widget-gcodeviewer-coords-end .coords-lbl {
background-color: black !important;
}
.com-chilipeppr-widget-gcodeviewer-coords .coords-axis {
background-color: #9933cc !important;
}
.com-chilipeppr-widget-spconsole-console-log pre {
color: #2a9fd6 !important;
}
</style>
<script type='text/javascript'>
//<![CDATA[
/* global cpdefine chilipeppr cprequire */
cprequire_test(["inline:com-chilipeppr-workspace-tinyg"], function(ws) {
console.log("initting workspace");
/**
* The Root workspace (when you see the ChiliPeppr Header) auto Loads the Flash
* Widget so we can show the 3 second flash messages. However, in test mode we
* like to see them as well, so just load it from the cprequire_test() method
* so we have similar functionality when testing this workspace.
*/
var loadFlashMsg = function() {
chilipeppr.load("#com-chilipeppr-widget-flash-instance",
"http://raw.githubusercontent.com/chilipeppr/element-flash/master/auto-generated-widget.html",
function() {
console.log("mycallback got called after loading flash msg module");
cprequire(["inline:com-chilipeppr-elem-flashmsg"], function(fm) {
//console.log("inside require of " + fm.id);
fm.init();
});
}
);
};
loadFlashMsg();
// Init workspace
ws.init();
// Do some niceties for testing like margins on widget and title for browser
$('title').html("Tinyg Workspace");
$('body').css('padding', '10px');
} /*end_test*/ );
// This is the main definition of your widget. Give it a unique name.
cpdefine("inline:com-chilipeppr-workspace-tinyg", ["chilipeppr_ready"], function() {
return {
/**
* The ID of the widget. You must define this and make it unique.
*/
id: "com-chilipeppr-workspace-tinyg", // Make the id the same as the cpdefine id
name: "Workspace / TinyG / Darkness", // The descriptive name of your widget.
desc: `This is a workspace for ChiliPeppr's Hardware Fiddle. It is geared towards CNC machines using TinyG. I've added a dark theme based on bootswatch cyborg by Thomas Park and a tablet mode that can be accessed via the main workspace menu. Try it at <a href="http://chilipeppr.com/darkness">chilipeppr.com/darkness</a>`,
url: "http://raw.githubusercontent.com/voodoomm/workspace-tinyg-darkness/master/auto-generated-workspace.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/voodoomm/workspace-tinyg-darkness", // 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/voodoomm/workspace-tinyg-darkness", // The backing github repo
testurl: "http://workspace-tinyg-darkness-voodoomm.c9users.io/workspace.html", // The standalone working widget so can view it working by itself
foreignSubscribe: {
"/com-chilipeppr-elem-dragdrop/ondragover": "The Chilipeppr drag drop element will publish on channel /com-chilipeppr-elem-dragdrop/ondropped when a file is dropped so we subscribe to it so we can load a Gcode file when the user drags it onto the browser. It also adds a hover class to the bound DOM elem so we can add a CSS to hilite on hover",
"/com-chilipeppr-elem-dragdrop/ondragleave": "We need to know when the drag is over to remove the CSS hilites.",
"/com-chilipeppr-widget-gcode/resize": "We watch if the Gcode viewer resizes so that we can reposition or resize other elements in the workspace. Specifically we ask the Serial Port Console to resize. We also redraw the 3D Viewer so it fills the whole screen."
},
foreignPublish: {},
/**
* Contains reference to the Console widget object. Hang onto the reference
* so we can resize it when the window resizes because we want it to manually
* resize to fill the height of the browser so it looks clean.
*/
widgetConsole: null,
/**
* Contains reference to the Serial Port JSON Server object.
*/
widgetSpjs: null,
/**
* The workspace's init method. It loads the all the widgets contained in the workspace
* and inits them.
*/
init: function() {
$('link[href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css"]').attr('href','//maxcdn.bootstrapcdn.com/bootswatch/3.3.6/cyborg/bootstrap.min.css');
this.loadTabletMode();
// Most workspaces will instantiate the Serial Port JSON Server widget
this.loadSpjsWidget();
// Most workspaces will instantiate the Serial Port Console widget
this.loadConsoleWidget();
// This is a huge method that was built from the original jsfiddle workspace
// we should technically put each widget in its own method for loading
this.loadWidgets();
// Create our workspace upper right corner triangle menu
this.loadWorkspaceMenu();
// Add our billboard to the menu (has name, url, picture of workspace)
this.addBillboardToWorkspaceMenu();
// Setup an event to react to window resize. This helps since
// some of our widgets have a manual resize to cleanly fill
// the height of the browser window. You could turn this off and
// just set widget min-height in CSS instead
this.setupResize();
setTimeout(function() {
$(window).trigger('resize');
}, 3000);
},
/**
* Returns the billboard HTML, CSS, and Javascript for this Workspace. The billboard
* is used by the home page, the workspace picker, and the fork pulldown to show a
* consistent name/image/description tag for the workspace throughout the ChiliPeppr ecosystem.
*/
getBillboard: function() {
var el = $('#' + this.id + '-billboard').clone();
el.removeClass("hidden");
el.find('.billboard-desc').text(this.desc);
return el;
},
/**
* Inject the billboard into the Workspace upper right corner pulldown which
* follows the standard template for workspace pulldown menus.
*/
addBillboardToWorkspaceMenu: function() {
// get copy of billboard
var billboardEl = this.getBillboard();
$('#' + this.id + ' .com-chilipeppr-ws-billboard').append(billboardEl);
},
/**
* Listen to window resize event.
*/
setupResize: function() {
$(window).on('resize', this.onResize.bind(this));
},
/**
* When browser window resizes, forcibly resize the Console window
*/
onResize: function() {
if (this.widgetConsole) this.widgetConsole.resize();
},
/**
* Load the Serial Port JSON Server widget via chilipeppr.load()
*/
loadSpjsWidget: function(callback) {
var that = this;
chilipeppr.load(
"#com-chilipeppr-widget-spjs-instance",
"http://raw.githubusercontent.com/chilipeppr/widget-spjs/master/auto-generated-widget.html",
function() {
console.log("mycallback got called after loading spjs module");
cprequire(["inline:com-chilipeppr-widget-serialport"], function(spjs) {
//console.log("inside require of " + fm.id);
spjs.setSingleSelectMode();
spjs.init({
isSingleSelectMode: true,
defaultBuffer: "tinyg",
defaultBaud: 115200,
bufferEncouragementMsg: 'For your device please choose the "tinyg" or "tinygg2" buffer in the pulldown and a 115200 baud rate before connecting.'
});
//spjs.showBody();
//spjs.consoleToggle();
that.widgetSpjs - spjs;
if (callback) callback(spjs);
});
}
);
},
/**
* Load the Console widget via chilipeppr.load()
*/
loadConsoleWidget: function(callback) {
var that = this;
chilipeppr.load(
"#com-chilipeppr-widget-console-instance",
"http://raw.githubusercontent.com/chilipeppr/widget-console/master/auto-generated-widget.html",
function() {
// Callback after widget loaded into #com-chilipeppr-widget-spconsole-instance
cprequire(
["inline:com-chilipeppr-widget-spconsole"], // the id you gave your widget
function(mywidget) {
// Callback that is passed reference to your newly loaded widget
console.log("My Console widget just got loaded.", mywidget);
that.widgetConsole = mywidget;
// init the serial port console
// 1st param tells the console to use "single port mode" which
// means it will only show data for the green selected serial port
// rather than for multiple serial ports
// 2nd param is a regexp filter where the console will filter out
// annoying messages you don't generally want to see back from your
// device, but that the user can toggle on/off with the funnel icon
that.widgetConsole.init(true, /^{/);
if (callback) callback(mywidget);
}
);
}
);
},
/**
* Load the workspace menu and show the pubsubviewer and fork links using
* our pubsubviewer widget that makes those links for us.
*/
loadWorkspaceMenu: function(callback) {
// Workspace Menu with Workspace Billboard
var that = this;
chilipeppr.load(
"http://raw.githubusercontent.com/chilipeppr/widget-pubsubviewer/master/auto-generated-widget.html",
function() {
require(['inline:com-chilipeppr-elem-pubsubviewer'], function(pubsubviewer) {
var el = $('#' + that.id + ' #com-chilipeppr-ws-menu .dropdown-menu-ws');
console.log("got callback for attachto menu for workspace. attaching to el:", el);
pubsubviewer.attachTo(
el,
that,
"Workspace"
);
if (callback) callback();
});
}
);
},
loadTabletMode: function(callback) {
$('#com-chilipeppr-ws-gcode-dragdrop').next('div').append('<button type="button" class="btn btn-xs btn-default tabmode-button" data-container="body" data-toggle="popover" data-placement="auto" data-content="Hide 3d viewer." data-trigger="hover" data-delay="100">Tablet Mode</button>');
$('#com-chilipeppr-3dviewer').parent().closest('div').addClass('tabmodecol');
$('#com-chilipeppr-xyz').parent().closest('div').addClass('tabmodecol');
$('#com-chilipeppr-ws-gcode-hdr .tabmode-button').click(function (evt) {
console.log("hide/unhide 3d");
if ($('#com-chilipeppr-3dviewer').hasClass('hidden')) {
$('#com-chilipeppr-3dviewer').removeClass('hidden');
$('#com-chilipeppr-3dviewer-controlpanel').removeClass('hidden');
$('.tabmodecol').removeClass('col-xs-6');
$('.tabmodecol').addClass('col-xs-3');
} else {
$('#com-chilipeppr-3dviewer').addClass('hidden');
$('#com-chilipeppr-3dviewer-controlpanel').addClass('hidden');
$('.tabmodecol').removeClass('col-xs-3');
$('.tabmodecol').addClass('col-xs-6');
}
});
},
loadWidgets: function(callback) {
// create a workspace object reference to this so inside the anonymous functions below
// the workspace can be referred to
var wsObj = this;
// Load XBox Controller Widget
chilipeppr.load(
"#com-chilipeppr-ws-xbox",
"http://raw.githubusercontent.com/voodoomm/widget-xbox/master/auto-generated-widget.html",
function() {
// Callback after widget loaded into #myDivWidgetXbox
// Now use require.js to get reference to instantiated widget
cprequire(
["inline:com-chilipeppr-widget-xbox"], // the id you gave your widget
function(myObjWidgetXbox) {
// Callback that is passed reference to the newly loaded widget
console.log("Widget / Xbox just got loaded.", myObjWidgetXbox);
myObjWidgetXbox.init();
// setup toggle button
var zwBtn = $('#com-chilipeppr-ws-menu .xbox-button');
var zwDiv = $('#com-chilipeppr-ws-xbox');
zwBtn.click(function() {
if (zwDiv.hasClass("hidden")) {
// unhide
zwDiv.removeClass("hidden");
zwBtn.addClass("active");
}
else {
zwDiv.addClass("hidden");
zwBtn.removeClass("active");
}
$(window).trigger('resize');
});
}
);
}
);
this.font2gcodeObj = function() {
return {
name: "font2gcode",
url: "http://raw.githubusercontent.com/chilipeppr/widget-font2gcode/master/auto-generated-widget.html",
id: "com-zipwhip-widget-font2gcode",
btn: $('#com-chilipeppr-ws-menu .font2gcode-button'),
div: $('#com-chilipeppr-ws-font2gcode'),
instance: null,
init: function() {
this.btn.click(this.toggle.bind(this));
// do NOT dynamically load this one since it has a pubsub that's key to get called
// and in future may register for drag/drop events for .txt files
this.load();
// we need to subscribe to the /didDrop signal of this widget so we know to show it
//chilipeppr.subscribe("/" + this.id + "/didDrop", this, this.show);
console.log("done instantiating " + this.name + " add-on widget");
},
load: function(callback) {
var that = this;
chilipeppr.load(
this.div.prop("id"),
this.url,
function() {
// Callback after widget loaded into #myDivWidgetRecvtext
// Now use require.js to get reference to instantiated widget
cprequire(
["inline:" + that.id], // the id you gave your widget
function(myObjWidget) {
// Callback that is passed reference to the newly loaded widget
console.log(that.name + " just got loaded.", myObjWidget);
//myObjWidget.init(myObjWidget.activate.bind(myObjWidget));
myObjWidget.init();
//myObjWidget.activate();
that.instance = myObjWidget;
if (callback) callback(that.instance);
}
);
}
);
},
toggle: function() {
if (this.div.hasClass("hidden")) {
// unhide
this.show();
}
else {
this.hide();
}
},
show: function() {
this.div.removeClass("hidden");
this.btn.addClass("active");
console.log("got show for " + this.name + ", this:", this, "wsObj:", wsObj);
// see if instantiated already
// if so, just activate
if (this.instance != null) {
console.log("activating " + this.name + " instead of re-instantiating cuz already created");
this.instance.activate();
//if (callback) callback(this.instance);
}
else {
// otherwise, dynamic load
console.log(this.name + " appears to not be instantiated, let us load it from scratch")
}
$(window).trigger('resize');
},
hide: function() {
this.div.addClass("hidden");
this.btn.removeClass("active");
console.log("got hide for " + this.name + ". this:", this, "wsObj:", wsObj);
if (this.instance != null) {
this.instance.unactivate();
}
$(window).trigger('resize');
}
};
}();
this.font2gcodeObj.init();
//End Font2Gcode
this.svg2gcodeObj = function() {
return {
name: "svg2gcode",
url: "http://raw.githubusercontent.com/chilipeppr/widget-svg2gcode/master/auto-generated-widget.html",
id: "com-zipwhip-widget-svg2gcode",
btn: $('#com-chilipeppr-ws-menu .svg2gcode-button'),
div: $('#com-chilipeppr-ws-svg2gcode'),
instance: null,
init: function() {
this.btn.click(this.toggle.bind(this));
// do NOT dynamically load this one since it registers for drag/drop events for .svg files
this.load();
// we need to subscribe to the /didDrop signal of this widget so we know to show it
chilipeppr.subscribe("/" + this.id + "/didDrop", this, this.show);
console.log("done instantiating " + this.name + " add-on widget");
},
load: function(callback) {
var that = this;
chilipeppr.load(
this.div.prop("id"),
this.url,
function() {
// Callback after widget loaded into #myDivWidgetRecvtext
// Now use require.js to get reference to instantiated widget
cprequire(
["inline:" + that.id], // the id you gave your widget
function(myObjWidget) {
// Callback that is passed reference to the newly loaded widget
console.log(that.name + " just got loaded.", myObjWidget);
//myObjWidget.init(myObjWidget.activate.bind(myObjWidget));
myObjWidget.init();
//myObjWidget.activate();
that.instance = myObjWidget;
if (callback) callback(that.instance);
}
);
}
);
},
toggle: function() {
if (this.div.hasClass("hidden")) {
// unhide
this.show();
}
else {
this.hide();
}
},
show: function() {
this.div.removeClass("hidden");
this.btn.addClass("active");
console.log("got show for " + this.name + ", this:", this, "wsObj:", wsObj);
// see if instantiated already
// if so, just activate
if (this.instance != null) {
console.log("activating " + this.name + " instead of re-instantiating cuz already created");
this.instance.activate();
//if (callback) callback(this.instance);
}
else {
// otherwise, dynamic load
console.log(this.name + " appears to not be instantiated, let us load it from scratch")
}
$(window).trigger('resize');
},
hide: function() {
this.div.addClass("hidden");
this.btn.removeClass("active");
console.log("got hide for " + this.name + ". this:", this, "wsObj:", wsObj);
if (this.instance != null) {
this.instance.unactivate();
}
$(window).trigger('resize');
}
};
}();
this.svg2gcodeObj.init();
//End SVG2Gcode
// Inject the Font2Gcode widget
/*
$('<div class="zhigh" id="com-chilipeppr-ws-font2gcode"></div>')
.insertAfter('#com-chilipeppr-ws-zipwhip-recvtext');
chilipeppr.load(
"#com-chilipeppr-ws-font2gcode",
"http://raw.githubusercontent.com/chilipeppr/widget-font2gcode/master/auto-generated-widget.html",
function() {
// Callback after widget loaded into #myDivComZipwhipWidgetFont2gcode
// Now use require.js to get reference to instantiated widget
cprequire(
["inline:com-zipwhip-widget-font2gcode"], // the id you gave your widget
function(myObjComZipwhipWidgetFont2gcode) {
// Callback that is passed reference to the newly loaded widget
console.log("Widget / Font2Gcode just got loaded.", myObjComZipwhipWidgetFont2gcode);
//myObjComZipwhipWidgetFont2gcode.init();
}
);
}
);
*/
// Zipwhip texting
// com-chilipeppr-ws-zipwhip
chilipeppr.load(
"#com-chilipeppr-ws-zipwhip",
"http://raw.githubusercontent.com/chilipeppr/widget-zipwhip/master/auto-generated-widget.html",
function() {
require(["inline:com-chilipeppr-elem-zipwhip"], function(zipwhip) {
zipwhip.init();
// setup toggle button
var zwBtn = $('#com-chilipeppr-ws-menu .zipwhip-button');
var zwDiv = $('#com-chilipeppr-ws-zipwhip');
zwBtn.click(function() {
if (zwDiv.hasClass("hidden")) {
// unhide
zwDiv.removeClass("hidden");
zwBtn.addClass("active");
}
else {
zwDiv.addClass("hidden");
zwBtn.removeClass("active");
}
$(window).trigger('resize');
});
});
}); //End Zipwhip texting
// Zipwhip Recieve Text widget
// Dynamically load the Zipwhip Recieve Text widget, i.e. wait til user clicks on the button
// first time.
wsObj.zipwhipRecvTextObj = {
zipwhipRecvTextBtn: null,
zipwhipRecvTextDiv: null,
zipwhipRecvTextInstance: null,
init: function() {
this.zipwhipRecvTextBtn = $('#com-chilipeppr-ws-menu .zipwhip-recvtext-button');
this.zipwhipRecvTextDiv = $('#com-chilipeppr-ws-zipwhip-recvtext');
this.setupBtn();
console.log("done instantiating zipwhipRecvText add-on widget");
},
setupBtn: function() {
this.zipwhipRecvTextBtn.click(this.togglezipwhipRecvText.bind(this));
},
togglezipwhipRecvText: function() {
if (this.zipwhipRecvTextDiv.hasClass("hidden")) {
// unhide
this.showzipwhipRecvText();
}
else {
this.hidezipwhipRecvText();
}
},
showzipwhipRecvText: function(callback) {
this.zipwhipRecvTextDiv.removeClass("hidden");
this.zipwhipRecvTextBtn.addClass("active");
console.log("got showzipwhipRecvText. this:", this, "wsObj:", wsObj);
// see if instantiated already
// if so, just activate
if (this.zipwhipRecvTextInstance != null) {
console.log("activating zipwhip recv text instead of re-instantiating cuz already created")
this.zipwhipRecvTextInstance.activateWidget();
if (callback) callback(this.zipwhipRecvTextInstance);
}
else {
// otherwise, dynamic load
console.log("zipwhip recv text appears to not be instantiated, let us load it from scratch")
var that = this;
chilipeppr.load(
this.zipwhipRecvTextDiv.prop("id"),
"http://raw.githubusercontent.com/chilipeppr/widget-recvtext/master/auto-generated-widget.html",
function() {
// Callback after widget loaded into #myDivWidgetRecvtext
// Now use require.js to get reference to instantiated widget
cprequire(
["inline:com-chilipeppr-widget-recvtext"], // the id you gave your widget
function(myObjWidgetRecvtext) {
// Callback that is passed reference to the newly loaded widget
console.log("Widget / Zipwhip Receive Text just got loaded.", myObjWidgetRecvtext);
myObjWidgetRecvtext.init();
that.zipwhipRecvTextInstance = myObjWidgetRecvtext;
if (callback) callback(that.zipwhipRecvTextInstance);
}
);
}
);
}
$(window).trigger('resize');
},
hidezipwhipRecvText: function() {
this.zipwhipRecvTextDiv.addClass("hidden");
this.zipwhipRecvTextBtn.removeClass("active");
console.log("got hidezipwhipRecvText. this:", this, "wsObj:", wsObj);
if (this.zipwhipRecvTextInstance != null) {
this.zipwhipRecvTextInstance.unactivateWidget();
}
$(window).trigger('resize');
},
};
wsObj.zipwhipRecvTextObj.init();
//End Zipwhip Receive Text
// Auto-Leveller
// com-chilipeppr-ws-autolevel
chilipeppr.load(
"#com-chilipeppr-ws-autolevel",
"http://raw.githubusercontent.com/chilipeppr/widget-autolevel/master/auto-generated-widget.html",
function() {
require(["inline:com-chilipeppr-widget-autolevel"], function(autolevel) {
autolevel.init();
// setup toggle button
var alBtn = $('#com-chilipeppr-ws-menu .autolevel-button');
var alDiv = $('#com-chilipeppr-ws-autolevel');
alBtn.click(function() {
if (alDiv.hasClass("hidden")) {
// unhide
alDiv.removeClass("hidden");
alBtn.addClass("active");
autolevel.onDisplay();
}
else {
alDiv.addClass("hidden");
alBtn.removeClass("active");
autolevel.onUndisplay();
}
$(window).trigger('resize');
});
});
}); //End Auto-Leveller
// Macro
// com-chilipeppr-ws-macro
chilipeppr.load(
"#com-chilipeppr-ws-macro",
"http://raw.githubusercontent.com/chilipeppr/widget-macro/master/auto-generated-widget.html",
function() {
//"http://fiddle.jshell.net/chilipeppr/ZJ5vV/show/light/", function () {
cprequire(["inline:com-chilipeppr-widget-macro"], function(macro) {
macro.init();
// setup toggle button
var alBtn = $('#com-chilipeppr-ws-menu .macro-button');
var alDiv = $('#com-chilipeppr-ws-macro');
alBtn.click(function() {
if (alDiv.hasClass("hidden")) {
// unhide
alDiv.removeClass("hidden");
alBtn.addClass("active");
//autolevel.onDisplay();
}
else {
alDiv.addClass("hidden");
alBtn.removeClass("active");
//autolevel.onUndisplay();
}
$(window).trigger('resize');
});
});
}); //End Macro
// JScut
// com-chilipeppr-ws-jscut
chilipeppr.load(
"#com-chilipeppr-ws-jscut",
"http://raw.githubusercontent.com/chilipeppr/widget-jscut/master/auto-generated-widget.html",
function() {
require(["inline:org-jscut-gcode-widget"], function(jscut) {
jscut.init();
// setup toggle button
var alBtn = $('#com-chilipeppr-ws-menu .jscut-button');
var alDiv = $('#com-chilipeppr-ws-jscut');
alBtn.click(function() {
if (alDiv.hasClass("hidden")) {
// unhide
alDiv.removeClass("hidden");
alBtn.addClass("active");
}
else {
alDiv.addClass("hidden");
alBtn.removeClass("active");
}
$(window).trigger('resize');
});
});
}); //End JSCut
// Laser Solder
// com-chilipeppr-ws-jscut
/*
chilipeppr.load(
"#com-chilipeppr-ws-lasersolder",
"http://fiddle.jshell.net/chilipeppr/xuu785yz/show/light/",