diff --git a/format.html b/format.html index a6779aa..e336bd4 100644 --- a/format.html +++ b/format.html @@ -1,6 +1,7 @@ -`; + `; // 超級樣板 HTML const superPromptHTML = ` @@ -4335,16 +3654,6 @@ const i18n = (key, params = []) => { document.querySelector("#dialog6-cancel"); const superPromptSettingsTableForm = superPromptSettingsDialog.querySelector("#super-table-form"); - const superPromptSettingsTableForm2 = - superPromptSettingsDialog.querySelector("#super-table-form2"); - const superPromptSettingsTableForm3 = - superPromptSettingsDialog.querySelector("#super-table-form3"); - const superPromptSettingsTableForm4 = - superPromptSettingsDialog.querySelector("#super-table-form4"); - const superPromptSettingsTableForm5 = - superPromptSettingsDialog.querySelector("#super-table-form5"); - const superPromptSettingsTableForm6 = - superPromptSettingsDialog.querySelector("#super-table-form6"); // superPrompt const superPromptDialog = document.getElementById("dialog7"); @@ -5601,29 +4910,10 @@ const i18n = (key, params = []) => { // ------------ super 設定視窗相關 程式碼 ------------ function showSuperPromptSettingDialog(superFormType) { - currentSuperSettingFormType = superFormType; superPromptSettingsDialog.style.display = "flex"; - superPromptSettingsTableForm.style.display = "none"; - superPromptSettingsTableForm2.style.display = "none"; - superPromptSettingsTableForm3.style.display = "none"; - superPromptSettingsTableForm4.style.display = "none"; - superPromptSettingsTableForm5.style.display = "none"; - superPromptSettingsTableForm6.style.display = "none"; - - if (currentSuperSettingFormType === 1) { - superPromptSettingsTableForm.style.display = "table"; - superPromptSettingsTableForm.style.width = "100%"; - } else { - const form = document.getElementById( - `super-table-form${currentSuperSettingFormType}` - ); - form.style.display = "table"; - form.style.width = "100%"; - } - const superPromptButtonTextElements = document.querySelectorAll( ".superPromptButtonText" ); @@ -5639,19 +4929,18 @@ const i18n = (key, params = []) => { dialogTitleElement.innerHTML = superPromptCategoryList[currentSuperSettingFormType - 1].name; - const startIndex = 0 * currentSuperSettingFormType; - const endIndex = 5 * currentSuperSettingFormType; + const nowSuperPromptList = superPromptList.slice( + (currentSuperSettingFormType - 1 ) * 5 , + currentSuperSettingFormType * 5 + ); - for (let index = startIndex; index < endIndex; index++) { - superPromptButtonTextElements[index].value = superPromptList[index].text; - superPromptTextElements[index].value = superPromptList[index].prompt; - superPromptSlideElements[index].checked = - superPromptList[index].isVisible; + for (let index = 0; index < 5; index++) { + superPromptButtonTextElements[index].value = nowSuperPromptList[index].text; + superPromptTextElements[index].value = nowSuperPromptList[index].prompt; + superPromptSlideElements[index].checked = nowSuperPromptList[index].isVisible; } - superPromptButtonTextElements[ - (currentSuperSettingFormType - 1) * 5 - ].focus(); + superPromptButtonTextElements[0].focus(); controlSuperPromptSettingsDialogTabindex(); } @@ -5663,25 +4952,27 @@ const i18n = (key, params = []) => { const textInputElements = document.querySelectorAll(".superPromptText"); const promptSlideElements = document.querySelectorAll(".superPromptSlide"); - const startIndex = 0 * currentSuperSettingFormType; - const endIndex = 5 * currentSuperSettingFormType; + const nowSuperPromptList = superPromptList.slice( + (currentSuperSettingFormType - 1 ) * 5 , + currentSuperSettingFormType * 5 + ); - const previousSuperPromptList = JSON.parse(JSON.stringify(superPromptList)); + const previousSuperPromptList = JSON.parse(JSON.stringify(nowSuperPromptList)); - for (let index = startIndex; index < endIndex; index++) { - superPromptList[index].text = btnTextInputElements[index].value; - superPromptList[index].prompt = textInputElements[index].value; - superPromptList[index].isVisible = promptSlideElements[index].checked; + for (let index = 0; index < 5; index++) { + nowSuperPromptList[index].text = btnTextInputElements[index].value; + nowSuperPromptList[index].prompt = textInputElements[index].value; + nowSuperPromptList[index].isVisible = promptSlideElements[index].checked; if (previousSuperPromptList.isVisible) { - superPromptList[index].buttonElement.removeEventListener( + nowSuperPromptList[index].buttonElement.removeEventListener( "click", - superPromptList[index].handleClickFn + nowSuperPromptList[index].handleClickFn ); - superPromptList[index].buttonElement.remove(); + nowSuperPromptList[index].buttonElement.remove(); - delete superPromptList[index].buttonElement; - delete superPromptList[index].handleClickFn; + delete nowSuperPromptList[index].buttonElement; + delete nowSuperPromptList[index].handleClickFn; } } @@ -6682,35 +5973,7 @@ const i18n = (key, params = []) => { let superPromptSettingsDialogBindTabindexHandler = null; function controlSuperPromptSettingsDialogTabindex() { - - let currentSuperPromptSettingsTableForm = null; - - switch (currentSuperSettingFormType) { - case 2: - currentSuperPromptSettingsTableForm = superPromptSettingsTableForm2; - break; - - case 3: - currentSuperPromptSettingsTableForm = superPromptSettingsTableForm3; - break; - - case 4: - currentSuperPromptSettingsTableForm = superPromptSettingsTableForm4; - break; - - case 5: - currentSuperPromptSettingsTableForm = superPromptSettingsTableForm5; - break; - - case 6: - currentSuperPromptSettingsTableForm = superPromptSettingsTableForm6; - break; - - case 1: - default: - currentSuperPromptSettingsTableForm = superPromptSettingsTableForm; - break; - } + let currentSuperPromptSettingsTableForm = superPromptSettingsTableForm; // tableForm tabindexElements let tableFormTabindexElements = @@ -6750,7 +6013,6 @@ const i18n = (key, params = []) => { let superDialogTabindexBindTabindexHandler = null; function controlSuperDialogTabindex() { - let superPromptDialogTabindexElements = superPromptDialog.querySelectorAll( "input, textarea, button" ); @@ -6783,7 +6045,6 @@ const i18n = (key, params = []) => { let superPromptCategoryNameSettingsDialogBindTabindexHandler = null; function controlSuperPromptCategoryNameSettingsDialogTabindex() { - let superPromptCategoryNameSettingsDialogTabindexElements = superPromptCategoryNameSettingsDialog.querySelectorAll("input, button"); @@ -6810,5 +6071,4 @@ const i18n = (key, params = []) => { superPromptCategoryNameSettingsDialogBindTabindexHandler ); } - })();