-
Notifications
You must be signed in to change notification settings - Fork 0
/
history.js
25 lines (22 loc) · 977 Bytes
/
history.js
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
const history = document.querySelector('.history');
const store = [];
const limit = 10;
function genCalcData() {
const str = store.reduce((acc, {task, timeParse, timePolNot, timeCalc, timeTotal, result}) => {
return acc += `<div class='item__history'>
<p>Задача: <b>${task}</b></p>
<p>Ответ: <b>${result}</b></p>
<p>Время парсинга строки: <b>${timeParse}</b> мс.</p>
<p>Время формирования "польской записи": <b>${timePolNot}</b> мс.</p>
<p>Время разбора "ПЗ" и вычисления: <b>${timeCalc}</b> мс.</p>
<p>Итоговое время: <b>${timeTotal}</b> мс.</p>
</div>`
}, '')
return str;
}
export function handlerResult(data) {
store.push(data);
if (store.length > limit) store.pop();
history.innerHTML = '';
history.insertAdjacentHTML('beforeend', genCalcData())
}