Skip to content

Commit

Permalink
feat: minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
kptdobe committed Jun 15, 2022
1 parent 9000bc8 commit 867a45f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
13 changes: 12 additions & 1 deletion js/crawl/crawl.ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ const displayCrawledURL = (url) => {
CRAWLED_URLS_HEADING.innerText = `Crawled URLs (${crawlStatus.crawled}):`;
};

const clearResultPanel = () => {
CRAWLED_URLS_LIST.innerHTML = '';
CRAWLED_URLS_HEADING.innerText = 'Crawling...';
};

const disableProcessButtons = () => {
PROCESS_BUTTONS.forEach((button) => {
button.disabled = true;
Expand Down Expand Up @@ -96,12 +101,14 @@ const attachListeners = () => {
attachOptionFieldsListeners(config.fields, PARENT_SELECTOR);

CRAWL_BUTTON.addEventListener('click', (async () => {
disableProcessButtons();
clearResultPanel();

if (config.fields['crawl-show-preview']) {
CRAWL_CONTAINER.classList.remove('hidden');
} else {
CRAWL_CONTAINER.classList.add('hidden');
}
disableProcessButtons();

CRAWL_REPORT_BUTTON.classList.remove('hidden');

Expand Down Expand Up @@ -272,6 +279,9 @@ const attachListeners = () => {
}));

GETURLSFROMROBOTS_BUTTON.addEventListener('click', (async () => {
disableProcessButtons();
clearResultPanel();

crawlStatus.crawled = 0;
crawlStatus.rows = [];
crawlStatus.urls = [];
Expand All @@ -293,6 +303,7 @@ const attachListeners = () => {
});

CRAWL_REPORT_BUTTON.classList.remove('hidden');
enableProcessButtons();
}));
};

Expand Down
9 changes: 9 additions & 0 deletions js/shared/alert.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ const doAlert = (message, variant) => {
toast.setAttribute('variant', variant);
toast.setAttribute('open', true);
toast.innerHTML = message;
toast.addEventListener('close', () => {
toast.remove();
});

if (ALERT.hasChildNodes()) {
ALERT.childNodes.forEach((node) => {
node.remove();
});
}
ALERT.append(toast);
};

Expand Down

0 comments on commit 867a45f

Please sign in to comment.