()
| 593 | * Update the fields in the form to the values of the currently selected panel. |
| 594 | */ |
| 595 | const updateForm = function() { |
| 596 | const panel = post.panels[currentlySelectedPanelIndex]; |
| 597 | const sign = (currentlySelectedSubPanelIndex != -1) ? (panel.sign.subPanels[currentlySelectedSubPanelIndex]) : (panel.sign); |
| 598 | const exitTab = (currentlySelectedNestedExitTabIndex != -1) ? (panel.exitTabs[currentlySelectedExitTabIndex].nestedExitTabs[currentlySelectedNestedExitTabIndex]) : (panel.exitTabs[currentlySelectedExitTabIndex]); |
| 599 | |
| 600 | const panelList = document.getElementById("panelList"); |
| 601 | const subPanelList = document.getElementById("subPanelList"); |
| 602 | const exitTabList = document.getElementById("exitTabList"); |
| 603 | |
| 604 | while (panelList.firstChild) { |
| 605 | panelList.removeChild(panelList.lastChild); |
| 606 | } |
| 607 | |
| 608 | while (subPanelList.firstChild) { |
| 609 | subPanelList.removeChild(subPanelList.lastChild); |
| 610 | |
| 611 | if (subPanelList.lastChild == document.getElementById("global")) { |
| 612 | if (currentlySelectedSubPanelIndex == -1) { |
| 613 | document.getElementById("global").className = "active"; |
| 614 | } else { |
| 615 | document.getElementById("global").className = ""; |
| 616 | } |
| 617 | |
| 618 | break; |
| 619 | } |
| 620 | } |
| 621 | |
| 622 | while (exitTabList.firstChild) { |
| 623 | exitTabList.removeChild(exitTabList.lastChild); |
| 624 | } |
| 625 | |
| 626 | for (let panelIndex = 0, panelsLength = post.panels.length; panelIndex < panelsLength; panelIndex++) { |
| 627 | const panelButton = document.createElement("input"); |
| 628 | panelButton.type = "button"; |
| 629 | panelButton.id = "edit" + (panelIndex + 1); |
| 630 | panelButton.value = "Panel " + (panelIndex + 1); |
| 631 | panelButton.className = (currentlySelectedPanelIndex == panelIndex) ? "active" : ""; |
| 632 | |
| 633 | panelButton.addEventListener("click", function() { |
| 634 | changeEditingPanel(panelIndex); |
| 635 | panelButton.className = "active"; |
| 636 | }); |
| 637 | |
| 638 | panelList.appendChild(panelButton); |
| 639 | } |
| 640 | |
| 641 | for (let subPanelIndex = 0, subPanelsLength = panel.sign.subPanels.length; subPanelIndex < subPanelsLength; subPanelIndex++) { |
| 642 | const subPanelButton = document.createElement("input"); |
| 643 | subPanelButton.type = "button"; |
| 644 | subPanelButton.id = "sub_edit" + (subPanelIndex + 1); |
| 645 | subPanelButton.value = "SubPanel " + (subPanelIndex + 1); |
| 646 | subPanelButton.className = (currentlySelectedSubPanelIndex == subPanelIndex) ? "active" : ""; |
| 647 | |
| 648 | subPanelButton.addEventListener("click", function() { |
| 649 | changeEditingSubPanel(subPanelIndex, panel); |
| 650 | subPanelButton.className = "active"; |
| 651 | }); |
| 652 |
no test coverage detected