shx-3d-render

main
Jan Umbach 2024-06-21 21:25:26 +02:00
parent 30eecdb349
commit bc7d19a767
1 changed files with 31 additions and 8 deletions

View File

@ -92,16 +92,30 @@
<script type="text/javascript">
const FilamentList = {
"#10": {
"10": {
"name": "Schwarz (Matt)",
"hex": "#000000"
},
"#11": {
"11": {
"name": "Weiß (Matt)",
"hex": "#FFFFFF"
},
}
function SHX_getFilamentById(id) {
let filament = FilamentList[id];
if(filament) {
return {...filament, "id": id};
} else {
console.error("Filament not found in FilamentList", id);
return {
"name": "undefined",
"hex": "#000000"
};
}
}
let globalInputFormsObjValues = {
"test1": {
@ -150,10 +164,16 @@
return html;
}
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 inputVal = _inputVal;
if(typeof _inputVal === 'object') {
inputVal = _inputVal.id;
}
if(!colorWhiteList || colorWhiteList.length === 0) {
options = {...FilamentList};
} else for(let i = 0; i < colorWhiteList.length; i++) {
@ -174,7 +194,6 @@
html += `
<input type="radio" id="${inputID}-${color}" form="product-form-${section_id}" name="properties[${inputName}]" value="${options[color].name}" ${inputVal === color ? 'checked' : ''}>
<label for="${inputID}-${color}" style="background-color: ${options[color].hex};"></label>
`;
}
@ -211,7 +230,7 @@
"renderHTML": (section_id) => {
let html = defaultStyle;
html += SHX_IFC_genColorSelect('shx-color', 'Farbe', 'Farbe', globalInputFormsObjValues['TextOne']['color'], ['#10', '#11', '#12', '#00FF00', '#0000FF'], section_id);
html += SHX_IFC_genColorSelect('shx-color', 'Farbe', 'Farbe', globalInputFormsObjValues['TextOne']['color'], ['10', '11', '12', '#00FF00', '#0000FF'], section_id);
html += SHX_IFC_genColorSelect('shx-color2', 'Farbe2', 'Farbe2', globalInputFormsObjValues['TextOne']['color'], ['#000000', '#FFFFFF', '#FF0000', '#00FF00', '#0000FF'], section_id);
html += SHX_IFC_genColorSelect('shx-color3', 'Farbe3', 'Farbe3', globalInputFormsObjValues['TextOne']['color'], ['#000000', '#FFFFFF', '#FF0000', '#00FF00', '#0000FF'], section_id);
html += SHX_IFC_genTextInput('shx-text1', 'Custom Text 1', 'Text', globalInputFormsObjValues['TextOne']['text1'], section_id);
@ -353,10 +372,14 @@
if(input.type === 'radio') {
if(input.checked) {
let name = input.id.replace('shx-', '');
name = name.slice(0, name.indexOf('-'));
let _name = input.id.replace('shx-', '');
let name = _name.slice(0, _name.indexOf('-'));
globalInputFormsObjValues[key][name] = input.value;
let filamentID = _name.slice(_name.indexOf('-') + 1);
let filament = SHX_getFilamentById(filamentID);
globalInputFormsObjValues[key][name] = JSON.stringify(filament);
}
}
else {