1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-03 09:49:28 +02:00

Add intro.js

This commit is contained in:
Daniel Neto 2024-05-13 10:48:47 -03:00
parent 1cfc673e42
commit abb433718e
71 changed files with 2775 additions and 2 deletions

View file

@ -4249,4 +4249,39 @@ function displayJsonAsHtml(jsonObjectOrString) {
});
return html;
}
function startTour(stepsFileRelativePath) {
let id = stepsFileRelativePath.replace(/[^a-zA-Z0-9]/g, '');
// Check if Intro.js is already loaded
if (typeof introJs === 'undefined') {
// Load Intro.js CSS
$('head').append('<link rel="stylesheet" href="' + webSiteRootURL + 'node_modules/intro.js/minified/introjs.min.css" type="text/css" />');
// Load Intro.js JavaScript
$.getScript(webSiteRootURL + 'node_modules/intro.js/minified/intro.min.js', function () {
loadAndStartTour(stepsFileRelativePath);
});
} else {
loadAndStartTour(stepsFileRelativePath);
}
function loadAndStartTour(stepsFileRelativePath) {
// Fetch the tour steps from a server
$.ajax({
url: webSiteRootURL + stepsFileRelativePath, // URL to the server-side script that returns JSON
type: 'GET',
dataType: 'json',
success: function (response) {
// Initialize the tour with the fetched data
var tour = introJs();
tour.setOptions({
steps: response
});
tour.start();
},
error: function (xhr, status, error) {
console.log("Error fetching tour data: " + error);
}
});
}
}