Merge branch 'main' of https://github.com/JannexNet/SHX-Theme
commit
549b287851
|
@ -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,15 +164,21 @@
|
|||
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++) {
|
||||
if(FilamentList[colorWhiteList[i]]) {
|
||||
options[i] = FilamentList[colorWhiteList[i]];
|
||||
options[colorWhiteList[i]] = FilamentList[colorWhiteList[i]];
|
||||
} else {
|
||||
console.error("Color not found in FilamentList", colorWhiteList[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,16 @@
|
|||
|
||||
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);
|
||||
|
||||
console.log('filamentID', filamentID);
|
||||
|
||||
let filament = SHX_getFilamentById(filamentID);
|
||||
|
||||
globalInputFormsObjValues[key][name] = JSON.stringify(filament);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
Loading…
Reference in New Issue