|
|
Line 397: |
Line 397: |
| </div> | | </div> |
| </footer> | | </footer> |
− | <script>
| + | |
− | (function (w) {
| + | |
− | var _this = w.slides = {};
| + | |
− | var slides = _this.slides = document.getElementsByClassName('mySlides');
| + | |
− | var dots = document.getElementsByClassName('dot');
| + | |
− | var prevButton = document.getElementsByClassName('prev')[0];
| + | |
− | var nextButton = document.getElementsByClassName('next')[0];
| + | |
− | var currentIndex = _this.currentIndex = 0;
| + | |
− | var maxIndex = _this.maxIndex = slides.length - 1;
| + | |
− | for (var i = 0; i <= maxIndex; i++) {
| + | |
− | slides[i].style.display = 'none';
| + | |
− | }
| + | |
− | var change = _this.change = function (index) {
| + | |
− | slides[currentIndex].style.display = 'none';
| + | |
− | slides[index].style.display = 'block';
| + | |
− | currentIndex = index;
| + | |
− | };
| + | |
− | var next = _this.next = function () {
| + | |
− | var index = currentIndex + 1;
| + | |
− | if (index > maxIndex) index = 0;
| + | |
− | change(index);
| + | |
− | };
| + | |
− | var prev = _this.prev = function () {
| + | |
− | var index = currentIndex - 1;
| + | |
− | if (index < 0) index = maxIndex;
| + | |
− | change(index);
| + | |
− | };
| + | |
− | var interval;
| + | |
− | var _setInterval = _this.setInterval = function () {
| + | |
− | interval = setInterval(next, 3000);
| + | |
− | };
| + | |
− | var _clearInterval = _this.clearInterval = function () {
| + | |
− | clearInterval(interval);
| + | |
− | };
| + | |
− | _setInterval();
| + | |
− | })(window);
| + | |
− | </script>
| + | |
| </body> | | </body> |
| </html> | | </html> |