initial commit, functional, needs proofing

034a5a48c25b934398149503e0a69f63e2655669

RossAscends <124905043+RossAscends@users.noreply.github.com>

3 files changed, +75 -8Showing whitespace changes
public/index.html+5 -1
@@ -4011,6 +4011,10 @@
4011 <input id="compact_input_area" type="checkbox" />4011 <input id="compact_input_area" type="checkbox" />
4012 <small data-i18n="Compact Input Area (Mobile)">Compact Input Area</small><i class="fa-solid fa-mobile-screen-button"></i>4012 <small data-i18n="Compact Input Area (Mobile)">Compact Input Area</small><i class="fa-solid fa-mobile-screen-button"></i>
4013 </label>4013 </label>
4014 <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.">
4015 <input id="show_swipe_num_all_messages" type="checkbox" />
4016 <small data-i18n="Swipe # for All Messages">Swipe # for All Messages</small><i class="fa-solid fa-mobile-screen-button"></i>
4017 </label>
4014 <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">4018 <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">
4015 <input id="hotswapEnabled" type="checkbox" />4019 <input id="hotswapEnabled" type="checkbox" />
4016 <small data-i18n="Characters Hotswap">Characters Hotswap</small>4020 <small data-i18n="Characters Hotswap">Characters Hotswap</small>
@@ -5939,7 +5943,7 @@
5939 </div>5943 </div>
5940 <div class="mes_bias"></div>5944 <div class="mes_bias"></div>
5941 </div>5945 </div>
5942 <div class="swipe_right fa-solid fa-chevron-right" style="display: none;">5946 <div class="swipe_right fa-solid" style="display: none;">
5943 <div class="swipes-counter"></div>5947 <div class="swipes-counter"></div>
5944 </div>5948 </div>
5945 </div>5949 </div>
public/script.js+25 -7
@@ -83,6 +83,7 @@ import {
83 resetMovableStyles,83 resetMovableStyles,
84 forceCharacterEditorTokenize,84 forceCharacterEditorTokenize,
85 applyPowerUserSettings,85 applyPowerUserSettings,
86 switchSwipeNumAllMessages,
86} from './scripts/power-user.js';87} from './scripts/power-user.js';
8788
88import {89import {
@@ -2368,9 +2369,20 @@ export function addOneMessage(mes, { type = 'normal', insertAfter = null, scroll
23682369
2369 addCopyToCodeBlocks(newMessage);2370 addCopyToCodeBlocks(newMessage);
23702371
2372 //const currentMessage = $('#chat').children().filter(`[mesid="${chat.length - 1}"]`);
2373
2374 // Set the swipes counter for past messages, only visible if 'Show Sipes on All Message' is enabled
2375 if (!params.isUser && newMessageId !== 0) {
2376 const swipesNum = chat[newMessageId].swipes?.length;
2377 const swipeId = chat[newMessageId].swipe_id + 1;
2378 newMessage.find('.swipes-counter').text(`${swipeId}\u200B/\u200b${swipesNum}`);
2379 }
2380
2381
2371 if (showSwipes) {2382 if (showSwipes) {
2372 $('#chat .mes').last().addClass('last_mes');2383 $('#chat .mes').last().addClass('last_mes');
2373 $('#chat .mes').eq(-2).removeClass('last_mes');2384 $('#chat .mes').eq(-2).removeClass('last_mes')
2385 .find('.swipe_right').removeClass('fa-chevron-right'); //otherwise it stays looking like it did when it was last_mes
2374 hideSwipeButtons();2386 hideSwipeButtons();
2375 showSwipeButtons();2387 showSwipeButtons();
2376 }2388 }
@@ -7489,19 +7501,25 @@ export function showSwipeButtons() {
7489 //console.log((chat[chat.length - 1]));7501 //console.log((chat[chat.length - 1]));
7490 if ((chat[chat.length - 1].swipes.length - swipeId) === 1) {7502 if ((chat[chat.length - 1].swipes.length - swipeId) === 1) {
7491 //console.log('highlighting R swipe');7503 //console.log('highlighting R swipe');
7492 currentMessage.children('.swipe_right').css('opacity', '0.7');7504
7505 //chevron was moved out of hardcode in HTML to class toggle dependent on last_mes or not
7506 //necessary for 'swipe_right' div in past messages to have no chevron if 'show swipes for all messages' is turned on
7507 currentMessage.children('.swipe_right').addClass('fa-chevron-right').css('opacity', '0.7');
7493 }7508 }
7494 //console.log(swipesCounterHTML);7509 //console.log(swipesCounterHTML);
74957510
7496 $('.swipes-counter').text(swipeCounterText);7511 //allows for writing individual swipe counters for past messages
7512 $('.last_mes .swipes-counter').text(swipeCounterText);
74977513
7498 //console.log(swipeId);7514 //console.log(swipeId);
7499 //console.log(chat[chat.length - 1].swipes.length);7515 //console.log(chat[chat.length - 1].swipes.length);
7516
7517 switchSwipeNumAllMessages();
7500}7518}
75017519
7502export function hideSwipeButtons() {7520export function hideSwipeButtons() {
7503 //console.log('hideswipebuttons entered');7521 //console.log('hideswipebuttons entered');
7504 $('#chat').find('.swipe_right').css('display', 'none');7522 $('#chat').find('.last_mes .swipe_right').css('display', 'none');
7505 $('#chat').find('.swipe_left').css('display', 'none');7523 $('#chat').find('.swipe_left').css('display', 'none');
7506}7524}
75077525
@@ -9395,9 +9413,9 @@ jQuery(async function () {
93959413
9396 ///// SWIPE BUTTON CLICKS ///////9414 ///// SWIPE BUTTON CLICKS ///////
93979415
9398 $(document).on('click', '.swipe_right', swipe_right);9416 //limit swiping to only last message clicks
93999417 $(document).on('click', '.last_mes .swipe_right', swipe_right);
9400 $(document).on('click', '.swipe_left', swipe_left);9418 $(document).on('click', '.last_mes .swipe_left', swipe_left);
94019419
9402 const debouncedCharacterSearch = debounce((searchQuery) => {9420 const debouncedCharacterSearch = debounce((searchQuery) => {
9403 entitiesFilter.setFilterData(FILTER_TYPES.SEARCH, searchQuery);9421 entitiesFilter.setFilterData(FILTER_TYPES.SEARCH, searchQuery);
public/scripts/power-user.js+45 -0
@@ -290,6 +290,7 @@ let power_user = {
290 restore_user_input: true,290 restore_user_input: true,
291 reduced_motion: false,291 reduced_motion: false,
292 compact_input_area: true,292 compact_input_area: true,
293 show_swipe_num_all_messages: false,
293 auto_connect: false,294 auto_connect: false,
294 auto_load_chat: false,295 auto_load_chat: false,
295 forbid_external_media: true,296 forbid_external_media: true,
@@ -469,6 +470,35 @@ function switchCompactInputArea() {
469 $('#compact_input_area').prop('checked', power_user.compact_input_area);470 $('#compact_input_area').prop('checked', power_user.compact_input_area);
470}471}
471472
473export function switchSwipeNumAllMessages() {
474 console.error('switching branch button initialted, function start!');
475 $('#show_swipe_num_all_messages').prop('checked', power_user.show_swipe_num_all_messages);
476
477 if (power_user.show_swipe_num_all_messages) {
478
479 $('.mes').each(function () {
480 //if the div also has the .lst_mes class, skip the loop for that item
481 if ($(this).hasClass('last_mes')) {
482 return;
483 }
484 //add the cloned button to every .mes .swipe_right EXCLUDING .mes.last_mes
485 $(this).find('.swipe_right').css('display', 'flex');
486 });
487
488 } else if (!power_user.show_swipe_num_all_messages) {
489 $('.mes:not(.last_mes)').each(function () {
490 if ($(this).hasClass('last_mes')) {
491 return;
492 }
493 //add the cloned button back to its original spot
494 $(this).find('.swipe_right').css('display', 'none');
495 });
496
497 }
498
499
500}
501
472var originalSliderValues = [];502var originalSliderValues = [];
473503
474async function switchLabMode() {504async function switchLabMode() {
@@ -1283,6 +1313,13 @@ function applyTheme(name) {
1283 switchCompactInputArea();1313 switchCompactInputArea();
1284 },1314 },
1285 },1315 },
1316 {
1317 key: 'show_swipe_num_all_messages',
1318 action: () => {
1319 $('#show_swipe_num_all_messages').prop('checked', power_user.show_swipe_num_all_messages);
1320 switchSwipeNumAllMessages();
1321 },
1322 },
1286 ];1323 ];
12871324
1288 for (const { key, selector, type, action } of themeProperties) {1325 for (const { key, selector, type, action } of themeProperties) {
@@ -1352,6 +1389,7 @@ function applyPowerUserSettings() {
1352 switchHideChatAvatars();1389 switchHideChatAvatars();
1353 switchTokenCount();1390 switchTokenCount();
1354 switchMessageActions();1391 switchMessageActions();
1392 switchSwipeNumAllMessages();
1355}1393}
13561394
1357function getExampleMessagesBehavior() {1395function getExampleMessagesBehavior() {
@@ -2296,6 +2334,7 @@ function getThemeObject(name) {
2296 zoomed_avatar_magnification: power_user.zoomed_avatar_magnification,2334 zoomed_avatar_magnification: power_user.zoomed_avatar_magnification,
2297 reduced_motion: power_user.reduced_motion,2335 reduced_motion: power_user.reduced_motion,
2298 compact_input_area: power_user.compact_input_area,2336 compact_input_area: power_user.compact_input_area,
2337 show_swipe_num_all_messages: power_user.show_swipe_num_all_messages,
2299 };2338 };
2300}2339}
23012340
@@ -3755,6 +3794,12 @@ $(document).ready(() => {
3755 saveSettingsDebounced();3794 saveSettingsDebounced();
3756 });3795 });
37573796
3797 $('#show_swipe_num_all_messages').on('input', function () {
3798 power_user.show_swipe_num_all_messages = !!$(this).prop('checked');
3799 switchSwipeNumAllMessages();
3800 saveSettingsDebounced();
3801 });
3802
3758 $('#auto-connect-checkbox').on('input', function () {3803 $('#auto-connect-checkbox').on('input', function () {
3759 power_user.auto_connect = !!$(this).prop('checked');3804 power_user.auto_connect = !!$(this).prop('checked');
3760 saveSettingsDebounced();3805 saveSettingsDebounced();