Feed tooltip based on filters

The feed logo tooltip text is now based on filters.
If no filters are set, it shows "All entries"
This commit is contained in:
Nikhil Tanwar 2023-03-19 09:09:08 +05:30
parent d7a3a417e1
commit ae58f009fb
5 changed files with 33 additions and 11 deletions

View File

@ -43,7 +43,8 @@
, "magnet-alt-text": "download magnet" , "magnet-alt-text": "download magnet"
, "torrent-download-link-text": "Torrent file" , "torrent-download-link-text": "Torrent file"
, "torrent-download-alt-text": "download torrent" , "torrent-download-alt-text": "download torrent"
, "library-opds-feed": "Library OPDS Feed" , "library-opds-feed-all-entries": "Library OPDS Feed - All entries"
, "filter-by-tag": "Filter by tag \"{{TAG}}\"" , "filter-by-tag": "Filter by tag \"{{TAG}}\""
, "stop-filtering-by-tag": "Stop filtering by tag \"{{TAG}}\"" , "stop-filtering-by-tag": "Stop filtering by tag \"{{TAG}}\""
, "library-opds-feed-parameterised": "Library OPDS Feed - entries matching {{#LANG}}\nLanguage: {{LANG}} {{/LANG}}{{#CATEGORY}}\nCategory: {{CATEGORY}} {{/CATEGORY}}{{#TAG}}\nTag: {{TAG}} {{/TAG}}{{#Q}}\nQuery: {{Q}} {{/Q}}"
} }

View File

@ -45,7 +45,8 @@
"magnet-alt-text": "Hint for the icon of a magnet link", "magnet-alt-text": "Hint for the icon of a magnet link",
"torrent-download-link-text": "Link text for downloading the torrent file", "torrent-download-link-text": "Link text for downloading the torrent file",
"torrent-download-alt-text": "Hint for the icon of torrent download", "torrent-download-alt-text": "Hint for the icon of torrent download",
"library-opds-feed": "Hint for the library OPDS feed link",
"filter-by-tag": "Hint for a link that would load results filtered by a single tag", "filter-by-tag": "Hint for a link that would load results filtered by a single tag",
"stop-filtering-by-tag": "Tooltip for the button that cancels filtering by tag" "stop-filtering-by-tag": "Tooltip for the button that cancels filtering by tag",
"library-opds-feed-all-entries": "Hint for the library OPDS feed for all entries",
"library-opds-feed-parameterised": "Hint for the library OPDS feed for filtered entries"
} }

View File

@ -32,7 +32,8 @@
, "magnet-alt-text": "download [I18N TESTING] magnet" , "magnet-alt-text": "download [I18N TESTING] magnet"
, "torrent-download-link-text": "Torrent [I18N TESTING] file" , "torrent-download-link-text": "Torrent [I18N TESTING] file"
, "torrent-download-alt-text": "download [I18N TESTING] torrent" , "torrent-download-alt-text": "download [I18N TESTING] torrent"
, "library-opds-feed": "Library [I18N] OPDS [TESTING] Feed" , "library-opds-feed-all-entries": "[I18N] Library [TESTING] OPDS Feed - All entries [I18N TESTING]"
, "filter-by-tag": "Filter [I18N] by [TESTING] tag \"{{TAG}}\"" , "filter-by-tag": "Filter [I18N] by [TESTING] tag \"{{TAG}}\""
, "stop-filtering-by-tag": "[I18N] Stop filtering [TESTING] by tag \"{{TAG}}\"" , "stop-filtering-by-tag": "[I18N] Stop filtering [TESTING] by tag \"{{TAG}}\""
, "library-opds-feed-parameterised": "[I18N] Library OPDS Feed - [TESTING] entries matching {{#LANG}}\nLanguage: {{LANG}} {{/LANG}}{{#CATEGORY}}\nCategory: {{CATEGORY}} {{/CATEGORY}}{{#TAG}}\nTag: {{TAG}} {{/TAG}}{{#Q}}\nQuery: {{Q}} {{/Q}}"
} }

View File

@ -39,6 +39,7 @@
const feedLink = `${root}/catalog/v2/entries?${filteredParams.toString()}`; const feedLink = `${root}/catalog/v2/entries?${filteredParams.toString()}`;
document.querySelector('#headFeedLink').href = feedLink; document.querySelector('#headFeedLink').href = feedLink;
document.querySelector('#feedLink').href = feedLink; document.querySelector('#feedLink').href = feedLink;
setFeedToolTip();
} }
function changeUILanguage() { function changeUILanguage() {
@ -496,6 +497,28 @@
window.addEventListener('hashchange', () => resetAndFilter()); window.addEventListener('hashchange', () => resetAndFilter());
function setFeedToolTip() {
const feedLogoElem = document.getElementById('feedLogo');
const libraryOpdsFeedHint = opdsFeedHintByParams();
for (const attr of ["alt", "aria-label", "title"] ) {
feedLogoElem.setAttribute(attr, libraryOpdsFeedHint);
}
}
function opdsFeedHintByParams() {
const paramObj = {};
const inputParams = new FragmentParams(window.location.hash);
for (const [key, value] of inputParams) {
if ( value != '' ) {
paramObj[key.toUpperCase()] = value;
}
}
if (!paramObj.LANG && !paramObj.CATEGORY && !paramObj.TAG && !paramObj.Q) {
return $t('library-opds-feed-all-entries');
}
return $t('library-opds-feed-parameterised', paramObj);
}
function updateUIText() { function updateUIText() {
footer.innerHTML = $t("powered-by-kiwix-html"); footer.innerHTML = $t("powered-by-kiwix-html");
const searchText = $t("search"); const searchText = $t("search");
@ -503,11 +526,7 @@
document.getElementById('searchButton').value = searchText; document.getElementById('searchButton').value = searchText;
document.getElementById('categoryFilter').children[0].innerHTML = $t("book-filtering-all-categories"); document.getElementById('categoryFilter').children[0].innerHTML = $t("book-filtering-all-categories");
document.getElementById('languageFilter').children[0].innerHTML = $t("book-filtering-all-languages"); document.getElementById('languageFilter').children[0].innerHTML = $t("book-filtering-all-languages");
const feedLogoElem = document.getElementById('feedLogo'); setFeedToolTip();
const libraryOpdsFeedHint = $t("library-opds-feed");
for (const attr of ["alt", "aria-label", "title"] ) {
feedLogoElem.setAttribute(attr, libraryOpdsFeedHint);
}
} }
async function onload() { async function onload() {

View File

@ -63,7 +63,7 @@ const ResourceCollection resources200Compressible{
{ DYNAMIC_CONTENT, "/ROOT%23%3F/skin/index.css" }, { DYNAMIC_CONTENT, "/ROOT%23%3F/skin/index.css" },
{ STATIC_CONTENT, "/ROOT%23%3F/skin/index.css?cacheid=e4d76d16" }, { STATIC_CONTENT, "/ROOT%23%3F/skin/index.css?cacheid=e4d76d16" },
{ DYNAMIC_CONTENT, "/ROOT%23%3F/skin/index.js" }, { DYNAMIC_CONTENT, "/ROOT%23%3F/skin/index.js" },
{ STATIC_CONTENT, "/ROOT%23%3F/skin/index.js?cacheid=cafa3d61" }, { STATIC_CONTENT, "/ROOT%23%3F/skin/index.js?cacheid=78cfd6a2" },
{ DYNAMIC_CONTENT, "/ROOT%23%3F/skin/iso6391To3.js" }, { DYNAMIC_CONTENT, "/ROOT%23%3F/skin/iso6391To3.js" },
{ STATIC_CONTENT, "/ROOT%23%3F/skin/iso6391To3.js?cacheid=ecde2bb3" }, { STATIC_CONTENT, "/ROOT%23%3F/skin/iso6391To3.js?cacheid=ecde2bb3" },
{ DYNAMIC_CONTENT, "/ROOT%23%3F/skin/isotope.pkgd.min.js" }, { DYNAMIC_CONTENT, "/ROOT%23%3F/skin/isotope.pkgd.min.js" },
@ -284,7 +284,7 @@ R"EXPECTEDRESULT( href="/ROOT%23%3F/skin/index.css?cacheid=e4d76d16"
<script type="text/javascript" src="/ROOT%23%3F/skin/languages.js?cacheid=b00b12db" defer></script> <script type="text/javascript" src="/ROOT%23%3F/skin/languages.js?cacheid=b00b12db" defer></script>
<script src="/ROOT%23%3F/skin/isotope.pkgd.min.js?cacheid=2e48d392" defer></script> <script src="/ROOT%23%3F/skin/isotope.pkgd.min.js?cacheid=2e48d392" defer></script>
<script src="/ROOT%23%3F/skin/iso6391To3.js?cacheid=ecde2bb3"></script> <script src="/ROOT%23%3F/skin/iso6391To3.js?cacheid=ecde2bb3"></script>
<script type="text/javascript" src="/ROOT%23%3F/skin/index.js?cacheid=cafa3d61" defer></script> <script type="text/javascript" src="/ROOT%23%3F/skin/index.js?cacheid=78cfd6a2" defer></script>
<img src="/ROOT%23%3F/skin/feed.svg?cacheid=055b333f" <img src="/ROOT%23%3F/skin/feed.svg?cacheid=055b333f"
<img src="/ROOT%23%3F/skin/langSelector.svg?cacheid=00b59961" <img src="/ROOT%23%3F/skin/langSelector.svg?cacheid=00b59961"
)EXPECTEDRESULT" )EXPECTEDRESULT"