()
| 884 | * Update the fields in the form relating to shields to the values of the currently selected panel. |
| 885 | */ |
| 886 | const updateShieldSubform = function() { |
| 887 | |
| 888 | const shieldsContainerElmt = document.getElementById("shields"); |
| 889 | var subPanel; |
| 890 | |
| 891 | if (currentlySelectedSubPanelIndex == -1) { |
| 892 | subPanel = post.panels[currentlySelectedPanelIndex].sign; |
| 893 | } else { |
| 894 | subPanel = post.panels[currentlySelectedPanelIndex].sign.subPanels[currentlySelectedSubPanelIndex]; |
| 895 | } |
| 896 | const shields = subPanel.shields; |
| 897 | |
| 898 | while (shieldsContainerElmt.firstChild) { |
| 899 | shieldsContainerElmt.removeChild(shieldsContainerElmt.lastChild); |
| 900 | } |
| 901 | |
| 902 | for (let shieldIndex = 0, length = shields.length; shieldIndex < length; shieldIndex++) { |
| 903 | |
| 904 | const rowContainerElmt = document.createElement("div"); |
| 905 | rowContainerElmt.style.width = "100%"; |
| 906 | |
| 907 | const toCheckElmt = document.createElement("input"); |
| 908 | toCheckElmt.type = "checkbox"; |
| 909 | toCheckElmt.id = `shield${shieldIndex}_to`; |
| 910 | toCheckElmt.name = `shield${shieldIndex}_to`; |
| 911 | toCheckElmt.checked = shields[shieldIndex].to; |
| 912 | toCheckElmt.addEventListener("change", readForm); |
| 913 | rowContainerElmt.appendChild(toCheckElmt); |
| 914 | |
| 915 | const toCheckLabelElmt = document.createElement("label"); |
| 916 | toCheckLabelElmt.setAttribute("for", `shield${shieldIndex}_to`); |
| 917 | toCheckLabelElmt.appendChild(document.createTextNode(" TO ")); |
| 918 | rowContainerElmt.appendChild(toCheckLabelElmt); |
| 919 | |
| 920 | // Populate shield options |
| 921 | const typeSelectElmt = document.createElement("select"); |
| 922 | for (const type in Shield.prototype.types) { |
| 923 | lib.appendOption(typeSelectElmt, Shield.prototype.types[type], { |
| 924 | selected: (shields[shieldIndex].type == Shield.prototype.types[type]), |
| 925 | text: type |
| 926 | }); |
| 927 | } |
| 928 | typeSelectElmt.id = `shield${shieldIndex}_type`; |
| 929 | typeSelectElmt.addEventListener("change", readForm); |
| 930 | rowContainerElmt.appendChild(typeSelectElmt); |
| 931 | |
| 932 | const routeNumberElmt = document.createElement("input"); |
| 933 | routeNumberElmt.type = "text"; |
| 934 | routeNumberElmt.id = `shield${shieldIndex}_routeNumber`; |
| 935 | routeNumberElmt.placeholder = "00"; |
| 936 | routeNumberElmt.value = shields[shieldIndex].routeNumber; |
| 937 | routeNumberElmt.addEventListener("change", readForm); |
| 938 | rowContainerElmt.appendChild(routeNumberElmt); |
| 939 | |
| 940 | // Populate special banner type options |
| 941 | const specialBannerTypeSelectElmt = document.createElement("select"); |
| 942 | |
| 943 | if (Shield.prototype.specialBannerTypes[shields[shieldIndex].type] != undefined) { |
no test coverage detected