Require tripple equals over double, fix in edit.js

This commit is contained in:
Zander Otavka 2016-07-13 16:03:44 -07:00
parent ded82294f9
commit 6417bb1859
2 changed files with 49 additions and 48 deletions

View file

@ -57,6 +57,7 @@ module.exports = {
"comma-dangle": ["error", "never"], "comma-dangle": ["error", "never"],
"camelcase": ["error"], "camelcase": ["error"],
"curly": ["error", "all"], "curly": ["error", "all"],
"eqeqeq": ["error", "always"],
"indent": ["error", 4, { "SwitchCase": 1 }], "indent": ["error", 4, { "SwitchCase": 1 }],
"keyword-spacing": ["error", { "before": true, "after": true }], "keyword-spacing": ["error", { "before": true, "after": true }],
"max-len": ["error", 128, 4], "max-len": ["error", 128, 4],

View file

@ -178,7 +178,7 @@ var toolBar = (function () {
var dimensions = properties.dimensions ? properties.dimensions : DEFAULT_DIMENSIONS; var dimensions = properties.dimensions ? properties.dimensions : DEFAULT_DIMENSIONS;
var position = getPositionToCreateEntity(); var position = getPositionToCreateEntity();
var entityID = null; var entityID = null;
if (position != null) { if (position !== null && position !== undefined) {
position = grid.snapToSurface(grid.snapToGrid(position, false, dimensions), dimensions), position = grid.snapToSurface(grid.snapToGrid(position, false, dimensions), dimensions),
properties.position = position; properties.position = position;
entityID = Entities.addEntity(properties); entityID = Entities.addEntity(properties);
@ -431,7 +431,7 @@ var toolBar = (function () {
}; };
that.setActive = function (active) { that.setActive = function (active) {
if (active == isActive) { if (active === isActive) {
return; return;
} }
if (active && !Entities.canRez() && !Entities.canRezTmp()) { if (active && !Entities.canRez() && !Entities.canRezTmp()) {
@ -481,8 +481,8 @@ var toolBar = (function () {
function isLocked(properties) { function isLocked(properties) {
// special case to lock the ground plane model in hq. // special case to lock the ground plane model in hq.
if (location.hostname == "hq.highfidelity.io" && if (location.hostname === "hq.highfidelity.io" &&
properties.modelURL == HIFI_PUBLIC_BUCKET + "ozan/Terrain_Reduce_forAlpha.fbx") { properties.modelURL === HIFI_PUBLIC_BUCKET + "ozan/Terrain_Reduce_forAlpha.fbx") {
return true; return true;
} }
return false; return false;
@ -682,7 +682,7 @@ function mouseClickEvent(event) {
var result, properties; var result, properties;
if (isActive && event.isLeftButton) { if (isActive && event.isLeftButton) {
result = findClickedEntity(event); result = findClickedEntity(event);
if (result === null) { if (result === null || result === undefined) {
if (!event.isShifted) { if (!event.isShifted) {
selectionManager.clearSelections(); selectionManager.clearSelections();
} }
@ -711,7 +711,7 @@ function mouseClickEvent(event) {
// x x - distance from A // x x - distance from A
// //
// |X-A| = (P-A).B // |X-A| = (P-A).B
// X == A + ((P-A).B)B // X === A + ((P-A).B)B
// d = |P-X| // d = |P-X|
var A = pickRay.origin; var A = pickRay.origin;
@ -882,7 +882,7 @@ function setupModelMenus() {
menuName: "Edit", menuName: "Edit",
menuItemName: MENU_AUTO_FOCUS_ON_SELECT, menuItemName: MENU_AUTO_FOCUS_ON_SELECT,
isCheckable: true, isCheckable: true,
isChecked: Settings.getValue(SETTING_AUTO_FOCUS_ON_SELECT) == "true", isChecked: Settings.getValue(SETTING_AUTO_FOCUS_ON_SELECT) === "true",
grouping: "Advanced" grouping: "Advanced"
}); });
Menu.addMenuItem({ Menu.addMenuItem({
@ -890,7 +890,7 @@ function setupModelMenus() {
menuItemName: MENU_EASE_ON_FOCUS, menuItemName: MENU_EASE_ON_FOCUS,
afterItem: MENU_AUTO_FOCUS_ON_SELECT, afterItem: MENU_AUTO_FOCUS_ON_SELECT,
isCheckable: true, isCheckable: true,
isChecked: Settings.getValue(SETTING_EASE_ON_FOCUS) == "true", isChecked: Settings.getValue(SETTING_EASE_ON_FOCUS) === "true",
grouping: "Advanced" grouping: "Advanced"
}); });
Menu.addMenuItem({ Menu.addMenuItem({
@ -898,7 +898,7 @@ function setupModelMenus() {
menuItemName: MENU_SHOW_LIGHTS_IN_EDIT_MODE, menuItemName: MENU_SHOW_LIGHTS_IN_EDIT_MODE,
afterItem: MENU_EASE_ON_FOCUS, afterItem: MENU_EASE_ON_FOCUS,
isCheckable: true, isCheckable: true,
isChecked: Settings.getValue(SETTING_SHOW_LIGHTS_IN_EDIT_MODE) == "true", isChecked: Settings.getValue(SETTING_SHOW_LIGHTS_IN_EDIT_MODE) === "true",
grouping: "Advanced" grouping: "Advanced"
}); });
Menu.addMenuItem({ Menu.addMenuItem({
@ -906,7 +906,7 @@ function setupModelMenus() {
menuItemName: MENU_SHOW_ZONES_IN_EDIT_MODE, menuItemName: MENU_SHOW_ZONES_IN_EDIT_MODE,
afterItem: MENU_SHOW_LIGHTS_IN_EDIT_MODE, afterItem: MENU_SHOW_LIGHTS_IN_EDIT_MODE,
isCheckable: true, isCheckable: true,
isChecked: Settings.getValue(SETTING_SHOW_ZONES_IN_EDIT_MODE) == "true", isChecked: Settings.getValue(SETTING_SHOW_ZONES_IN_EDIT_MODE) === "true",
grouping: "Advanced" grouping: "Advanced"
}); });
@ -990,7 +990,7 @@ function selectAllEtitiesInCurrentSelectionBox(keepIfTouching) {
if (!keepIfTouching) { if (!keepIfTouching) {
var isValid; var isValid;
if (selectionManager.localPosition === null) { if (selectionManager.localPosition === null || selectionManager.localPosition === undefined) {
isValid = function (position) { isValid = function (position) {
return insideBox(selectionManager.worldPosition, selectionManager.worldDimensions, position); return insideBox(selectionManager.worldPosition, selectionManager.worldDimensions, position);
}; };
@ -1070,15 +1070,15 @@ function toggleSelectedEntitiesVisible() {
} }
function handeMenuEvent(menuItem) { function handeMenuEvent(menuItem) {
if (menuItem == "Allow Selecting of Small Models") { if (menuItem === "Allow Selecting of Small Models") {
allowSmallModels = Menu.isOptionChecked("Allow Selecting of Small Models"); allowSmallModels = Menu.isOptionChecked("Allow Selecting of Small Models");
} else if (menuItem == "Allow Selecting of Large Models") { } else if (menuItem === "Allow Selecting of Large Models") {
allowLargeModels = Menu.isOptionChecked("Allow Selecting of Large Models"); allowLargeModels = Menu.isOptionChecked("Allow Selecting of Large Models");
} else if (menuItem == "Allow Selecting of Lights") { } else if (menuItem === "Allow Selecting of Lights") {
Entities.setLightsArePickable(Menu.isOptionChecked("Allow Selecting of Lights")); Entities.setLightsArePickable(Menu.isOptionChecked("Allow Selecting of Lights"));
} else if (menuItem == "Delete") { } else if (menuItem === "Delete") {
deleteSelectedEntities(); deleteSelectedEntities();
} else if (menuItem == "Export Entities") { } else if (menuItem === "Export Entities") {
if (!selectionManager.hasSelection()) { if (!selectionManager.hasSelection()) {
Window.alert("No entities have been selected."); Window.alert("No entities have been selected.");
} else { } else {
@ -1090,10 +1090,10 @@ function handeMenuEvent(menuItem) {
} }
} }
} }
} else if (menuItem == "Import Entities" || menuItem == "Import Entities from URL") { } else if (menuItem === "Import Entities" || menuItem === "Import Entities from URL") {
var importURL = null; var importURL = null;
if (menuItem == "Import Entities") { if (menuItem === "Import Entities") {
var fullPath = Window.browse("Select Model to Import", "", "*.json"); var fullPath = Window.browse("Select Model to Import", "", "*.json");
if (fullPath) { if (fullPath) {
importURL = "file:///" + fullPath; importURL = "file:///" + fullPath;
@ -1105,15 +1105,15 @@ function handeMenuEvent(menuItem) {
if (importURL) { if (importURL) {
importSVO(importURL); importSVO(importURL);
} }
} else if (menuItem == "Entity List...") { } else if (menuItem === "Entity List...") {
entityListTool.toggleVisible(); entityListTool.toggleVisible();
} else if (menuItem == "Select All Entities In Box") { } else if (menuItem === "Select All Entities In Box") {
selectAllEtitiesInCurrentSelectionBox(false); selectAllEtitiesInCurrentSelectionBox(false);
} else if (menuItem == "Select All Entities Touching Box") { } else if (menuItem === "Select All Entities Touching Box") {
selectAllEtitiesInCurrentSelectionBox(true); selectAllEtitiesInCurrentSelectionBox(true);
} else if (menuItem == MENU_SHOW_LIGHTS_IN_EDIT_MODE) { } else if (menuItem === MENU_SHOW_LIGHTS_IN_EDIT_MODE) {
lightOverlayManager.setVisible(isActive && Menu.isOptionChecked(MENU_SHOW_LIGHTS_IN_EDIT_MODE)); lightOverlayManager.setVisible(isActive && Menu.isOptionChecked(MENU_SHOW_LIGHTS_IN_EDIT_MODE));
} else if (menuItem == MENU_SHOW_ZONES_IN_EDIT_MODE) { } else if (menuItem === MENU_SHOW_ZONES_IN_EDIT_MODE) {
Entities.setDrawZoneBoundaries(isActive && Menu.isOptionChecked(MENU_SHOW_ZONES_IN_EDIT_MODE)); Entities.setDrawZoneBoundaries(isActive && Menu.isOptionChecked(MENU_SHOW_ZONES_IN_EDIT_MODE));
} }
tooltip.show(false); tooltip.show(false);
@ -1175,7 +1175,7 @@ function importSVO(importURL) {
if (Clipboard.getClipboardContentsLargestDimension() < VERY_LARGE) { if (Clipboard.getClipboardContentsLargestDimension() < VERY_LARGE) {
position = getPositionToCreateEntity(); position = getPositionToCreateEntity();
} }
if (position != null) { if (position !== null && position !== undefined) {
var pastedEntityIDs = Clipboard.pasteEntities(position); var pastedEntityIDs = Clipboard.pasteEntities(position);
if (isActive) { if (isActive) {
@ -1212,13 +1212,13 @@ Controller.keyReleaseEvent.connect(function (event) {
cameraManager.keyReleaseEvent(event); cameraManager.keyReleaseEvent(event);
} }
// since sometimes our menu shortcut keys don't work, trap our menu items here also and fire the appropriate menu items // since sometimes our menu shortcut keys don't work, trap our menu items here also and fire the appropriate menu items
if (event.text == "BACKSPACE" || event.text == "DELETE") { if (event.text === "BACKSPACE" || event.text === "DELETE") {
deleteSelectedEntities(); deleteSelectedEntities();
} else if (event.text == "ESC") { } else if (event.text === "ESC") {
selectionManager.clearSelections(); selectionManager.clearSelections();
} else if (event.text == "TAB") { } else if (event.text === "TAB") {
selectionDisplay.toggleSpaceMode(); selectionDisplay.toggleSpaceMode();
} else if (event.text == "f") { } else if (event.text === "f") {
if (isActive) { if (isActive) {
if (selectionManager.hasSelection()) { if (selectionManager.hasSelection()) {
cameraManager.enable(); cameraManager.enable();
@ -1227,11 +1227,11 @@ Controller.keyReleaseEvent.connect(function (event) {
Menu.isOptionChecked(MENU_EASE_ON_FOCUS)); Menu.isOptionChecked(MENU_EASE_ON_FOCUS));
} }
} }
} else if (event.text == '[') { } else if (event.text === '[') {
if (isActive) { if (isActive) {
cameraManager.enable(); cameraManager.enable();
} }
} else if (event.text == 'g') { } else if (event.text === 'g') {
if (isActive && selectionManager.hasSelection()) { if (isActive && selectionManager.hasSelection()) {
var newPosition = selectionManager.worldPosition; var newPosition = selectionManager.worldPosition;
newPosition = Vec3.subtract(newPosition, { newPosition = Vec3.subtract(newPosition, {
@ -1368,11 +1368,11 @@ var PropertiesTool = function (opts) {
webView.webEventReceived.connect(function (data) { webView.webEventReceived.connect(function (data) {
data = JSON.parse(data); data = JSON.parse(data);
var i, properties, dY, diff, newPosition; var i, properties, dY, diff, newPosition;
if (data.type == "print") { if (data.type === "print") {
if (data.message) { if (data.message) {
print(data.message); print(data.message);
} }
} else if (data.type == "update") { } else if (data.type === "update") {
selectionManager.saveProperties(); selectionManager.saveProperties();
if (selectionManager.selections.length > 1) { if (selectionManager.selections.length > 1) {
properties = { properties = {
@ -1414,10 +1414,10 @@ var PropertiesTool = function (opts) {
} }
pushCommandForSelections(); pushCommandForSelections();
selectionManager._update(); selectionManager._update();
} else if (data.type == "showMarketplace") { } else if (data.type === "showMarketplace") {
showMarketplace(); showMarketplace();
} else if (data.type == "action") { } else if (data.type === "action") {
if (data.action == "moveSelectionToGrid") { if (data.action === "moveSelectionToGrid") {
if (selectionManager.hasSelection()) { if (selectionManager.hasSelection()) {
selectionManager.saveProperties(); selectionManager.saveProperties();
dY = grid.getOrigin().y - (selectionManager.worldPosition.y - selectionManager.worldDimensions.y / 2); dY = grid.getOrigin().y - (selectionManager.worldPosition.y - selectionManager.worldDimensions.y / 2);
@ -1436,7 +1436,7 @@ var PropertiesTool = function (opts) {
pushCommandForSelections(); pushCommandForSelections();
selectionManager._update(); selectionManager._update();
} }
} else if (data.action == "moveAllToGrid") { } else if (data.action === "moveAllToGrid") {
if (selectionManager.hasSelection()) { if (selectionManager.hasSelection()) {
selectionManager.saveProperties(); selectionManager.saveProperties();
for (i = 0; i < selectionManager.selections.length; i++) { for (i = 0; i < selectionManager.selections.length; i++) {
@ -1456,7 +1456,7 @@ var PropertiesTool = function (opts) {
pushCommandForSelections(); pushCommandForSelections();
selectionManager._update(); selectionManager._update();
} }
} else if (data.action == "resetToNaturalDimensions") { } else if (data.action === "resetToNaturalDimensions") {
if (selectionManager.hasSelection()) { if (selectionManager.hasSelection()) {
selectionManager.saveProperties(); selectionManager.saveProperties();
for (i = 0; i < selectionManager.selections.length; i++) { for (i = 0; i < selectionManager.selections.length; i++) {
@ -1464,8 +1464,8 @@ var PropertiesTool = function (opts) {
var naturalDimensions = properties.naturalDimensions; var naturalDimensions = properties.naturalDimensions;
// If any of the natural dimensions are not 0, resize // If any of the natural dimensions are not 0, resize
if (properties.type == "Model" && naturalDimensions.x == 0 && naturalDimensions.y == 0 && if (properties.type === "Model" && naturalDimensions.x === 0 && naturalDimensions.y === 0 &&
naturalDimensions.z == 0) { naturalDimensions.z === 0) {
Window.alert("Cannot reset entity to its natural dimensions: Model URL" + Window.alert("Cannot reset entity to its natural dimensions: Model URL" +
" is invalid or the model has not yet been loaded."); " is invalid or the model has not yet been loaded.");
} else { } else {
@ -1477,12 +1477,12 @@ var PropertiesTool = function (opts) {
pushCommandForSelections(); pushCommandForSelections();
selectionManager._update(); selectionManager._update();
} }
} else if (data.action == "previewCamera") { } else if (data.action === "previewCamera") {
if (selectionManager.hasSelection()) { if (selectionManager.hasSelection()) {
Camera.mode = "entity"; Camera.mode = "entity";
Camera.cameraEntity = selectionManager.selections[0]; Camera.cameraEntity = selectionManager.selections[0];
} }
} else if (data.action == "rescaleDimensions") { } else if (data.action === "rescaleDimensions") {
var multiplier = data.percentage / 100; var multiplier = data.percentage / 100;
if (selectionManager.hasSelection()) { if (selectionManager.hasSelection()) {
selectionManager.saveProperties(); selectionManager.saveProperties();
@ -1495,7 +1495,7 @@ var PropertiesTool = function (opts) {
pushCommandForSelections(); pushCommandForSelections();
selectionManager._update(); selectionManager._update();
} }
} else if (data.action == "reloadScript") { } else if (data.action === "reloadScript") {
if (selectionManager.hasSelection()) { if (selectionManager.hasSelection()) {
var timestamp = Date.now(); var timestamp = Date.now();
for (i = 0; i < selectionManager.selections.length; i++) { for (i = 0; i < selectionManager.selections.length; i++) {
@ -1605,13 +1605,13 @@ var PopupMenu = function () {
y: event.y y: event.y
}); });
if (!pressingOverlay) { if (!pressingOverlay) {
if (hoveringOverlay != null && overlay != hoveringOverlay) { if (hoveringOverlay !== null && hoveringOverlay !== null && overlay !== hoveringOverlay) {
Overlays.editOverlay(hoveringOverlay, { Overlays.editOverlay(hoveringOverlay, {
backgroundColor: upColor backgroundColor: upColor
}); });
hoveringOverlay = null; hoveringOverlay = null;
} }
if (overlay != hoveringOverlay && overlay in overlayInfo) { if (overlay !== hoveringOverlay && overlay in overlayInfo) {
Overlays.editOverlay(overlay, { Overlays.editOverlay(overlay, {
backgroundColor: overColor backgroundColor: overColor
}); });
@ -1626,8 +1626,8 @@ var PopupMenu = function () {
x: event.x, x: event.x,
y: event.y y: event.y
}); });
if (pressingOverlay != null) { if (pressingOverlay !== null && pressingOverlay !== undefined) {
if (overlay == pressingOverlay) { if (overlay === pressingOverlay) {
self.onSelectMenuItem(overlayInfo[overlay].name); self.onSelectMenuItem(overlayInfo[overlay].name);
} }
Overlays.editOverlay(pressingOverlay, { Overlays.editOverlay(pressingOverlay, {
@ -1641,7 +1641,7 @@ var PopupMenu = function () {
var visible = false; var visible = false;
self.setVisible = function (newVisible) { self.setVisible = function (newVisible) {
if (newVisible != visible) { if (newVisible !== visible) {
visible = newVisible; visible = newVisible;
for (var key in overlayInfo) { for (var key in overlayInfo) {
Overlays.editOverlay(key, { Overlays.editOverlay(key, {
@ -1688,7 +1688,7 @@ var particleExplorerTool = new ParticleExplorerTool();
var selectedParticleEntity = 0; var selectedParticleEntity = 0;
entityListTool.webView.webEventReceived.connect(function (data) { entityListTool.webView.webEventReceived.connect(function (data) {
data = JSON.parse(data); data = JSON.parse(data);
if (data.type == "selectionUpdate") { if (data.type === "selectionUpdate") {
var ids = data.entityIds; var ids = data.entityIds;
if (ids.length === 1) { if (ids.length === 1) {
if (Entities.getEntityProperties(ids[0], "type").type === "ParticleEffect") { if (Entities.getEntityProperties(ids[0], "type").type === "ParticleEffect") {