Skip to content

Commit 793de78

Browse files
committed
Beautified code
1 parent ff48336 commit 793de78

File tree

1 file changed

+54
-54
lines changed

1 file changed

+54
-54
lines changed

tuning.js

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -15,62 +15,62 @@
1515
var propName = key.substring(16, key.length);
1616
// Check if value is new, starts with /SmartDashboard/, and doesn't have a spot on the list yet
1717
if (isNew && value && document.getElementsByName(propName).length === 0) {
18-
if (key.substring(0, 16) === '/SmartDashboard/') {
19-
// Make a new div for this value
20-
var div = document.createElement('div'); // Make div
21-
ui.tuning.list.appendChild(div); // Add the div to the page
18+
if (key.substring(0, 16) === '/SmartDashboard/') {
19+
// Make a new div for this value
20+
var div = document.createElement('div'); // Make div
21+
ui.tuning.list.appendChild(div); // Add the div to the page
2222

23-
var p = document.createElement('p'); // Make a <p> to display the name of the property
24-
p.innerHTML = propName; // Make content of <p> have the name of the NetworkTables value
25-
div.appendChild(p); // Put <p> in div
23+
var p = document.createElement('p'); // Make a <p> to display the name of the property
24+
p.innerHTML = propName; // Make content of <p> have the name of the NetworkTables value
25+
div.appendChild(p); // Put <p> in div
2626

27-
var input = document.createElement('input'); // Create input
28-
input.name = propName; // Make its name property be the name of the NetworkTables value
29-
input.value = value; // Set
30-
// The following statement figures out which data type the variable is.
31-
// If it's a boolean, it will make the input be a checkbox. If it's a number,
32-
// it will make it a number chooser with up and down arrows in the box. Otherwise, it will make it a textbox.
33-
if (value === true || value === false) { // Is it a boolean value?
34-
input.type = 'checkbox';
35-
input.checked = value; // value property doesn't work on checkboxes, we'll need to use the checked property instead
36-
} else if (!isNaN(value)) { // Is the value not not a number? Great!
37-
input.type = 'number';
38-
} else { // Just use a text if there's no better manipulation method
39-
input.type = 'text';
40-
}
41-
// Create listener for value of input being modified
42-
input.onchange = function() {
43-
switch (input.type) { // Figure out how to pass data based on data type
44-
case 'checkbox':
45-
// For booleans, send bool of whether or not checkbox is checked
46-
NetworkTables.setValue(key, input.checked);
47-
break;
48-
case 'number':
49-
// For number values, send value of input as an int.
50-
NetworkTables.setValue(key, parseInt(input.value));
51-
break;
52-
case 'text':
53-
// For normal text values, just send the value.
54-
NetworkTables.setValue(key, input.value);
55-
break;
56-
}
57-
};
58-
// Put the input into the div.
59-
div.appendChild(input);
60-
}
61-
} else { // If the value is new
62-
// Find already-existing input for changing this variable
63-
var oldInput = document.getElementsByName(propName)[0];
64-
if (oldInput) { // If there is one (there should be, unless something is wrong)
65-
if (oldInput.type === 'checkbox') { // Figure out what data type it is and update it in the list
66-
oldInput.checked = value;
67-
} else {
68-
oldInput.value = value;
69-
}
70-
} else {
71-
console.log('Error: Non-new variable ' + propName + ' not present in tuning list!');
72-
}
73-
}
27+
var input = document.createElement('input'); // Create input
28+
input.name = propName; // Make its name property be the name of the NetworkTables value
29+
input.value = value; // Set
30+
// The following statement figures out which data type the variable is.
31+
// If it's a boolean, it will make the input be a checkbox. If it's a number,
32+
// it will make it a number chooser with up and down arrows in the box. Otherwise, it will make it a textbox.
33+
if (value === true || value === false) { // Is it a boolean value?
34+
input.type = 'checkbox';
35+
input.checked = value; // value property doesn't work on checkboxes, we'll need to use the checked property instead
36+
} else if (!isNaN(value)) { // Is the value not not a number? Great!
37+
input.type = 'number';
38+
} else { // Just use a text if there's no better manipulation method
39+
input.type = 'text';
40+
}
41+
// Create listener for value of input being modified
42+
input.onchange = function() {
43+
switch (input.type) { // Figure out how to pass data based on data type
44+
case 'checkbox':
45+
// For booleans, send bool of whether or not checkbox is checked
46+
NetworkTables.setValue(key, input.checked);
47+
break;
48+
case 'number':
49+
// For number values, send value of input as an int.
50+
NetworkTables.setValue(key, parseInt(input.value));
51+
break;
52+
case 'text':
53+
// For normal text values, just send the value.
54+
NetworkTables.setValue(key, input.value);
55+
break;
56+
}
57+
};
58+
// Put the input into the div.
59+
div.appendChild(input);
60+
}
61+
} else { // If the value is new
62+
// Find already-existing input for changing this variable
63+
var oldInput = document.getElementsByName(propName)[0];
64+
if (oldInput) { // If there is one (there should be, unless something is wrong)
65+
if (oldInput.type === 'checkbox') { // Figure out what data type it is and update it in the list
66+
oldInput.checked = value;
67+
} else {
68+
oldInput.value = value;
69+
}
70+
} else {
71+
console.log('Error: Non-new variable ' + propName + ' not present in tuning list!');
72+
}
73+
}
7474

7575
// End section
7676

0 commit comments

Comments
 (0)