mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 01:41:22 +01:00
AI Assistant widget (#1115)
* feat: add assistan widget * feat: remove gtm * feat: assistant - minify js, add option UI * feat: assistant - ability to toggle assistant * chore: update version to 1.102.00 * chore: resolve version conflict * chore: cleanup * chore: cleanup * feat: ai widget - improve style --------- Co-authored-by: Azgaar <azgaar.fmg@yandex.com>
This commit is contained in:
parent
97e504d2aa
commit
e25f231697
6 changed files with 64 additions and 9 deletions
28
main.js
28
main.js
|
|
@ -317,7 +317,8 @@ async function generateMapOnLoad() {
|
|||
applyLayersPreset(); // apply saved layers preset and reder layers
|
||||
drawLayers();
|
||||
fitMapToScreen();
|
||||
focusOn(); // focus on point, cell or burg from MFCG based on url searchParams
|
||||
focusOn(); // based on searchParams focus on point, cell or burg from MFCG
|
||||
toggleAssistant();
|
||||
}
|
||||
|
||||
// focus on coordinates, cell or burg provided in searchParams
|
||||
|
|
@ -367,6 +368,31 @@ function focusOn() {
|
|||
}
|
||||
}
|
||||
|
||||
let isAssistantLoaded = false;
|
||||
function toggleAssistant() {
|
||||
const assistantContainer = byId("chat-widget-container");
|
||||
const showAssistant = byId("azgaarAssistant").value === "show";
|
||||
|
||||
if (showAssistant) {
|
||||
if (isAssistantLoaded) {
|
||||
assistantContainer.style.display = "block";
|
||||
} else {
|
||||
import("./libs/openwidget.min.js").then(() => {
|
||||
isAssistantLoaded = true;
|
||||
setTimeout(() => {
|
||||
const bubble = byId("chat-widget-minimized");
|
||||
if (bubble) {
|
||||
bubble.dataset.tip = "Click to open the Assistant";
|
||||
bubble.on("mouseover", showDataTip);
|
||||
}
|
||||
}, 5000);
|
||||
});
|
||||
}
|
||||
} else if (isAssistantLoaded) {
|
||||
assistantContainer.style.display = "none";
|
||||
}
|
||||
}
|
||||
|
||||
// find burg for MFCG and focus on it
|
||||
function findBurgForMFCG(params) {
|
||||
const cells = pack.cells,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue