-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy path_main.html_BAK_20131013
752 lines (583 loc) · 23 KB
/
_main.html_BAK_20131013
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
<!DOCTYPE html>
<html>
<head>
<title>My first Three.js app</title>
<meta charset="UTF-8">
<style>
body {
font-family: Monospace;
font-size: 10pt;
}
h3 {
margin-bottom: 0px;
margin-top: 0px;
}
input {
font-family: Monospace;
}
canvas#preview_canvas {
position: absolute;
top: 10px;
left: 10px;
width: 512px;
height: 768px;
border: 1px solid #000000;
}
canvas#bezier_canvas {
position: absolute;
top: 10px;
left: 532px;
width: 512px;
height: 768px;
border: 1px solid #000000;
}
div#mesh_controls {
position: absolute;
top: 10px;
left: 1054px;
width: 400px;
height: 330px;
border: 1px solid #000000;
padding: 10px;
}
div#shape_controls {
position: absolute;
top: 370px;
left: 1054px;
width: 400px;
height: 130px;
border: 1px solid #000000;
padding: 10px;
}
div#stl_builder {
position: absolute;
top: 530px;
left: 1054px;
width: 400px;
height: 58px;
border: 1px solid #000000;
padding: 10px;
}
div#zip_builder {
position: absolute;
top: 620px;
left: 1054px;
width: 400px;
height: 138px;
border: 1px solid #000000;
padding: 10px;
}
.tooltip {
display: inline;
position: relative;
font-size: 10pt;
}
.tooltip:hover:after{
background: #333;
background: rgba(0,0,0,.8);
border-radius: 5px;
bottom: 26px;
color: #fff;
content: attr(title);
left: 20%;
padding: 5px 15px;
position: absolute;
z-index: 98;
width: 220px;
font-size: 10pt;
}
tooltip:hover:before{
border: solid;
border-color: #333 transparent;
border-width: 6px 6px 0 6px;
bottom: 20px;
content: "";
left: 50%;
position: absolute;
z-index: 99;
font-size: 10pt;
}
#version_tag {
position: absolute;
top: 0px;
left: 10px;
width: 512px;
text-align: right;
font-size: 7pt;
}
</style>
</head>
<body>
<div id="version_tag">
v0.1.8 built 20130925#1
</div>
<canvas
title="Click, hold and drag to rotate the view."
class="tooltip"
id="preview_canvas">
</canvas>
<div style="position: absolute; left: 10px; top: 788px; width: 256px;">
<div style="position: absolute; top: 0px; left: 256px; width: 256px; text-align: right;">
<button onclick="decreaseZoomFactor(true);">-</button>
<button onclick="increaseZoomFactor(true);">+</button>
</div>
</div>
<!--
ATTENTION: THE CANVAS SIZE MUST NOT BE SET USING CSS!
OTHERWISE LINES WILL BE DRAWN BLURRY AND UNCLEAR!
-->
<canvas
title="Double click onto the curve to add new control points. Press the [DEL] key to delete selected points."
class="tooltip"
id="bezier_canvas"
width="512px"
height="768px">
</canvas>
<div style="position: absolute; left: 532px; top: 788px; width: 256px;">
<div>
<form name="bezier_form">
<input type="checkbox" id="draw_tangents" name="draw_tangents" checked="checked" onchange="javascript:bezierCanvasHandler.redraw();" class="tooltip" title="Disables the control points and tangents." />
<label for="draw_tangents">Draw tangents</label>
<br/>
<input type="checkbox" id="draw_perpendiculars" name="draw_perpendiculars" onchange="javascript:bezierCanvasHandler.redraw();" class="tooltip" title="Draws a perpendicular hull that shows how the material thickness must be calculated." />
<label for="draw_perpendiculars">Draw perpendiculars</label>
<br/>
<input type="checkbox" id="draw_linear_path_segments" name="draw_linear_path_segments" onchange="javascript:bezierCanvasHandler.redraw();" class="tooltip" title="The outer shape is a sequence of cubic bezier curves connected with each other. Enabling this will draw the linear path between the start- and end-points." />
<label for="draw_linear_path_segments">Draw linear path segments</label>
<!--
<br/>
<input type="checkbox" id="draw_coordinate_system" name="draw_coordinate_system" onchange="javascript:bezierCanvasHandler.redraw();" class="tooltip" title="Show the origin at (0,0) on the X-Y-plane." />
<label for="draw_coordinate_system">Draw coordinate system</label>
-->
<br/>
<input type="checkbox" id="draw_rulers" name="draw_rulers" onchange="javascript:bezierCanvasHandler.redraw();" class="tooltip" title="Check if rulers should be painted." checked="checked" />
<label for="draw_rulers">Draw rulers</label>
<br/>
<input type="checkbox" id="draw_bounding_box" name="draw_bounding_box" checked="checked" onchange="javascript:bezierCanvasHandler.redraw();" class="tooltip" title="The curve's bounding box is the minimal rectangular area around the bezier path that encloses the path itself." />
<label for="draw_bounding_box">Draw bounding box</label>
</form>
</div>
<div style="position: absolute; top: 0px; left: 256px; width: 256px; text-align: right;">
<button onclick="bezierCanvasHandler.decreaseZoomFactor(true);">-</button>
<button onclick="bezierCanvasHandler.increaseZoomFactor(true);">+</button>
<br/>
</div>
</div>
<div id="mesh_controls">
<h3>Mesh controls</h3>
<form name="mesh_form">
<table border="0">
<tr>
<td valign="top">Segments:</td>
<td>
<table border="0" style="padding: 0px; spacing: 0px;" width="100%">
<tr>
<td align="left" valign="top">
<input type="number" id="shape_segments" name="shape_segments" value="80" class="tooltip" title="The number of vertices on the vertical shape (on the circle). More vertices make the mesh more accurate but it renders slower." size="4" style="width: 35px;" />
<label for="shape_segments">Shape</label>
</td>
<td align="center" valign="top">
<input type="number" id="path_segments" name="path_segments" value="80" class="tooltip" title="The number of vertices on the horizontal shape (on the outer path). More vertices make the mesh more accurate but it renders slower." size="4" style="width: 35px;" />
<label for="path_segments">Path</label>
</td>
<td valign="top">
<input type="button" onclick="increase_mesh_details()" value="+" />
</td>
<td valign="top">
<input type="button" onclick="decrease_mesh_details()" value="-" />
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td valign="top">Bend (<span id="preview_bend_display">0</span>°):</td>
<td>
<script language="Javascript">
preview_bend_mousedown = false;
</script>
<br/>
0°<input type="range" id="preview_bend" name="preview_bend" min="0" max="180" value="0"
style="width: 150px; margin-top: -12px;"
onmousedown="preview_bend_mousedown=true;"
onmouseup="preview_bend_mousedown=false;"
onmousemove="if(preview_bend_mousedown) document.getElementById('preview_bend_display').innerHTML=document.getElementById('preview_bend').value;"
onchange="document.getElementById('preview_bend_display').innerHTML=document.getElementById('preview_bend').value;preview_rebuild_model();" />180°
</td>
</tr>
<tr>
<td></td>
<td>
<input type="checkbox" id="build_negative_mesh" name="build_negative_mesh" class="tooltip" title="Set this value if you want to have a hollow shape to be generated. The strength of the hollow hull is specified by the 'Mesh Hull Strength' setting." onchange="document.getElementById('mesh_hull_strength').disabled=(document.getElementById('build_negative_mesh').checked?'':'disabled'); preview_rebuild_model();"/>
<label for="build_negative_mesh">Hollow</label>
</td>
</tr>
<tr>
<td> <label for="mesh_hull_strength">Mesh Hull Strength:</label><br/>
(only if hollow)
</td>
<td valign="top">
<input type="number" id="mesh_hull_strength" name="mesh_hull_strength" value="25" class="tooltip" title="..." onchange="javascript:bezierCanvasHandler.redraw();" onkeyup="javascript:bezierCanvasHandler.redraw();preview_rebuild_model();" size="4" style="width: 35px;" onchange="preview_rebuild_model();" disabled="disabled" />px
</td>
</tr>
<tr>
<td>Close path</td>
<td>
<table border="0" style="padding: 0px; spacing: 0px;" width="100%">
<tr><td align="left">
<input type="checkbox" id="mesh_close_path_begin" name="mesh_close_path_begin" onchange="preview_rebuild_model();" class="tooltip" title="The path begin is the top of the mesh. In some cases the top bezier point is not located at the right bound. The top shape can be closed with this option then." />
<label for="mesh_close_path_begin">begin</label>
</td>
<td align="right">
<input type="checkbox" id="mesh_close_path_end" name="mesh_close_path_end" onchange="preview_rebuild_model();" class="tooltip" title="The path end is the bottom of the mesh." checked="checked" />
<label for="mesh_close_path_end">end</label>
</td></tr>
</table>
</td>
</tr>
<tr>
<td></td>
<td>
<input type="checkbox" id="wireframe" name="wireframe" onchange="preview_rebuild_model();" class="tooltip" title="Well, just toggles wireframe on/off." />
<label for="wireframe">Wireframe</label>
</td>
</tr>
<tr>
<td></td>
<td>
<div style="position: relative; top: -12px; margin-bottom: -15px;">
<input type="checkbox" id="triangulate" name="triangulate" onchange="preview_rebuild_model();" checked="checked" />
<label for="triangulate">Triangulate</label>
<span class="tooltip" title="Note: quad faces render faster but only triangulated meshes are STL compatible!" style="font-size: 22pt;">⚠</span><br/>
</div>
</td>
</tr>
<tr>
<td></td>
<td>
<input type="checkbox" id="split_shape" name="split_shape" onchange="preview_rebuild_model();" />
<label for="split_shape">Split shape/mesh</label>
</td>
</tr>
<tr>
<td></label></td>
<td><input type="button" value="Rebuild" onclick="preview_rebuild_model();"></td>
</tr>
</table>
</form>
</div>
<div id="shape_controls">
<h3>Save shape to JSON file</h3>
<button onclick="saveTextFile( bezierCanvasHandler.bezierPath.toJSON(), 'bezier_shape.json', 'application/json' );">Export JSON ...</button>
<br/>
<br/>
<h3>Load shape from JSON file</h3>
<form name="bezier_file_upload_form">
<input type="file" name="bezier_json_file" /><br/>
<input type="button" value="Upload JSON file" onclick="upload_bezier_json_file( document.forms['bezier_file_upload_form'].elements['bezier_json_file'] );">
</form>
</div>
<div id="stl_builder">
<h3>Export STL file</h3>
<form name="stl_form">
<label for="stl_filename">Filename</label>
<input type="text" id="stl_filename" name="stl_filename" value="my_extrusion.stl" />
<!--
<input type="button" value="Save STL ..." onclick="STLBuilder.saveSTL( getPreviewMeshes(), document.forms['stl_form'].elements['stl_filename'].value );" />
-->
<input type="button" value="Save STL ..." onclick="exportSTL();" />
<span class="tooltip" title="Note: split meshes result in two unconnected objects; they will be stored as a sequence of objects in the STL file. Not all programs are capable to read this!" style="font-size: 22pt;">⚠</span>
</form>
</div>
<div id="zip_builder">
<h3>Export ZIP file</h3>
<form name="zip_form">
<label for="zip_filename">Filename</label>
<input type="text" id="zip_filename" name="zip_filename" value="full_backup.zip" />
<input type="button" value="Save ZIP ..." onclick="ZipFileExporter.exportZipFile( document.forms['zip_form'].elements['zip_filename'].value );" /> <br/>
<div style="text-align: right"><input type="checkbox" id="compress_zip" name="compress_zip" /><label for="compress_zip">Compress (slower!)</label></div>
</form>
<h3>Import ZIP file</h3>
<form name="zip_import_form">
<input type="file" name="zip_upload_file" /><br/>
<input type="button" value="Upload ZIP file" onclick="ZipFileImporter.importZipFile( document.forms['zip_import_form'].elements['zip_upload_file'] );">
</form>
</div>
<button style="position: absolute; left: 10px; top: 788px;" onclick="debug();">DEBUG</button><br/>
<button style="position: absolute; left: 10px; top: 818px;" onclick="showLoadingBar();">Message Box</button><br/>
<script language="Javascript" type="text/javascript" src="three.js"></script>
<script language="Javascript" type="text/javascript" src="Blob.js"></script>
<script language="Javascript" type="text/javascript" src="FileSaver.js"></script>
<script language="Javascript" type="text/javascript" src="jszip.js"></script>
<script language="Javascript" type="text/javascript" src="jszip-deflate.js"></script>
<script language="Javascript" type="text/javascript" src="jszip-load.js"></script>
<!-- <script language="Javascript" type="text/javascript" src="STLBuilder.js"></script> -->
<script language="Javascript" type="text/javascript" src="StringFileExporter.js"></script>
<script language="Javascript" type="text/javascript" src="upload_bezier_json_file.js"></script>
<script language="Javascript" type="text/javascript" src="base64-binary.js"></script>
<script language="Javascript" type="text/javascript" src="ZipFileExporter.js"></script>
<script language="Javascript" type="text/javascript" src="ZipFileImporter.js"></script>
<script language="Javascript" type="text/javascript" src="IKRS.js"></script>
<script language="Javascript" type="text/javascript" src="IKRS.Object.js"></script>
<script language="Javascript" type="text/javascript" src="IKRS.ShapedPathGeometry.js"></script>
<script language="Javascript" type="text/javascript" src="IKRS.PathDirectedExtrudeGeometry.js"></script>
<script language="Javascript" type="text/javascript" src="IKRS.Utils.js"></script>
<script language="Javascript" type="text/javascript" src="IKRS.DivisibleSTLBuilder.js"></script>
<script language="Javascript" type="text/javascript" src="IKRS.BoundingBox2.js"></script>
<script language="Javascript" type="text/javascript" src="IKRS.CubicBezierCurve.js"></script>
<script language="Javascript" type="text/javascript" src="IKRS.BezierCanvasHandler.js"></script>
<script language="Javascript" type="text/javascript" src="IKRS.BezierPath.js"></script>
<script language="Javascript" type="text/javascript" src="IKRS.UndoHistory.js"></script>
<script language="Javascript" type="text/javascript" src="IKRS.ProcessListener.js"></script>
<script language="Javascript">
/**
* ...
**/
function getPreviewMeshes() {
//return preview_mesh;
//return previewCanvasHandler.preview_mesh;
return previewCanvasHandler.getMeshes();
}
function bezier_undo() {
var hasMoreUndoSteps = this.bezierCanvasHandler.undo();
window.alert( this.bezierCanvasHandler.undoHistory._toString() );
//document.getElementById( "bezier_undo" ).disabled = !hasMoreUndoSteps;
}
function bezier_redo() {
var hasMoreRedoteps = this.bezierCanvasHandler.redo();
//document.getElementById( "bezier_redo" ).disabled = !hasMoreRedoSteps;
}
function setBezierPath( bezierPath ) {
//this.bezierCanvasHandler.bezierPath = bezierPath;
this.bezierCanvasHandler.setBezierPath( bezierPath );
//addToBezierUndoHistory( bezierPath );
//this.bezierCanvasHandler.redraw();
preview_rebuild_model();
}
function getBezierPath() {
return this.bezierCanvasHandler.bezierPath;
}
this.bezierCanvasHandler = new IKRS.BezierCanvasHandler();
</script>
<script language="Javascript" type="text/javascript" src="IKRS.PreviewCanvasHandler.js"></script>
<script>
var previewCanvasHandler = new IKRS.PreviewCanvasHandler( this.bezierCanvasHandler,
512,
768
);
previewCanvasHandler.preview_rebuild_model();
// previewCanvasHandler.preview_camera.position.z = 500;
function preview_render() {
// Recursive call
requestAnimationFrame( this.preview_render );
previewCanvasHandler.render( this.preview_scene,
this.preview_camera
);
}
function decreaseZoomFactor( redraw ) {
this.previewCanvasHandler.decreaseZoomFactor();
if( redraw )
preview_render();
}
function increaseZoomFactor( redraw ) {
this.previewCanvasHandler.increaseZoomFactor();
if( redraw )
preview_render();
}
function increase_mesh_details() {
var shape_segments = this.document.forms["mesh_form"].elements["shape_segments"].value;
var path_segments = this.document.forms["mesh_form"].elements["path_segments"].value;
shape_segments = parseInt( shape_segments );
path_segments = parseInt( path_segments );
shape_segments = Math.ceil( shape_segments * 1.2 );
path_segments = Math.ceil( path_segments * 1.2 );
this.document.forms["mesh_form"].elements["shape_segments"].value = shape_segments;
this.document.forms["mesh_form"].elements["path_segments"].value = path_segments;
preview_rebuild_model();
}
function decrease_mesh_details() {
var shape_segments = this.document.forms["mesh_form"].elements["shape_segments"].value;
var path_segments = this.document.forms["mesh_form"].elements["path_segments"].value;
shape_segments = parseInt( shape_segments );
path_segments = parseInt( path_segments );
shape_segments = Math.max( 3, Math.floor( shape_segments / 1.2 ) );
path_segments = Math.max( 2, Math.floor( path_segments / 1.2 ) );
if( shape_segments < 3 && path_segments < 2 )
return; // No change
this.document.forms["mesh_form"].elements["shape_segments"].value = shape_segments;
this.document.forms["mesh_form"].elements["path_segments"].value = path_segments;
preview_rebuild_model();
}
function preview_rebuild_model() {
this.previewCanvasHandler.preview_rebuild_model();
}
window.onload = preview_render;
function mouseWheelHandler( e ) {
//this.previewCanvasHandler.handleMouseWheelEvent( e );
var delta = 0;
if (!e) /* For IE. */
e = window.event;
if (e.wheelDelta) { /* IE/Opera. */
delta = e.wheelDelta/120;
} else if (e.detail) { /** Mozilla case. */
/** In Mozilla, sign of delta is different than in IE.
* Also, delta is multiple of 3.
*/
delta = -e.detail/3;
}
/** If delta is nonzero, handle it.
* Basically, delta is now positive if wheel was scrolled up,
* and negative, if wheel was scrolled down.
*/
if (delta) {
if( delta < 0 )
decreaseZoomFactor( true ); // redraw
else
increaseZoomFactor( true ); // redraw
}
/** Prevent default actions caused by mouse wheel.
* That might be ugly, but we handle scrolls somehow
* anyway, so don't bother here..
*/
if (e.preventDefault)
e.preventDefault();
e.returnValue = false;
}
// Install a mouse wheel listener
if( window.addEventListener ) {
// For Mozilla
window.addEventListener( 'DOMMouseScroll', mouseWheelHandler, false );
}
// IE and Opera
window.onmousewheel = document.onmousewheel = mouseWheelHandler;
// window.previewCanvasHandler = this;
function debug() {
window.alert(
"camera.ikrsSettings.rotation=" + JSON.stringify(this.previewCanvasHandler.preview_camera.ikrsSettings.rotation) + ",\n" +
"camera.ikrsSettings.position=" + JSON.stringify(this.previewCanvasHandler.preview_camera.ikrsSettings.position) + ",\n" +
"camera.rotation=" + JSON.stringify(this.previewCanvasHandler.preview_camera.rotation) + ",\n" +
"camera.position=" + JSON.stringify(this.previewCanvasHandler.preview_camera.position) + "\n"
);
}
var divisibleSTLBuilder = null;
function exportSTL() {
var meshes = getPreviewMeshes();
var filename = document.forms['stl_form'].elements['stl_filename'].value;
// Init the divisible STL builder
divisibleSTLBuilder = new IKRS.DivisibleSTLBuilder( meshes,
filename,
function( e ) { },
1024
);
}
</script>
<!-- Add some CSS layers -->
<!--
<style>
div#message_layer_blanket {
display: none; /* Initially invisible */
position: absolute;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
background-color: #888888;
filter: alpha(opacity=65);
opacity: 0.65;
z-index: 9001;
}
div#message_layer_box {
display: none; /* Initially invisible */
position: absolute;
background-color: #eeeeee;
border-width: 1px;
border-style: solid;
border-color: #000000;
padding: 0em;
/*
width: 640px;
height: auto;
*/
z-index: 9002;
}
</style>
-->
<!--
<div id="message_layer_blanket"></div>
<div id="message_layer_box">Blubb</div>
-->
<script language="Javascript" type="text/javascript" src="IKRS.MessageBox.js"></script>
<script language="Javascript">
/**
* This script adds the message box/layer to the DOM and initializes
* the process listener.
**/
var messageBox = new IKRS.MessageBox( "message_layer" );
/*
messageBox.getBlanket().addEventListener( "mousedown",
function() { messageBox.hide();
stopLoadingAnimation();
}
);
*/
function displayProcessState( currentStep, maxStep ) {
var pct = Math.ceil( currentStep / maxStep ) * 100;
document.getElementById( "process_div" ).innerHTML = "" + currentStep + "/" + maxStep + " [" + pct + "%]";
}
var stlProcessListener = new IKRS.ProcessListener( null, // startCallback
null, // stepCallback
null, // terminationCallback
75 // stepIntervalLength
);
stlProcessListener.startCallback = function(x,y) { }; // displayProcessState;
stlProcessListener.stepCallback = function(x,y) { }; // displayProcessState;
stlProcessListener.terminationCallback = function(x,y) { }; // displayProcessState;
function showLoadingBar() {
messageBox.show(
"<br/><br/>Loading ...<br/>\n" +
"<br/>\n" +
"<span id=\"loading_span\"></span><br/>\n" +
"<div id=\"process_div\">X</div><br/>\n" +
"<br/><button onclick=\"messageBox.hide();\">Cancel</button>"
);
startLoadingAnimation();
window.setTimeout( tmp_process, 100 );
}
function tmp_process() {
var maxSteps = 65535;
stlProcessListener.reportStart( maxSteps );
for( var i = 0; i < maxSteps; i++ ) {
stlProcessListener.reportCurrentStep( i );
delay( 10 );
}
stlProcessListener.reportTemination();
}
function delay( ms ) {
var startTime = new Date().getTime();
var currentTime;
var delay;
do {
currentTime = new Date().getTime();
delay = currentTime - startTime;
// NOOP
console.log( "startTime=" + startTime + ", currentTime=" + currentTime + ", delay=" + delay );
} while( delay < ms );
}
var loadingAnimationKey = null;
var loadingAnimationElements = [ '|', '/', '–', '\\' ];
var loadingAnimationPointer = 0;
function startLoadingAnimation() {
if( !loadingAnimationKey )
loadingAnimationKey = window.setInterval( "startLoadingAnimation();", 250 );
document.getElementById("loading_span").innerHTML = loadingAnimationElements[loadingAnimationPointer];
displayProcessState( stlProcessListener.getCurrentStep(), stlProcessListener.getTotalStepCount() );
loadingAnimationPointer = (loadingAnimationPointer + 1) % loadingAnimationElements.length;
}
function stopLoadingAnimation() {
if( loadingAnimationKey )
window.clearInterval( loadingAnimationKey );
loadingAnimationKey;
}
</script>
</body>
</html>