Fix A/N and CFG menus on first in the list
| @@ -389,49 +389,49 @@ export function setFloatingPrompt() { | |||
| 389 | } | 389 | } |
| 390 | 390 | ||
| 391 | function onANMenuItemClick() { | 391 | function onANMenuItemClick() { |
| 392 | if (selected_group || this_chid) { | 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 | if ($('#ANBlockToggle') | 407 | $('#floatingPrompt').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 | } else { | 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 | async function onChatChanged() { | 437 | async function onChatChanged() { |
| @@ -40,7 +40,7 @@ function setCharCfg(tempValue, setting) { | |||
| 40 | name: avatarName, | 40 | name: avatarName, |
| 41 | }; | 41 | }; |
| 42 | 42 | ||
| 43 | switch(setting) { | 43 | switch (setting) { |
| 44 | case settingType.guidance_scale: | 44 | case settingType.guidance_scale: |
| 45 | tempCharaCfg['guidance_scale'] = Number(tempValue); | 45 | tempCharaCfg['guidance_scale'] = Number(tempValue); |
| 46 | break; | 46 | break; |
| @@ -69,8 +69,7 @@ function setCharCfg(tempValue, setting) { | |||
| 69 | if (!existingCharaCfg.useChara && | 69 | if (!existingCharaCfg.useChara && |
| 70 | (tempAssign.guidance_scale ?? 1.00) === 1.00 && | 70 | (tempAssign.guidance_scale ?? 1.00) === 1.00 && |
| 71 | (tempAssign.negative_prompt?.length ?? 0) === 0 && | 71 | (tempAssign.negative_prompt?.length ?? 0) === 0 && |
| 72 | (tempAssign.positive_prompt?.length ?? 0) === 0) | 72 | (tempAssign.positive_prompt?.length ?? 0) === 0) { |
| 73 | { | ||
| 74 | extension_settings.cfg.chara.splice(existingCharaCfgIndex, 1); | 73 | extension_settings.cfg.chara.splice(existingCharaCfgIndex, 1); |
| 75 | } | 74 | } |
| 76 | } else if (avatarName && tempValue.length > 0) { | 75 | } else if (avatarName && tempValue.length > 0) { |
| @@ -92,7 +91,7 @@ function setCharCfg(tempValue, setting) { | |||
| 92 | } | 91 | } |
| 93 | 92 | ||
| 94 | function setChatCfg(tempValue, setting) { | 93 | function setChatCfg(tempValue, setting) { |
| 95 | switch(setting) { | 94 | switch (setting) { |
| 96 | case settingType.guidance_scale: | 95 | case settingType.guidance_scale: |
| 97 | chat_metadata[metadataKeys.guidance_scale] = tempValue; | 96 | chat_metadata[metadataKeys.guidance_scale] = tempValue; |
| 98 | break; | 97 | break; |
| @@ -113,49 +112,49 @@ function setChatCfg(tempValue, setting) { | |||
| 113 | 112 | ||
| 114 | // TODO: Only change CFG when character is selected | 113 | // TODO: Only change CFG when character is selected |
| 115 | function onCfgMenuItemClick() { | 114 | function onCfgMenuItemClick() { |
| 116 | if (selected_group || this_chid) { | 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 | if ($('#CFGBlockToggle') | 130 | $('#cfgConfig').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 | } else { | 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 | async function onChatChanged() { | 160 | async function onChatChanged() { |
| @@ -288,7 +287,7 @@ export function initCfg() { | |||
| 288 | setTimeout(function () { $('#cfgConfig').hide(); }, animation_duration); | 287 | setTimeout(function () { $('#cfgConfig').hide(); }, animation_duration); |
| 289 | }); | 288 | }); |
| 290 | 289 | ||
| 291 | $('#chat_cfg_guidance_scale').on('input', function() { | 290 | $('#chat_cfg_guidance_scale').on('input', function () { |
| 292 | const numberValue = Number($(this).val()); | 291 | const numberValue = Number($(this).val()); |
| 293 | const success = setChatCfg(numberValue, settingType.guidance_scale); | 292 | const success = setChatCfg(numberValue, settingType.guidance_scale); |
| 294 | if (success) { | 293 | if (success) { |
| @@ -296,15 +295,15 @@ export function initCfg() { | |||
| 296 | } | 295 | } |
| 297 | }); | 296 | }); |
| 298 | 297 | ||
| 299 | $('#chat_cfg_negative_prompt').on('input', function() { | 298 | $('#chat_cfg_negative_prompt').on('input', function () { |
| 300 | setChatCfg($(this).val(), settingType.negative_prompt); | 299 | setChatCfg($(this).val(), settingType.negative_prompt); |
| 301 | }); | 300 | }); |
| 302 | 301 | ||
| 303 | $('#chat_cfg_positive_prompt').on('input', function() { | 302 | $('#chat_cfg_positive_prompt').on('input', function () { |
| 304 | setChatCfg($(this).val(), settingType.positive_prompt); | 303 | setChatCfg($(this).val(), settingType.positive_prompt); |
| 305 | }); | 304 | }); |
| 306 | 305 | ||
| 307 | $('#chara_cfg_guidance_scale').on('input', function() { | 306 | $('#chara_cfg_guidance_scale').on('input', function () { |
| 308 | const value = $(this).val(); | 307 | const value = $(this).val(); |
| 309 | const success = setCharCfg(value, settingType.guidance_scale); | 308 | const success = setCharCfg(value, settingType.guidance_scale); |
| 310 | if (success) { | 309 | if (success) { |
| @@ -312,34 +311,34 @@ export function initCfg() { | |||
| 312 | } | 311 | } |
| 313 | }); | 312 | }); |
| 314 | 313 | ||
| 315 | $('#chara_cfg_negative_prompt').on('input', function() { | 314 | $('#chara_cfg_negative_prompt').on('input', function () { |
| 316 | setCharCfg($(this).val(), settingType.negative_prompt); | 315 | setCharCfg($(this).val(), settingType.negative_prompt); |
| 317 | }); | 316 | }); |
| 318 | 317 | ||
| 319 | $('#chara_cfg_positive_prompt').on('input', function() { | 318 | $('#chara_cfg_positive_prompt').on('input', function () { |
| 320 | setCharCfg($(this).val(), settingType.positive_prompt); | 319 | setCharCfg($(this).val(), settingType.positive_prompt); |
| 321 | }); | 320 | }); |
| 322 | 321 | ||
| 323 | $('#global_cfg_guidance_scale').on('input', function() { | 322 | $('#global_cfg_guidance_scale').on('input', function () { |
| 324 | extension_settings.cfg.global.guidance_scale = Number($(this).val()); | 323 | extension_settings.cfg.global.guidance_scale = Number($(this).val()); |
| 325 | $('#global_cfg_guidance_scale_counter').val(extension_settings.cfg.global.guidance_scale.toFixed(2)); | 324 | $('#global_cfg_guidance_scale_counter').val(extension_settings.cfg.global.guidance_scale.toFixed(2)); |
| 326 | saveSettingsDebounced(); | 325 | saveSettingsDebounced(); |
| 327 | }); | 326 | }); |
| 328 | 327 | ||
| 329 | $('#global_cfg_negative_prompt').on('input', function() { | 328 | $('#global_cfg_negative_prompt').on('input', function () { |
| 330 | extension_settings.cfg.global.negative_prompt = $(this).val(); | 329 | extension_settings.cfg.global.negative_prompt = $(this).val(); |
| 331 | saveSettingsDebounced(); | 330 | saveSettingsDebounced(); |
| 332 | }); | 331 | }); |
| 333 | 332 | ||
| 334 | $('#global_cfg_positive_prompt').on('input', function() { | 333 | $('#global_cfg_positive_prompt').on('input', function () { |
| 335 | extension_settings.cfg.global.positive_prompt = $(this).val(); | 334 | extension_settings.cfg.global.positive_prompt = $(this).val(); |
| 336 | saveSettingsDebounced(); | 335 | saveSettingsDebounced(); |
| 337 | }); | 336 | }); |
| 338 | 337 | ||
| 339 | $('input[name="cfg_prompt_combine"]').on('input', function() { | 338 | $('input[name="cfg_prompt_combine"]').on('input', function () { |
| 340 | const values = $('#cfgConfig').find('input[name="cfg_prompt_combine"]') | 339 | const values = $('#cfgConfig').find('input[name="cfg_prompt_combine"]') |
| 341 | .filter(':checked') | 340 | .filter(':checked') |
| 342 | .map(function() { return Number($(this).val()); }) | 341 | .map(function () { return Number($(this).val()); }) |
| 343 | .get() | 342 | .get() |
| 344 | .filter((e) => !Number.isNaN(e)) || []; | 343 | .filter((e) => !Number.isNaN(e)) || []; |
| 345 | 344 | ||
| @@ -347,17 +346,17 @@ export function initCfg() { | |||
| 347 | saveMetadataDebounced(); | 346 | saveMetadataDebounced(); |
| 348 | }); | 347 | }); |
| 349 | 348 | ||
| 350 | $('#cfg_prompt_insertion_depth').on('input', function() { | 349 | $('#cfg_prompt_insertion_depth').on('input', function () { |
| 351 | chat_metadata[metadataKeys.prompt_insertion_depth] = Number($(this).val()); | 350 | chat_metadata[metadataKeys.prompt_insertion_depth] = Number($(this).val()); |
| 352 | saveMetadataDebounced(); | 351 | saveMetadataDebounced(); |
| 353 | }); | 352 | }); |
| 354 | 353 | ||
| 355 | $('#cfg_prompt_separator').on('input', function() { | 354 | $('#cfg_prompt_separator').on('input', function () { |
| 356 | chat_metadata[metadataKeys.prompt_separator] = $(this).val(); | 355 | chat_metadata[metadataKeys.prompt_separator] = $(this).val(); |
| 357 | saveMetadataDebounced(); | 356 | saveMetadataDebounced(); |
| 358 | }); | 357 | }); |
| 359 | 358 | ||
| 360 | $('#groupchat_cfg_use_chara').on('input', function() { | 359 | $('#groupchat_cfg_use_chara').on('input', function () { |
| 361 | const checked = !!$(this).prop('checked'); | 360 | const checked = !!$(this).prop('checked'); |
| 362 | chat_metadata[metadataKeys.groupchat_individual_chars] = checked; | 361 | chat_metadata[metadataKeys.groupchat_individual_chars] = checked; |
| 363 | 362 | ||