Minor code change

Minor code change
This commit is contained in:
Alezia Kurdis 2020-12-01 23:32:52 -05:00 committed by GitHub
parent 5a71881799
commit 670d832c8b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -9,8 +9,8 @@
const ASCENDING_SORT = 1; const ASCENDING_SORT = 1;
const DESCENDING_SORT = -1; const DESCENDING_SORT = -1;
const ASCENDING_STRING = '▴'; const ASCENDING_STRING = "▴";
const DESCENDING_STRING = '▾'; const DESCENDING_STRING = "▾";
const BYTES_PER_MEGABYTE = 1024 * 1024; const BYTES_PER_MEGABYTE = 1024 * 1024;
const COLLAPSE_EXTRA_INFO = "E"; const COLLAPSE_EXTRA_INFO = "E";
const EXPAND_EXTRA_INFO = "D"; const EXPAND_EXTRA_INFO = "D";
@ -34,7 +34,7 @@ function displayIfNonZero(number) {
} }
function getFilename(url) { function getFilename(url) {
let urlParts = url.split('/'); let urlParts = url.split("/");
return urlParts[urlParts.length - 1]; return urlParts[urlParts.length - 1];
} }
@ -195,7 +195,7 @@ let lastSelectedEntity;
*/ */
let entityListContextMenu = null; let entityListContextMenu = null;
let currentSortColumnID = 'type'; let currentSortColumnID = "type";
let currentSortOrder = ASCENDING_SORT; let currentSortOrder = ASCENDING_SORT;
let elSortOrders = {}; let elSortOrders = {};
let typeFilters = []; let typeFilters = [];
@ -279,7 +279,7 @@ let elEntityTable,
elRenameInput; elRenameInput;
const ENABLE_PROFILING = false; const ENABLE_PROFILING = false;
let profileIndent = ''; let profileIndent = "";
const PROFILE_NOOP = function(_name, fn, args) { const PROFILE_NOOP = function(_name, fn, args) {
fn.apply(this, args); fn.apply(this, args);
} ; } ;
@ -330,7 +330,7 @@ function loaded() {
elSelectTopParent = document.getElementById("selecttopparent"); elSelectTopParent = document.getElementById("selecttopparent");
elAddChildrenToSelection = document.getElementById("addchildrentoselection"); elAddChildrenToSelection = document.getElementById("addchildrentoselection");
elSelectFamily = document.getElementById("selectfamily"); elSelectFamily = document.getElementById("selectfamily");
elSelectTopFamily = document.getElementById("selecttopfamily"); elSelectTopFamily = document.getElementById("selecttopfamily");
elTeleportToEntity = document.getElementById("teleport-to-entity"); elTeleportToEntity = document.getElementById("teleport-to-entity");
elSetCameraFocusToSelection = document.getElementById("setCameraFocusToSelection"); elSetCameraFocusToSelection = document.getElementById("setCameraFocusToSelection");
elToggleLocalWorldMode = document.getElementById("toggleLocalWorldMode"); elToggleLocalWorldMode = document.getElementById("toggleLocalWorldMode");
@ -357,17 +357,17 @@ function loaded() {
elNoEntitiesMessage = document.getElementById("no-entities"); elNoEntitiesMessage = document.getElementById("no-entities");
elColumnsMultiselectBox = document.getElementById("entity-table-columns-multiselect-box"); elColumnsMultiselectBox = document.getElementById("entity-table-columns-multiselect-box");
elColumnsOptions = document.getElementById("entity-table-columns-options"); elColumnsOptions = document.getElementById("entity-table-columns-options");
elToggleSpaceMode = document.getElementById('toggle-space-mode'); elToggleSpaceMode = document.getElementById("toggle-space-mode");
document.body.onclick = onBodyClick; document.body.onclick = onBodyClick;
elToggleLocked.onclick = function() { elToggleLocked.onclick = function() {
EventBridge.emitWebEvent(JSON.stringify({ type: 'toggleLocked' })); EventBridge.emitWebEvent(JSON.stringify({ type: "toggleLocked" }));
}; };
elToggleVisible.onclick = function() { elToggleVisible.onclick = function() {
EventBridge.emitWebEvent(JSON.stringify({ type: 'toggleVisible' })); EventBridge.emitWebEvent(JSON.stringify({ type: "toggleVisible" }));
}; };
elExport.onclick = function() { elExport.onclick = function() {
EventBridge.emitWebEvent(JSON.stringify({ type: 'export'})); EventBridge.emitWebEvent(JSON.stringify({ type: "export"}));
}; };
elHmdMultiSelect.onclick = function() { elHmdMultiSelect.onclick = function() {
if (hmdMultiSelectMode) { if (hmdMultiSelectMode) {
@ -377,7 +377,7 @@ function loaded() {
elHmdMultiSelect.className = "white vglyph"; elHmdMultiSelect.className = "white vglyph";
hmdMultiSelectMode = true; hmdMultiSelectMode = true;
} }
EventBridge.emitWebEvent(JSON.stringify({ type: 'hmdMultiSelectMode', value: hmdMultiSelectMode })); EventBridge.emitWebEvent(JSON.stringify({ type: "hmdMultiSelectMode", value: hmdMultiSelectMode }));
}; };
elActionsMenu.onclick = function() { elActionsMenu.onclick = function() {
document.getElementById("menuBackgroundOverlay").style.display = "block"; document.getElementById("menuBackgroundOverlay").style.display = "block";
@ -395,43 +395,43 @@ function loaded() {
closeAllEntityListMenu(); closeAllEntityListMenu();
}; };
elHmdCopy.onclick = function() { elHmdCopy.onclick = function() {
EventBridge.emitWebEvent(JSON.stringify({ type: 'copy' })); EventBridge.emitWebEvent(JSON.stringify({ type: "copy" }));
closeAllEntityListMenu(); closeAllEntityListMenu();
}; };
elHmdCut.onclick = function() { elHmdCut.onclick = function() {
EventBridge.emitWebEvent(JSON.stringify({ type: 'cut' })); EventBridge.emitWebEvent(JSON.stringify({ type: "cut" }));
closeAllEntityListMenu(); closeAllEntityListMenu();
}; };
elHmdPaste.onclick = function() { elHmdPaste.onclick = function() {
EventBridge.emitWebEvent(JSON.stringify({ type: 'paste' })); EventBridge.emitWebEvent(JSON.stringify({ type: "paste" }));
closeAllEntityListMenu(); closeAllEntityListMenu();
}; };
elHmdDuplicate.onclick = function() { elHmdDuplicate.onclick = function() {
EventBridge.emitWebEvent(JSON.stringify({ type: 'duplicate' })); EventBridge.emitWebEvent(JSON.stringify({ type: "duplicate" }));
closeAllEntityListMenu(); closeAllEntityListMenu();
}; };
elParent.onclick = function() { elParent.onclick = function() {
EventBridge.emitWebEvent(JSON.stringify({ type: 'parent' })); EventBridge.emitWebEvent(JSON.stringify({ type: "parent" }));
closeAllEntityListMenu(); closeAllEntityListMenu();
}; };
elUnparent.onclick = function() { elUnparent.onclick = function() {
EventBridge.emitWebEvent(JSON.stringify({ type: 'unparent' })); EventBridge.emitWebEvent(JSON.stringify({ type: "unparent" }));
closeAllEntityListMenu(); closeAllEntityListMenu();
}; };
elUndo.onclick = function() { elUndo.onclick = function() {
EventBridge.emitWebEvent(JSON.stringify({ type: 'undo' })); EventBridge.emitWebEvent(JSON.stringify({ type: "undo" }));
closeAllEntityListMenu(); closeAllEntityListMenu();
}; };
elRedo.onclick = function() { elRedo.onclick = function() {
EventBridge.emitWebEvent(JSON.stringify({ type: 'redo' })); EventBridge.emitWebEvent(JSON.stringify({ type: "redo" }));
closeAllEntityListMenu(); closeAllEntityListMenu();
}; };
elDelete.onclick = function() { elDelete.onclick = function() {
EventBridge.emitWebEvent(JSON.stringify({ type: 'delete' })); EventBridge.emitWebEvent(JSON.stringify({ type: "delete" }));
closeAllEntityListMenu(); closeAllEntityListMenu();
}; };
elMoveEntitySelectionToAvatar.onclick = function() { elMoveEntitySelectionToAvatar.onclick = function() {
EventBridge.emitWebEvent(JSON.stringify({ type: 'moveEntitySelectionToAvatar' })); EventBridge.emitWebEvent(JSON.stringify({ type: "moveEntitySelectionToAvatar" }));
closeAllEntityListMenu(); closeAllEntityListMenu();
}; };
elSelectAll.onclick = function() { elSelectAll.onclick = function() {
@ -493,31 +493,31 @@ function loaded() {
closeAllEntityListMenu(); closeAllEntityListMenu();
}; };
elSelectAllInBox.onclick = function() { elSelectAllInBox.onclick = function() {
EventBridge.emitWebEvent(JSON.stringify({ type: 'selectAllInBox' })); EventBridge.emitWebEvent(JSON.stringify({ type: "selectAllInBox" }));
closeAllEntityListMenu(); closeAllEntityListMenu();
}; };
elSelectAllTouchingBox.onclick = function() { elSelectAllTouchingBox.onclick = function() {
EventBridge.emitWebEvent(JSON.stringify({ type: 'selectAllTouchingBox' })); EventBridge.emitWebEvent(JSON.stringify({ type: "selectAllTouchingBox" }));
closeAllEntityListMenu(); closeAllEntityListMenu();
}; };
elSelectParent.onclick = function() { elSelectParent.onclick = function() {
EventBridge.emitWebEvent(JSON.stringify({ type: 'selectParent' })); EventBridge.emitWebEvent(JSON.stringify({ type: "selectParent" }));
closeAllEntityListMenu(); closeAllEntityListMenu();
}; };
elSelectTopParent.onclick = function() { elSelectTopParent.onclick = function() {
EventBridge.emitWebEvent(JSON.stringify({ type: 'selectTopParent' })); EventBridge.emitWebEvent(JSON.stringify({ type: "selectTopParent" }));
closeAllEntityListMenu(); closeAllEntityListMenu();
}; };
elAddChildrenToSelection.onclick = function() { elAddChildrenToSelection.onclick = function() {
EventBridge.emitWebEvent(JSON.stringify({ type: 'addChildrenToSelection' })); EventBridge.emitWebEvent(JSON.stringify({ type: "addChildrenToSelection" }));
closeAllEntityListMenu(); closeAllEntityListMenu();
}; };
elSelectFamily.onclick = function() { elSelectFamily.onclick = function() {
EventBridge.emitWebEvent(JSON.stringify({ type: 'selectFamily' })); EventBridge.emitWebEvent(JSON.stringify({ type: "selectFamily" }));
closeAllEntityListMenu(); closeAllEntityListMenu();
}; };
elSelectTopFamily.onclick = function() { elSelectTopFamily.onclick = function() {
EventBridge.emitWebEvent(JSON.stringify({ type: 'selectTopFamily' })); EventBridge.emitWebEvent(JSON.stringify({ type: "selectTopFamily" }));
closeAllEntityListMenu(); closeAllEntityListMenu();
}; };
elTeleportToEntity.onclick = function () { elTeleportToEntity.onclick = function () {
@ -529,19 +529,19 @@ function loaded() {
closeAllEntityListMenu(); closeAllEntityListMenu();
}; };
elToggleLocalWorldMode.onclick = function () { elToggleLocalWorldMode.onclick = function () {
EventBridge.emitWebEvent(JSON.stringify({ type: 'toggleSpaceMode' })); EventBridge.emitWebEvent(JSON.stringify({ type: "toggleSpaceMode" }));
closeAllEntityListMenu(); closeAllEntityListMenu();
}; };
elExportSelectedEntities.onclick = function () { elExportSelectedEntities.onclick = function () {
EventBridge.emitWebEvent(JSON.stringify({ type: 'export'})); EventBridge.emitWebEvent(JSON.stringify({ type: "export"}));
closeAllEntityListMenu(); closeAllEntityListMenu();
}; };
elImportEntitiesFromFile.onclick = function () { elImportEntitiesFromFile.onclick = function () {
EventBridge.emitWebEvent(JSON.stringify({ type: 'importFromFile'})); EventBridge.emitWebEvent(JSON.stringify({ type: "importFromFile"}));
closeAllEntityListMenu(); closeAllEntityListMenu();
}; };
elImportEntitiesFromUrl.onclick = function () { elImportEntitiesFromUrl.onclick = function () {
EventBridge.emitWebEvent(JSON.stringify({ type: 'importFromUrl'})); EventBridge.emitWebEvent(JSON.stringify({ type: "importFromUrl"}));
closeAllEntityListMenu(); closeAllEntityListMenu();
}; };
elGridActivator.onclick = function () { elGridActivator.onclick = function () {
@ -561,7 +561,7 @@ function loaded() {
closeAllEntityListMenu(); closeAllEntityListMenu();
}; };
elToggleSpaceMode.onclick = function() { elToggleSpaceMode.onclick = function() {
EventBridge.emitWebEvent(JSON.stringify({ type: 'toggleSpaceMode' })); EventBridge.emitWebEvent(JSON.stringify({ type: "toggleSpaceMode" }));
}; };
elRefresh.onclick = refreshEntities; elRefresh.onclick = refreshEntities;
elFilterTypeMultiselectBox.onclick = onToggleTypeDropdown; elFilterTypeMultiselectBox.onclick = onToggleTypeDropdown;
@ -579,11 +579,11 @@ function loaded() {
let type = FILTER_TYPES[i]; let type = FILTER_TYPES[i];
let typeFilterID = "filter-type-" + type; let typeFilterID = "filter-type-" + type;
let elDiv = document.createElement('div'); let elDiv = document.createElement("div");
elDiv.onclick = onToggleTypeFilter; elDiv.onclick = onToggleTypeFilter;
elFilterTypeOptions.insertBefore(elDiv, elFilterTypeOptionsButtons); elFilterTypeOptions.insertBefore(elDiv, elFilterTypeOptionsButtons);
let elInput = document.createElement('input'); let elInput = document.createElement("input");
elInput.setAttribute("type", "checkbox"); elInput.setAttribute("type", "checkbox");
elInput.setAttribute("id", typeFilterID); elInput.setAttribute("id", typeFilterID);
elInput.setAttribute("filterType", type); elInput.setAttribute("filterType", type);
@ -591,12 +591,12 @@ function loaded() {
elFilterTypeInputs[type] = elInput; elFilterTypeInputs[type] = elInput;
elDiv.appendChild(elInput); elDiv.appendChild(elInput);
let elLabel = document.createElement('label'); let elLabel = document.createElement("label");
elLabel.setAttribute("for", typeFilterID); elLabel.setAttribute("for", typeFilterID);
elLabel.innerText = type; elLabel.innerText = type;
elDiv.appendChild(elLabel); elDiv.appendChild(elLabel);
let elSpan = document.createElement('span'); let elSpan = document.createElement("span");
elSpan.setAttribute("class", "typeIcon"); elSpan.setAttribute("class", "typeIcon");
elSpan.innerHTML = ENTITY_TYPE_ICON[type]; elSpan.innerHTML = ENTITY_TYPE_ICON[type];
@ -629,11 +629,11 @@ function loaded() {
elTh.innerText = columnData.columnHeader; elTh.innerText = columnData.columnHeader;
} }
elTh.onmousedown = function(event) { elTh.onmousedown = function(event) {
if (event.target.nodeName === 'TH') { if (event.target.nodeName === "TH") {
elTargetTh = event.target; elTargetTh = event.target;
targetColumnIndex = parseInt(elTargetTh.getAttribute("columnIndex")); targetColumnIndex = parseInt(elTargetTh.getAttribute("columnIndex"));
lastColumnSwapPosition = event.clientX; lastColumnSwapPosition = event.clientX;
} else if (event.target.nodeName === 'SPAN') { } else if (event.target.nodeName === "SPAN") {
elTargetSpan = event.target; elTargetSpan = event.target;
} }
initialThEvent = event; initialThEvent = event;
@ -656,18 +656,18 @@ function loaded() {
if (columnData.alwaysShown !== true) { if (columnData.alwaysShown !== true) {
let columnDropdownID = "entity-table-column-" + columnID; let columnDropdownID = "entity-table-column-" + columnID;
let elDiv = document.createElement('div'); let elDiv = document.createElement("div");
elDiv.onclick = onToggleColumn; elDiv.onclick = onToggleColumn;
elColumnsOptions.appendChild(elDiv); elColumnsOptions.appendChild(elDiv);
let elInput = document.createElement('input'); let elInput = document.createElement("input");
elInput.setAttribute("type", "checkbox"); elInput.setAttribute("type", "checkbox");
elInput.setAttribute("id", columnDropdownID); elInput.setAttribute("id", columnDropdownID);
elInput.setAttribute("columnID", columnID); elInput.setAttribute("columnID", columnID);
elInput.checked = columnData.initiallyShown === true; elInput.checked = columnData.initiallyShown === true;
elDiv.appendChild(elInput); elDiv.appendChild(elInput);
let elLabel = document.createElement('label'); let elLabel = document.createElement("label");
elLabel.setAttribute("for", columnDropdownID); elLabel.setAttribute("for", columnDropdownID);
elLabel.innerText = columnData.dropdownLabel; elLabel.innerText = columnData.dropdownLabel;
elDiv.appendChild(elLabel); elDiv.appendChild(elLabel);
@ -702,7 +702,7 @@ function loaded() {
let elCell = entity.elRow.childNodes[getColumnIndex("name")]; let elCell = entity.elRow.childNodes[getColumnIndex("name")];
elRenameInput = document.createElement("input"); elRenameInput = document.createElement("input");
elRenameInput.setAttribute('class', 'rename-entity'); elRenameInput.setAttribute("class", "rename-entity");
elRenameInput.value = entity.name; elRenameInput.value = entity.name;
let ignoreClicks = function(event) { let ignoreClicks = function(event) {
event.stopPropagation(); event.stopPropagation();
@ -767,22 +767,22 @@ function loaded() {
entityListContextMenu.setOnSelectedCallback(function(optionName, selectedEntityID) { entityListContextMenu.setOnSelectedCallback(function(optionName, selectedEntityID) {
switch (optionName) { switch (optionName) {
case "Cut": case "Cut":
EventBridge.emitWebEvent(JSON.stringify({ type: 'cut' })); EventBridge.emitWebEvent(JSON.stringify({ type: "cut" }));
break; break;
case "Copy": case "Copy":
EventBridge.emitWebEvent(JSON.stringify({ type: 'copy' })); EventBridge.emitWebEvent(JSON.stringify({ type: "copy" }));
break; break;
case "Paste": case "Paste":
EventBridge.emitWebEvent(JSON.stringify({ type: 'paste' })); EventBridge.emitWebEvent(JSON.stringify({ type: "paste" }));
break; break;
case "Rename": case "Rename":
startRenamingEntity(selectedEntityID); startRenamingEntity(selectedEntityID);
break; break;
case "Duplicate": case "Duplicate":
EventBridge.emitWebEvent(JSON.stringify({ type: 'duplicate' })); EventBridge.emitWebEvent(JSON.stringify({ type: "duplicate" }));
break; break;
case "Delete": case "Delete":
EventBridge.emitWebEvent(JSON.stringify({ type: 'delete' })); EventBridge.emitWebEvent(JSON.stringify({ type: "delete" }));
break; break;
} }
}); });
@ -806,11 +806,11 @@ function loaded() {
})); }));
} }
let enabledContextMenuItems = ['Copy', 'Paste', 'Duplicate']; let enabledContextMenuItems = ["Copy", "Paste", "Duplicate"];
if (entitiesByID[entityID] && !entitiesByID[entityID].locked) { if (entitiesByID[entityID] && !entitiesByID[entityID].locked) {
enabledContextMenuItems.push('Cut'); enabledContextMenuItems.push("Cut");
enabledContextMenuItems.push('Rename'); enabledContextMenuItems.push("Rename");
enabledContextMenuItems.push('Delete'); enabledContextMenuItems.push("Delete");
} }
entityListContextMenu.open(clickEvent, entityID, enabledContextMenuItems); entityListContextMenu.open(clickEvent, entityID, enabledContextMenuItems);
@ -1009,7 +1009,7 @@ function loaded() {
if (id === deletedIDs[i]) { if (id === deletedIDs[i]) {
let elRow = entities[j].elRow; let elRow = entities[j].elRow;
if (elRow) { if (elRow) {
elRow.className = ''; elRow.className = "";
elRow.dataset.entityID = EMPTY_ENTITY_ID; elRow.dataset.entityID = EMPTY_ENTITY_ID;
} }
entities.splice(j, 1); entities.splice(j, 1);
@ -1092,7 +1092,7 @@ function loaded() {
} }
function refreshEntities() { function refreshEntities() {
EventBridge.emitWebEvent(JSON.stringify({ type: 'refresh' })); EventBridge.emitWebEvent(JSON.stringify({ type: "refresh" }));
} }
function refreshFooter() { function refreshFooter() {
@ -1119,7 +1119,7 @@ function loaded() {
if (entity !== undefined) { if (entity !== undefined) {
entity.selected = false; entity.selected = false;
if (entity.elRow) { if (entity.elRow) {
entity.elRow.className = ''; entity.elRow.className = "";
} }
} }
}); });
@ -1133,9 +1133,9 @@ function loaded() {
entity.selected = true; entity.selected = true;
if (entity.elRow) { if (entity.elRow) {
if (id === lastSelectedEntity) { if (id === lastSelectedEntity) {
entity.elRow.className = 'last-selected'; entity.elRow.className = "last-selected";
} else { } else {
entity.elRow.className = 'selected'; entity.elRow.className = "selected";
} }
} }
} else { } else {
@ -1206,12 +1206,12 @@ function loaded() {
// if this entity was previously selected flag it's row as selected // if this entity was previously selected flag it's row as selected
if (itemData.selected) { if (itemData.selected) {
if (itemData.id === lastSelectedEntity) { if (itemData.id === lastSelectedEntity) {
elRow.className = 'last-selected'; elRow.className = "last-selected";
} else { } else {
elRow.className = 'selected'; elRow.className = "selected";
} }
} else { } else {
elRow.className = ''; elRow.className = "";
} }
// if this row previously had an associated entity ID that wasn't the new entity ID then clear // if this row previously had an associated entity ID that wasn't the new entity ID then clear
@ -1264,9 +1264,9 @@ function loaded() {
} }
function onRadiusChange() { function onRadiusChange() {
elFilterRadius.value = elFilterRadius.value.replace(/[^0-9]/g, ''); elFilterRadius.value = elFilterRadius.value.replace(/[^0-9]/g, "");
elFilterRadius.value = Math.max(elFilterRadius.value, 0); elFilterRadius.value = Math.max(elFilterRadius.value, 0);
EventBridge.emitWebEvent(JSON.stringify({ type: 'radius', radius: elFilterRadius.value })); EventBridge.emitWebEvent(JSON.stringify({ type: "radius", radius: elFilterRadius.value }));
refreshEntities(); refreshEntities();
} }
@ -1487,7 +1487,7 @@ function loaded() {
} }
if (isColumnsSettingLoaded) { if (isColumnsSettingLoaded) {
EventBridge.emitWebEvent(JSON.stringify({ type: 'saveColumnsConfigSetting', columnsData: columns })); EventBridge.emitWebEvent(JSON.stringify({ type: "saveColumnsConfigSetting", columnsData: columns }));
} }
entityList.refresh(); entityList.refresh();
@ -1690,7 +1690,7 @@ function loaded() {
} }
EventBridge.emitWebEvent(JSON.stringify({ EventBridge.emitWebEvent(JSON.stringify({
type: 'keyUpEvent', type: "keyUpEvent",
keyUpEvent: { keyUpEvent: {
code, code,
key, key,
@ -1790,7 +1790,7 @@ function loaded() {
} }
} }
} else { } else {
EventBridge.emitWebEvent(JSON.stringify({ type: 'saveColumnsConfigSetting', columnsData: "" })); EventBridge.emitWebEvent(JSON.stringify({ type: "saveColumnsConfigSetting", columnsData: "" }));
} }
} }
isColumnsSettingLoaded = true; isColumnsSettingLoaded = true;
@ -1803,7 +1803,7 @@ function loaded() {
window.addEventListener("resize", updateColumnWidths); window.addEventListener("resize", updateColumnWidths);
EventBridge.emitWebEvent(JSON.stringify({ type: 'loadConfigSetting' })); EventBridge.emitWebEvent(JSON.stringify({ type: "loadConfigSetting" }));
}); });
augmentSpinButtons(); augmentSpinButtons();