Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions InteractiveHtmlBom/web/ibom.css
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ button#copy:active {
box-shadow: inset 0px 0px 5px #6c6c6c;
}

.button-highlight {
border: 2px solid red;
}

textarea.clipboard-temp {
position: fixed;
top: 0;
Expand Down Expand Up @@ -206,11 +210,37 @@ canvas:active {
position: relative;
}

.bom th,
.bom td button {
margin-right: 6px;
border-radius: 4px;
padding: 4px 0;
font-size: 10pt;
height: fit-content !important;

}

.bom th,
.bom td button:hover {
background: rgba(255, 255, 255, 0.5);
}

.dark .bom th,
.dark .bom td {
border: 1px solid #777;
}

.dark .bom th,
.dark .bom td button {
background: #666666;
color: #dddddd;
}

.dark .bom th,
.dark .bom td button:hover {
background: rgba(102, 102, 102, 0.5);
}

.bom th {
background-color: #CCCCCC;
background-clip: padding-box;
Expand Down
81 changes: 80 additions & 1 deletion InteractiveHtmlBom/web/ibom.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,14 @@ function createRowHighlightHandler(rowid, refs, net) {
}
document.getElementById(currentHighlightedRowId).classList.remove("highlighted");
}

// highlight buttons by refs
removeAllBtnHighlight();
refs.forEach(ref => {
let btnOfRef = document.getElementById(`refId${ref[1]}`);
btnOfRef.classList.add('button-highlight');
})

document.getElementById(rowid).classList.add("highlighted");
currentHighlightedRowId = rowid;
highlightedFootprints = refs ? refs.map(r => r[1]) : [];
Expand Down Expand Up @@ -636,6 +644,69 @@ function populateBomHeader(placeHolderColumn = null, placeHolderElements = null)
bomhead.appendChild(tr);
}

function removeAllBtnHighlight() {
const elements = document.querySelectorAll('.button-highlight');
elements.forEach(element => {
element.classList.remove('button-highlight');
});
}

function onRefsBtnClick(refName, refId, rowId, netName) {
console.log("Ref click: name = " + refName + ", Id = " + refId + ", rowId = " + rowId);
console.log("currentHighlightedRowId = " + currentHighlightedRowId);

if (currentHighlightedRowId) {
if (currentHighlightedRowId !== rowId) {
removeAllBtnHighlight(); // remove old btns highlight
highlightedFootprints = null; // remove old refs highlight
document.getElementById(currentHighlightedRowId).classList.remove("highlighted"); // remove old row highlight
}
}

// Button style update to highlight mode
let btnThis = document.getElementById(`refId${refId}`);

document.getElementById(rowId).classList.add("highlighted");
currentHighlightedRowId = rowId;
highlightedNet = netName;
// append to 'highlightedFootprints' if not exists
if (highlightedFootprints == null) {
highlightedFootprints = [refId];
btnThis.classList.add('button-highlight');
} else {
let indexOfHighlightList = highlightedFootprints.indexOf(refId);
if (indexOfHighlightList === -1) {
highlightedFootprints.push(refId); // set highlight
btnThis.classList.add('button-highlight');
} else {
highlightedFootprints.splice(indexOfHighlightList, 1); // clear highlight
btnThis.classList.remove('button-highlight');
}
}
drawHighlights();
EventHandler.emitEvent(
IBOM_EVENT_TYPES.HIGHLIGHT_EVENT, {
rowid: rowId,
refs: [[refName, refId]],
net: netName
});
}

function createButtonForRefs(container, refs, rowId, netName) {
console.log("refs = ", refs);
refs.forEach(ref => {
const button = document.createElement('button');
button.innerHTML = highlightFilter(ref[0]);
button.type = 'button'; // Not form
button.id = `refId${ref[1]}`; // Bind btn to ref, example: refId233, we can getElementById.
button.onmousedown = (e) => e.stopPropagation(); // Not row select.
button.onclick = (e) => {
onRefsBtnClick(ref[0], ref[1], rowId, netName);
}
container.appendChild(button);
});
}

function populateBomBody(placeholderColumn = null, placeHolderElements = null) {
const urlRegex = /^(https?:\/\/[^\s\/$.?#][^\s]*|file:\/\/([a-zA-Z]:|\/)[^\x00]+)$/;
while (bom.firstChild) {
Expand Down Expand Up @@ -721,7 +792,7 @@ function populateBomBody(placeholderColumn = null, placeHolderElements = null) {
}
} else if (column === "References") {
td = document.createElement("TD");
td.innerHTML = highlightFilter(references.map(r => r[0]).join(", "));
createButtonForRefs(td, references, tr.id, netname); // create buttons for references
tr.appendChild(td);
} else if (column === "Quantity" && settings.bommode == "grouped") {
// Quantity
Expand Down Expand Up @@ -821,7 +892,15 @@ function highlightNextRow() {
smoothScrollToRow(currentHighlightedRowId);
}

function highlightClear() {
currentHighlightedRowId = null;
highlightedFootprints = []; // remove old refs highlight
removeAllBtnHighlight(); // remove old btns highlight
drawHighlights();
}

function populateBomTable() {
highlightClear();
populateBomHeader();
populateBomBody();
setBomHandlers();
Expand Down