Refactor banned strings kill switch functions into a single toggle function

c87e203b4a6840cf4a0e448dd6108e9f6597e735

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

1 files changed, +13 -18Ignore whitespace
public/scripts/textgen-settings.js+13 -18
@@ -458,22 +458,18 @@ function getCustomTokenBans() {
458 };458 };
459}459}
460460
461async function enableBannedStringsKillSwitch() {461/**
462 $('#send_banned_tokens_textgenerationwebui').prop('checked', true);462 * Sets the banned strings kill switch toggle.
463 $('#send_banned_tokens_label').find('.menu_button').addClass('toggleEnabled').prop('title', t`Banned tokens/strings are being sent in the request.`);463 * @param {boolean} isEnabled Kill switch state
464 settings.send_banned_tokens = true;464 * @param {string} title Label title
465 saveSettingsDebounced();465 */
466 return '';466function toggleBannedStringsKillSwitch(isEnabled, title) {
467}467 $('#send_banned_tokens_textgenerationwebui').prop('checked', isEnabled);
468468 $('#send_banned_tokens_label').find('.menu_button').toggleClass('toggleEnabled', isEnabled).prop('title', title);
469async function disableBannedStringsKillSwitch() {469 settings.send_banned_tokens = isEnabled;
470 $('#send_banned_tokens_textgenerationwebui').prop('checked', false);
471 $('#send_banned_tokens_label').find('.menu_button').removeClass('toggleEnabled').prop('title', t`Banned tokens/strings are NOT being sent in the request.`);
472 settings.send_banned_tokens = false;
473 saveSettingsDebounced();470 saveSettingsDebounced();
474 return '';471 return '';
475}472}
476
477/**473/**
478 * Calculates logit bias object from the logit bias list.474 * Calculates logit bias object from the logit bias list.
479 * @returns {object} Logit bias object475 * @returns {object} Logit bias object
@@ -618,11 +614,10 @@ function sortAphroditeItemsByOrder(orderArray) {
618jQuery(function () {614jQuery(function () {
619 $('#send_banned_tokens_textgenerationwebui').on('change', function () {615 $('#send_banned_tokens_textgenerationwebui').on('change', function () {
620 const checked = !!$(this).prop('checked');616 const checked = !!$(this).prop('checked');
621 if (checked) {617 toggleBannedStringsKillSwitch(checked,
622 enableBannedStringsKillSwitch();618 checked
623 } else {619 ? t`Banned tokens/strings are being sent in the request.`
624 disableBannedStringsKillSwitch();620 : t`Banned tokens/strings are NOT being sent in the request.`);
625 }
626 });621 });
627622
628 $('#koboldcpp_order').sortable({623 $('#koboldcpp_order').sortable({