Merge with browser fixes from RossMods
| @@ -1,4 +1,4 @@ | ||
| 1 | 1 | import { humanizedDateTime, favsToHotswap, getMessageTimeStamp, dragElement, isMobile, initRossMods, shouldSendOnEnter, addSafariPatch } from './scripts/RossAscends-mods.js'; |
| 2 | 2 | import { userStatsHandler, statMesProcess, initStats } from './scripts/stats.js'; |
| 3 | 3 | import { |
| 4 | 4 | generateKoboldWithStreaming, |
| @@ -273,7 +273,6 @@ await new Promise((resolve) => { | ||
| 273 | 273 | }); |
| 274 | 274 | |
| 275 | 275 | showLoader(); |
| 276 | -applyBrowserFixes(); | |
| 277 | 276 | |
| 278 | 277 | // Configure toast library: |
| 279 | 278 | toastr.options.escapeHtml = true; // Prevent raw HTML inserts |
| @@ -940,7 +939,7 @@ async function firstLoadInit() { | ||
| 940 | 939 | throw new Error('Initialization failed'); |
| 941 | 940 | } |
| 942 | 941 | |
| 943 | 942 | addSafariPatchapplyBrowserFixes(); |
| 944 | 943 | await getClientVersion(); |
| 945 | 944 | await readSecretState(); |
| 946 | 945 | await initLocales(); |
| @@ -121,7 +121,7 @@ export function humanizeGenTime(total_gen_time) { | ||
| 121 | 121 | */ |
| 122 | 122 | var parsedUA = null; |
| 123 | 123 | |
| 124 | 124 | export function getParsedUA() { |
| 125 | 125 | if (!parsedUA) { |
| 126 | 126 | try { |
| 127 | 127 | parsedUA = Bowser.parse(navigator.userAgent); |
| @@ -717,18 +717,6 @@ export const autoFitSendTextAreaDebounced = debounce(autoFitSendTextArea, deboun | ||
| 717 | 717 | |
| 718 | 718 | // --------------------------------------------------- |
| 719 | 719 | |
| 720 | -export function addSafariPatch() { | |
| 721 | - const userAgent = getParsedUA(); | |
| 722 | - console.debug('User Agent', userAgent); | |
| 723 | - const isMobileSafari = /iPad|iPhone|iPod/.test(navigator.platform) || (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1); | |
| 724 | - const isDesktopSafari = userAgent?.browser?.name === 'Safari' && userAgent?.platform?.type === 'desktop'; | |
| 725 | - const isIOS = userAgent?.os?.name === 'iOS'; | |
| 726 | - | |
| 727 | - if (isIOS || isMobileSafari || isDesktopSafari) { | |
| 728 | - document.body.classList.add('safari'); | |
| 729 | - } | |
| 730 | -} | |
| 731 | - | |
| 732 | 720 | export function initRossMods() { |
| 733 | 721 | // initial status check |
| 734 | 722 | checkStatusDebounced(); |
| @@ -741,16 +729,6 @@ export function initRossMods() { | ||
| 741 | 729 | RA_autoconnect(); |
| 742 | 730 | } |
| 743 | 731 | |
| 744 | - if (isMobile()) { | |
| 745 | - const fixFunkyPositioning = () => { | |
| 746 | - console.debug('[Mobile] Device viewport change detected.'); | |
| 747 | - document.documentElement.style.position = 'fixed'; | |
| 748 | - requestAnimationFrame(() => document.documentElement.style.position = ''); | |
| 749 | - }; | |
| 750 | - window.addEventListener('resize', fixFunkyPositioning); | |
| 751 | - window.addEventListener('orientationchange', fixFunkyPositioning); | |
| 752 | - } | |
| 753 | - | |
| 754 | 732 | $('#main_api').change(function () { |
| 755 | 733 | var PrevAPI = main_api; |
| 756 | 734 | setTimeout(() => RA_autoconnect(PrevAPI), 100); |
| @@ -1,3 +1,5 @@ | ||
| 1 | +import { getParsedUA, isMobile } from './RossAscends-mods.js'; | |
| 2 | + | |
| 1 | 3 | const isFirefox = () => /firefox/i.test(navigator.userAgent); |
| 2 | 4 | |
| 3 | 5 | function sanitizeInlineQuotationOnCopy() { |
| @@ -43,10 +45,34 @@ function sanitizeInlineQuotationOnCopy() { | ||
| 43 | 45 | }); |
| 44 | 46 | } |
| 45 | 47 | |
| 48 | +function addSafariPatch() { | |
| 49 | + const userAgent = getParsedUA(); | |
| 50 | + console.debug('User Agent', userAgent); | |
| 51 | + const isMobileSafari = /iPad|iPhone|iPod/.test(navigator.platform) || (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1); | |
| 52 | + const isDesktopSafari = userAgent?.browser?.name === 'Safari' && userAgent?.platform?.type === 'desktop'; | |
| 53 | + const isIOS = userAgent?.os?.name === 'iOS'; | |
| 54 | + | |
| 55 | + if (isIOS || isMobileSafari || isDesktopSafari) { | |
| 56 | + document.body.classList.add('safari'); | |
| 57 | + } | |
| 58 | +} | |
| 59 | + | |
| 46 | 60 | function applyBrowserFixes() { |
| 47 | 61 | if (isFirefox()) { |
| 48 | 62 | sanitizeInlineQuotationOnCopy(); |
| 49 | 63 | } |
| 64 | + | |
| 65 | + if (isMobile()) { | |
| 66 | + const fixFunkyPositioning = () => { | |
| 67 | + console.debug('[Mobile] Device viewport change detected.'); | |
| 68 | + document.documentElement.style.position = 'fixed'; | |
| 69 | + requestAnimationFrame(() => document.documentElement.style.position = ''); | |
| 70 | + }; | |
| 71 | + window.addEventListener('resize', fixFunkyPositioning); | |
| 72 | + window.addEventListener('orientationchange', fixFunkyPositioning); | |
| 73 | + } | |
| 74 | + | |
| 75 | + addSafariPatch(); | |
| 50 | 76 | } |
| 51 | 77 | |
| 52 | 78 | export { isFirefox, applyBrowserFixes }; |