Skip to content

Commit

Permalink
main: edits - 2 (small refactoring)
Browse files Browse the repository at this point in the history
  • Loading branch information
MiggRabbid committed Dec 14, 2023
1 parent c315837 commit da4aa42
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
6 changes: 1 addition & 5 deletions src/app/parserRss.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@ export default (rss) => {

const items = xml.querySelectorAll('item');
const data = {
feeds: {
title: xml.querySelector('title').textContent,
description: xml.querySelector('description').textContent,
url: xml.querySelector('link').textContent,
},
feeds: extractDataFromItem(xml),
items: Array.from(items).map((item) => extractDataFromItem(item)),
};

Expand Down
14 changes: 9 additions & 5 deletions src/app/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,19 @@ const renderFeedback = (rssForm, path, value) => {
const oldFeedback = rssForm.parentElement.querySelector('.feedback');

if (oldFeedback) oldFeedback.remove();


newFeedback.classList.add('feedback', 'm-0', 'position-absolute', 'small');
let newTextContent;

if (path === 'currentUrl.feedback' && value !== null) {
newFeedback.classList.add('feedback', 'm-0', 'position-absolute', 'small', 'text-success');
newFeedback.textContent = value.at(-1).feedback;
newFeedback.classList.add('text-success');
newTextContent = value.at(-1).feedback;
}
if (path === 'currentUrl.error' && value !== null) {
newFeedback.classList.add('feedback', 'm-0', 'position-absolute', 'small', 'text-danger');
newFeedback.textContent = value.at(-1).error;
newFeedback.classList.add('text-danger');
newTextContent = value.at(-1).error;
}
newFeedback.textContent = newTextContent

rssForm.parentElement.append(newFeedback);
};
Expand Down

0 comments on commit da4aa42

Please sign in to comment.