Fix A/N and CFG menus on first in the list
| @@ -389,49 +389,49 @@ export function setFloatingPrompt() { | ||
| 389 | 389 | } |
| 390 | 390 | |
| 391 | 391 | function onANMenuItemClick() { |
| 392 | 392 | if (!selected_group ||&& this_chid === undefined) { |
| 393 | - //show AN if it's hidden | |
| 393 | + toastr.warning(t`Select a character before trying to use Author's Note`, '', { timeOut: 2000 }); | |
| 394 | - if ($('#floatingPrompt').css('display') !== 'flex') { | |
| 394 | + return; | |
| 395 | - $('#floatingPrompt').addClass('resizing'); | |
| 395 | + } | |
| 396 | - $('#floatingPrompt').css('display', 'flex'); | |
| 396 | + | |
| 397 | - $('#floatingPrompt').css('opacity', 0.0); | |
| 397 | + //show AN if it's hidden | |
| 398 | - $('#floatingPrompt').transition({ | |
| 398 | + if ($('#floatingPrompt').css('display') !== 'flex') { | |
| 399 | - opacity: 1.0, | |
| 399 | + $('#floatingPrompt').addClass('resizing'); | |
| 400 | - duration: animation_duration, | |
| 400 | + $('#floatingPrompt').css('display', 'flex'); | |
| 401 | - }, async function () { | |
| 401 | + $('#floatingPrompt').css('opacity', 0.0); | |
| 402 | - await delay(50); | |
| 402 | + $('#floatingPrompt').transition({ | |
| 403 | - $('#floatingPrompt').removeClass('resizing'); | |
| 403 | + opacity: 1.0, | |
| 404 | - }); | |
| 404 | + duration: animation_duration, | |
| 405 | - | |
| 405 | + }, async function () { | |
| 406 | - //auto-open the main AN inline drawer | |
| 406 | + await delay(50); | |
| 407 | 407 | if ($('#ANBlockTogglefloatingPrompt').removeClass('resizing'); |
| 408 | - .siblings('.inline-drawer-content') | |
| 408 | + }); | |
| 409 | - .css('display') !== 'block') { | |
| 410 | - $('#floatingPrompt').addClass('resizing'); | |
| 411 | - $('#ANBlockToggle').click(); | |
| 412 | - } | |
| 413 | - } else { | |
| 414 | - //hide AN if it's already displayed | |
| 415 | - $('#floatingPrompt').addClass('resizing'); | |
| 416 | - $('#floatingPrompt').transition({ | |
| 417 | - opacity: 0.0, | |
| 418 | - duration: animation_duration, | |
| 419 | - }, | |
| 420 | - async function () { | |
| 421 | - await delay(50); | |
| 422 | - $('#floatingPrompt').removeClass('resizing'); | |
| 423 | - }); | |
| 424 | - setTimeout(function () { | |
| 425 | - $('#floatingPrompt').hide(); | |
| 426 | - }, animation_duration); | |
| 427 | 409 | |
| 410 | + //auto-open the main AN inline drawer | |
| 411 | + if ($('#ANBlockToggle') | |
| 412 | + .siblings('.inline-drawer-content') | |
| 413 | + .css('display') !== 'block') { | |
| 414 | + $('#floatingPrompt').addClass('resizing'); | |
| 415 | + $('#ANBlockToggle').click(); | |
| 428 | 416 | } |
| 429 | - //duplicate options menu close handler from script.js | |
| 430 | - //because this listener takes priority | |
| 431 | - $('#options').stop().fadeOut(animation_duration); | |
| 432 | 417 | } else { |
| 433 | - toastr.warning(t`Select a character before trying to use Author's Note`, '', { timeOut: 2000 }); | |
| 418 | + //hide AN if it's already displayed | |
| 419 | + $('#floatingPrompt').addClass('resizing'); | |
| 420 | + $('#floatingPrompt').transition({ | |
| 421 | + opacity: 0.0, | |
| 422 | + duration: animation_duration, | |
| 423 | + }, async function () { | |
| 424 | + await delay(50); | |
| 425 | + $('#floatingPrompt').removeClass('resizing'); | |
| 426 | + }); | |
| 427 | + setTimeout(function () { | |
| 428 | + $('#floatingPrompt').hide(); | |
| 429 | + }, animation_duration); | |
| 434 | 430 | } |
| 431 | + | |
| 432 | + //duplicate options menu close handler from script.js | |
| 433 | + //because this listener takes priority | |
| 434 | + $('#options').stop().fadeOut(animation_duration); | |
| 435 | 435 | } |
| 436 | 436 | |
| 437 | 437 | async function onChatChanged() { |
| @@ -40,7 +40,7 @@ function setCharCfg(tempValue, setting) { | ||
| 40 | 40 | name: avatarName, |
| 41 | 41 | }; |
| 42 | 42 | |
| 43 | 43 | switch (setting) { |
| 44 | 44 | case settingType.guidance_scale: |
| 45 | 45 | tempCharaCfg['guidance_scale'] = Number(tempValue); |
| 46 | 46 | break; |
| @@ -69,8 +69,7 @@ function setCharCfg(tempValue, setting) { | ||
| 69 | 69 | if (!existingCharaCfg.useChara && |
| 70 | 70 | (tempAssign.guidance_scale ?? 1.00) === 1.00 && |
| 71 | 71 | (tempAssign.negative_prompt?.length ?? 0) === 0 && |
| 72 | 72 | (tempAssign.positive_prompt?.length ?? 0) === 0) { |
| 73 | - { | |
| 74 | 73 | extension_settings.cfg.chara.splice(existingCharaCfgIndex, 1); |
| 75 | 74 | } |
| 76 | 75 | } else if (avatarName && tempValue.length > 0) { |
| @@ -92,7 +91,7 @@ function setCharCfg(tempValue, setting) { | ||
| 92 | 91 | } |
| 93 | 92 | |
| 94 | 93 | function setChatCfg(tempValue, setting) { |
| 95 | 94 | switch (setting) { |
| 96 | 95 | case settingType.guidance_scale: |
| 97 | 96 | chat_metadata[metadataKeys.guidance_scale] = tempValue; |
| 98 | 97 | break; |
| @@ -113,49 +112,49 @@ function setChatCfg(tempValue, setting) { | ||
| 113 | 112 | |
| 114 | 113 | // TODO: Only change CFG when character is selected |
| 115 | 114 | function onCfgMenuItemClick() { |
| 116 | 115 | if (!selected_group ||&& this_chid === undefined) { |
| 117 | - //show CFG config if it's hidden | |
| 116 | + toastr.warning('Select a character before trying to configure CFG', '', { timeOut: 2000 }); | |
| 118 | - if ($('#cfgConfig').css('display') !== 'flex') { | |
| 117 | + return; | |
| 119 | - $('#cfgConfig').addClass('resizing'); | |
| 118 | + } | |
| 120 | - $('#cfgConfig').css('display', 'flex'); | |
| 119 | + | |
| 121 | - $('#cfgConfig').css('opacity', 0.0); | |
| 120 | + //show CFG config if it's hidden | |
| 122 | - $('#cfgConfig').transition({ | |
| 121 | + if ($('#cfgConfig').css('display') !== 'flex') { | |
| 123 | - opacity: 1.0, | |
| 122 | + $('#cfgConfig').addClass('resizing'); | |
| 124 | - duration: animation_duration, | |
| 123 | + $('#cfgConfig').css('display', 'flex'); | |
| 125 | - }, async function () { | |
| 124 | + $('#cfgConfig').css('opacity', 0.0); | |
| 126 | - await delay(50); | |
| 125 | + $('#cfgConfig').transition({ | |
| 127 | - $('#cfgConfig').removeClass('resizing'); | |
| 126 | + opacity: 1.0, | |
| 128 | - }); | |
| 127 | + duration: animation_duration, | |
| 129 | - | |
| 128 | + }, async function () { | |
| 130 | - //auto-open the main AN inline drawer | |
| 129 | + await delay(50); | |
| 131 | 130 | if ($('#CFGBlockTogglecfgConfig').removeClass('resizing'); |
| 132 | - .siblings('.inline-drawer-content') | |
| 131 | + }); | |
| 133 | - .css('display') !== 'block') { | |
| 134 | - $('#floatingPrompt').addClass('resizing'); | |
| 135 | - $('#CFGBlockToggle').click(); | |
| 136 | - } | |
| 137 | - } else { | |
| 138 | - //hide AN if it's already displayed | |
| 139 | - $('#cfgConfig').addClass('resizing'); | |
| 140 | - $('#cfgConfig').transition({ | |
| 141 | - opacity: 0.0, | |
| 142 | - duration: animation_duration, | |
| 143 | - }, | |
| 144 | - async function () { | |
| 145 | - await delay(50); | |
| 146 | - $('#cfgConfig').removeClass('resizing'); | |
| 147 | - }); | |
| 148 | - setTimeout(function () { | |
| 149 | - $('#cfgConfig').hide(); | |
| 150 | - }, animation_duration); | |
| 151 | 132 | |
| 133 | + //auto-open the main AN inline drawer | |
| 134 | + if ($('#CFGBlockToggle') | |
| 135 | + .siblings('.inline-drawer-content') | |
| 136 | + .css('display') !== 'block') { | |
| 137 | + $('#floatingPrompt').addClass('resizing'); | |
| 138 | + $('#CFGBlockToggle').click(); | |
| 152 | 139 | } |
| 153 | - //duplicate options menu close handler from script.js | |
| 154 | - //because this listener takes priority | |
| 155 | - $('#options').stop().fadeOut(animation_duration); | |
| 156 | 140 | } else { |
| 157 | - toastr.warning('Select a character before trying to configure CFG', '', { timeOut: 2000 }); | |
| 141 | + //hide AN if it's already displayed | |
| 142 | + $('#cfgConfig').addClass('resizing'); | |
| 143 | + $('#cfgConfig').transition({ | |
| 144 | + opacity: 0.0, | |
| 145 | + duration: animation_duration, | |
| 146 | + }, async function () { | |
| 147 | + await delay(50); | |
| 148 | + $('#cfgConfig').removeClass('resizing'); | |
| 149 | + }); | |
| 150 | + setTimeout(function () { | |
| 151 | + $('#cfgConfig').hide(); | |
| 152 | + }, animation_duration); | |
| 153 | + | |
| 158 | 154 | } |
| 155 | + //duplicate options menu close handler from script.js | |
| 156 | + //because this listener takes priority | |
| 157 | + $('#options').stop().fadeOut(animation_duration); | |
| 159 | 158 | } |
| 160 | 159 | |
| 161 | 160 | async function onChatChanged() { |
| @@ -288,7 +287,7 @@ export function initCfg() { | ||
| 288 | 287 | setTimeout(function () { $('#cfgConfig').hide(); }, animation_duration); |
| 289 | 288 | }); |
| 290 | 289 | |
| 291 | 290 | $('#chat_cfg_guidance_scale').on('input', function () { |
| 292 | 291 | const numberValue = Number($(this).val()); |
| 293 | 292 | const success = setChatCfg(numberValue, settingType.guidance_scale); |
| 294 | 293 | if (success) { |
| @@ -296,15 +295,15 @@ export function initCfg() { | ||
| 296 | 295 | } |
| 297 | 296 | }); |
| 298 | 297 | |
| 299 | 298 | $('#chat_cfg_negative_prompt').on('input', function () { |
| 300 | 299 | setChatCfg($(this).val(), settingType.negative_prompt); |
| 301 | 300 | }); |
| 302 | 301 | |
| 303 | 302 | $('#chat_cfg_positive_prompt').on('input', function () { |
| 304 | 303 | setChatCfg($(this).val(), settingType.positive_prompt); |
| 305 | 304 | }); |
| 306 | 305 | |
| 307 | 306 | $('#chara_cfg_guidance_scale').on('input', function () { |
| 308 | 307 | const value = $(this).val(); |
| 309 | 308 | const success = setCharCfg(value, settingType.guidance_scale); |
| 310 | 309 | if (success) { |
| @@ -312,34 +311,34 @@ export function initCfg() { | ||
| 312 | 311 | } |
| 313 | 312 | }); |
| 314 | 313 | |
| 315 | 314 | $('#chara_cfg_negative_prompt').on('input', function () { |
| 316 | 315 | setCharCfg($(this).val(), settingType.negative_prompt); |
| 317 | 316 | }); |
| 318 | 317 | |
| 319 | 318 | $('#chara_cfg_positive_prompt').on('input', function () { |
| 320 | 319 | setCharCfg($(this).val(), settingType.positive_prompt); |
| 321 | 320 | }); |
| 322 | 321 | |
| 323 | 322 | $('#global_cfg_guidance_scale').on('input', function () { |
| 324 | 323 | extension_settings.cfg.global.guidance_scale = Number($(this).val()); |
| 325 | 324 | $('#global_cfg_guidance_scale_counter').val(extension_settings.cfg.global.guidance_scale.toFixed(2)); |
| 326 | 325 | saveSettingsDebounced(); |
| 327 | 326 | }); |
| 328 | 327 | |
| 329 | 328 | $('#global_cfg_negative_prompt').on('input', function () { |
| 330 | 329 | extension_settings.cfg.global.negative_prompt = $(this).val(); |
| 331 | 330 | saveSettingsDebounced(); |
| 332 | 331 | }); |
| 333 | 332 | |
| 334 | 333 | $('#global_cfg_positive_prompt').on('input', function () { |
| 335 | 334 | extension_settings.cfg.global.positive_prompt = $(this).val(); |
| 336 | 335 | saveSettingsDebounced(); |
| 337 | 336 | }); |
| 338 | 337 | |
| 339 | 338 | $('input[name="cfg_prompt_combine"]').on('input', function () { |
| 340 | 339 | const values = $('#cfgConfig').find('input[name="cfg_prompt_combine"]') |
| 341 | 340 | .filter(':checked') |
| 342 | 341 | .map(function () { return Number($(this).val()); }) |
| 343 | 342 | .get() |
| 344 | 343 | .filter((e) => !Number.isNaN(e)) || []; |
| 345 | 344 | |
| @@ -347,17 +346,17 @@ export function initCfg() { | ||
| 347 | 346 | saveMetadataDebounced(); |
| 348 | 347 | }); |
| 349 | 348 | |
| 350 | 349 | $('#cfg_prompt_insertion_depth').on('input', function () { |
| 351 | 350 | chat_metadata[metadataKeys.prompt_insertion_depth] = Number($(this).val()); |
| 352 | 351 | saveMetadataDebounced(); |
| 353 | 352 | }); |
| 354 | 353 | |
| 355 | 354 | $('#cfg_prompt_separator').on('input', function () { |
| 356 | 355 | chat_metadata[metadataKeys.prompt_separator] = $(this).val(); |
| 357 | 356 | saveMetadataDebounced(); |
| 358 | 357 | }); |
| 359 | 358 | |
| 360 | 359 | $('#groupchat_cfg_use_chara').on('input', function () { |
| 361 | 360 | const checked = !!$(this).prop('checked'); |
| 362 | 361 | chat_metadata[metadataKeys.groupchat_individual_chars] = checked; |
| 363 | 362 | |