initial commit, functional, needs proofing
| @@ -4011,6 +4011,10 @@ | ||
| 4011 | 4011 | <input id="compact_input_area" type="checkbox" /> |
| 4012 | 4012 | <small data-i18n="Compact Input Area (Mobile)">Compact Input Area</small><i class="fa-solid fa-mobile-screen-button"></i> |
| 4013 | 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 | 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 | 4019 | <input id="hotswapEnabled" type="checkbox" /> |
| 4016 | 4020 | <small data-i18n="Characters Hotswap">Characters Hotswap</small> |
| @@ -5939,7 +5943,7 @@ | ||
| 5939 | 5943 | </div> |
| 5940 | 5944 | <div class="mes_bias"></div> |
| 5941 | 5945 | </div> |
| 5942 | 5946 | <div class="swipe_right fa-solid fa-chevron-right" style="display: none;"> |
| 5943 | 5947 | <div class="swipes-counter"></div> |
| 5944 | 5948 | </div> |
| 5945 | 5949 | </div> |
| @@ -83,6 +83,7 @@ import { | ||
| 83 | 83 | resetMovableStyles, |
| 84 | 84 | forceCharacterEditorTokenize, |
| 85 | 85 | applyPowerUserSettings, |
| 86 | + switchSwipeNumAllMessages, | |
| 86 | 87 | } from './scripts/power-user.js'; |
| 87 | 88 | |
| 88 | 89 | import { |
| @@ -2368,9 +2369,20 @@ export function addOneMessage(mes, { type = 'normal', insertAfter = null, scroll | ||
| 2368 | 2369 | |
| 2369 | 2370 | addCopyToCodeBlocks(newMessage); |
| 2370 | 2371 | |
| 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 | 2382 | if (showSwipes) { |
| 2372 | 2383 | $('#chat .mes').last().addClass('last_mes'); |
| 2373 | 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 | 2386 | hideSwipeButtons(); |
| 2375 | 2387 | showSwipeButtons(); |
| 2376 | 2388 | } |
| @@ -7489,19 +7501,25 @@ export function showSwipeButtons() { | ||
| 7489 | 7501 | //console.log((chat[chat.length - 1])); |
| 7490 | 7502 | if ((chat[chat.length - 1].swipes.length - swipeId) === 1) { |
| 7491 | 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 | 7509 | //console.log(swipesCounterHTML); |
| 7495 | 7510 | |
| 7496 | - $('.swipes-counter').text(swipeCounterText); | |
| 7511 | + //allows for writing individual swipe counters for past messages | |
| 7512 | + $('.last_mes .swipes-counter').text(swipeCounterText); | |
| 7497 | 7513 | |
| 7498 | 7514 | //console.log(swipeId); |
| 7499 | 7515 | //console.log(chat[chat.length - 1].swipes.length); |
| 7516 | + | |
| 7517 | + switchSwipeNumAllMessages(); | |
| 7500 | 7518 | } |
| 7501 | 7519 | |
| 7502 | 7520 | export function hideSwipeButtons() { |
| 7503 | 7521 | //console.log('hideswipebuttons entered'); |
| 7504 | 7522 | $('#chat').find('.last_mes .swipe_right').css('display', 'none'); |
| 7505 | 7523 | $('#chat').find('.swipe_left').css('display', 'none'); |
| 7506 | 7524 | } |
| 7507 | 7525 | |
| @@ -9395,9 +9413,9 @@ jQuery(async function () { | ||
| 9395 | 9413 | |
| 9396 | 9414 | ///// SWIPE BUTTON CLICKS /////// |
| 9397 | 9415 | |
| 9398 | - $(document).on('click', '.swipe_right', swipe_right); | |
| 9416 | + //limit swiping to only last message clicks | |
| 9399 | - | |
| 9417 | + $(document).on('click', '.last_mes .swipe_right', swipe_right); | |
| 9400 | 9418 | $(document).on('click', '.last_mes .swipe_left', swipe_left); |
| 9401 | 9419 | |
| 9402 | 9420 | const debouncedCharacterSearch = debounce((searchQuery) => { |
| 9403 | 9421 | entitiesFilter.setFilterData(FILTER_TYPES.SEARCH, searchQuery); |
| @@ -290,6 +290,7 @@ let power_user = { | ||
| 290 | 290 | restore_user_input: true, |
| 291 | 291 | reduced_motion: false, |
| 292 | 292 | compact_input_area: true, |
| 293 | + show_swipe_num_all_messages: false, | |
| 293 | 294 | auto_connect: false, |
| 294 | 295 | auto_load_chat: false, |
| 295 | 296 | forbid_external_media: true, |
| @@ -469,6 +470,35 @@ function switchCompactInputArea() { | ||
| 469 | 470 | $('#compact_input_area').prop('checked', power_user.compact_input_area); |
| 470 | 471 | } |
| 471 | 472 | |
| 473 | +export 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 | + | |
| 472 | 502 | var originalSliderValues = []; |
| 473 | 503 | |
| 474 | 504 | async function switchLabMode() { |
| @@ -1283,6 +1313,13 @@ function applyTheme(name) { | ||
| 1283 | 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 | ]; |
| 1287 | 1324 | |
| 1288 | 1325 | for (const { key, selector, type, action } of themeProperties) { |
| @@ -1352,6 +1389,7 @@ function applyPowerUserSettings() { | ||
| 1352 | 1389 | switchHideChatAvatars(); |
| 1353 | 1390 | switchTokenCount(); |
| 1354 | 1391 | switchMessageActions(); |
| 1392 | + switchSwipeNumAllMessages(); | |
| 1355 | 1393 | } |
| 1356 | 1394 | |
| 1357 | 1395 | function getExampleMessagesBehavior() { |
| @@ -2296,6 +2334,7 @@ function getThemeObject(name) { | ||
| 2296 | 2334 | zoomed_avatar_magnification: power_user.zoomed_avatar_magnification, |
| 2297 | 2335 | reduced_motion: power_user.reduced_motion, |
| 2298 | 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 | } |
| 2301 | 2340 | |
| @@ -3755,6 +3794,12 @@ $(document).ready(() => { | ||
| 3755 | 3794 | saveSettingsDebounced(); |
| 3756 | 3795 | }); |
| 3757 | 3796 | |
| 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 | 3803 | $('#auto-connect-checkbox').on('input', function () { |
| 3759 | 3804 | power_user.auto_connect = !!$(this).prop('checked'); |
| 3760 | 3805 | saveSettingsDebounced(); |