Character source link processing

This commit is contained in:
berbant 2024-03-02 23:37:18 +04:00 committed by GitHub
parent a38bfe39b5
commit 8769630b68
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 23 additions and 0 deletions

View File

@ -6478,6 +6478,13 @@ export function select_selected_character(chid) {
setWorldInfoButtonClass(chid);
checkEmbeddedWorld(chid);
// Disable or enable Link to Source dropdown menu item depending on the presence of 'full_path' property
$('#character_source').prop( "disabled", true );
const chidSourceData = Object.values(characters[this_chid].data.extensions)
Object.entries(chidSourceData).forEach(function([key, value]) {
if (Object.keys(value).includes('full_path')) $('#character_source').prop( "disabled", false );
});
$('#form_create').attr('actiontype', 'editcharacter');
$('.form_create_bottom_buttons_block .chat_lorebook_button').show();
saveSettingsDebounced();
@ -9806,6 +9813,22 @@ jQuery(async function () {
await importEmbeddedWorldInfo();
saveCharacterDebounced();
break;
case 'character_source':
const chidSourceData = characters[this_chid].data.extensions
switch(true) {
case Object.hasOwn(chidSourceData, 'chub') :
window.open('https://chub.ai/characters/' + chidSourceData.chub.full_path, '_blank');
break;
case Object.hasOwn(chidSourceData, 'janitorai') : // not implemented yet
window.open('https://janitorai.com/characters/' + chidSourceData.janitorai.full_path, '_blank');
break;
case Object.hasOwn(chidSourceData, 'pygmalion') : // not implemented yet
window.open('https://pygmalion.chat/character/' + chidSourceData.pygmalion.full_path, '_blank');
break;
default: toastr.info("This character doesn't seem to have a source.");
}
break;
/*case 'delete_button':
popup_type = "del_ch";
callPopup(`