rivia 0.0.9 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +108 -89
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -84,7 +84,7 @@ function Onboarding(topTitle = "Get Started", subtitle, completion = 0, checklis
|
|
|
84
84
|
const backendUrl2 = `http://localhost:5000/clients/${checklist_id}/${user_var12}`;
|
|
85
85
|
try {
|
|
86
86
|
const res = await fetch(backendUrl2, { credentials: "include" });
|
|
87
|
-
if (!res.ok)
|
|
87
|
+
if (!res.ok) console.warn(`GET failed: ${res.status}`);
|
|
88
88
|
const data2 = await res.json();
|
|
89
89
|
let userData = data2[user_var12];
|
|
90
90
|
if (Array.isArray(userData)) {
|
|
@@ -122,7 +122,7 @@ function Onboarding(topTitle = "Get Started", subtitle, completion = 0, checklis
|
|
|
122
122
|
const backendUrl2 = `http://localhost:5000/clients/${checklist_id}/${user_var12}`;
|
|
123
123
|
try {
|
|
124
124
|
const res = await fetch(backendUrl2, { credentials: "include" });
|
|
125
|
-
if (!res.ok)
|
|
125
|
+
if (!res.ok) console.warn(`GET failed: ${res.status}`);
|
|
126
126
|
const data2 = await res.json();
|
|
127
127
|
let userData = data2[user_var12];
|
|
128
128
|
if (Array.isArray(userData)) {
|
|
@@ -577,7 +577,7 @@ async function fetchWithTimeout(topTitle = "Get Started", subtitle, completion =
|
|
|
577
577
|
try {
|
|
578
578
|
data = JSON.parse(event.data);
|
|
579
579
|
} catch (err) {
|
|
580
|
-
console.
|
|
580
|
+
console.warn("Invalid SSE JSON:", event.data, err);
|
|
581
581
|
return;
|
|
582
582
|
}
|
|
583
583
|
if (data.ping) {
|
|
@@ -735,7 +735,7 @@ async function fetchWithTimeout(topTitle = "Get Started", subtitle, completion =
|
|
|
735
735
|
try {
|
|
736
736
|
data = JSON.parse(event.data);
|
|
737
737
|
} catch (err) {
|
|
738
|
-
console.
|
|
738
|
+
console.warn("Invalid SSE JSON:", event.data, err);
|
|
739
739
|
return;
|
|
740
740
|
}
|
|
741
741
|
if (data.ping) {
|
|
@@ -762,7 +762,7 @@ async function fetchWithTimeout(topTitle = "Get Started", subtitle, completion =
|
|
|
762
762
|
});
|
|
763
763
|
console.log("ACK sent for", eventId);
|
|
764
764
|
} catch (err) {
|
|
765
|
-
console.
|
|
765
|
+
console.warn("Failed to ACK", eventId, err);
|
|
766
766
|
}
|
|
767
767
|
try {
|
|
768
768
|
const stepEl = label ? label.querySelector(`#${it.id}`) : null;
|
|
@@ -821,12 +821,12 @@ async function fetchWithTimeout(topTitle = "Get Started", subtitle, completion =
|
|
|
821
821
|
body: JSON.stringify(payload),
|
|
822
822
|
keepalive: true
|
|
823
823
|
}).then((res) => {
|
|
824
|
-
if (!res.ok)
|
|
824
|
+
if (!res.ok) console.warn(`Upload failed: ${res.status}`);
|
|
825
825
|
}).catch((err) => {
|
|
826
|
-
console.
|
|
826
|
+
console.warn("\u26A0\uFE0F Background PUT upload failed:", err);
|
|
827
827
|
});
|
|
828
828
|
} catch (err) {
|
|
829
|
-
console.
|
|
829
|
+
console.warn("\u274C Error preparing background upload:", err);
|
|
830
830
|
}
|
|
831
831
|
}
|
|
832
832
|
if (check == 0) uploadVisitedPagesInBackground(storedVisited, false);
|
|
@@ -842,7 +842,7 @@ async function fetchWithTimeout(topTitle = "Get Started", subtitle, completion =
|
|
|
842
842
|
const backendUrl2 = `http://localhost:5000/clients/${checklist_id}/${user_var}`;
|
|
843
843
|
try {
|
|
844
844
|
const res = await fetch(backendUrl2, { credentials: "include" });
|
|
845
|
-
if (!res.ok)
|
|
845
|
+
if (!res.ok) console.warn(`GET failed: ${res.status}`);
|
|
846
846
|
const data2 = await res.json();
|
|
847
847
|
let userData = data2[user_var1];
|
|
848
848
|
if (Array.isArray(userData)) {
|
|
@@ -941,7 +941,7 @@ async function fetchWithTimeout(topTitle = "Get Started", subtitle, completion =
|
|
|
941
941
|
try {
|
|
942
942
|
completed2 = JSON.parse(completed2);
|
|
943
943
|
} catch (e) {
|
|
944
|
-
console.
|
|
944
|
+
console.warn("Failed to parse onboardingVisited:", e);
|
|
945
945
|
completed2 = [];
|
|
946
946
|
}
|
|
947
947
|
} else {
|
|
@@ -1175,9 +1175,9 @@ async function Checklist(checklist_id, user_var) {
|
|
|
1175
1175
|
);
|
|
1176
1176
|
if (!res.ok) {
|
|
1177
1177
|
if (res.status === 404) {
|
|
1178
|
-
|
|
1178
|
+
console.warn("Invalid checklist id");
|
|
1179
1179
|
}
|
|
1180
|
-
console.
|
|
1180
|
+
console.warn("\u274C Failed to fetch checklist");
|
|
1181
1181
|
return;
|
|
1182
1182
|
}
|
|
1183
1183
|
const data = await res.json();
|
|
@@ -1263,11 +1263,11 @@ var RIVIA_TOUR = function() {
|
|
|
1263
1263
|
}, 500);
|
|
1264
1264
|
}
|
|
1265
1265
|
} catch (error) {
|
|
1266
|
-
console.
|
|
1266
|
+
console.warn("Error restoring tour state:", error);
|
|
1267
1267
|
window.sessionStorage.removeItem("rivia_tour_state");
|
|
1268
1268
|
}
|
|
1269
1269
|
}
|
|
1270
|
-
function createTooltip({
|
|
1270
|
+
async function createTooltip({
|
|
1271
1271
|
id,
|
|
1272
1272
|
selector,
|
|
1273
1273
|
title,
|
|
@@ -1282,7 +1282,7 @@ var RIVIA_TOUR = function() {
|
|
|
1282
1282
|
card_next_button = true,
|
|
1283
1283
|
card_skip_button = false
|
|
1284
1284
|
}) {
|
|
1285
|
-
const anchor = findBySelector(selector);
|
|
1285
|
+
const anchor = await findBySelector(selector);
|
|
1286
1286
|
if (!anchor) return null;
|
|
1287
1287
|
const tip = document.createElement("div");
|
|
1288
1288
|
tip.dataset.riviaTipId = id;
|
|
@@ -1485,7 +1485,7 @@ var RIVIA_TOUR = function() {
|
|
|
1485
1485
|
keepalive: true
|
|
1486
1486
|
}).then((res) => {
|
|
1487
1487
|
if (res.status === 404) {
|
|
1488
|
-
|
|
1488
|
+
console.warn("Invalid tour id");
|
|
1489
1489
|
}
|
|
1490
1490
|
}).catch((err) => {
|
|
1491
1491
|
});
|
|
@@ -1502,14 +1502,14 @@ var RIVIA_TOUR = function() {
|
|
|
1502
1502
|
STATE.tour_id = tourId;
|
|
1503
1503
|
console.log("Loading tips for tour ID:", tourId, "and user_var:", user_var12);
|
|
1504
1504
|
try {
|
|
1505
|
-
if (!tourId)
|
|
1505
|
+
if (!tourId) console.warn("Tour ID is required");
|
|
1506
1506
|
const res = await fetch(`http://localhost:5000/tours2/${tourId}`, {
|
|
1507
1507
|
method: "GET",
|
|
1508
1508
|
headers: { "Content-Type": "application/json" }
|
|
1509
1509
|
});
|
|
1510
1510
|
if (!res.ok) {
|
|
1511
1511
|
if (res.status === 404) {
|
|
1512
|
-
|
|
1512
|
+
console.warn("Invalid tour id");
|
|
1513
1513
|
}
|
|
1514
1514
|
}
|
|
1515
1515
|
const data = await res.json();
|
|
@@ -1537,12 +1537,12 @@ var RIVIA_TOUR = function() {
|
|
|
1537
1537
|
console.log(`Loaded tips for tour ${tourId}:`, STATE.tips);
|
|
1538
1538
|
return STATE.tips;
|
|
1539
1539
|
} catch (err) {
|
|
1540
|
-
console.
|
|
1540
|
+
console.warn("Invalid tour id ", err);
|
|
1541
1541
|
STATE.tips = [];
|
|
1542
1542
|
return STATE.tips;
|
|
1543
1543
|
}
|
|
1544
1544
|
}
|
|
1545
|
-
function showStep(i, isPreview = false) {
|
|
1545
|
+
async function showStep(i, isPreview = false) {
|
|
1546
1546
|
uploadVisitedPagesInBackground(STATE.tour_id, user_var12, i);
|
|
1547
1547
|
console.log("Showing step", i, "of", STATE.tips.length);
|
|
1548
1548
|
document.querySelectorAll("[data-rivia-tip-id]").forEach((n) => n.remove());
|
|
@@ -1578,7 +1578,7 @@ var RIVIA_TOUR = function() {
|
|
|
1578
1578
|
if (step.card_type === "video_explainer") {
|
|
1579
1579
|
if (isPreview) {
|
|
1580
1580
|
console.log("Preview mode: Showing video explainer for step:", step.id);
|
|
1581
|
-
const targetElement = findBySelector(step.selector);
|
|
1581
|
+
const targetElement = await findBySelector(step.selector);
|
|
1582
1582
|
if (targetElement) {
|
|
1583
1583
|
try {
|
|
1584
1584
|
targetElement.scrollIntoView({ behavior: "smooth", block: "center", inline: "nearest" });
|
|
@@ -1606,7 +1606,7 @@ var RIVIA_TOUR = function() {
|
|
|
1606
1606
|
console.log("Edit mode: Showing video explainer for step:", step.id);
|
|
1607
1607
|
console.log("Step selector:", step.selector);
|
|
1608
1608
|
if (step.selector) {
|
|
1609
|
-
const targetElement = findBySelector(step.selector);
|
|
1609
|
+
const targetElement = await findBySelector(step.selector);
|
|
1610
1610
|
console.log("Found target element:", targetElement, "for selector:", step.selector);
|
|
1611
1611
|
if (targetElement) {
|
|
1612
1612
|
console.log("Element found, scrolling into view...");
|
|
@@ -1653,7 +1653,7 @@ var RIVIA_TOUR = function() {
|
|
|
1653
1653
|
return;
|
|
1654
1654
|
}
|
|
1655
1655
|
if (isPreview) {
|
|
1656
|
-
const el = findBySelector(step.selector);
|
|
1656
|
+
const el = await findBySelector(step.selector);
|
|
1657
1657
|
if (el) {
|
|
1658
1658
|
try {
|
|
1659
1659
|
el.scrollIntoView({ behavior: "smooth", block: "center", inline: "nearest" });
|
|
@@ -1696,7 +1696,7 @@ var RIVIA_TOUR = function() {
|
|
|
1696
1696
|
return;
|
|
1697
1697
|
}
|
|
1698
1698
|
if (!isPreview && step.selector && !step.card_type) {
|
|
1699
|
-
const el = findBySelector(step.selector);
|
|
1699
|
+
const el = await findBySelector(step.selector);
|
|
1700
1700
|
if (el) {
|
|
1701
1701
|
try {
|
|
1702
1702
|
el.scrollIntoView({ behavior: "smooth", block: "center", inline: "nearest" });
|
|
@@ -1752,9 +1752,9 @@ var RIVIA_TOUR = function() {
|
|
|
1752
1752
|
}
|
|
1753
1753
|
}, 100);
|
|
1754
1754
|
}
|
|
1755
|
-
function createVideoUI(step) {
|
|
1755
|
+
async function createVideoUI(step) {
|
|
1756
1756
|
console.log("Creating video UI for step:", step);
|
|
1757
|
-
const anchor = findBySelector(step.selector);
|
|
1757
|
+
const anchor = await findBySelector(step.selector);
|
|
1758
1758
|
console.log("Found anchor:", anchor);
|
|
1759
1759
|
if (!anchor) {
|
|
1760
1760
|
console.warn("Anchor not found for selector:", step.selector);
|
|
@@ -1990,7 +1990,7 @@ var RIVIA_TOUR = function() {
|
|
|
1990
1990
|
}, 0);
|
|
1991
1991
|
return videoContainer;
|
|
1992
1992
|
}
|
|
1993
|
-
function previewAnimation(selector, animationType) {
|
|
1993
|
+
async function previewAnimation(selector, animationType) {
|
|
1994
1994
|
try {
|
|
1995
1995
|
const element = document.querySelector(selector);
|
|
1996
1996
|
if (!element) {
|
|
@@ -2016,19 +2016,39 @@ var RIVIA_TOUR = function() {
|
|
|
2016
2016
|
}, 2e3);
|
|
2017
2017
|
}
|
|
2018
2018
|
} catch (err) {
|
|
2019
|
-
console.
|
|
2019
|
+
console.warn("Error previewing animation:", err);
|
|
2020
2020
|
}
|
|
2021
2021
|
}
|
|
2022
|
-
function findBySelector(selector) {
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2022
|
+
async function findBySelector(selector) {
|
|
2023
|
+
return new Promise((resolve) => {
|
|
2024
|
+
const maxRetries = 50;
|
|
2025
|
+
const retryInterval = 100;
|
|
2026
|
+
let attempts = 0;
|
|
2027
|
+
const checkElement = () => {
|
|
2028
|
+
try {
|
|
2029
|
+
const element = document.querySelector(selector);
|
|
2030
|
+
if (element) {
|
|
2031
|
+
resolve(element);
|
|
2032
|
+
return;
|
|
2033
|
+
}
|
|
2034
|
+
} catch (e) {
|
|
2035
|
+
console.warn("Invalid selector:", selector, e);
|
|
2036
|
+
resolve(null);
|
|
2037
|
+
return;
|
|
2038
|
+
}
|
|
2039
|
+
attempts++;
|
|
2040
|
+
if (attempts < maxRetries) {
|
|
2041
|
+
setTimeout(checkElement, retryInterval);
|
|
2042
|
+
} else {
|
|
2043
|
+
console.warn("Element not found after retries:", selector);
|
|
2044
|
+
resolve(null);
|
|
2045
|
+
}
|
|
2046
|
+
};
|
|
2047
|
+
checkElement();
|
|
2048
|
+
});
|
|
2029
2049
|
}
|
|
2030
|
-
function highlightElementBySelector(selector) {
|
|
2031
|
-
const el = findBySelector(selector);
|
|
2050
|
+
async function highlightElementBySelector(selector) {
|
|
2051
|
+
const el = await findBySelector(selector);
|
|
2032
2052
|
if (!el) return;
|
|
2033
2053
|
try {
|
|
2034
2054
|
el.scrollIntoView({
|
|
@@ -2051,7 +2071,7 @@ var RIVIA_TOUR = function() {
|
|
|
2051
2071
|
height: r.height + "px"
|
|
2052
2072
|
});
|
|
2053
2073
|
}
|
|
2054
|
-
function previewBackdrop(selector, backdropType) {
|
|
2074
|
+
async function previewBackdrop(selector, backdropType) {
|
|
2055
2075
|
try {
|
|
2056
2076
|
let backdropOverlay = document.getElementById("rivia-backdrop-overlay");
|
|
2057
2077
|
if (backdropOverlay) {
|
|
@@ -2060,7 +2080,7 @@ var RIVIA_TOUR = function() {
|
|
|
2060
2080
|
if (backdropType === "none") {
|
|
2061
2081
|
return;
|
|
2062
2082
|
}
|
|
2063
|
-
const targetElement = findBySelector(selector);
|
|
2083
|
+
const targetElement = await findBySelector(selector);
|
|
2064
2084
|
if (!targetElement) return;
|
|
2065
2085
|
const targetRect = targetElement.getBoundingClientRect();
|
|
2066
2086
|
const padding = 8;
|
|
@@ -2169,10 +2189,10 @@ var RIVIA_TOUR = function() {
|
|
|
2169
2189
|
window.addEventListener("resize", updateBackdrop);
|
|
2170
2190
|
svg.updateBackdrop = updateBackdrop;
|
|
2171
2191
|
} catch (err) {
|
|
2172
|
-
console.
|
|
2192
|
+
console.warn("Error previewing backdrop:", err);
|
|
2173
2193
|
}
|
|
2174
2194
|
}
|
|
2175
|
-
function showWelcomeCardPreview(step, stepIndex) {
|
|
2195
|
+
async function showWelcomeCardPreview(step, stepIndex) {
|
|
2176
2196
|
if (!step) {
|
|
2177
2197
|
console.warn("Step not found for preview");
|
|
2178
2198
|
return;
|
|
@@ -2345,7 +2365,7 @@ var RIVIA_TOUR = function() {
|
|
|
2345
2365
|
nextBtn.onmouseout = () => {
|
|
2346
2366
|
nextBtn.style.background = "#2563eb";
|
|
2347
2367
|
};
|
|
2348
|
-
nextBtn.onclick = () => {
|
|
2368
|
+
nextBtn.onclick = async () => {
|
|
2349
2369
|
const advanceAction = step.basic_advanceAction || "next button";
|
|
2350
2370
|
overlay2.remove();
|
|
2351
2371
|
const backdropOverlay = document.getElementById(
|
|
@@ -2363,7 +2383,7 @@ var RIVIA_TOUR = function() {
|
|
|
2363
2383
|
STATE.tourIndex = Math.min(STATE.tourIndex + 1, STATE.tips.length - 1);
|
|
2364
2384
|
if (STATE.tourIndex < STATE.tips.length) {
|
|
2365
2385
|
const nextStep2 = STATE.tips[STATE.tourIndex];
|
|
2366
|
-
const nextElement = findBySelector(nextStep2.selector);
|
|
2386
|
+
const nextElement = await findBySelector(nextStep2.selector);
|
|
2367
2387
|
if (nextElement) {
|
|
2368
2388
|
nextElement.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
2369
2389
|
setTimeout(() => showStep(STATE.tourIndex, true), 600);
|
|
@@ -2413,7 +2433,7 @@ var RIVIA_TOUR = function() {
|
|
|
2413
2433
|
step.basic_advanceAction
|
|
2414
2434
|
);
|
|
2415
2435
|
}
|
|
2416
|
-
function showModalDialogPreview(step, stepIndex) {
|
|
2436
|
+
async function showModalDialogPreview(step, stepIndex) {
|
|
2417
2437
|
const existingCenteredModal = document.getElementById(
|
|
2418
2438
|
"rivia-modal-dialog-preview-modal"
|
|
2419
2439
|
);
|
|
@@ -2546,7 +2566,7 @@ var RIVIA_TOUR = function() {
|
|
|
2546
2566
|
`;
|
|
2547
2567
|
nextBtn.onmouseover = () => nextBtn.style.background = "#1d4ed8";
|
|
2548
2568
|
nextBtn.onmouseout = () => nextBtn.style.background = "#2563eb";
|
|
2549
|
-
nextBtn.onclick = () => {
|
|
2569
|
+
nextBtn.onclick = async () => {
|
|
2550
2570
|
const advanceAction = step.basic_advanceAction || "next button";
|
|
2551
2571
|
centeredContainer.remove();
|
|
2552
2572
|
const backdropOverlay = document.getElementById(
|
|
@@ -2564,7 +2584,7 @@ var RIVIA_TOUR = function() {
|
|
|
2564
2584
|
STATE.tourIndex = Math.min(STATE.tourIndex + 1, STATE.tips.length - 1);
|
|
2565
2585
|
if (STATE.tourIndex < STATE.tips.length) {
|
|
2566
2586
|
const nextStepData = STATE.tips[STATE.tourIndex];
|
|
2567
|
-
const nextElement = findBySelector(nextStepData.selector);
|
|
2587
|
+
const nextElement = await findBySelector(nextStepData.selector);
|
|
2568
2588
|
if (nextElement) {
|
|
2569
2589
|
nextElement.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
2570
2590
|
setTimeout(() => showStep(STATE.tourIndex, true), 600);
|
|
@@ -2601,7 +2621,7 @@ var RIVIA_TOUR = function() {
|
|
|
2601
2621
|
step.basic_advanceAction
|
|
2602
2622
|
);
|
|
2603
2623
|
}
|
|
2604
|
-
function attachNavigationButtons(tip, i, isPreview) {
|
|
2624
|
+
async function attachNavigationButtons(tip, i, isPreview) {
|
|
2605
2625
|
const nav = document.createElement("div");
|
|
2606
2626
|
const navStyle = isPreview ? `
|
|
2607
2627
|
display: flex;
|
|
@@ -2652,7 +2672,7 @@ var RIVIA_TOUR = function() {
|
|
|
2652
2672
|
nav.appendChild(back);
|
|
2653
2673
|
}
|
|
2654
2674
|
if (advanceAction === "manual click") {
|
|
2655
|
-
const targetElement = findBySelector(step.selector);
|
|
2675
|
+
const targetElement = await findBySelector(step.selector);
|
|
2656
2676
|
if (targetElement) {
|
|
2657
2677
|
attachClickListenerToElement(targetElement);
|
|
2658
2678
|
}
|
|
@@ -2752,7 +2772,7 @@ var RIVIA_TOUR = function() {
|
|
|
2752
2772
|
tip.appendChild(stepIndicator);
|
|
2753
2773
|
}
|
|
2754
2774
|
}
|
|
2755
|
-
function cleanupAllOverlays() {
|
|
2775
|
+
async function cleanupAllOverlays() {
|
|
2756
2776
|
const welcomeBackdropOverlay = document.getElementById(
|
|
2757
2777
|
"rivia-welcome-backdrop-overlay"
|
|
2758
2778
|
);
|
|
@@ -2792,24 +2812,8 @@ var RIVIA_TOUR = function() {
|
|
|
2792
2812
|
svg.remove();
|
|
2793
2813
|
});
|
|
2794
2814
|
}
|
|
2795
|
-
function nextStep() {
|
|
2815
|
+
async function nextStep() {
|
|
2796
2816
|
if (STATE.tourIndex < STATE.tips.length - 1) {
|
|
2797
|
-
let getNextStepInfo3 = function(currentIndex2) {
|
|
2798
|
-
if (currentIndex2 >= STATE.tips.length - 1) {
|
|
2799
|
-
return { type: "end", index: currentIndex2 };
|
|
2800
|
-
}
|
|
2801
|
-
const nextStep2 = STATE.tips[currentIndex2 + 1];
|
|
2802
|
-
if (!nextStep2) return { type: "end", index: currentIndex2 };
|
|
2803
|
-
if (nextStep2.targetUrl && nextStep2.targetUrl.trim()) {
|
|
2804
|
-
console.log("WE reached navigation");
|
|
2805
|
-
return { type: "navigate", index: currentIndex2 + 1, url: nextStep2.targetUrl };
|
|
2806
|
-
}
|
|
2807
|
-
if (isStepAvailableOnCurrentPage(nextStep2)) {
|
|
2808
|
-
return { type: "show", index: currentIndex2 + 1 };
|
|
2809
|
-
}
|
|
2810
|
-
return getNextStepInfo3(currentIndex2 + 1);
|
|
2811
|
-
};
|
|
2812
|
-
var getNextStepInfo2 = getNextStepInfo3;
|
|
2813
2817
|
const currentIndex = STATE.tourIndex;
|
|
2814
2818
|
STATE.tourIndex++;
|
|
2815
2819
|
const nextStepData = STATE.tips[STATE.tourIndex];
|
|
@@ -2828,7 +2832,22 @@ var RIVIA_TOUR = function() {
|
|
|
2828
2832
|
window.location.href = navUrl;
|
|
2829
2833
|
return;
|
|
2830
2834
|
}
|
|
2831
|
-
|
|
2835
|
+
async function getNextStepInfo2(currentIndex2) {
|
|
2836
|
+
if (currentIndex2 >= STATE.tips.length - 1) {
|
|
2837
|
+
return { type: "end", index: currentIndex2 };
|
|
2838
|
+
}
|
|
2839
|
+
const nextStep2 = STATE.tips[currentIndex2 + 1];
|
|
2840
|
+
if (!nextStep2) return { type: "end", index: currentIndex2 };
|
|
2841
|
+
if (nextStep2.targetUrl && nextStep2.targetUrl.trim()) {
|
|
2842
|
+
console.log("WE reached navigation");
|
|
2843
|
+
return { type: "navigate", index: currentIndex2 + 1, url: nextStep2.targetUrl };
|
|
2844
|
+
}
|
|
2845
|
+
if (isStepAvailableOnCurrentPage(nextStep2)) {
|
|
2846
|
+
return { type: "show", index: currentIndex2 + 1 };
|
|
2847
|
+
}
|
|
2848
|
+
return getNextStepInfo2(currentIndex2 + 1);
|
|
2849
|
+
}
|
|
2850
|
+
const nextStepInfo = getNextStepInfo2(currentIndex);
|
|
2832
2851
|
if (nextStepInfo.type === "navigate") {
|
|
2833
2852
|
sessionStorage.setItem("rivia_tour_state", JSON.stringify({
|
|
2834
2853
|
tourIndex: nextStepInfo.index,
|
|
@@ -2850,7 +2869,7 @@ var RIVIA_TOUR = function() {
|
|
|
2850
2869
|
endTour();
|
|
2851
2870
|
}
|
|
2852
2871
|
}
|
|
2853
|
-
function getNextStepInfo(currentIndex) {
|
|
2872
|
+
async function getNextStepInfo(currentIndex) {
|
|
2854
2873
|
if (currentIndex >= STATE.tips.length - 1) {
|
|
2855
2874
|
return { type: "end", index: currentIndex };
|
|
2856
2875
|
}
|
|
@@ -2864,12 +2883,12 @@ var RIVIA_TOUR = function() {
|
|
|
2864
2883
|
}
|
|
2865
2884
|
return getNextStepInfo(currentIndex + 1);
|
|
2866
2885
|
}
|
|
2867
|
-
function isStepAvailableOnCurrentPage(step) {
|
|
2886
|
+
async function isStepAvailableOnCurrentPage(step) {
|
|
2868
2887
|
if (!step) return false;
|
|
2869
2888
|
if (!step.targetUrl || !step.targetUrl.trim()) return true;
|
|
2870
2889
|
return urlMatches(step.targetUrl);
|
|
2871
2890
|
}
|
|
2872
|
-
function urlMatches(pattern, currentUrl = window.location.href) {
|
|
2891
|
+
async function urlMatches(pattern, currentUrl = window.location.href) {
|
|
2873
2892
|
if (!pattern || !pattern.trim()) return true;
|
|
2874
2893
|
const cleanPattern = pattern.trim();
|
|
2875
2894
|
const cleanUrl = currentUrl.trim();
|
|
@@ -2900,7 +2919,7 @@ var RIVIA_TOUR = function() {
|
|
|
2900
2919
|
}
|
|
2901
2920
|
return cleanUrl.includes(cleanPattern);
|
|
2902
2921
|
}
|
|
2903
|
-
function addTourParamsToUrl(url, tourId) {
|
|
2922
|
+
async function addTourParamsToUrl(url, tourId) {
|
|
2904
2923
|
if (!url || !tourId) return url;
|
|
2905
2924
|
try {
|
|
2906
2925
|
const urlObj = new URL(url);
|
|
@@ -2910,7 +2929,7 @@ var RIVIA_TOUR = function() {
|
|
|
2910
2929
|
return url;
|
|
2911
2930
|
}
|
|
2912
2931
|
}
|
|
2913
|
-
function getPreviousStepInfo(currentIndex) {
|
|
2932
|
+
async function getPreviousStepInfo(currentIndex) {
|
|
2914
2933
|
if (currentIndex <= 0) {
|
|
2915
2934
|
return { type: "start", index: 0 };
|
|
2916
2935
|
}
|
|
@@ -2924,7 +2943,7 @@ var RIVIA_TOUR = function() {
|
|
|
2924
2943
|
}
|
|
2925
2944
|
return getPreviousStepInfo(currentIndex - 1);
|
|
2926
2945
|
}
|
|
2927
|
-
function prevStep() {
|
|
2946
|
+
async function prevStep() {
|
|
2928
2947
|
if (STATE.tourIndex > 0) {
|
|
2929
2948
|
const prevInfo = getPreviousStepInfo(STATE.tourIndex);
|
|
2930
2949
|
if (prevInfo.type === "start") {
|
|
@@ -2953,7 +2972,7 @@ var RIVIA_TOUR = function() {
|
|
|
2953
2972
|
}
|
|
2954
2973
|
}
|
|
2955
2974
|
}
|
|
2956
|
-
function endTour() {
|
|
2975
|
+
async function endTour() {
|
|
2957
2976
|
console.log("Ending tour and cleaning up UI elements...");
|
|
2958
2977
|
document.querySelectorAll("[data-rivia-tip-id]").forEach((n) => n.remove());
|
|
2959
2978
|
STATE.tourIndex = 0;
|
|
@@ -2972,10 +2991,10 @@ var RIVIA_TOUR = function() {
|
|
|
2972
2991
|
keepalive: true
|
|
2973
2992
|
// allow sending even during unload
|
|
2974
2993
|
}).catch((err) => {
|
|
2975
|
-
console.
|
|
2994
|
+
console.warn("Failed to end tour:", err);
|
|
2976
2995
|
});
|
|
2977
2996
|
}
|
|
2978
|
-
function updateUrlStatus() {
|
|
2997
|
+
async function updateUrlStatus() {
|
|
2979
2998
|
const urlStatus = document.getElementById("rivia-url-status");
|
|
2980
2999
|
if (!urlStatus) return;
|
|
2981
3000
|
const currentStep = STATE.tips[STATE.tourIndex];
|
|
@@ -2996,7 +3015,7 @@ var RIVIA_TOUR = function() {
|
|
|
2996
3015
|
urlStatus.title = stepUrlInfo.displayText;
|
|
2997
3016
|
}
|
|
2998
3017
|
}
|
|
2999
|
-
function playTour() {
|
|
3018
|
+
async function playTour() {
|
|
3000
3019
|
if (STATE.is_completed)
|
|
3001
3020
|
return;
|
|
3002
3021
|
if (!STATE.tips.length) {
|
|
@@ -3050,7 +3069,7 @@ var RIVIA_TOUR = function() {
|
|
|
3050
3069
|
}
|
|
3051
3070
|
showStep(STATE.tourIndex, true);
|
|
3052
3071
|
}
|
|
3053
|
-
function cleanUrlForStorage(url) {
|
|
3072
|
+
async function cleanUrlForStorage(url) {
|
|
3054
3073
|
if (!url || !url.trim()) return url;
|
|
3055
3074
|
try {
|
|
3056
3075
|
const urlObj = new URL(url);
|
|
@@ -3062,7 +3081,7 @@ var RIVIA_TOUR = function() {
|
|
|
3062
3081
|
return url;
|
|
3063
3082
|
}
|
|
3064
3083
|
}
|
|
3065
|
-
function showFeedbackCardPreview(step, stepIndex) {
|
|
3084
|
+
async function showFeedbackCardPreview(step, stepIndex) {
|
|
3066
3085
|
if (!step) {
|
|
3067
3086
|
console.warn("Step not found for preview");
|
|
3068
3087
|
return;
|
|
@@ -3283,7 +3302,7 @@ var RIVIA_TOUR = function() {
|
|
|
3283
3302
|
nextBtn.onmouseout = () => {
|
|
3284
3303
|
nextBtn.style.background = "#2563eb";
|
|
3285
3304
|
};
|
|
3286
|
-
nextBtn.onclick = () => {
|
|
3305
|
+
nextBtn.onclick = async () => {
|
|
3287
3306
|
const advanceAction = step.basic_advanceAction || "next button";
|
|
3288
3307
|
overlay2.remove();
|
|
3289
3308
|
const backdropOverlay = document.getElementById(
|
|
@@ -3307,7 +3326,7 @@ var RIVIA_TOUR = function() {
|
|
|
3307
3326
|
STATE.tourIndex = Math.min(STATE.tourIndex + 1, STATE.tips.length - 1);
|
|
3308
3327
|
if (STATE.tourIndex < STATE.tips.length) {
|
|
3309
3328
|
const nextStep2 = STATE.tips[STATE.tourIndex];
|
|
3310
|
-
const nextElement = findBySelector(nextStep2.selector);
|
|
3329
|
+
const nextElement = await findBySelector(nextStep2.selector);
|
|
3311
3330
|
if (nextElement) {
|
|
3312
3331
|
nextElement.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
3313
3332
|
setTimeout(() => showStep(STATE.tourIndex, true), 600);
|
|
@@ -3359,7 +3378,7 @@ var RIVIA_TOUR = function() {
|
|
|
3359
3378
|
}
|
|
3360
3379
|
return { loadTips, playTour, endTour, STATE };
|
|
3361
3380
|
}();
|
|
3362
|
-
function tours(tourId, userId) {
|
|
3381
|
+
async function tours(tourId, userId) {
|
|
3363
3382
|
if (!sessionStorage.getItem("rivia_tour_state")) {
|
|
3364
3383
|
RIVIA_TOUR.loadTips(tourId, userId).then(() => {
|
|
3365
3384
|
try {
|
|
@@ -3391,14 +3410,14 @@ function injectBanner(banner = {}, opts = {}, userId, bannerId) {
|
|
|
3391
3410
|
keepalive: true
|
|
3392
3411
|
}).then((res) => {
|
|
3393
3412
|
if (res.status === 404) {
|
|
3394
|
-
|
|
3413
|
+
console.warn("Invalid banner id");
|
|
3395
3414
|
}
|
|
3396
|
-
|
|
3415
|
+
console.warn(`Upload failed: ${res.status}`);
|
|
3397
3416
|
}).catch((err) => {
|
|
3398
|
-
console.
|
|
3417
|
+
console.warn("\u26A0\uFE0F Background PUT upload failed:", err);
|
|
3399
3418
|
});
|
|
3400
3419
|
} catch (err) {
|
|
3401
|
-
console.
|
|
3420
|
+
console.warn("\u274C Error preparing background upload:", err);
|
|
3402
3421
|
}
|
|
3403
3422
|
};
|
|
3404
3423
|
var uploadVisitedPagesInBackground = uploadVisitedPagesInBackground2;
|
|
@@ -3581,7 +3600,7 @@ function injectBanner(banner = {}, opts = {}, userId, bannerId) {
|
|
|
3581
3600
|
remove: () => container.remove()
|
|
3582
3601
|
};
|
|
3583
3602
|
} catch (err) {
|
|
3584
|
-
console.
|
|
3603
|
+
console.warn("injectBanner error:", err);
|
|
3585
3604
|
}
|
|
3586
3605
|
}
|
|
3587
3606
|
async function Banner(bannerId, userId) {
|
|
@@ -3591,7 +3610,7 @@ async function Banner(bannerId, userId) {
|
|
|
3591
3610
|
const response = await fetch(`http://localhost:5000/banners2/${bannerId}`);
|
|
3592
3611
|
if (!response.ok) {
|
|
3593
3612
|
if (response.status === 404) {
|
|
3594
|
-
|
|
3613
|
+
console.warn("Invalid Banner id");
|
|
3595
3614
|
}
|
|
3596
3615
|
}
|
|
3597
3616
|
const data = await response.json();
|
|
@@ -3606,7 +3625,7 @@ async function Banner(bannerId, userId) {
|
|
|
3606
3625
|
console.log("Fetched banner:", bannerFromBackend);
|
|
3607
3626
|
return bannerFromBackend;
|
|
3608
3627
|
} catch (error) {
|
|
3609
|
-
console.
|
|
3628
|
+
console.warn("Invalid banner id:", error);
|
|
3610
3629
|
}
|
|
3611
3630
|
}
|
|
3612
3631
|
var banner_default = Banner;
|