Skip to content

Commit

Permalink
add multiple support flow support
Browse files Browse the repository at this point in the history
  • Loading branch information
spiceywasabi committed Feb 1, 2024
1 parent f8d18ad commit d9686f7
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 20 deletions.
2 changes: 1 addition & 1 deletion core/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ document.addEventListener("DOMContentLoaded", () => {
// to ensure people read things.
butWelcome.disabled=true;
butProgram.disabled = true;
buildReleaseSelectors();
//buildReleaseSelectors(); // DISABLE IN DEBUG
accordionDisable();
logMsg("Welcome to O.MG Web Serial Flasher. Ready...");

Expand Down
5 changes: 5 additions & 0 deletions core/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -239,4 +239,9 @@ button.fancy:hover::after {
.btn-mode-select {
padding: 1.75rem 1.5rem;
font-size: 1.25rem;
}

.wizard-button {
padding-left: 5px;
padding-right: 4px;
}
50 changes: 32 additions & 18 deletions core/wizard.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ function generateStepHTML(step) {

if (step.help_message) {
let buttonMoreHelp = document.createElement('button');
buttonMoreHelp.id = `btnWizard_${step.step}_help`;
buttonMoreHelp.classList.add('fancy', 'btn', 'btn-secondary', 'btn-lg');
buttonMoreHelp.id = `btn_wizard_${step.step}_help`;
buttonMoreHelp.classList.add('fancy', 'btn', 'btn-secondary', 'btn-lg', 'wizard-button');
buttonMoreHelp.type = 'button';
buttonMoreHelp.textContent = 'I Need More Help';
//buttonMoreHelp.disabled = true;
Expand All @@ -81,20 +81,32 @@ function generateStepHTML(step) {
handleExtraHelp(step);
});
}

var buttonNextStep = document.createElement('button');
buttonNextStep.id = `btnWizard_${step.next_step}`;
buttonNextStep.classList.add('fancy', 'btn', 'btn-success', 'btn-lg');
buttonNextStep.type = 'button';
buttonNextStep.textContent = 'Next';

buttonContainer.appendChild(buttonNextStep);

var nextStep;

// compat
if (typeof step.next_step === 'string') {
nextStep = [{'step':step.next_step,'label':"Next"}];
} else {
nextStep = step.next_step;
}
for (var i = 0; i < nextStep.length; i++) {
var step_path = nextStep[i].step;
var step_label = nextStep[i].label;
var buttonNextStep = document.createElement('button');
buttonNextStep.id = `btn_wizard_${step_path}`;
buttonNextStep.classList.add('fancy', 'btn', 'btn-success', 'btn-lg', 'wizard-button');
buttonNextStep.type = 'button';
buttonNextStep.textContent = `${step_label}`;
buttonContainer.appendChild(buttonNextStep);
}

stepContainer.appendChild(bodyElement);
stepContainer.appendChild(buttonContainer);

buttonNextStep.addEventListener('click', () => {
handleNextWizardStep(step);
buttonNextStep.addEventListener('click', (e) => {
let next_step = e.target.id.replace("btn_wizard_","")
handleNextWizardStep(step,next_step);
});
//console.log(buttonNextStep);
//console.log(stepContainer)
Expand All @@ -110,20 +122,20 @@ function renderWizard(steps){
});
}

function handleExtraHelp(step){
function handleExtraHelp(step,clicked_step){
let curr_step = `wizard_${step.step}`
let next_step = `wizard_${step.next_step}`
let next_step = `wizard_${clicked_step}`
if(doesElementExist(curr_step)){
// do nothing right now
logMsg(`User has requested extra help for step ${curr_step}`)
}
}

function handleNextWizardStep(step){
function handleNextWizardStep(step,clicked_step){
let curr_step = `wizard_${step.step}`
let next_step = `wizard_${step.next_step}`
let next_step = `wizard_${clicked_step}`

logMsg(`User progressing from '${curr_step}' to ${next_step}.`)
logMsg(`User progressing from '${curr_step}' to ${clicked_step} (${next_step}).`)
if(doesElementExist(next_step)){
var ready = true;
if (step.validator && (typeof window[step.validator] === 'function')) {
Expand All @@ -132,6 +144,8 @@ function handleNextWizardStep(step){
if(ready){
switchStep(next_step);
}
} else {
console.log(`Attempting to navigate to nonexistant wizard step ${clicked_step}`)
}
}

Expand All @@ -145,4 +159,4 @@ document.addEventListener('DOMContentLoaded', () => {
await switchStep(wizardStart);
}
});
});
});
5 changes: 4 additions & 1 deletion wizard/wizard.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
"help_message": "This is more advanced help. ",
"validator": "",
"image": "wizard/wizard.png",
"next_step": "fw_programmer_needed"
"next_step": [
{"step":"fw_programmer_needed","label":"Not Found?"},
{"step":"fw_swap_cable","label":"Next"}
]
},
{
"step": "fw_programmer_needed",
Expand Down

0 comments on commit d9686f7

Please sign in to comment.