-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
28 lines (24 loc) · 721 Bytes
/
script.js
File metadata and controls
28 lines (24 loc) · 721 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
;(function () {
'use strict'
const _reader = document.getElementById('reader')
const _book = document.getElementById('book')
const _btnStart = document.getElementById('startReading')
const _btnStop = document.getElementById('stopReading')
let partBook = []
let readingTime
_btnStart.addEventListener('click', () => {
const fullBook = _book.value
partBook = fullBook.split(/\s/gim)
readingTime = setInterval(() => {
console.log(partBook[0])
if(partBook.length !== 0){
_reader.textContent = partBook.shift()
} else {
clearInterval(readingTime)
}
}, 200)
})
_btnStop.addEventListener('click', () => {
clearInterval(readingTime)
})
})()