|
188 | 188 | height: 5px; |
189 | 189 | } |
190 | 190 |
|
191 | | - .filter { |
| 191 | + .searchbox { |
192 | 192 | float: left; |
193 | | - width: calc(100% - 10px); |
194 | 193 | height: 40px; |
195 | 194 | margin: 10px 5px; |
196 | 195 | padding: 12px 32px; |
197 | | - font-family: "Lucida Console", Monaco, monospace; |
| 196 | + font-family: Consolas, "DejaVu Sans Mono", monospace; |
198 | 197 | font-size: 18px; |
199 | 198 | box-sizing: border-box; |
200 | 199 | border: 1px solid #888; |
|
207 | 206 | background-repeat: no-repeat; |
208 | 207 | } |
209 | 208 |
|
210 | | - .filter::placeholder { |
| 209 | + .searchbox::placeholder { |
211 | 210 | color: #ccc; |
212 | 211 | } |
213 | 212 |
|
| 213 | + .filter { |
| 214 | + width: calc(60% - 10px); |
| 215 | + } |
| 216 | + |
| 217 | + .reflookup { |
| 218 | + width: calc(40% - 10px); |
| 219 | + } |
| 220 | + |
214 | 221 | input[type=text]:focus { |
215 | 222 | background-color: white; |
216 | 223 | border: 1px solid #333; |
|
581 | 588 | return false; |
582 | 589 | } |
583 | 590 |
|
| 591 | + function findRefInEntry(entry) { |
| 592 | + for (ref of entry[3]) { |
| 593 | + if (ref.toLowerCase() == reflookup) { |
| 594 | + return [ref]; |
| 595 | + } |
| 596 | + } |
| 597 | + return false; |
| 598 | + } |
| 599 | + |
584 | 600 | function highlightFilter(s) { |
585 | 601 | if (!filter) { |
586 | 602 | return s; |
|
604 | 620 | return r; |
605 | 621 | } |
606 | 622 |
|
607 | | - function populateBomTable(layout) { |
| 623 | + function populateBomTable() { |
608 | 624 | while (bom.firstChild) { |
609 | 625 | bom.removeChild(bom.firstChild); |
610 | 626 | } |
611 | 627 | var first = true; |
612 | | - switch (layout) { |
| 628 | + switch (canvaslayout) { |
613 | 629 | case 'F': |
614 | 630 | bomtable = pcbdata.bom.F; |
615 | 631 | break; |
|
625 | 641 | if (filter && !entryMatches(bomentry)) { |
626 | 642 | continue; |
627 | 643 | } |
| 644 | + references = bomentry[3]; |
| 645 | + if (reflookup) { |
| 646 | + references = findRefInEntry(bomentry); |
| 647 | + if (!references) { |
| 648 | + continue; |
| 649 | + } |
| 650 | + } |
628 | 651 | var tr = document.createElement("TR"); |
629 | 652 | var td = document.createElement("TD"); |
630 | 653 | var rownum = +i + 1; |
|
639 | 662 | tr.appendChild(td); |
640 | 663 | // References |
641 | 664 | td = document.createElement("TD"); |
642 | | - td.innerHTML = highlightFilter(bomentry[3].join(", ")); |
| 665 | + td.innerHTML = highlightFilter(references.join(", ")); |
643 | 666 | tr.appendChild(td); |
644 | 667 | // Value |
645 | 668 | td = document.createElement("TD"); |
|
654 | 677 | td.textContent = bomentry[3].length; |
655 | 678 | tr.appendChild(td); |
656 | 679 | bom.appendChild(tr); |
657 | | - tr.onmouseenter = createRowMouseEnterHandler(bomentry[3]); |
658 | | - if (filter && first) { |
659 | | - drawHighlights(bomentry[3]); |
| 680 | + tr.onmouseenter = createRowMouseEnterHandler(references); |
| 681 | + if ((filter || reflookup) && first) { |
| 682 | + drawHighlights(references); |
660 | 683 | first = false; |
661 | 684 | } |
662 | 685 | } |
663 | 686 | } |
664 | 687 |
|
665 | 688 | function updateFilter(input) { |
666 | 689 | filter = input.toLowerCase(); |
667 | | - populateBomTable(canvaslayout); |
| 690 | + populateBomTable(); |
| 691 | + } |
| 692 | + |
| 693 | + function updateRefLookup(input) { |
| 694 | + reflookup = input.toLowerCase(); |
| 695 | + populateBomTable(); |
668 | 696 | } |
669 | 697 |
|
670 | 698 | function silkscreenVisible(visible) { |
|
817 | 845 | bomlayout = "none"; |
818 | 846 | canvaslayout = "FB"; |
819 | 847 | filter = ""; |
| 848 | + reflookup = ""; |
820 | 849 | populateMetadata(); |
821 | 850 | resizeCanvas(); |
822 | 851 | changeBomLayout('LR'); |
|
883 | 912 | </div> |
884 | 913 | <div id="bot" class="split" style="height: calc(100% - 80px)"> |
885 | 914 | <div id="bomdiv" class="split split-horizontal"> |
886 | | - <input class="filter hideonprint" type="text" placeholder="Filter" |
887 | | - oninput="updateFilter(this.value)"> |
| 915 | + <div style="width: 100%"> |
| 916 | + <input class="searchbox reflookup hideonprint" type="text" placeholder="Ref lookup" |
| 917 | + oninput="updateRefLookup(this.value)"> |
| 918 | + <input class="searchbox filter hideonprint" type="text" placeholder="Filter" |
| 919 | + oninput="updateFilter(this.value)"> |
| 920 | + </div> |
888 | 921 | <div id="dbg"></div> |
889 | 922 | <table class="bom"> |
890 | 923 | <thead> |
|
0 commit comments