mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 00:36:47 +02:00
[Case 7049] JSHint Run: Fixes majority of noted lint issues (details below).
* 3 JSHint issues remain as of this commit, 3 instances of the same error. * Error: Functions declared within loops referencing an outer scoped variable may lead to confusing semantics. * scripts/system/html/js/entityProperties.js: line 469, col 27 * scripts/system/html/js/entityProperties.js: line 1634, col 30 * scripts/system/html/js/entityProperties.js: line 1641, col 32 Tested and prior fix to remove duplicate color fields for entity types is preserved for non-particle entity types. Changes Committed: modified: scripts/system/html/js/entityProperties.js
This commit is contained in:
parent
3152d5808e
commit
834fe2f5d5
1 changed files with 155 additions and 152 deletions
|
@ -6,6 +6,9 @@
|
||||||
// Distributed under the Apache License, Version 2.0.
|
// Distributed under the Apache License, Version 2.0.
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
|
||||||
|
/* global alert, clearTimeout, console, document, Element, EventBridge,
|
||||||
|
HifiEntityUI, JSONEditor, openEventBridge, setTimeout, window, _ $ */
|
||||||
|
|
||||||
var PI = 3.14159265358979;
|
var PI = 3.14159265358979;
|
||||||
var DEGREES_TO_RADIANS = PI / 180.0;
|
var DEGREES_TO_RADIANS = PI / 180.0;
|
||||||
var RADIANS_TO_DEGREES = 180.0 / PI;
|
var RADIANS_TO_DEGREES = 180.0 / PI;
|
||||||
|
@ -22,33 +25,33 @@ var ICON_FOR_TYPE = {
|
||||||
PolyVox: "",
|
PolyVox: "",
|
||||||
Multiple: "",
|
Multiple: "",
|
||||||
PolyLine: ""
|
PolyLine: ""
|
||||||
}
|
};
|
||||||
|
|
||||||
var EDITOR_TIMEOUT_DURATION = 1500;
|
var EDITOR_TIMEOUT_DURATION = 1500;
|
||||||
const KEY_P = 80; //Key code for letter p used for Parenting hotkey.
|
var KEY_P = 80; // Key code for letter p used for Parenting hotkey.
|
||||||
var colorPickers = [];
|
var colorPickers = [];
|
||||||
var lastEntityID = null;
|
var lastEntityID = null;
|
||||||
|
|
||||||
debugPrint = function(message) {
|
function debugPrint(message) {
|
||||||
EventBridge.emitWebEvent(
|
EventBridge.emitWebEvent(
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
type: "print",
|
type: "print",
|
||||||
message: message
|
message: message
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
};
|
}
|
||||||
|
|
||||||
function enableChildren(el, selector) {
|
function enableChildren(el, selector) {
|
||||||
els = el.querySelectorAll(selector);
|
var elSelectors = el.querySelectorAll(selector);
|
||||||
for (var i = 0; i < els.length; i++) {
|
for (var selectorIndex = 0; selectorIndex < elSelectors.length; ++selectorIndex) {
|
||||||
els[i].removeAttribute('disabled');
|
elSelectors[selectorIndex].removeAttribute('disabled');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function disableChildren(el, selector) {
|
function disableChildren(el, selector) {
|
||||||
els = el.querySelectorAll(selector);
|
var elSelectors = el.querySelectorAll(selector);
|
||||||
for (var i = 0; i < els.length; i++) {
|
for (var selectorIndex = 0; selectorIndex < elSelectors.length; ++selectorIndex) {
|
||||||
els[i].setAttribute('disabled', 'disabled');
|
elSelectors[selectorIndex].setAttribute('disabled', 'disabled');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,16 +106,6 @@ function createEmitCheckedPropertyUpdateFunction(propertyName) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function createEmitCheckedToStringPropertyUpdateFunction(checkboxElement, name, propertyName) {
|
|
||||||
var newString = "";
|
|
||||||
if (checkboxElement.checked) {
|
|
||||||
newString += name + "";
|
|
||||||
} else {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function createEmitGroupCheckedPropertyUpdateFunction(group, propertyName) {
|
function createEmitGroupCheckedPropertyUpdateFunction(group, propertyName) {
|
||||||
return function() {
|
return function() {
|
||||||
var properties = {};
|
var properties = {};
|
||||||
|
@ -123,7 +116,7 @@ function createEmitGroupCheckedPropertyUpdateFunction(group, propertyName) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function createEmitNumberPropertyUpdateFunction(propertyName, decimals) {
|
function createEmitNumberPropertyUpdateFunction(propertyName, decimals) {
|
||||||
decimals = decimals == undefined ? 4 : decimals;
|
decimals = ((decimals === undefined) ? 4 : decimals);
|
||||||
return function() {
|
return function() {
|
||||||
var value = parseFloat(this.value).toFixed(decimals);
|
var value = parseFloat(this.value).toFixed(decimals);
|
||||||
updateProperty(propertyName, value);
|
updateProperty(propertyName, value);
|
||||||
|
@ -146,7 +139,9 @@ function createEmitTextPropertyUpdateFunction(propertyName) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function createZoneComponentModeChangedFunction(zoneComponent, zoneComponentModeInherit, zoneComponentModeDisabled, zoneComponentModeEnabled) {
|
function createZoneComponentModeChangedFunction(zoneComponent, zoneComponentModeInherit,
|
||||||
|
zoneComponentModeDisabled, zoneComponentModeEnabled) {
|
||||||
|
|
||||||
return function() {
|
return function() {
|
||||||
var zoneComponentMode;
|
var zoneComponentMode;
|
||||||
|
|
||||||
|
@ -159,7 +154,7 @@ function createZoneComponentModeChangedFunction(zoneComponent, zoneComponentMode
|
||||||
}
|
}
|
||||||
|
|
||||||
updateProperty(zoneComponent, zoneComponentMode);
|
updateProperty(zoneComponent, zoneComponentMode);
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function createEmitGroupTextPropertyUpdateFunction(group, propertyName) {
|
function createEmitGroupTextPropertyUpdateFunction(group, propertyName) {
|
||||||
|
@ -177,11 +172,11 @@ function createEmitVec3PropertyUpdateFunction(property, elX, elY, elZ) {
|
||||||
properties[property] = {
|
properties[property] = {
|
||||||
x: elX.value,
|
x: elX.value,
|
||||||
y: elY.value,
|
y: elY.value,
|
||||||
z: elZ.value,
|
z: elZ.value
|
||||||
};
|
};
|
||||||
updateProperties(properties);
|
updateProperties(properties);
|
||||||
}
|
};
|
||||||
};
|
}
|
||||||
|
|
||||||
function createEmitGroupVec3PropertyUpdateFunction(group, property, elX, elY, elZ) {
|
function createEmitGroupVec3PropertyUpdateFunction(group, property, elX, elY, elZ) {
|
||||||
return function() {
|
return function() {
|
||||||
|
@ -190,11 +185,11 @@ function createEmitGroupVec3PropertyUpdateFunction(group, property, elX, elY, el
|
||||||
properties[group][property] = {
|
properties[group][property] = {
|
||||||
x: elX.value,
|
x: elX.value,
|
||||||
y: elY.value,
|
y: elY.value,
|
||||||
z: elZ ? elZ.value : 0,
|
z: elZ ? elZ.value : 0
|
||||||
};
|
};
|
||||||
updateProperties(properties);
|
updateProperties(properties);
|
||||||
}
|
};
|
||||||
};
|
}
|
||||||
|
|
||||||
function createEmitVec3PropertyUpdateFunctionWithMultiplier(property, elX, elY, elZ, multiplier) {
|
function createEmitVec3PropertyUpdateFunctionWithMultiplier(property, elX, elY, elZ, multiplier) {
|
||||||
return function() {
|
return function() {
|
||||||
|
@ -202,17 +197,17 @@ function createEmitVec3PropertyUpdateFunctionWithMultiplier(property, elX, elY,
|
||||||
properties[property] = {
|
properties[property] = {
|
||||||
x: elX.value * multiplier,
|
x: elX.value * multiplier,
|
||||||
y: elY.value * multiplier,
|
y: elY.value * multiplier,
|
||||||
z: elZ.value * multiplier,
|
z: elZ.value * multiplier
|
||||||
};
|
};
|
||||||
updateProperties(properties);
|
updateProperties(properties);
|
||||||
}
|
};
|
||||||
};
|
}
|
||||||
|
|
||||||
function createEmitColorPropertyUpdateFunction(property, elRed, elGreen, elBlue) {
|
function createEmitColorPropertyUpdateFunction(property, elRed, elGreen, elBlue) {
|
||||||
return function() {
|
return function() {
|
||||||
emitColorPropertyUpdate(property, elRed.value, elGreen.value, elBlue.value);
|
emitColorPropertyUpdate(property, elRed.value, elGreen.value, elBlue.value);
|
||||||
}
|
};
|
||||||
};
|
}
|
||||||
|
|
||||||
function emitColorPropertyUpdate(property, red, green, blue, group) {
|
function emitColorPropertyUpdate(property, red, green, blue, group) {
|
||||||
var properties = {};
|
var properties = {};
|
||||||
|
@ -221,17 +216,17 @@ function emitColorPropertyUpdate(property, red, green, blue, group) {
|
||||||
properties[group][property] = {
|
properties[group][property] = {
|
||||||
red: red,
|
red: red,
|
||||||
green: green,
|
green: green,
|
||||||
blue: blue,
|
blue: blue
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
properties[property] = {
|
properties[property] = {
|
||||||
red: red,
|
red: red,
|
||||||
green: green,
|
green: green,
|
||||||
blue: blue,
|
blue: blue
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
updateProperties(properties);
|
updateProperties(properties);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
function createEmitGroupColorPropertyUpdateFunction(group, property, elRed, elGreen, elBlue) {
|
function createEmitGroupColorPropertyUpdateFunction(group, property, elRed, elGreen, elBlue) {
|
||||||
|
@ -241,11 +236,11 @@ function createEmitGroupColorPropertyUpdateFunction(group, property, elRed, elGr
|
||||||
properties[group][property] = {
|
properties[group][property] = {
|
||||||
red: elRed.value,
|
red: elRed.value,
|
||||||
green: elGreen.value,
|
green: elGreen.value,
|
||||||
blue: elBlue.value,
|
blue: elBlue.value
|
||||||
};
|
};
|
||||||
updateProperties(properties);
|
updateProperties(properties);
|
||||||
}
|
};
|
||||||
};
|
}
|
||||||
|
|
||||||
function updateCheckedSubProperty(propertyName, propertyValue, subPropertyElement, subPropertyString) {
|
function updateCheckedSubProperty(propertyName, propertyValue, subPropertyElement, subPropertyString) {
|
||||||
if (subPropertyElement.checked) {
|
if (subPropertyElement.checked) {
|
||||||
|
@ -264,12 +259,12 @@ function setUserDataFromEditor(noUpdate) {
|
||||||
try {
|
try {
|
||||||
json = editor.get();
|
json = editor.get();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
alert('Invalid JSON code - look for red X in your code ', +e)
|
alert('Invalid JSON code - look for red X in your code ', +e);
|
||||||
}
|
}
|
||||||
if (json === null) {
|
if (json === null) {
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
var text = editor.getText()
|
var text = editor.getText();
|
||||||
if (noUpdate === true) {
|
if (noUpdate === true) {
|
||||||
EventBridge.emitWebEvent(
|
EventBridge.emitWebEvent(
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
|
@ -277,7 +272,7 @@ function setUserDataFromEditor(noUpdate) {
|
||||||
type: "saveUserData",
|
type: "saveUserData",
|
||||||
properties: {
|
properties: {
|
||||||
userData: text
|
userData: text
|
||||||
},
|
}
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
|
@ -292,22 +287,24 @@ function multiDataUpdater(groupName, updateKeyPair, userDataElement, defaults) {
|
||||||
var parsedData = {};
|
var parsedData = {};
|
||||||
try {
|
try {
|
||||||
if ($('#userdata-editor').css('height') !== "0px") {
|
if ($('#userdata-editor').css('height') !== "0px") {
|
||||||
//if there is an expanded, we want to use its json.
|
// if there is an expanded, we want to use its json.
|
||||||
parsedData = getEditorJSON();
|
parsedData = getEditorJSON();
|
||||||
} else {
|
} else {
|
||||||
parsedData = JSON.parse(userDataElement.value);
|
parsedData = JSON.parse(userDataElement.value);
|
||||||
}
|
}
|
||||||
} catch (e) {}
|
} catch (e) {
|
||||||
|
// TODO: Should an alert go here?
|
||||||
|
}
|
||||||
|
|
||||||
if (!(groupName in parsedData)) {
|
if (!(groupName in parsedData)) {
|
||||||
parsedData[groupName] = {}
|
parsedData[groupName] = {};
|
||||||
}
|
}
|
||||||
var keys = Object.keys(updateKeyPair);
|
var keys = Object.keys(updateKeyPair);
|
||||||
keys.forEach(function (key) {
|
keys.forEach(function (key) {
|
||||||
delete parsedData[groupName][key];
|
delete parsedData[groupName][key];
|
||||||
if (updateKeyPair[key] !== null && updateKeyPair[key] !== "null") {
|
if (updateKeyPair[key] !== null && updateKeyPair[key] !== "null") {
|
||||||
if (updateKeyPair[key] instanceof Element) {
|
if (updateKeyPair[key] instanceof Element) {
|
||||||
if(updateKeyPair[key].type === "checkbox") {
|
if (updateKeyPair[key].type === "checkbox") {
|
||||||
if (updateKeyPair[key].checked !== defaults[key]) {
|
if (updateKeyPair[key].checked !== defaults[key]) {
|
||||||
parsedData[groupName][key] = updateKeyPair[key].checked;
|
parsedData[groupName][key] = updateKeyPair[key].checked;
|
||||||
}
|
}
|
||||||
|
@ -322,16 +319,16 @@ function multiDataUpdater(groupName, updateKeyPair, userDataElement, defaults) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (Object.keys(parsedData[groupName]).length == 0) {
|
if (Object.keys(parsedData[groupName]).length === 0) {
|
||||||
delete parsedData[groupName];
|
delete parsedData[groupName];
|
||||||
}
|
}
|
||||||
if (Object.keys(parsedData).length > 0) {
|
if (Object.keys(parsedData).length > 0) {
|
||||||
properties['userData'] = JSON.stringify(parsedData);
|
properties.userData = JSON.stringify(parsedData);
|
||||||
} else {
|
} else {
|
||||||
properties['userData'] = '';
|
properties.userData = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
userDataElement.value = properties['userData'];
|
userDataElement.value = properties.userData;
|
||||||
|
|
||||||
updateProperties(properties);
|
updateProperties(properties);
|
||||||
}
|
}
|
||||||
|
@ -340,13 +337,12 @@ function userDataChanger(groupName, keyName, values, userDataElement, defaultVal
|
||||||
val[keyName] = values;
|
val[keyName] = values;
|
||||||
def[keyName] = defaultValue;
|
def[keyName] = defaultValue;
|
||||||
multiDataUpdater(groupName, val, userDataElement, def);
|
multiDataUpdater(groupName, val, userDataElement, def);
|
||||||
};
|
}
|
||||||
|
|
||||||
function setTextareaScrolling(element) {
|
function setTextareaScrolling(element) {
|
||||||
var isScrolling = element.scrollHeight > element.offsetHeight;
|
var isScrolling = element.scrollHeight > element.offsetHeight;
|
||||||
element.setAttribute("scrolling", isScrolling ? "true" : "false");
|
element.setAttribute("scrolling", isScrolling ? "true" : "false");
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var editor = null;
|
var editor = null;
|
||||||
|
@ -364,7 +360,7 @@ function createJSONEditor() {
|
||||||
$('.jsoneditor-poweredBy').remove();
|
$('.jsoneditor-poweredBy').remove();
|
||||||
},
|
},
|
||||||
onError: function(e) {
|
onError: function(e) {
|
||||||
alert('JSON editor:' + e)
|
alert('JSON editor:' + e);
|
||||||
},
|
},
|
||||||
onChange: function() {
|
onChange: function() {
|
||||||
var currentJSONString = editor.getText();
|
var currentJSONString = editor.getText();
|
||||||
|
@ -372,22 +368,22 @@ function createJSONEditor() {
|
||||||
if (currentJSONString === '{"":""}') {
|
if (currentJSONString === '{"":""}') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$('#userdata-save').attr('disabled', false)
|
$('#userdata-save').attr('disabled', false);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
editor = new JSONEditor(container, options);
|
editor = new JSONEditor(container, options);
|
||||||
};
|
}
|
||||||
|
|
||||||
function hideNewJSONEditorButton() {
|
function hideNewJSONEditorButton() {
|
||||||
$('#userdata-new-editor').hide();
|
$('#userdata-new-editor').hide();
|
||||||
|
|
||||||
};
|
}
|
||||||
|
|
||||||
function hideClearUserDataButton() {
|
function hideClearUserDataButton() {
|
||||||
$('#userdata-clear').hide();
|
$('#userdata-clear').hide();
|
||||||
};
|
}
|
||||||
|
|
||||||
function showSaveUserDataButton() {
|
function showSaveUserDataButton() {
|
||||||
$('#userdata-save').show();
|
$('#userdata-save').show();
|
||||||
|
@ -401,65 +397,65 @@ function hideSaveUserDataButton() {
|
||||||
function showNewJSONEditorButton() {
|
function showNewJSONEditorButton() {
|
||||||
$('#userdata-new-editor').show();
|
$('#userdata-new-editor').show();
|
||||||
|
|
||||||
};
|
}
|
||||||
|
|
||||||
function showClearUserDataButton() {
|
function showClearUserDataButton() {
|
||||||
$('#userdata-clear').show();
|
$('#userdata-clear').show();
|
||||||
|
|
||||||
};
|
}
|
||||||
|
|
||||||
function showUserDataTextArea() {
|
function showUserDataTextArea() {
|
||||||
$('#property-user-data').show();
|
$('#property-user-data').show();
|
||||||
};
|
}
|
||||||
|
|
||||||
function hideUserDataTextArea() {
|
function hideUserDataTextArea() {
|
||||||
$('#property-user-data').hide();
|
$('#property-user-data').hide();
|
||||||
};
|
}
|
||||||
|
|
||||||
function showStaticUserData() {
|
function showStaticUserData() {
|
||||||
if (editor !== null) {
|
if (editor !== null) {
|
||||||
$('#static-userdata').show();
|
$('#static-userdata').show();
|
||||||
$('#static-userdata').css('height', $('#userdata-editor').height())
|
$('#static-userdata').css('height', $('#userdata-editor').height());
|
||||||
$('#static-userdata').text(editor.getText());
|
$('#static-userdata').text(editor.getText());
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
function removeStaticUserData() {
|
function removeStaticUserData() {
|
||||||
$('#static-userdata').hide();
|
$('#static-userdata').hide();
|
||||||
};
|
}
|
||||||
|
|
||||||
function setEditorJSON(json) {
|
function setEditorJSON(json) {
|
||||||
editor.set(json)
|
editor.set(json);
|
||||||
if (editor.hasOwnProperty('expandAll')) {
|
if (editor.hasOwnProperty('expandAll')) {
|
||||||
editor.expandAll();
|
editor.expandAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
}
|
||||||
|
|
||||||
function getEditorJSON() {
|
function getEditorJSON() {
|
||||||
return editor.get();
|
return editor.get();
|
||||||
};
|
}
|
||||||
|
|
||||||
function deleteJSONEditor() {
|
function deleteJSONEditor() {
|
||||||
if (editor !== null) {
|
if (editor !== null) {
|
||||||
editor.destroy();
|
editor.destroy();
|
||||||
editor = null;
|
editor = null;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
var savedJSONTimer = null;
|
var savedJSONTimer = null;
|
||||||
|
|
||||||
function saveJSONUserData(noUpdate) {
|
function saveJSONUserData(noUpdate) {
|
||||||
setUserDataFromEditor(noUpdate);
|
setUserDataFromEditor(noUpdate);
|
||||||
$('#userdata-saved').show();
|
$('#userdata-saved').show();
|
||||||
$('#userdata-save').attr('disabled', true)
|
$('#userdata-save').attr('disabled', true);
|
||||||
if (savedJSONTimer !== null) {
|
if (savedJSONTimer !== null) {
|
||||||
clearTimeout(savedJSONTimer);
|
clearTimeout(savedJSONTimer);
|
||||||
}
|
}
|
||||||
savedJSONTimer = setTimeout(function() {
|
savedJSONTimer = setTimeout(function() {
|
||||||
$('#userdata-saved').hide();
|
$('#userdata-saved').hide();
|
||||||
|
|
||||||
}, 1500)
|
}, 1500);
|
||||||
}
|
}
|
||||||
|
|
||||||
function bindAllNonJSONEditorElements() {
|
function bindAllNonJSONEditorElements() {
|
||||||
|
@ -468,6 +464,8 @@ function bindAllNonJSONEditorElements() {
|
||||||
for (i = 0; i < inputs.length; i++) {
|
for (i = 0; i < inputs.length; i++) {
|
||||||
var input = inputs[i];
|
var input = inputs[i];
|
||||||
var field = $(input);
|
var field = $(input);
|
||||||
|
// TODO FIXME: (JSHint) Functions declared within loops referencing
|
||||||
|
// an outer scoped variable may lead to confusing semantics.
|
||||||
field.on('focus', function(e) {
|
field.on('focus', function(e) {
|
||||||
if (e.target.id === "userdata-new-editor" || e.target.id === "userdata-clear") {
|
if (e.target.id === "userdata-new-editor" || e.target.id === "userdata-clear") {
|
||||||
return;
|
return;
|
||||||
|
@ -477,7 +475,7 @@ function bindAllNonJSONEditorElements() {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -492,12 +490,12 @@ function unbindAllInputs() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearSelection() {
|
function clearSelection() {
|
||||||
if(document.selection && document.selection.empty) {
|
if (document.selection && document.selection.empty) {
|
||||||
document.selection.empty();
|
document.selection.empty();
|
||||||
} else if(window.getSelection) {
|
} else if (window.getSelection) {
|
||||||
var sel = window.getSelection();
|
var sel = window.getSelection();
|
||||||
sel.removeAllRanges();
|
sel.removeAllRanges();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function loaded() {
|
function loaded() {
|
||||||
|
@ -752,9 +750,9 @@ function loaded() {
|
||||||
} else {
|
} else {
|
||||||
elServerScriptStatus.innerText = "Not running";
|
elServerScriptStatus.innerText = "Not running";
|
||||||
}
|
}
|
||||||
} else if (data.type == "update") {
|
} else if (data.type === "update") {
|
||||||
|
|
||||||
if (!data.selections || data.selections.length == 0) {
|
if (!data.selections || data.selections.length === 0) {
|
||||||
if (editor !== null && lastEntityID !== null) {
|
if (editor !== null && lastEntityID !== null) {
|
||||||
saveJSONUserData(true);
|
saveJSONUserData(true);
|
||||||
deleteJSONEditor();
|
deleteJSONEditor();
|
||||||
|
@ -774,20 +772,19 @@ function loaded() {
|
||||||
|
|
||||||
for (var i = 0; i < selections.length; i++) {
|
for (var i = 0; i < selections.length; i++) {
|
||||||
ids.push(selections[i].id);
|
ids.push(selections[i].id);
|
||||||
var type = selections[i].properties.type;
|
var curSelectedType = selections[i].properties.type;
|
||||||
if (types[type] === undefined) {
|
if (types[curSelectedType] === undefined) {
|
||||||
types[type] = 0;
|
types[curSelectedType] = 0;
|
||||||
numTypes += 1;
|
numTypes += 1;
|
||||||
}
|
}
|
||||||
types[type]++;
|
types[curSelectedType]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
var type;
|
var type = "Multiple";
|
||||||
if (numTypes === 1) {
|
if (numTypes === 1) {
|
||||||
type = selections[0].properties.type;
|
type = selections[0].properties.type;
|
||||||
} else {
|
|
||||||
type = "Multiple";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
elType.innerHTML = type + " (" + data.selections.length + ")";
|
elType.innerHTML = type + " (" + data.selections.length + ")";
|
||||||
elTypeIcon.innerHTML = ICON_FOR_TYPE[type];
|
elTypeIcon.innerHTML = ICON_FOR_TYPE[type];
|
||||||
elTypeIcon.style.display = "inline-block";
|
elTypeIcon.style.display = "inline-block";
|
||||||
|
@ -882,13 +879,13 @@ function loaded() {
|
||||||
elCloneableLifetime.value = 300;
|
elCloneableLifetime.value = 300;
|
||||||
|
|
||||||
var grabbablesSet = false;
|
var grabbablesSet = false;
|
||||||
var parsedUserData = {}
|
var parsedUserData = {};
|
||||||
try {
|
try {
|
||||||
parsedUserData = JSON.parse(properties.userData);
|
parsedUserData = JSON.parse(properties.userData);
|
||||||
|
|
||||||
if ("grabbableKey" in parsedUserData) {
|
if ("grabbableKey" in parsedUserData) {
|
||||||
grabbablesSet = true;
|
grabbablesSet = true;
|
||||||
var grabbableData = parsedUserData["grabbableKey"];
|
var grabbableData = parsedUserData.grabbableKey;
|
||||||
if ("grabbable" in grabbableData) {
|
if ("grabbable" in grabbableData) {
|
||||||
elGrabbable.checked = grabbableData.grabbable;
|
elGrabbable.checked = grabbableData.grabbable;
|
||||||
} else {
|
} else {
|
||||||
|
@ -906,27 +903,28 @@ function loaded() {
|
||||||
}
|
}
|
||||||
if ("cloneable" in grabbableData) {
|
if ("cloneable" in grabbableData) {
|
||||||
elCloneable.checked = grabbableData.cloneable;
|
elCloneable.checked = grabbableData.cloneable;
|
||||||
elCloneableGroup.style.display = elCloneable.checked ? "block": "none";
|
elCloneableGroup.style.display = elCloneable.checked ? "block" : "none";
|
||||||
elCloneableDynamic.checked =
|
elCloneableDynamic.checked =
|
||||||
grabbableData.cloneDynamic ? grabbableData.cloneDynamic : properties.dynamic;
|
grabbableData.cloneDynamic ? grabbableData.cloneDynamic : properties.dynamic;
|
||||||
if (elCloneable.checked) {
|
if (elCloneable.checked) {
|
||||||
if ("cloneLifetime" in grabbableData) {
|
if ("cloneLifetime" in grabbableData) {
|
||||||
elCloneableLifetime.value =
|
elCloneableLifetime.value =
|
||||||
grabbableData.cloneLifetime ? grabbableData.cloneLifetime : 300;
|
grabbableData.cloneLifetime ? grabbableData.cloneLifetime : 300;
|
||||||
}
|
}
|
||||||
if ("cloneLimit" in grabbableData) {
|
if ("cloneLimit" in grabbableData) {
|
||||||
elCloneableLimit.value = grabbableData.cloneLimit ? grabbableData.cloneLimit : 0;
|
elCloneableLimit.value = grabbableData.cloneLimit ? grabbableData.cloneLimit : 0;
|
||||||
}
|
}
|
||||||
if ("cloneAvatarEntity" in grabbableData) {
|
if ("cloneAvatarEntity" in grabbableData) {
|
||||||
elCloneableAvatarEntity.checked =
|
elCloneableAvatarEntity.checked =
|
||||||
grabbableData.cloneAvatarEntity ? grabbableData.cloneAvatarEntity : false;
|
grabbableData.cloneAvatarEntity ? grabbableData.cloneAvatarEntity : false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
elCloneable.checked = false;
|
elCloneable.checked = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
// TODO: What should go here?
|
||||||
}
|
}
|
||||||
if (!grabbablesSet) {
|
if (!grabbablesSet) {
|
||||||
elGrabbable.checked = true;
|
elGrabbable.checked = true;
|
||||||
|
@ -967,19 +965,19 @@ function loaded() {
|
||||||
elDescription.value = properties.description;
|
elDescription.value = properties.description;
|
||||||
|
|
||||||
|
|
||||||
if (properties.type == "Shape" || properties.type == "Box" || properties.type == "Sphere") {
|
if (properties.type === "Shape" || properties.type === "Box" || properties.type === "Sphere") {
|
||||||
elShape.value = properties.shape;
|
elShape.value = properties.shape;
|
||||||
setDropdownText(elShape);
|
setDropdownText(elShape);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (properties.type == "Shape" || properties.type == "Box" || properties.type == "Sphere" || properties.type == "ParticleEffect") {
|
if (properties.type === "Shape" || properties.type === "Box" || properties.type === "Sphere" || properties.type === "ParticleEffect") {
|
||||||
elColorRed.value = properties.color.red;
|
elColorRed.value = properties.color.red;
|
||||||
elColorGreen.value = properties.color.green;
|
elColorGreen.value = properties.color.green;
|
||||||
elColorBlue.value = properties.color.blue;
|
elColorBlue.value = properties.color.blue;
|
||||||
elColorControlVariant2.style.backgroundColor = "rgb(" + properties.color.red + "," + properties.color.green + "," + properties.color.blue + ")";
|
elColorControlVariant2.style.backgroundColor = "rgb(" + properties.color.red + "," + properties.color.green + "," + properties.color.blue + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (properties.type == "Model") {
|
if (properties.type === "Model") {
|
||||||
elModelURL.value = properties.modelURL;
|
elModelURL.value = properties.modelURL;
|
||||||
elShapeType.value = properties.shapeType;
|
elShapeType.value = properties.shapeType;
|
||||||
setDropdownText(elShapeType);
|
setDropdownText(elShapeType);
|
||||||
|
@ -997,10 +995,10 @@ function loaded() {
|
||||||
setTextareaScrolling(elModelTextures);
|
setTextareaScrolling(elModelTextures);
|
||||||
elModelOriginalTextures.value = properties.originalTextures;
|
elModelOriginalTextures.value = properties.originalTextures;
|
||||||
setTextareaScrolling(elModelOriginalTextures);
|
setTextareaScrolling(elModelOriginalTextures);
|
||||||
} else if (properties.type == "Web") {
|
} else if (properties.type === "Web") {
|
||||||
elWebSourceURL.value = properties.sourceUrl;
|
elWebSourceURL.value = properties.sourceUrl;
|
||||||
elWebDPI.value = properties.dpi;
|
elWebDPI.value = properties.dpi;
|
||||||
} else if (properties.type == "Text") {
|
} else if (properties.type === "Text") {
|
||||||
elTextText.value = properties.text;
|
elTextText.value = properties.text;
|
||||||
elTextLineHeight.value = properties.lineHeight.toFixed(4);
|
elTextLineHeight.value = properties.lineHeight.toFixed(4);
|
||||||
elTextFaceCamera.checked = properties.faceCamera;
|
elTextFaceCamera.checked = properties.faceCamera;
|
||||||
|
@ -1011,7 +1009,7 @@ function loaded() {
|
||||||
elTextBackgroundColorRed.value = properties.backgroundColor.red;
|
elTextBackgroundColorRed.value = properties.backgroundColor.red;
|
||||||
elTextBackgroundColorGreen.value = properties.backgroundColor.green;
|
elTextBackgroundColorGreen.value = properties.backgroundColor.green;
|
||||||
elTextBackgroundColorBlue.value = properties.backgroundColor.blue;
|
elTextBackgroundColorBlue.value = properties.backgroundColor.blue;
|
||||||
} else if (properties.type == "Light") {
|
} else if (properties.type === "Light") {
|
||||||
elLightSpotLight.checked = properties.isSpotlight;
|
elLightSpotLight.checked = properties.isSpotlight;
|
||||||
|
|
||||||
elLightColor.style.backgroundColor = "rgb(" + properties.color.red + "," + properties.color.green + "," + properties.color.blue + ")";
|
elLightColor.style.backgroundColor = "rgb(" + properties.color.red + "," + properties.color.green + "," + properties.color.blue + ")";
|
||||||
|
@ -1023,7 +1021,7 @@ function loaded() {
|
||||||
elLightFalloffRadius.value = properties.falloffRadius.toFixed(1);
|
elLightFalloffRadius.value = properties.falloffRadius.toFixed(1);
|
||||||
elLightExponent.value = properties.exponent.toFixed(2);
|
elLightExponent.value = properties.exponent.toFixed(2);
|
||||||
elLightCutoff.value = properties.cutoff.toFixed(2);
|
elLightCutoff.value = properties.cutoff.toFixed(2);
|
||||||
} else if (properties.type == "Zone") {
|
} else if (properties.type === "Zone") {
|
||||||
elZoneStageSunModelEnabled.checked = properties.stage.sunModelEnabled;
|
elZoneStageSunModelEnabled.checked = properties.stage.sunModelEnabled;
|
||||||
elZoneKeyLightColor.style.backgroundColor = "rgb(" + properties.keyLight.color.red + "," + properties.keyLight.color.green + "," + properties.keyLight.color.blue + ")";
|
elZoneKeyLightColor.style.backgroundColor = "rgb(" + properties.keyLight.color.red + "," + properties.keyLight.color.green + "," + properties.keyLight.color.blue + ")";
|
||||||
elZoneKeyLightColorRed.value = properties.keyLight.color.red;
|
elZoneKeyLightColorRed.value = properties.keyLight.color.red;
|
||||||
|
@ -1095,7 +1093,7 @@ function loaded() {
|
||||||
elZoneFilterURL.value = properties.filterURL;
|
elZoneFilterURL.value = properties.filterURL;
|
||||||
|
|
||||||
showElements(document.getElementsByClassName('skybox-section'), elZoneBackgroundMode.value == 'skybox');
|
showElements(document.getElementsByClassName('skybox-section'), elZoneBackgroundMode.value == 'skybox');
|
||||||
} else if (properties.type == "PolyVox") {
|
} else if (properties.type === "PolyVox") {
|
||||||
elVoxelVolumeSizeX.value = properties.voxelVolumeSize.x.toFixed(2);
|
elVoxelVolumeSizeX.value = properties.voxelVolumeSize.x.toFixed(2);
|
||||||
elVoxelVolumeSizeY.value = properties.voxelVolumeSize.y.toFixed(2);
|
elVoxelVolumeSizeY.value = properties.voxelVolumeSize.y.toFixed(2);
|
||||||
elVoxelVolumeSizeZ.value = properties.voxelVolumeSize.z.toFixed(2);
|
elVoxelVolumeSizeZ.value = properties.voxelVolumeSize.z.toFixed(2);
|
||||||
|
@ -1278,7 +1276,7 @@ function loaded() {
|
||||||
showUserDataTextArea();
|
showUserDataTextArea();
|
||||||
showNewJSONEditorButton();
|
showNewJSONEditorButton();
|
||||||
hideSaveUserDataButton();
|
hideSaveUserDataButton();
|
||||||
updateProperty('userData', elUserData.value)
|
updateProperty('userData', elUserData.value);
|
||||||
});
|
});
|
||||||
|
|
||||||
elSaveUserData.addEventListener("click", function() {
|
elSaveUserData.addEventListener("click", function() {
|
||||||
|
@ -1445,7 +1443,7 @@ function loaded() {
|
||||||
elZoneKeyLightDirectionX.addEventListener('change', zoneKeyLightDirectionChangeFunction);
|
elZoneKeyLightDirectionX.addEventListener('change', zoneKeyLightDirectionChangeFunction);
|
||||||
elZoneKeyLightDirectionY.addEventListener('change', zoneKeyLightDirectionChangeFunction);
|
elZoneKeyLightDirectionY.addEventListener('change', zoneKeyLightDirectionChangeFunction);
|
||||||
|
|
||||||
var hazeModeChanged = createZoneComponentModeChangedFunction('hazeMode', elZoneHazeModeInherit, elZoneHazeModeDisabled, elZoneHazeModeEnabled)
|
var hazeModeChanged = createZoneComponentModeChangedFunction('hazeMode', elZoneHazeModeInherit, elZoneHazeModeDisabled, elZoneHazeModeEnabled);
|
||||||
elZoneHazeModeInherit.addEventListener('change', hazeModeChanged);
|
elZoneHazeModeInherit.addEventListener('change', hazeModeChanged);
|
||||||
elZoneHazeModeDisabled.addEventListener('change', hazeModeChanged);
|
elZoneHazeModeDisabled.addEventListener('change', hazeModeChanged);
|
||||||
elZoneHazeModeEnabled.addEventListener('change', hazeModeChanged);
|
elZoneHazeModeEnabled.addEventListener('change', hazeModeChanged);
|
||||||
|
@ -1565,26 +1563,26 @@ function loaded() {
|
||||||
elMoveSelectionToGrid.addEventListener("click", function() {
|
elMoveSelectionToGrid.addEventListener("click", function() {
|
||||||
EventBridge.emitWebEvent(JSON.stringify({
|
EventBridge.emitWebEvent(JSON.stringify({
|
||||||
type: "action",
|
type: "action",
|
||||||
action: "moveSelectionToGrid",
|
action: "moveSelectionToGrid"
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
elMoveAllToGrid.addEventListener("click", function() {
|
elMoveAllToGrid.addEventListener("click", function() {
|
||||||
EventBridge.emitWebEvent(JSON.stringify({
|
EventBridge.emitWebEvent(JSON.stringify({
|
||||||
type: "action",
|
type: "action",
|
||||||
action: "moveAllToGrid",
|
action: "moveAllToGrid"
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
elResetToNaturalDimensions.addEventListener("click", function() {
|
elResetToNaturalDimensions.addEventListener("click", function() {
|
||||||
EventBridge.emitWebEvent(JSON.stringify({
|
EventBridge.emitWebEvent(JSON.stringify({
|
||||||
type: "action",
|
type: "action",
|
||||||
action: "resetToNaturalDimensions",
|
action: "resetToNaturalDimensions"
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
elRescaleDimensionsButton.addEventListener("click", function() {
|
elRescaleDimensionsButton.addEventListener("click", function() {
|
||||||
EventBridge.emitWebEvent(JSON.stringify({
|
EventBridge.emitWebEvent(JSON.stringify({
|
||||||
type: "action",
|
type: "action",
|
||||||
action: "rescaleDimensions",
|
action: "rescaleDimensions",
|
||||||
percentage: parseFloat(elRescaleDimensionsPct.value),
|
percentage: parseFloat(elRescaleDimensionsPct.value)
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
elReloadScriptsButton.addEventListener("click", function() {
|
elReloadScriptsButton.addEventListener("click", function() {
|
||||||
|
@ -1603,20 +1601,20 @@ function loaded() {
|
||||||
});
|
});
|
||||||
|
|
||||||
document.addEventListener("keydown", function (keyDown) {
|
document.addEventListener("keydown", function (keyDown) {
|
||||||
if (keyDown.keyCode === KEY_P && keyDown.ctrlKey) {
|
if (keyDown.keyCode === KEY_P && keyDown.ctrlKey) {
|
||||||
if (keyDown.shiftKey) {
|
if (keyDown.shiftKey) {
|
||||||
EventBridge.emitWebEvent(JSON.stringify({ type: 'unparent' }));
|
EventBridge.emitWebEvent(JSON.stringify({ type: 'unparent' }));
|
||||||
} else {
|
} else {
|
||||||
EventBridge.emitWebEvent(JSON.stringify({ type: 'parent' }));
|
EventBridge.emitWebEvent(JSON.stringify({ type: 'parent' }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
window.onblur = function() {
|
window.onblur = function() {
|
||||||
// Fake a change event
|
// Fake a change event
|
||||||
var ev = document.createEvent("HTMLEvents");
|
var ev = document.createEvent("HTMLEvents");
|
||||||
ev.initEvent("change", true, true);
|
ev.initEvent("change", true, true);
|
||||||
document.activeElement.dispatchEvent(ev);
|
document.activeElement.dispatchEvent(ev);
|
||||||
}
|
};
|
||||||
|
|
||||||
// For input and textarea elements, select all of the text on focus
|
// For input and textarea elements, select all of the text on focus
|
||||||
// WebKit-based browsers, such as is used with QWebView, have a quirk
|
// WebKit-based browsers, such as is used with QWebView, have a quirk
|
||||||
|
@ -1631,13 +1629,17 @@ function loaded() {
|
||||||
for (var i = 0; i < els.length; i++) {
|
for (var i = 0; i < els.length; i++) {
|
||||||
var clicked = false;
|
var clicked = false;
|
||||||
var originalText;
|
var originalText;
|
||||||
|
// TODO FIXME: (JSHint) Functions declared within loops referencing
|
||||||
|
// an outer scoped variable may lead to confusing semantics.
|
||||||
els[i].onfocus = function(e) {
|
els[i].onfocus = function(e) {
|
||||||
originalText = this.value;
|
originalText = this.value;
|
||||||
this.select();
|
this.select();
|
||||||
clicked = false;
|
clicked = false;
|
||||||
};
|
};
|
||||||
|
// TODO FIXME: (JSHint) Functions declared within loops referencing
|
||||||
|
// an outer scoped variable may lead to confusing semantics.
|
||||||
els[i].onmouseup = function(e) {
|
els[i].onmouseup = function(e) {
|
||||||
if (!clicked && originalText == this.value) {
|
if (!clicked && originalText === this.value) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
clicked = true;
|
clicked = true;
|
||||||
|
@ -1652,15 +1654,15 @@ function loaded() {
|
||||||
var toggleCollapsedEvent = function(event) {
|
var toggleCollapsedEvent = function(event) {
|
||||||
var element = event.target.parentNode.parentNode;
|
var element = event.target.parentNode.parentNode;
|
||||||
var isCollapsed = element.dataset.collapsed !== "true";
|
var isCollapsed = element.dataset.collapsed !== "true";
|
||||||
element.dataset.collapsed = isCollapsed ? "true" : false
|
element.dataset.collapsed = isCollapsed ? "true" : false;
|
||||||
element.setAttribute("collapsed", isCollapsed ? "true" : "false");
|
element.setAttribute("collapsed", isCollapsed ? "true" : "false");
|
||||||
element.getElementsByTagName("span")[0].textContent = isCollapsed ? "L" : "M";
|
element.getElementsByTagName("span")[0].textContent = isCollapsed ? "L" : "M";
|
||||||
};
|
};
|
||||||
|
|
||||||
for (var i = 0, length = elCollapsible.length; i < length; i++) {
|
for (var collapseIndex = 0, numCollapsibles = elCollapsible.length; collapseIndex < numCollapsibles; ++collapseIndex) {
|
||||||
var element = elCollapsible[i];
|
var curCollapsibleElement = elCollapsible[collapseIndex];
|
||||||
element.addEventListener("click", toggleCollapsedEvent, true);
|
curCollapsibleElement.addEventListener("click", toggleCollapsedEvent, true);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
// Textarea scrollbars
|
// Textarea scrollbars
|
||||||
|
@ -1668,17 +1670,17 @@ function loaded() {
|
||||||
|
|
||||||
var textareaOnChangeEvent = function(event) {
|
var textareaOnChangeEvent = function(event) {
|
||||||
setTextareaScrolling(event.target);
|
setTextareaScrolling(event.target);
|
||||||
}
|
};
|
||||||
|
|
||||||
for (var i = 0, length = elTextareas.length; i < length; i++) {
|
for (var textAreaIndex = 0, numTextAreas = elTextareas.length; textAreaIndex < numTextAreas; ++textAreaIndex) {
|
||||||
var element = elTextareas[i];
|
var curTextAreaElement = elTextareas[textAreaIndex];
|
||||||
setTextareaScrolling(element);
|
setTextareaScrolling(curTextAreaElement);
|
||||||
element.addEventListener("input", textareaOnChangeEvent, false);
|
curTextAreaElement.addEventListener("input", textareaOnChangeEvent, false);
|
||||||
element.addEventListener("change", textareaOnChangeEvent, false);
|
curTextAreaElement.addEventListener("change", textareaOnChangeEvent, false);
|
||||||
/* FIXME: Detect and update textarea scrolling attribute on resize. Unfortunately textarea doesn't have a resize
|
/* FIXME: Detect and update textarea scrolling attribute on resize. Unfortunately textarea doesn't have a resize
|
||||||
event; mouseup is a partial stand-in but doesn't handle resizing if mouse moves outside textarea rectangle. */
|
event; mouseup is a partial stand-in but doesn't handle resizing if mouse moves outside textarea rectangle. */
|
||||||
element.addEventListener("mouseup", textareaOnChangeEvent, false);
|
curTextAreaElement.addEventListener("mouseup", textareaOnChangeEvent, false);
|
||||||
};
|
}
|
||||||
|
|
||||||
// Dropdowns
|
// Dropdowns
|
||||||
// For each dropdown the following replacement is created in place of the oriringal dropdown...
|
// For each dropdown the following replacement is created in place of the oriringal dropdown...
|
||||||
|
@ -1727,22 +1729,23 @@ function loaded() {
|
||||||
}
|
}
|
||||||
|
|
||||||
var elDropdowns = document.getElementsByTagName("select");
|
var elDropdowns = document.getElementsByTagName("select");
|
||||||
for (var i = 0; i < elDropdowns.length; i++) {
|
for (var dropDownIndex = 0; dropDownIndex < elDropdowns.length; ++dropDownIndex) {
|
||||||
var options = elDropdowns[i].getElementsByTagName("option");
|
var options = elDropdowns[dropDownIndex].getElementsByTagName("option");
|
||||||
var selectedOption = 0;
|
var selectedOption = 0;
|
||||||
for (var j = 0; j < options.length; j++) {
|
for (var optionIndex = 0; optionIndex < options.length; ++optionIndex) {
|
||||||
if (options[j].getAttribute("selected") === "selected") {
|
if (options[optionIndex].getAttribute("selected") === "selected") {
|
||||||
selectedOption = j;
|
selectedOption = optionIndex;
|
||||||
|
// TODO: Shouldn't there be a break here?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var div = elDropdowns[i].parentNode;
|
var div = elDropdowns[dropDownIndex].parentNode;
|
||||||
|
|
||||||
var dl = document.createElement("dl");
|
var dl = document.createElement("dl");
|
||||||
div.appendChild(dl);
|
div.appendChild(dl);
|
||||||
|
|
||||||
var dt = document.createElement("dt");
|
var dt = document.createElement("dt");
|
||||||
dt.name = elDropdowns[i].name;
|
dt.name = elDropdowns[dropDownIndex].name;
|
||||||
dt.id = elDropdowns[i].id;
|
dt.id = elDropdowns[dropDownIndex].id;
|
||||||
dt.addEventListener("click", toggleDropdown, true);
|
dt.addEventListener("click", toggleDropdown, true);
|
||||||
dl.appendChild(dt);
|
dl.appendChild(dt);
|
||||||
|
|
||||||
|
@ -1751,9 +1754,9 @@ function loaded() {
|
||||||
span.textContent = options[selectedOption].firstChild.textContent;
|
span.textContent = options[selectedOption].firstChild.textContent;
|
||||||
dt.appendChild(span);
|
dt.appendChild(span);
|
||||||
|
|
||||||
var span = document.createElement("span");
|
var spanCaratDn = document.createElement("span");
|
||||||
span.textContent = "5"; // caratDn
|
spanCaratDn.textContent = "5"; // caratDn
|
||||||
dt.appendChild(span);
|
dt.appendChild(spanCaratDn);
|
||||||
|
|
||||||
var dd = document.createElement("dd");
|
var dd = document.createElement("dd");
|
||||||
dl.appendChild(dd);
|
dl.appendChild(dd);
|
||||||
|
@ -1761,10 +1764,10 @@ function loaded() {
|
||||||
var ul = document.createElement("ul");
|
var ul = document.createElement("ul");
|
||||||
dd.appendChild(ul);
|
dd.appendChild(ul);
|
||||||
|
|
||||||
for (var j = 0; j < options.length; j++) {
|
for (var listOptionIndex = 0; listOptionIndex < options.length; ++listOptionIndex) {
|
||||||
var li = document.createElement("li");
|
var li = document.createElement("li");
|
||||||
li.setAttribute("value", options[j].value);
|
li.setAttribute("value", options[listOptionIndex].value);
|
||||||
li.textContent = options[j].firstChild.textContent;
|
li.textContent = options[listOptionIndex].firstChild.textContent;
|
||||||
li.addEventListener("click", setDropdownValue);
|
li.addEventListener("click", setDropdownValue);
|
||||||
ul.appendChild(li);
|
ul.appendChild(li);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue