From f034018b5cb28f9da0dcc6d88eb0fc38f2743499 Mon Sep 17 00:00:00 2001
From: Nikhil Tanwar <2002nikhiltanwar@gmail.com>
Date: Fri, 24 Jun 2022 21:46:11 +0530
Subject: [PATCH] Extract setNoResultsContent() from
checkAndInjectEmptyMessage()
Extracted the code from the un-named function in setTimeout for easier understanding.
---
static/skin/index.js | 19 +++++++++++--------
test/server.cpp | 2 +-
2 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/static/skin/index.js b/static/skin/index.js
index c33c47d9..a6bcdd74 100644
--- a/static/skin/index.js
+++ b/static/skin/index.js
@@ -267,6 +267,16 @@
});
}
+ function setNoResultsContent() {
+ const kiwixHomeBody = document.querySelector('.kiwixHomeBody');
+ const divTag = document.createElement('div');
+ divTag.setAttribute('class', 'noResults');
+ divTag.innerHTML = `No result. Would you like to reset filter?`;
+ kiwixHomeBody.append(divTag);
+ kiwixHomeBody.setAttribute('style', 'display: flex; justify-content: center; align-items: center');
+ loader.setAttribute('style', 'position: absolute; top: 50%');
+ }
+
function checkAndInjectEmptyMessage() {
const kiwixHomeBody = document.querySelector('.kiwixHomeBody');
if (!bookOrderMap.size) {
@@ -274,14 +284,7 @@
noResultInjected = true;
iso.remove(document.getElementsByClassName('book__list')[0].getElementsByTagName('div'));
iso.layout();
- setTimeout(() => {
- const divTag = document.createElement('div');
- divTag.setAttribute('class', 'noResults');
- divTag.innerHTML = `No result. Would you like to reset filter?`;
- kiwixHomeBody.append(divTag);
- kiwixHomeBody.setAttribute('style', 'display: flex; justify-content: center; align-items: center');
- loader.setAttribute('style', 'position: absolute; top: 50%');
- }, 300);
+ setTimeout(setNoResultsContent, 300);
}
return true;
} else if (noResultInjected) {
diff --git a/test/server.cpp b/test/server.cpp
index a0c22362..145f5922 100644
--- a/test/server.cpp
+++ b/test/server.cpp
@@ -184,7 +184,7 @@ R"EXPECTEDRESULT( src="/ROOT/skin/jquery-ui/external/jquery/jquery.js?cache
src: url("/ROOT/skin/fonts/Roboto.ttf?cacheid=84d10248") format("truetype");
-
+
)EXPECTEDRESULT"
},
{