48 lines
1.9 KiB
JavaScript
48 lines
1.9 KiB
JavaScript
export function update_rev2(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) => {
|
||
let 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);
|
||
});
|
||
}
|