MCPcopy Index your code
hub / github.com/JKPotato-Computer/SignMaker / updateForm

Function updateForm

js/main.js:595–881  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers 15

newPanelFunction · 0.70
duplicatePanelFunction · 0.70
deletePanelFunction · 0.70
changeEditingPanelFunction · 0.70
addSubPanelFunction · 0.70
removeSubPanelFunction · 0.70
duplicateSubPanelFunction · 0.70
changeEditingSubPanelFunction · 0.70
newExitTabFunction · 0.70
newNestExitTabFunction · 0.70
duplicateExitTabFunction · 0.70
removeExitTabFunction · 0.70

Calls 4

changeEditingSubPanelFunction · 0.85
changeEditingExitTabFunction · 0.85
changeEditingPanelFunction · 0.70
updateShieldSubformFunction · 0.70

Tested by

no test coverage detected