Skip to content

Commit 4346bdc

Browse files
committed
Configure and store bom checkboxes
Issue #17
1 parent 29a7d18 commit 4346bdc

File tree

3 files changed

+87
-11
lines changed

3 files changed

+87
-11
lines changed

InteractiveHtmlBom/ibom.css

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ canvas:active {
100100

101101
.bom {
102102
border-collapse: collapse;
103-
font-family: Consolas, monospace;
103+
font-family: Consolas, "DejaVu Sans Mono", Monaco, monospace;
104104
font-size: 10pt;
105105
table-layout: fixed;
106106
width: 100%;
@@ -134,6 +134,10 @@ canvas:active {
134134
width: 25px;
135135
}
136136

137+
.bom .bom-checkbox {
138+
width: 30px;
139+
}
140+
137141
.bom .Description {
138142
width: 10%;
139143
}
@@ -186,7 +190,7 @@ canvas:active {
186190
height: 40px;
187191
margin: 10px 5px;
188192
padding: 12px 32px;
189-
font-family: Consolas, "DejaVu Sans Mono", monospace;
193+
font-family: Consolas, "DejaVu Sans Mono", Monaco, monospace;
190194
font-size: 18px;
191195
box-sizing: border-box;
192196
border: 1px solid #888;
@@ -268,6 +272,22 @@ mark.highlight {
268272
border-top: 1px solid #ccc;
269273
}
270274

275+
.menu-textbox {
276+
float: left;
277+
height: 24px;
278+
margin: 10px 5px;
279+
padding: 5px 5px;
280+
font-family: Consolas, "DejaVu Sans Mono", Monaco, monospace;
281+
font-size: 14px;
282+
box-sizing: border-box;
283+
border: 1px solid #888;
284+
border-radius: 4px;
285+
outline: none;
286+
background-color: #eee;
287+
transition: background-color 0.2s, border 0.2s;
288+
width: calc(100% - 10px);
289+
}
290+
271291
#dbg {
272292
display: none;
273293
}

InteractiveHtmlBom/ibom.html

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@
4343
<input id="dragCheckbox" type="checkbox" checked onchange="setRedrawOnDrag(this.checked)">
4444
Continuous redraw on drag
4545
</label>
46+
<label class="menu-label">
47+
<div style="margin-left: 5px">Bom checkboxes</div>
48+
<input id="bomCheckboxes" class="menu-textbox" type=text
49+
oninput="setBomCheckboxes(this.value)">
50+
</label>
4651
</div>
4752
</div>
4853
<div class="button-container hideonprint"
@@ -100,14 +105,7 @@
100105
</div>
101106
<div id="dbg"></div>
102107
<table class="bom">
103-
<thead>
104-
<tr>
105-
<th class="numCol"></th>
106-
<th class="References">References</th>
107-
<th class="Value">Value</th>
108-
<th class="Footprint">Footprint</th>
109-
<th class="Quantity">Quantity</th>
110-
</tr>
108+
<thead id="bomhead">
111109
</thead>
112110
<tbody id="bombody">
113111
</tbody>

InteractiveHtmlBom/ibom.js

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ var canvassplit;
77
var canvaslayout = "default";
88
var bomlayout = "default";
99
var highlightedRefs = [];
10+
var bomCheckboxes = "";
1011

1112
function readStorage(key) {
1213
return window.localStorage.getItem(storagePrefix + '#' + key);
@@ -81,6 +82,41 @@ function populateBomTable() {
8182
while (bom.firstChild) {
8283
bom.removeChild(bom.firstChild);
8384
}
85+
while (bomhead.firstChild) {
86+
bomhead.removeChild(bomhead.firstChild);
87+
}
88+
// Populate header
89+
var tr = document.createElement("TR");
90+
var td = document.createElement("TH");
91+
td.classList.add("numCol");
92+
tr.appendChild(td);
93+
checkboxes = bomCheckboxes.split(",");
94+
for (checkbox of checkboxes) {
95+
if (checkbox) {
96+
td = document.createElement("TH");
97+
td.classList.add("bom-checkbox");
98+
td.innerHTML = checkbox;
99+
tr.appendChild(td);
100+
}
101+
}
102+
td = document.createElement("TH");
103+
td.classList.add("References");
104+
td.innerHTML = "References";
105+
tr.appendChild(td);
106+
td = document.createElement("TH");
107+
td.classList.add("Value");
108+
td.innerHTML = "Value";
109+
tr.appendChild(td);
110+
td = document.createElement("TH");
111+
td.classList.add("Footprint");
112+
td.innerHTML = "Footprint";
113+
tr.appendChild(td);
114+
td = document.createElement("TH");
115+
td.classList.add("Quantity");
116+
td.innerHTML = "Quantity";
117+
tr.appendChild(td);
118+
bomhead.appendChild(tr);
119+
// Populate table body
84120
var first = true;
85121
switch (canvaslayout) {
86122
case 'F':
@@ -111,6 +147,16 @@ function populateBomTable() {
111147
tr.id = "bomrow" + rownum;
112148
td.textContent = rownum;
113149
tr.appendChild(td);
150+
// Checkboxes
151+
for (checkbox of checkboxes) {
152+
if (checkbox) {
153+
td = document.createElement("TD");
154+
input = document.createElement("input");
155+
input.type = "checkbox";
156+
td.appendChild(input);
157+
tr.appendChild(td);
158+
}
159+
}
114160
// References
115161
td = document.createElement("TD");
116162
td.innerHTML = highlightFilter(references.join(", "));
@@ -185,7 +231,7 @@ function changeCanvasLayout(layout) {
185231
canvaslayout = layout;
186232
writeStorage("canvaslayout", layout);
187233
resizeAll();
188-
populateBomTable(layout);
234+
populateBomTable();
189235
}
190236

191237
function populateMetadata() {
@@ -289,11 +335,18 @@ function cleanGutters() {
289335
removeGutterNode(document.getElementById("canvasdiv"));
290336
}
291337

338+
function setBomCheckboxes(value) {
339+
bomCheckboxes = value;
340+
writeStorage("bomCheckboxes", value);
341+
populateBomTable();
342+
}
343+
292344
window.onload = function(e) {
293345
cleanGutters();
294346
initRender();
295347
dbgdiv = document.getElementById("dbg");
296348
bom = document.getElementById("bombody");
349+
bomhead = document.getElementById("bomhead");
297350
bomlayout = readStorage("bomlayout");
298351
if (!bomlayout) {
299352
bomlayout = "LR";
@@ -305,6 +358,11 @@ window.onload = function(e) {
305358
filter = "";
306359
reflookup = "";
307360
populateMetadata();
361+
bomCheckboxes = readStorage("bomCheckboxes");
362+
if (bomCheckboxes === null) {
363+
bomCheckboxes = "Sourced,Placed";
364+
}
365+
document.getElementById("bomCheckboxes").value = bomCheckboxes;
308366
changeBomLayout(bomlayout);
309367
if (readStorage("silkscreenVisible") === "false") {
310368
document.getElementById("silkscreenCheckbox").checked = false;

0 commit comments

Comments
 (0)