mobile.install.js 893 B

123456789101112131415161718192021222324252627282930313233
  1. (function () {
  2. 'use strict';
  3. function findActiveStep(steps) {
  4. for (var 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. var steps = document.querySelectorAll('.task-list li');
  17. if (steps.length) {
  18. var header = document.querySelector('header[role="banner"]');
  19. var 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. })();