mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
added <base> tag to HTML
added observer to wait for expressions before enabling drag
This commit is contained in:
@ -2,6 +2,7 @@
|
|||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
|
<base href="/">
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, viewport-fit=cover, initial-scale=1, maximum-scale=1.0, user-scalable=no">
|
<meta name="viewport" content="width=device-width, viewport-fit=cover, initial-scale=1, maximum-scale=1.0, user-scalable=no">
|
||||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||||
|
@ -60,11 +60,46 @@ const observer = new MutationObserver(function (mutations) {
|
|||||||
} else if (mutation.target.parentNode === SelectedCharacterTab) {
|
} else if (mutation.target.parentNode === SelectedCharacterTab) {
|
||||||
setTimeout(RA_CountCharTokens, 200);
|
setTimeout(RA_CountCharTokens, 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
observer.observe(document.documentElement, observerConfig);
|
observer.observe(document.documentElement, observerConfig);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wait for an element before resolving a promise
|
||||||
|
* @param {String} querySelector - Selector of element to wait for
|
||||||
|
* @param {Integer} timeout - Milliseconds to wait before timing out, or 0 for no timeout
|
||||||
|
*/
|
||||||
|
function waitForElement(querySelector, timeout) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
var timer = false;
|
||||||
|
if (document.querySelectorAll(querySelector).length) return resolve();
|
||||||
|
const observer = new MutationObserver(() => {
|
||||||
|
if (document.querySelectorAll(querySelector).length) {
|
||||||
|
observer.disconnect();
|
||||||
|
if (timer !== false) clearTimeout(timer);
|
||||||
|
return resolve();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
observer.observe(document.body, {
|
||||||
|
childList: true,
|
||||||
|
subtree: true
|
||||||
|
});
|
||||||
|
if (timeout) timer = setTimeout(() => {
|
||||||
|
observer.disconnect();
|
||||||
|
reject();
|
||||||
|
}, timeout);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
waitForElement("#expression-image", 10000).then(function () {
|
||||||
|
console.log("expression image loaded, now draggable.");
|
||||||
|
dragElement(document.getElementById("expression-holder"));
|
||||||
|
}).catch(() => {
|
||||||
|
console.log("expression holder not loaded yet");
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
//RossAscends: Added function to format dates used in files and chat timestamps to a humanized format.
|
//RossAscends: Added function to format dates used in files and chat timestamps to a humanized format.
|
||||||
//Mostly I wanted this to be for file names, but couldn't figure out exactly where the filename save code was as everything seemed to be connected.
|
//Mostly I wanted this to be for file names, but couldn't figure out exactly where the filename save code was as everything seemed to be connected.
|
||||||
@ -315,9 +350,7 @@ function OpenNavPanels() {
|
|||||||
dragElement(document.getElementById("sheld"));
|
dragElement(document.getElementById("sheld"));
|
||||||
dragElement(document.getElementById("left-nav-panel"));
|
dragElement(document.getElementById("left-nav-panel"));
|
||||||
dragElement(document.getElementById("right-nav-panel"));
|
dragElement(document.getElementById("right-nav-panel"));
|
||||||
setTimeout(function () {
|
|
||||||
dragElement(document.getElementById("expression-holder"))
|
|
||||||
}, 2000);
|
|
||||||
|
|
||||||
|
|
||||||
function dragElement(elmnt) {
|
function dragElement(elmnt) {
|
||||||
@ -460,6 +493,7 @@ function dragElement(elmnt) {
|
|||||||
// ---------------------------------------------------
|
// ---------------------------------------------------
|
||||||
|
|
||||||
$("document").ready(function () {
|
$("document").ready(function () {
|
||||||
|
|
||||||
// initial status check
|
// initial status check
|
||||||
setTimeout(RA_checkOnlineStatus, 100);
|
setTimeout(RA_checkOnlineStatus, 100);
|
||||||
|
|
||||||
|
@ -297,7 +297,7 @@ function onClickExpressionImage() {
|
|||||||
const html = `
|
const html = `
|
||||||
<div id="expression-holder" class="expression-holder">
|
<div id="expression-holder" class="expression-holder">
|
||||||
<div id="expression-holderheader" class="fa-solid fa-grip drag-grabber"></div>
|
<div id="expression-holderheader" class="fa-solid fa-grip drag-grabber"></div>
|
||||||
<img class="expression">
|
<img id="expression-image" class="expression">
|
||||||
</div>`;
|
</div>`;
|
||||||
$('body').append(html);
|
$('body').append(html);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user