|
244 | 244 | ///PCBDATA/// |
245 | 245 | /////////////////////////////////////////////// |
246 | 246 |
|
| 247 | + var storagePrefix = 'KiCad_HTML_BOM__' + pcbdata.metadata.title + '__' |
| 248 | + + pcbdata.metadata.revision + '__'; |
| 249 | + var bomsplit; |
| 250 | + var canvassplit; |
247 | 251 | var frontscale = 12; |
248 | 252 | var backscale = 12; |
249 | 253 | var canvaslayout = "default"; |
250 | 254 | var bomlayout = "default"; |
251 | 255 |
|
| 256 | + function readStorage(key) { |
| 257 | + return window.localStorage.getItem(storagePrefix + '#' + key); |
| 258 | + } |
| 259 | + |
| 260 | + function writeStorage(key, value) { |
| 261 | + window.localStorage.setItem(storagePrefix + '#' + key, value); |
| 262 | + } |
| 263 | + |
252 | 264 | function deg2rad(deg) { |
253 | 265 | return deg * Math.PI / 180; |
254 | 266 | } |
|
693 | 705 | if (visible) { |
694 | 706 | allcanvas.front.silk.style.display = ""; |
695 | 707 | allcanvas.back.silk.style.display = ""; |
| 708 | + writeStorage("silkscreenVisible", true); |
696 | 709 | } else { |
697 | 710 | allcanvas.front.silk.style.display = "none"; |
698 | 711 | allcanvas.back.silk.style.display = "none"; |
| 712 | + writeStorage("silkscreenVisible", false); |
699 | 713 | } |
700 | 714 | } |
701 | 715 |
|
|
723 | 737 | } |
724 | 738 | } |
725 | 739 | canvaslayout = layout; |
| 740 | + writeStorage("canvaslayout", layout); |
726 | 741 | resizeCanvas(); |
727 | 742 | populateBomTable(layout); |
728 | 743 | } |
|
744 | 759 | switch (layout) { |
745 | 760 | case 'BOM': |
746 | 761 | document.getElementById("bom-btn").classList.add("depressed"); |
747 | | - if (["LR", "TB"].includes(bomlayout)) { |
| 762 | + if (bomsplit) { |
748 | 763 | bomsplit.destroy(); |
| 764 | + bomsplit = null; |
749 | 765 | canvassplit.destroy(); |
| 766 | + canvassplit = null; |
750 | 767 | } |
751 | 768 | document.getElementById("frontcanvas").style.display = "none"; |
752 | 769 | document.getElementById("backcanvas").style.display = "none"; |
|
761 | 778 | document.getElementById("canvasdiv").classList.remove("split-horizontal"); |
762 | 779 | document.getElementById("frontcanvas").classList.add("split-horizontal"); |
763 | 780 | document.getElementById("backcanvas").classList.add("split-horizontal"); |
764 | | - if (["LR", "TB"].includes(bomlayout)) { |
| 781 | + if (bomsplit) { |
765 | 782 | bomsplit.destroy(); |
| 783 | + bomsplit = null; |
766 | 784 | canvassplit.destroy(); |
| 785 | + canvassplit = null; |
767 | 786 | } |
768 | 787 | bomsplit = Split(['#bomdiv', '#canvasdiv'], { |
769 | 788 | sizes: [50, 50], |
|
786 | 805 | document.getElementById("canvasdiv").classList.add("split-horizontal"); |
787 | 806 | document.getElementById("frontcanvas").classList.remove("split-horizontal"); |
788 | 807 | document.getElementById("backcanvas").classList.remove("split-horizontal"); |
789 | | - if (["LR", "TB"].includes(bomlayout)) { |
| 808 | + if (bomsplit) { |
790 | 809 | bomsplit.destroy(); |
| 810 | + bomsplit = null; |
791 | 811 | canvassplit.destroy(); |
| 812 | + canvassplit = null; |
792 | 813 | } |
793 | 814 | bomsplit = Split(['#bomdiv', '#canvasdiv'], { |
794 | 815 | sizes: [50, 50], |
|
803 | 824 | }); |
804 | 825 | } |
805 | 826 | bomlayout = layout; |
806 | | - if (bomlayout != "BOM") { |
807 | | - changeCanvasLayout(canvaslayout); |
808 | | - } |
| 827 | + writeStorage("bomlayout", layout); |
| 828 | + changeCanvasLayout(canvaslayout); |
809 | 829 | } |
810 | 830 |
|
811 | 831 | function removeGutterNode(node) { |
|
836 | 856 | allcanvas.back.highlight = document.getElementById("B_hl"); |
837 | 857 | dbgdiv = document.getElementById("dbg"); |
838 | 858 | bom = document.getElementById("bombody"); |
839 | | - bomlayout = "none"; |
840 | | - canvaslayout = "FB"; |
| 859 | + bomlayout = readStorage("bomlayout"); |
| 860 | + if (!bomlayout) { |
| 861 | + bomlayout = "LR"; |
| 862 | + } |
| 863 | + canvaslayout = readStorage("canvaslayout"); |
| 864 | + if (!canvaslayout) { |
| 865 | + canvaslayout = "FB"; |
| 866 | + } |
841 | 867 | filter = ""; |
842 | 868 | reflookup = ""; |
843 | 869 | populateMetadata(); |
844 | | - resizeCanvas(); |
845 | | - changeBomLayout('LR'); |
| 870 | + changeBomLayout(bomlayout); |
| 871 | + if (readStorage("silkscreenVisible") === "false") { |
| 872 | + document.getElementById("silkscreenCheckbox").checked = false; |
| 873 | + silkscreenVisible(false); |
| 874 | + } |
846 | 875 | } |
847 | 876 |
|
848 | 877 | window.onresize = resizeCanvas; |
849 | 878 | window.matchMedia("print").addListener(resizeCanvas); |
850 | | - |
851 | 879 | </script> |
852 | 880 | </head> |
853 | 881 |
|
|
856 | 884 | <div id="top" class="split" style="height: 80px; border-bottom: 2px solid black;"> |
857 | 885 | <div style="float: right;"> |
858 | 886 | <div class="hideonprint" style="float: right; margin: 10px; position: relative; top: 20px"> |
859 | | - <input type="checkbox" name="silkscreen" value="silkscreen" checked |
| 887 | + <input id="silkscreenCheckbox" type="checkbox" name="silkscreen" value="silkscreen" checked |
860 | 888 | onchange="silkscreenVisible(this.checked)">Silkscreen |
861 | 889 | </div> |
862 | 890 | <div class="button-container hideonprint" |
|
0 commit comments