shx-3d-render
parent
62f7bdafd1
commit
f3f6f486f2
|
@ -115,7 +115,7 @@
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
let FilamentList = {
|
const FilamentList = {
|
||||||
"10": {
|
"10": {
|
||||||
"name": "Schwarz (Matt)",
|
"name": "Schwarz (Matt)",
|
||||||
"hex": "#000000",
|
"hex": "#000000",
|
||||||
|
@ -193,29 +193,12 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// sort FilamentList by hex
|
// sort FilamentList by hex
|
||||||
function SHX_sortFilamentList() {
|
const sortedFilementIDs = Object.keys(FilamentList).sort((a, b) => {
|
||||||
let sortable = [];
|
return FilamentList[a].hex.localeCompare(FilamentList[b].hex);
|
||||||
for (let filament in FilamentList) {
|
});
|
||||||
sortable.push([filament, FilamentList[filament]]);
|
|
||||||
}
|
|
||||||
|
|
||||||
sortable.sort(function(a, b) {
|
|
||||||
return a[1].hex.localeCompare(b[1].hex);
|
|
||||||
});
|
|
||||||
|
|
||||||
let sortedList = {};
|
|
||||||
for(let i = 0; i < sortable.length; i++) {
|
|
||||||
sortedList[sortable[i][0]] = sortable[i][1];
|
|
||||||
}
|
|
||||||
|
|
||||||
return sortedList;
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log("FilamentList", FilamentList);
|
|
||||||
|
|
||||||
FilamentList = SHX_sortFilamentList();
|
|
||||||
console.log("FilamentList2", FilamentList);
|
|
||||||
|
|
||||||
function SHX_getFilamentById(id) {
|
function SHX_getFilamentById(id) {
|
||||||
let filament = FilamentList[id];
|
let filament = FilamentList[id];
|
||||||
|
@ -275,7 +258,7 @@
|
||||||
|
|
||||||
function SHX_IFC_genColorSelect(inputID, labelText, inputName, _inputVal, colorWhiteList, section_id) {
|
function SHX_IFC_genColorSelect(inputID, labelText, inputName, _inputVal, colorWhiteList, section_id) {
|
||||||
|
|
||||||
let options = {};
|
let options = [];
|
||||||
|
|
||||||
let inputVal = _inputVal;
|
let inputVal = _inputVal;
|
||||||
|
|
||||||
|
@ -284,10 +267,10 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!colorWhiteList || colorWhiteList.length === 0) {
|
if(!colorWhiteList || colorWhiteList.length === 0) {
|
||||||
options = {...FilamentList};
|
options = [...sortedFilementIDs];
|
||||||
} else for(let i = 0; i < colorWhiteList.length; i++) {
|
} else for(let i = 0; i < colorWhiteList.length; i++) {
|
||||||
if(FilamentList[colorWhiteList[i]]) {
|
if(FilamentList[colorWhiteList[i]]) {
|
||||||
options[colorWhiteList[i]] = FilamentList[colorWhiteList[i]];
|
options.push(colorWhiteList[i]);
|
||||||
} else {
|
} else {
|
||||||
console.error("Color not found in FilamentList", colorWhiteList[i]);
|
console.error("Color not found in FilamentList", colorWhiteList[i]);
|
||||||
}
|
}
|
||||||
|
@ -297,18 +280,12 @@
|
||||||
let html = `
|
let html = `
|
||||||
<label class="form__label custom shx-ifc-form_label" for="${inputID}-label">${labelText}: <span class="shx-ifc-form_label_selected shx-ifc-form_label_selected_${inputID}">${SHX_getFilamentById(inputVal).name}</span></label>
|
<label class="form__label custom shx-ifc-form_label" for="${inputID}-label">${labelText}: <span class="shx-ifc-form_label_selected shx-ifc-form_label_selected_${inputID}">${SHX_getFilamentById(inputVal).name}</span></label>
|
||||||
<div id="${inputID}" class="shx-ifc-colorselect">
|
<div id="${inputID}" class="shx-ifc-colorselect">
|
||||||
`;
|
`;
|
||||||
|
|
||||||
// Convert object to Map
|
|
||||||
let optionsKeys = Object.keys(options);
|
|
||||||
console.log("FilamentList", FilamentList);
|
|
||||||
console.log("options", options);
|
|
||||||
console.log("optionsKeys", optionsKeys );
|
|
||||||
|
|
||||||
|
|
||||||
// Iterate over the Map
|
// Iterate over the Map
|
||||||
for (let i = 0; i < optionsKeys.length; i++) {
|
for (let i = 0; i < options.length; i++) {
|
||||||
let color = optionsKeys[i];
|
let color = options[i];
|
||||||
|
|
||||||
console.log(color);
|
console.log(color);
|
||||||
html += `
|
html += `
|
||||||
|
|
Loading…
Reference in New Issue