Skip to content

Commit dfd25d3

Browse files
committed
Style fixes for 'ui.js'. One bug with modernizr warning not getting printed out.
1 parent a962f56 commit dfd25d3

File tree

2 files changed

+23
-37
lines changed

2 files changed

+23
-37
lines changed

Diff for: js/gCodeReader.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ GCODE.gCodeReader = (function(){
102102
reader.target.result = null;
103103
// prepareGCode();
104104

105-
worker.postMessage({
105+
GCODE.ui.worker.postMessage({
106106
"cmd":"parseGCode",
107107
"msg":{
108108
gcode: lines,

Diff for: js/ui.js

+22-36
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ GCODE.ui = (function(){
1313
var sliderHor;
1414
var gCodeLines = {first: 0, last: 0};
1515
var showGCode = false;
16+
// var worker;
1617

1718
var setProgress = function(id, progress){
18-
$('#'+id).width(parseInt(progress)+'%');
19-
$('#'+id).text(parseInt(progress)+'%');
20-
19+
$('#'+id).width(parseInt(progress)+'%').text(parseInt(progress)+'%');
20+
// $('#'+id);
2121
};
2222

2323
var chooseAccordion = function(id){
@@ -26,15 +26,14 @@ GCODE.ui = (function(){
2626
};
2727

2828
var setLinesColor = function(toggle){
29-
var i=0;
30-
for(i=gCodeLines.first;i<gCodeLines.last; i++){
29+
for(var i=gCodeLines.first;i<gCodeLines.last; i++){
3130
if(toggle){
3231
myCodeMirror.setLineClass(Number(i), null, "activeline");
3332
}else{
3433
myCodeMirror.setLineClass(Number(i), null, null);
3534
}
3635
}
37-
}
36+
};
3837

3938

4039
var printLayerInfo = function(layerNum){
@@ -45,9 +44,9 @@ GCODE.ui = (function(){
4544
var renderOptions = GCODE.renderer.getOptions();
4645
var colors = renderOptions["colorLine"];
4746
var speedIndex = 0;
48-
var keys, type;
49-
var showMove=false;
50-
var i = 0;
47+
// var keys, type;
48+
// var showMove=false;
49+
var i;
5150
var output = [];
5251
output.push("Layer number: " + layerNum);
5352
output.push("Layer height (mm): " + z);
@@ -95,7 +94,7 @@ GCODE.ui = (function(){
9594
resultSet.push("Estimated layer height: " + modelInfo.layerHeight.toFixed(2) + "mm<br>");
9695
resultSet.push("Layer count: " + modelInfo.layerCnt.toFixed(0) + "printed, " + modelInfo.layerTotal.toFixed(0) + 'visited<br>');
9796
document.getElementById('list').innerHTML = resultSet.join('');
98-
}
97+
};
9998

10099
var handleFileSelect = function(evt) {
101100
// console.log("handleFileSelect");
@@ -139,8 +138,8 @@ GCODE.ui = (function(){
139138
};
140139

141140
var initSliders = function(){
142-
var prevX=0;
143-
var prevY=0;
141+
// var prevX=0;
142+
// var prevY=0;
144143
var handle;
145144
sliderVer = $( "#slider-vertical" );
146145
sliderHor = $( "#slider-horizontal" );
@@ -167,7 +166,7 @@ GCODE.ui = (function(){
167166
});
168167

169168
//this stops slider reacting to arrow keys, since we do it below manually
170-
$( "#slider-vertical .ui-slider-handle" ).unbind('keydown');
169+
$( "#slider-vertical").find(".ui-slider-handle" ).unbind('keydown');
171170

172171
sliderHor.slider({
173172
orientation: "horizontal",
@@ -204,15 +203,15 @@ GCODE.ui = (function(){
204203
switch (data.cmd) {
205204
case 'returnModel':
206205
setProgress('loadProgress', 100);
207-
worker.postMessage({
206+
GCODE.ui.worker.postMessage({
208207
"cmd":"analyzeModel",
209208
"msg":{
210209
}
211210
}
212211
);
213212
break;
214213
case 'analyzeDone':
215-
var resultSet = [];
214+
// var resultSet = [];
216215

217216
setProgress('analyzeProgress',100);
218217
GCODE.gCodeReader.processAnalyzeModelDone(data.msg);
@@ -221,7 +220,7 @@ GCODE.ui = (function(){
221220
printModelInfo();
222221
printLayerInfo(0);
223222
chooseAccordion('infoAccordionTab');
224-
$('#myTab a[href="#tab2d"]').tab('show');
223+
$('#myTab').find('a[href="#tab2d"]').tab('show');
225224
break;
226225
case 'returnLayer':
227226
GCODE.gCodeReader.processLayerFromWorker(data.msg);
@@ -254,7 +253,7 @@ GCODE.ui = (function(){
254253

255254
if(fatal.length>0){
256255
document.getElementById('errorList').innerHTML = '<ul>' + fatal.join('') + '</ul>';
257-
console.log("Initialization failed: unsupported browser.")
256+
console.log("Initialization failed: unsupported browser.");
258257
return false;
259258
}
260259

@@ -265,7 +264,7 @@ GCODE.ui = (function(){
265264
if(!Modernizr.draganddrop)warnings.push("<li>Your browser doesn't seem to support HTML5 Drag'n'Drop, Drop area will not work.</li>");
266265

267266
if(warnings.length>0){
268-
document.getElementById('errorList').innerHTML = '<ul>' + wanings.join('') + '</ul>';
267+
document.getElementById('errorList').innerHTML = '<ul>' + warnings.join('') + '</ul>';
269268
console.log("Initialization succeeded with warnings.")
270269
}
271270
return true;
@@ -290,14 +289,14 @@ GCODE.ui = (function(){
290289

291290
$(".collapse").collapse({parent: '#accordion2'});
292291

293-
$('#myTab a[href="#tab3d"]').click(function (e) {
292+
$('#myTab').find('a[href="#tab3d"]').click(function (e) {
294293
e.preventDefault();
295294
console.log("Switching to 3d mode");
296295
$(this).tab('show');
297296
GCODE.renderer3d.doRender();
298297
});
299298

300-
$('#myTab a[href="#tabGCode"]').click(function (e) {
299+
$('#myTab').find('a[href="#tabGCode"]').click(function (e) {
301300
e.preventDefault();
302301
console.log("Switching to GCode preview mode");
303302
$(this).tab('show');
@@ -308,9 +307,9 @@ GCODE.ui = (function(){
308307
myCodeMirror.focus();
309308
});
310309

311-
worker = new Worker('js/Worker.js');
310+
this.worker = new Worker('js/Worker.js');
312311

313-
worker.addEventListener('message', processMessage, false);
312+
this.worker.addEventListener('message', processMessage, false);
314313

315314
GCODE.ui.processOptions();
316315
GCODE.renderer.render(0,0);
@@ -327,27 +326,14 @@ GCODE.ui = (function(){
327326

328327
},
329328

330-
ArrayIndexOf: function(a, fnc) {
331-
if (!fnc || typeof (fnc) != 'function') {
332-
return -1;
333-
}
334-
if (!a || !a.length || a.length < 1) return -1;
335-
for (var i = 0; i < a.length; i++) {
336-
if(!a[i]) continue;
337-
if (fnc(a[i])) return i;
338-
}
339-
return -1;
340-
},
341-
342329
processOptions: function(){
343330
if(document.getElementById('sortLayersCheckbox').checked)GCODE.gCodeReader.setOption({sortLayers: true});
344331
else GCODE.gCodeReader.setOption({sortLayers: false});
345332

346333
if(document.getElementById('purgeEmptyLayersCheckbox').checked)GCODE.gCodeReader.setOption({purgeEmptyLayers: true});
347334
else GCODE.gCodeReader.setOption({purgeEmptyLayers: false});
348335

349-
if(document.getElementById('showGCodeCheckbox').checked)showGCode = true;
350-
else showGCode = false;
336+
showGCode = document.getElementById('showGCodeCheckbox').checked;
351337

352338
if(document.getElementById('moveModelCheckbox').checked)GCODE.renderer.setOption({moveModel: true});
353339
else GCODE.renderer.setOption({moveModel: false});

0 commit comments

Comments
 (0)