Code clean-up

882e86be117645c08eb34a9e2c2cd3e63886e4be

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

1 files changed, +7 -27Showing whitespace changes
public/scripts/instruct-mode.js+7 -27
@@ -7,7 +7,7 @@ import {
7 power_user,7 power_user,
8 context_presets,8 context_presets,
9} from './power-user.js';9} from './power-user.js';
10import { regexFromString, resetScrollHeight } from './utils.js';10import { regexFromString } from './utils.js';
1111
12/**12/**
13 * @type {any[]} Instruct mode presets.13 * @type {any[]} Instruct mode presets.
@@ -85,19 +85,9 @@ export async function loadInstructMode(data) {
8585
86 migrateInstructModeSettings(power_user.instruct);86 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
102 controls.forEach(control => {92 controls.forEach(control => {
103 const $element = $(`#${control.id}`);93 const $element = $(`#${control.id}`);
@@ -111,11 +101,6 @@ export async function loadInstructMode(data) {
111 $element.on('input', async function () {101 $element.on('input', async function () {
112 power_user.instruct[control.property] = control.isCheckbox ? !!$(this).prop('checked') : $(this)[0].innerText;102 power_user.instruct[control.property] = control.isCheckbox ? !!$(this).prop('checked') : $(this)[0].innerText;
113 saveSettingsDebounced();103 saveSettingsDebounced();
114 /*
115 if (!control.isCheckbox) {
116 await resetScrollHeight($element);
117 }
118 */
119 });104 });
120105
121 if (control.trigger) {106 if (control.trigger) {
@@ -623,13 +608,12 @@ jQuery(() => {
623608
624 $('#instruct_system_same_as_user').on('input', function () {609 $('#instruct_system_same_as_user').on('input', function () {
625 const state = !!$(this).prop('checked');610 const state = !!$(this).prop('checked');
626 if (state == true) {611 if (state) {
627 let tempHeightForDisabled = $('#instruct_system_sequence').css('height');612 const tempHeightForDisabled = $('#instruct_system_sequence').css('height');
628 $('#instruct_system_sequence_block').addClass('disabled');613 $('#instruct_system_sequence_block').addClass('disabled');
629 $('#instruct_system_suffix_block').addClass('disabled');614 $('#instruct_system_suffix_block').addClass('disabled');
630 $('#instruct_system_sequence').css('height', tempHeightForDisabled);615 $('#instruct_system_sequence').css('height', tempHeightForDisabled);
631 $('#instruct_system_suffix').css('height', tempHeightForDisabled);616 $('#instruct_system_suffix').css('height', tempHeightForDisabled);
632
633 $('#instruct_system_sequence').prop('contenteditable', false);617 $('#instruct_system_sequence').prop('contenteditable', false);
634 $('#instruct_system_suffix').prop('contenteditable', false);618 $('#instruct_system_suffix').prop('contenteditable', false);
635 } else {619 } else {
@@ -669,11 +653,7 @@ jQuery(() => {
669 });653 });
670654
671 $('#instruct_bind_to_context').on('change', function () {655 $('#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 }
677 });657 });
678658
679 $('#instruct_presets').on('change', function () {659 $('#instruct_presets').on('change', function () {