mobile.install.es6.js 901 B

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