diff --git a/pages/js/rev2.js b/pages/js/rev2.js index 2cf986d..1d6767e 100644 --- a/pages/js/rev2.js +++ b/pages/js/rev2.js @@ -1,4 +1,47 @@ export function update_rev2(data) { - let time_remaining = document.getElementById('rev2_time_remaining'); - console.log(data); + // Обновление оставшегося времени + const time_remaining_element = document.getElementById('rev2_time_remaining'); + + const time_remaining_counter = document.createTextNode(data.time_remaining); + const time_remaining_text = document.createElement('span'); + time_remaining_text.classList.add('fw-bold'); + time_remaining_text.innerText = 'Времени осталось: '; + + [time_remaining_text, time_remaining_counter].forEach((element) => { + time_remaining_element.appendChild(element); + }); + + time_remaining_element.removeAttribute('class'); + + // Обновление HP + const content_element = document.getElementById('rev2_emenies'); + data.enemies.forEach((emeny) => { + enemy_data = emeny.split(' '); + + // Элемент с именем монстра + const enemy_name = document.createElement('p'); + enemy_name.innerText = enemy_data[0]; + + ['my-1', 'fw-bold', 'd-flex', 'justify-content-between'].forEach((style_class) => { + enemy_name.classList.add(style_class); + }); + + // Элемент с полосой здоровья босса + const progressbar_element = document.createElement('div'); + ['progress-bar', 'bg-danger'].forEach((style_class) => { + progressbar_element.classList.add(style_class); + }); + progressbar_element.style.width = enemy_data[1]; + progressbar_element.innerText = enemy_data[1]; + + const progress_element = document.createElement('div'); + progress_element.classList.add('progress'); + time_remaining_element.setAttribute('aria-valuemin', 0); + time_remaining_element.setAttribute('aria-valuemax', 100); + time_remaining_element.setAttribute('aria-valuenow', enemy_data[1].replace('%', '')); + progress_element.appendChild(progressbar_element); + + content_element.appendChild(enemy_name); + content_element.appendChild(progress_element); + }); } diff --git a/pages/rer2.html b/pages/rer2.html index c2e41ca..ceff87f 100644 --- a/pages/rer2.html +++ b/pages/rer2.html @@ -55,34 +55,10 @@ -
- Aello - [? / ?] -
-- Ocypete - [? / ?] -
-