├── index.html └── src └── js └── index.js /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | HW8-DOM-part-3 9 | 10 | 11 |
12 | 13 |
14 | 15 | 16 | -------------------------------------------------------------------------------- /src/js/index.js: -------------------------------------------------------------------------------- 1 | console.log('------------- #3') 2 | function decrimentOrIncrement(a, b, dec = false) { 3 | if (a < b + 1 && !dec) { 4 | console.log(a) 5 | a++ 6 | decrimentOrIncrement(a,b) 7 | } else if (a >= b && dec) { 8 | console.log(a) 9 | a-- 10 | decrimentOrIncrement(a,b,true) 11 | } 12 | } 13 | decrimentOrIncrement(1,5) 14 | console.log('------------- #4') 15 | const time = document.getElementById('time'); 16 | 17 | setInterval(setDate,1000) 18 | 19 | function setDate() { 20 | const currentDate = new Date(); 21 | let hours = currentDate.getHours() < 10 ? '0'+currentDate.getHours() : currentDate.getHours() 22 | let minutes = currentDate.getMinutes() < 10 ? '0'+currentDate.getMinutes() : currentDate.getMinutes() 23 | let seconds = currentDate.getSeconds() < 10 ? '0'+currentDate.getSeconds() : currentDate.getSeconds() 24 | 25 | if (time.classList.contains('full')) { 26 | time.innerHTML = `${hours}:${minutes}:${seconds}` 27 | } else { 28 | time.innerHTML = `${hours}:${minutes}` 29 | } 30 | } 31 | 32 | time.addEventListener('click', changeFormat) 33 | 34 | function changeFormat() { 35 | time.classList.toggle('full') 36 | } 37 | --------------------------------------------------------------------------------