mobile.install.es6.js 879 B

1234567891011121314151617181920212223242526272829
  1. (function() {
  2. function findActiveStep(steps) {
  3. for (let i = 0; i < steps.length; i++) {
  4. if (steps[i].className === 'is-active') {
  5. return i + 1;
  6. }
  7. }
  8. // The final "Finished" step is never "active".
  9. if (steps[steps.length - 1].className === 'done') {
  10. return steps.length;
  11. }
  12. return 0;
  13. }
  14. function installStepsSetup() {
  15. const steps = document.querySelectorAll('.task-list li');
  16. if (steps.length) {
  17. const header = document.querySelector('header[role="banner"]');
  18. const stepIndicator = document.createElement('div');
  19. stepIndicator.className = 'step-indicator';
  20. stepIndicator.innerHTML = `${findActiveStep(steps)}/${steps.length}`;
  21. header.appendChild(stepIndicator);
  22. }
  23. }
  24. if (document.addEventListener) {
  25. document.addEventListener('DOMContentLoaded', installStepsSetup);
  26. }
  27. })();