Code clean-up

882e86be117645c08eb34a9e2c2cd3e63886e4be

Cohee <18619528+Cohee1207@users.noreply.github.com>

1 files changed, +7 -27Ignore whitespace
public/scripts/instruct-mode.js+7 -27
@@ -7,7 +7,7 @@ import {
77 power_user,
88 context_presets,
99} from './power-user.js';
1010import { regexFromString, resetScrollHeight } from './utils.js';
1111
1212/**
1313 * @type {any[]} Instruct mode presets.
@@ -85,19 +85,9 @@ export async function loadInstructMode(data) {
8585
8686 migrateInstructModeSettings(power_user.instruct);
8787
88- if (power_user.instruct.enabled) {
88+ $('#instruct_enabled').parent().find('i').toggleClass('toggleEnabled', !!power_user.instruct.enabled);
89- $('#instruct_enabled').parent().find('i').addClass('toggleEnabled');
89+ $('#instructSettingsBlock, #InstructSequencesColumn').toggleClass('disabled', !power_user.instruct.enabled);
90- $('#instructSettingsBlock, #InstructSequencesColumn').removeClass('disabled');
90+ $('#instruct_bind_to_context').parent().find('i').toggleClass('toggleEnabled', !!power_user.instruct.bind_to_context);
91- } else {
92- $('#instruct_enabled').parent().find('i').removeClass('toggleEnabled');
93- $('#instructSettingsBlock, #InstructSequencesColumn').addClass('disabled');
94- }
95-
96- if (power_user.instruct.bind_to_context) {
97- $('#instruct_bind_to_context').parent().find('i').addClass('toggleEnabled');
98- } else {
99- $('#instruct_bind_to_context').parent().find('i').removeClass('toggleEnabled');
100- }
10191
10292 controls.forEach(control => {
10393 const $element = $(`#${control.id}`);
@@ -111,11 +101,6 @@ export async function loadInstructMode(data) {
111101 $element.on('input', async function () {
112102 power_user.instruct[control.property] = control.isCheckbox ? !!$(this).prop('checked') : $(this)[0].innerText;
113103 saveSettingsDebounced();
114- /*
115- if (!control.isCheckbox) {
116- await resetScrollHeight($element);
117- }
118- */
119104 });
120105
121106 if (control.trigger) {
@@ -623,13 +608,12 @@ jQuery(() => {
623608
624609 $('#instruct_system_same_as_user').on('input', function () {
625610 const state = !!$(this).prop('checked');
626611 if (state == true) {
627612 letconst tempHeightForDisabled = $('#instruct_system_sequence').css('height');
628613 $('#instruct_system_sequence_block').addClass('disabled');
629614 $('#instruct_system_suffix_block').addClass('disabled');
630615 $('#instruct_system_sequence').css('height', tempHeightForDisabled);
631616 $('#instruct_system_suffix').css('height', tempHeightForDisabled);
632-
633617 $('#instruct_system_sequence').prop('contenteditable', false);
634618 $('#instruct_system_suffix').prop('contenteditable', false);
635619 } else {
@@ -669,11 +653,7 @@ jQuery(() => {
669653 });
670654
671655 $('#instruct_bind_to_context').on('change', function () {
672- if (power_user.instruct.bind_to_context) {
656+ $('#instruct_bind_to_context').parent().find('i').toggleClass('toggleEnabled', !!power_user.instruct.bind_to_context);
673- $('#instruct_bind_to_context').parent().find('i').addClass('toggleEnabled');
674- } else {
675- $('#instruct_bind_to_context').parent().find('i').removeClass('toggleEnabled');
676- }
677657 });
678658
679659 $('#instruct_presets').on('change', function () {