()
| 791 | * Update the fields in the form relating to shields to the values of the currently selected panel. |
| 792 | */ |
| 793 | const updateShieldSubform = function() { |
| 794 | const shieldsContainerElmt = document.getElementById("shields"); |
| 795 | lib.clearChildren(shieldsContainerElmt); |
| 796 | |
| 797 | const shields = post.panels[currentlySelectedPanelIndex].sign.shields; |
| 798 | |
| 799 | for (let shieldIndex = 0, length = shields.length; shieldIndex < length; shieldIndex++) { |
| 800 | |
| 801 | const rowContainerElmt = document.createElement("div"); |
| 802 | rowContainerElmt.style.width = "100%"; |
| 803 | |
| 804 | const toCheckElmt = document.createElement("input"); |
| 805 | toCheckElmt.type = "checkbox"; |
| 806 | toCheckElmt.id = `shield${shieldIndex}_to`; |
| 807 | toCheckElmt.name = `shield${shieldIndex}_to`; |
| 808 | toCheckElmt.checked = shields[shieldIndex].to; |
| 809 | toCheckElmt.addEventListener("change", readForm); |
| 810 | rowContainerElmt.appendChild(toCheckElmt); |
| 811 | |
| 812 | const toCheckLabelElmt = document.createElement("label"); |
| 813 | toCheckLabelElmt.setAttribute("for", `shield${shieldIndex}_to`); |
| 814 | toCheckLabelElmt.appendChild(document.createTextNode(" TO ")); |
| 815 | rowContainerElmt.appendChild(toCheckLabelElmt); |
| 816 | |
| 817 | // Populate shield options |
| 818 | const typeSelectElmt = document.createElement("select"); |
| 819 | for (const type in Shield.prototype.types) { |
| 820 | lib.appendOption(typeSelectElmt, Shield.prototype.types[type], {selected : (shields[shieldIndex].type == Shield.prototype.types[type]), text : type}); |
| 821 | } |
| 822 | typeSelectElmt.id = `shield${shieldIndex}_type`; |
| 823 | typeSelectElmt.addEventListener("change", readForm); |
| 824 | rowContainerElmt.appendChild(typeSelectElmt); |
| 825 | |
| 826 | const routeNumberElmt = document.createElement("input"); |
| 827 | routeNumberElmt.type = "text"; |
| 828 | routeNumberElmt.id = `shield${shieldIndex}_routeNumber`; |
| 829 | routeNumberElmt.placeholder = "00"; |
| 830 | routeNumberElmt.value = shields[shieldIndex].routeNumber; |
| 831 | routeNumberElmt.addEventListener("change", readForm); |
| 832 | rowContainerElmt.appendChild(routeNumberElmt); |
| 833 | |
| 834 | // Populate special banner type options |
| 835 | const specialBannerTypeSelectElmt = document.createElement("select"); |
| 836 | |
| 837 | for (const specialBannerType of Shield.prototype.specialBannerTypes) { |
| 838 | var current = specialBannerType; |
| 839 | current = current.split(":"); |
| 840 | if (typeSelectElmt.value == current[0]) { |
| 841 | var currently = current[1].split("/") |
| 842 | |
| 843 | for (let i = 0; i < currently.length; i++) { |
| 844 | var value = currently[i]; |
| 845 | |
| 846 | if (value.includes(";")) { |
| 847 | value = value.split(";") |
| 848 | var lengths = value[1].length; |
| 849 | |
| 850 | if (lengths < 2) { |
no test coverage detected