Skip to content

Commit

Permalink
Merge pull request #5 from GenZerg/main
Browse files Browse the repository at this point in the history
Preset elements and code block working just fine but it have no data in it plz help me fix
  • Loading branch information
Nicezki authored Oct 17, 2023
2 parents 6304336 + 96bfa2b commit 096e349
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions main-dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class ARMMane{
"status_conv01_backward" : this.querySel(".status-conv01-bw"),
"command_area" : document.querySelectorAll(".ins-command-area"),
"function_box" : document.querySelectorAll(".ins-func-box"),
"preset_box" : document.querySelectorAll(".ins-preset-box"),
"livepreview" : this.querySel(".livepreview"),
"settingbox1" : this.querySel(".settingbox-1"),
"settingbox2" : this.querySel(".settingbox-2"),
Expand Down Expand Up @@ -117,6 +118,7 @@ class ARMMane{
"log_alert" : this.querySel(".tp-log-alert"),
"ins_function" : document.querySelectorAll(".tp-ins-func"),
"code_block" : this.querySel(".tp-ins-code-block"),
"ins_preset" : document.querySelectorAll(".tp-ins-preset"),
},
"text" : {
"connect_url" : this.querySel(".connecting-url").querySelector("div > h2"),
Expand Down Expand Up @@ -1148,7 +1150,6 @@ class ARMMane{
console.error(`Element with ID '${uniqueElementId}' not found.`);
}
}


//This will change the property of the element after click save button
openConfigBox() {
Expand Down Expand Up @@ -1207,7 +1208,7 @@ class ARMMane{

getPreset() {
// Return the promise for the fetch operation
return fetch(`${this.serverURL}/config`, {
return fetch(`${this.appStatus["server"]["fullURL"]}/config`, {
method: "GET",
headers: {
"Content-Type": "application/json"
Expand Down Expand Up @@ -1247,8 +1248,8 @@ class ARMMane{

// Add the translateInstruction function to your class
translateInstruction(instruction) {
console.log("Instruction:", instruction);
const type = instruction[0];

if (type === 'S') {
const id = parseInt(instruction[2]);
const degree = parseInt(instruction.substring(4));
Expand All @@ -1263,7 +1264,6 @@ class ARMMane{
return `Unsupported instruction type: ${type}`;
}
}

createPresetList(presetsWithSteps) {
const spawnArea = this.elements["ui"]["preset_box"][0].querySelector("div");

Expand All @@ -1281,12 +1281,12 @@ class ARMMane{
const newPresetElement = this.elements["template"]["ins_preset"][0].cloneNode(true);
const uniqueId = `preset_${presetName}`;
newPresetElement.id = uniqueId;

newPresetElement.classList.add("ins-preset", presetName);
newPresetElement.querySelector(".tp-ins-preset > div > h4").textContent = presetName;
newPresetElement.style.display = "flex";
newPresetElement.setAttribute("data-preset-name", presetName);

return newPresetElement;
}

Expand All @@ -1296,12 +1296,16 @@ class ARMMane{

preset.steps.forEach(step => {
const newDiv = this.cloneCodeBlockElement(newPresetElement); // Pass newPresetElement as an argument
const data = this.translateInstruction(step);
this.attachCodeBlockEventListeners(newDiv, newPresetElement); // Pass newPresetElement as well
newDiv.querySelector(".cmd-text > div > h2").textContent = this.translateInstruction(step);
newDiv.setAttribute("data-type", data.type);
newDiv.setAttribute("data-device", data.id);
newDiv.setAttribute("data-value", data.degree);
newDiv.setAttribute("data-speed", data.speed);
swimLane.appendChild(newDiv);
});
}

initializePreset() {
// Fetch the presets and steps
this.getPreset()
Expand Down

0 comments on commit 096e349

Please sign in to comment.