Skip to content

Commit

Permalink
[CfgEditor] Check properties existence in loop
Browse files Browse the repository at this point in the history
This commit checks properties' existence in for loop.

ONE-vscode-DCO-1.0-Signed-off-by: Dayoung Lee <[email protected]>
  • Loading branch information
dayo09 committed Sep 26, 2023
1 parent 3ccbdc8 commit 32a1fcf
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 33 deletions.
7 changes: 4 additions & 3 deletions media/CfgEditor/displaycfg.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,10 @@ export function displayCfgToEditor(cfg) {
oneOptimize?.["output_path"]
);
for (const optName in oneOptimizationList) {
document.getElementById("checkboxOptimize" + optName).checked = cfgBoolean(
oneOptimize?.[optName]
);
if (Object.prototype.hasOwnProperty.call(oneOptimizationList, optName)) {
document.getElementById("checkboxOptimize" + optName).checked =
cfgBoolean(oneOptimize?.[optName]);
}
}

const oneQuantize = cfg["one-quantize"];
Expand Down
56 changes: 30 additions & 26 deletions media/CfgEditor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,35 +347,39 @@ function registerOptimizeOptions() {
});

for (const optName in oneOptimizationList) {
let row = document.createElement("vscode-data-grid-row");

let cellSwitch = document.createElement("vscode-data-grid-cell");
let checkbox = document.createElement("vscode-checkbox");
checkbox.setAttribute("id", "checkboxOptimize" + optName);
cellSwitch.appendChild(checkbox);
cellSwitch.setAttribute("grid-column", "1");
row.appendChild(cellSwitch);

let cellName = document.createElement("vscode-data-grid-cell");
cellName.textContent = optName;
cellName.setAttribute("grid-column", "2");
row.appendChild(cellName);

let cellDescription = document.createElement("vscode-data-grid-cell");
cellDescription.textContent = oneOptimizationList[optName].description;
cellDescription.setAttribute("grid-column", "3");
row.appendChild(cellDescription);

basicOptimizeTable.appendChild(row);
if (Object.prototype.hasOwnProperty.call(oneOptimizationList, optName)) {
let row = document.createElement("vscode-data-grid-row");

let cellSwitch = document.createElement("vscode-data-grid-cell");
let checkbox = document.createElement("vscode-checkbox");
checkbox.setAttribute("id", "checkboxOptimize" + optName);
cellSwitch.appendChild(checkbox);
cellSwitch.setAttribute("grid-column", "1");
row.appendChild(cellSwitch);

let cellName = document.createElement("vscode-data-grid-cell");
cellName.textContent = optName;
cellName.setAttribute("grid-column", "2");
row.appendChild(cellName);

let cellDescription = document.createElement("vscode-data-grid-cell");
cellDescription.textContent = oneOptimizationList[optName].description;
cellDescription.setAttribute("grid-column", "3");
row.appendChild(cellDescription);

basicOptimizeTable.appendChild(row);
}
}

for (const optName in oneOptimizationList) {
document
.getElementById("checkboxOptimize" + optName)
.addEventListener("click", function () {
updateOptimize();
applyUpdates();
});
if (Object.prototype.hasOwnProperty.call(oneOptimizationList, optName)) {
document
.getElementById("checkboxOptimize" + optName)
.addEventListener("click", function () {
updateOptimize();
applyUpdates();
});
}
}
}

Expand Down
10 changes: 6 additions & 4 deletions media/CfgEditor/updateContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,10 +286,12 @@ export function updateOptimize() {
);

for (const optName in oneOptimizationList) {
content += iniKeyValueString(
optName,
document.getElementById("checkboxOptimize" + optName).checked
);
if (Object.prototype.hasOwnProperty.call(oneOptimizationList, optName)) {
content += iniKeyValueString(
optName,
document.getElementById("checkboxOptimize" + optName).checked
);
}
}

postMessageToVsCode({
Expand Down

0 comments on commit 32a1fcf

Please sign in to comment.