I am building a website which makes HTTP request that takes about 3 minutes to run. I want to make an animated progress bar in Bootstrap 5. Progress bar should appear on page and run for exactly 3 minutes, independently from any requests. It should show estimated time left. And some "informal" step that server is doing. For example for first 10 seconds it should show: "Warming up servers". Next 15 seconds, "Establishing secure connection", Next "Preparing the input", "Running Prediction Model", etc until it reaches 3 minutes and progress bar disappears
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
To create an animated progress bar in Bootstrap 5 that runs for exactly 3 minutes and shows estimated time left and informal steps, you can follow these steps:
First, include the necessary Bootstrap 5 CSS and JavaScript files in your HTML file. You can use a CDN or download the files and include them locally. Here's an example using a CDN:
Add the JavaScript code to animate the progress bar and update the estimated time left and informal steps. Here's an example:
javascript
const progressBar = document.querySelector('.progress-bar');
const progressInfo = document.getElementById('progress-info');
const steps = [
{ time: 10, message: 'Warming up servers' },
{ time: 15, message: 'Establishing secure connection' },
{ time: 20, message: 'Preparing the input' },
{ time: 30, message: 'Running Prediction Model' },
// Add more steps here if needed
];
let currentStep = 0;
let timeElapsed = 0;
let intervalId;
function updateProgress() {
timeElapsed += 1;
const percentage = (timeElapsed / 180) * 100;
progressBar.style.width = `${percentage}%`;
progressBar.setAttribute('aria-valuenow', percentage);
if (timeElapsed === steps[currentStep].time) {
progressInfo.textContent = steps[currentStep].message;
currentStep += 1;
}
if (timeElapsed === 180) {
clearInterval(intervalId);
progressInfo.textContent = 'Done!';
}
}
intervalId = setInterval(updateProgress, 1000);
This code sets up an interval that updates the progress bar and the estimated time left and informal steps every second for 3 minutes (180 seconds). You can customize the steps array to add more steps or change the timing and messages as needed.