Проблем със задача 01. Forum posts от JS Advanced Retake Exam - 6 Apr 2022
Здравейте, получавам 25/100, някой може ли да ми помогне ?
Благодаря :)
задача : https://judge.softuni.org/Contests/Practice/Index/3425#0
код :
function solve() {
let titleEl = document.getElementById("post-title")
let categoryEl = document.getElementById("post-category")
let contentEl = document.getElementById("post-content")
let addBtnEl = document.getElementById("publish-btn")
let reviewElement = document.querySelector("#review-list");
let publishElement = document.querySelector('#published-list');
addBtnEl.addEventListener('click',onNext)
function onNext(e) {
e.preventDefault();
if(titleEl.value == '' || categoryEl.value == '' || contentEl.value == '') {
return;
}
let liElementInfo = document.createElement('li');
liElementInfo.setAttribute('class', 'post-content');
let articleElementInfo = document.createElement("article");
let title = document.createElement('h3');
title.textContent = `Exam completion`;
let category = document.createElement('p');
category.textContent = `Exam`;
let post = document.createElement('p');
post.textContent = `On the 06.04.2022 there will be exam that includes this problem`;
let editBtn = document.createElement("button");
editBtn.setAttribute('class', 'edit-btn');
editBtn.textContent = 'Edit';
let approveBtn = document.createElement("button");
approveBtn.setAttribute('class', 'approve-btn');
approveBtn.textContent = 'Approve';
articleElementInfo.appendChild(title);
articleElementInfo.appendChild(category);
articleElementInfo.appendChild(post);
liElementInfo.appendChild(articleElementInfo);
liElementInfo.appendChild(editBtn);
liElementInfo.appendChild(approveBtn);
reviewElement.appendChild(liElementInfo); //
let editTitle = titleEl.value;
let editCategory = categoryEl.value;
let editPost = contentEl.value;
titleEl.value = ""
categoryEl.value = ""
contentEl.value = ""
addBtnEl.disabled = true;
editBtn.addEventListener("click", onEdit);
function onEdit() {
titleEl.value = editTitle;
categoryEl.value = editCategory;
contentEl.value = editPost;
liElementInfo.remove();
addBtnEl.disabled = false;
}
approveBtn.addEventListener('click', onContinue);
function onContinue() {
let liElementconfirm = document.createElement('li');
liElementconfirm.setAttribute('class', 'approve-content');
let articleElementApprove = document.createElement("article");
articleElementApprove = articleElementInfo;
let clearBtn = document.createElement("button");
clearBtn.setAttribute('class', 'cancel-btn');
clearBtn.textContent = 'Clear';
liElementconfirm.appendChild(articleElementApprove);
liElementconfirm.appendChild(clearBtn);
liElementInfo.remove();
publishElement.appendChild(liElementconfirm)
clearBtn.addEventListener('click',onCancel);
function onCancel() {
liElementconfirm.remove();
addBtnEl.disabled = false;
}
}
}
}
Много благодаря :)