initial commit, functional, needs proofing

This commit is contained in:
RossAscends
2024-09-29 21:47:18 +09:00
parent 53424d4c8e
commit 034a5a48c2
3 changed files with 75 additions and 8 deletions

View File

@ -4011,6 +4011,10 @@
<input id="compact_input_area" type="checkbox" />
<small data-i18n="Compact Input Area (Mobile)">Compact Input Area</small><i class="fa-solid fa-mobile-screen-button"></i>
</label>
<label for="show_swipe_num_all_messages" class="checkbox_label" title="Display swipe numbers for all messages, not just the last." data-i18n="[title]Display swipe numbers for all messages, not just the last.">
<input id="show_swipe_num_all_messages" type="checkbox" />
<small data-i18n="Swipe # for All Messages">Swipe # for All Messages</small><i class="fa-solid fa-mobile-screen-button"></i>
</label>
<label for="hotswapEnabled" class="checkbox_label" title="In the Character Management panel, show quick selection buttons for favorited characters." data-i18n="[title]In the Character Management panel, show quick selection buttons for favorited characters">
<input id="hotswapEnabled" type="checkbox" />
<small data-i18n="Characters Hotswap">Characters Hotswap</small>
@ -5939,7 +5943,7 @@
</div>
<div class="mes_bias"></div>
</div>
<div class="swipe_right fa-solid fa-chevron-right" style="display: none;">
<div class="swipe_right fa-solid" style="display: none;">
<div class="swipes-counter"></div>
</div>
</div>

View File

@ -83,6 +83,7 @@ import {
resetMovableStyles,
forceCharacterEditorTokenize,
applyPowerUserSettings,
switchSwipeNumAllMessages,
} from './scripts/power-user.js';
import {
@ -2368,9 +2369,20 @@ export function addOneMessage(mes, { type = 'normal', insertAfter = null, scroll
addCopyToCodeBlocks(newMessage);
//const currentMessage = $('#chat').children().filter(`[mesid="${chat.length - 1}"]`);
// Set the swipes counter for past messages, only visible if 'Show Sipes on All Message' is enabled
if (!params.isUser && newMessageId !== 0) {
const swipesNum = chat[newMessageId].swipes?.length;
const swipeId = chat[newMessageId].swipe_id + 1;
newMessage.find('.swipes-counter').text(`${swipeId}\u200B/\u200b${swipesNum}`);
}
if (showSwipes) {
$('#chat .mes').last().addClass('last_mes');
$('#chat .mes').eq(-2).removeClass('last_mes');
$('#chat .mes').eq(-2).removeClass('last_mes')
.find('.swipe_right').removeClass('fa-chevron-right'); //otherwise it stays looking like it did when it was last_mes
hideSwipeButtons();
showSwipeButtons();
}
@ -7489,19 +7501,25 @@ export function showSwipeButtons() {
//console.log((chat[chat.length - 1]));
if ((chat[chat.length - 1].swipes.length - swipeId) === 1) {
//console.log('highlighting R swipe');
currentMessage.children('.swipe_right').css('opacity', '0.7');
//chevron was moved out of hardcode in HTML to class toggle dependent on last_mes or not
//necessary for 'swipe_right' div in past messages to have no chevron if 'show swipes for all messages' is turned on
currentMessage.children('.swipe_right').addClass('fa-chevron-right').css('opacity', '0.7');
}
//console.log(swipesCounterHTML);
$('.swipes-counter').text(swipeCounterText);
//allows for writing individual swipe counters for past messages
$('.last_mes .swipes-counter').text(swipeCounterText);
//console.log(swipeId);
//console.log(chat[chat.length - 1].swipes.length);
switchSwipeNumAllMessages();
}
export function hideSwipeButtons() {
//console.log('hideswipebuttons entered');
$('#chat').find('.swipe_right').css('display', 'none');
$('#chat').find('.last_mes .swipe_right').css('display', 'none');
$('#chat').find('.swipe_left').css('display', 'none');
}
@ -9395,9 +9413,9 @@ jQuery(async function () {
///// SWIPE BUTTON CLICKS ///////
$(document).on('click', '.swipe_right', swipe_right);
$(document).on('click', '.swipe_left', swipe_left);
//limit swiping to only last message clicks
$(document).on('click', '.last_mes .swipe_right', swipe_right);
$(document).on('click', '.last_mes .swipe_left', swipe_left);
const debouncedCharacterSearch = debounce((searchQuery) => {
entitiesFilter.setFilterData(FILTER_TYPES.SEARCH, searchQuery);

View File

@ -290,6 +290,7 @@ let power_user = {
restore_user_input: true,
reduced_motion: false,
compact_input_area: true,
show_swipe_num_all_messages: false,
auto_connect: false,
auto_load_chat: false,
forbid_external_media: true,
@ -469,6 +470,35 @@ function switchCompactInputArea() {
$('#compact_input_area').prop('checked', power_user.compact_input_area);
}
export function switchSwipeNumAllMessages() {
console.error('switching branch button initialted, function start!');
$('#show_swipe_num_all_messages').prop('checked', power_user.show_swipe_num_all_messages);
if (power_user.show_swipe_num_all_messages) {
$('.mes').each(function () {
//if the div also has the .lst_mes class, skip the loop for that item
if ($(this).hasClass('last_mes')) {
return;
}
//add the cloned button to every .mes .swipe_right EXCLUDING .mes.last_mes
$(this).find('.swipe_right').css('display', 'flex');
});
} else if (!power_user.show_swipe_num_all_messages) {
$('.mes:not(.last_mes)').each(function () {
if ($(this).hasClass('last_mes')) {
return;
}
//add the cloned button back to its original spot
$(this).find('.swipe_right').css('display', 'none');
});
}
}
var originalSliderValues = [];
async function switchLabMode() {
@ -1283,6 +1313,13 @@ function applyTheme(name) {
switchCompactInputArea();
},
},
{
key: 'show_swipe_num_all_messages',
action: () => {
$('#show_swipe_num_all_messages').prop('checked', power_user.show_swipe_num_all_messages);
switchSwipeNumAllMessages();
},
},
];
for (const { key, selector, type, action } of themeProperties) {
@ -1352,6 +1389,7 @@ function applyPowerUserSettings() {
switchHideChatAvatars();
switchTokenCount();
switchMessageActions();
switchSwipeNumAllMessages();
}
function getExampleMessagesBehavior() {
@ -2296,6 +2334,7 @@ function getThemeObject(name) {
zoomed_avatar_magnification: power_user.zoomed_avatar_magnification,
reduced_motion: power_user.reduced_motion,
compact_input_area: power_user.compact_input_area,
show_swipe_num_all_messages: power_user.show_swipe_num_all_messages,
};
}
@ -3755,6 +3794,12 @@ $(document).ready(() => {
saveSettingsDebounced();
});
$('#show_swipe_num_all_messages').on('input', function () {
power_user.show_swipe_num_all_messages = !!$(this).prop('checked');
switchSwipeNumAllMessages();
saveSettingsDebounced();
});
$('#auto-connect-checkbox').on('input', function () {
power_user.auto_connect = !!$(this).prop('checked');
saveSettingsDebounced();