Skip to content

Commit

Permalink
Feed tooltip based on filters
Browse files Browse the repository at this point in the history
The feed logo tooltip text is now based on filters.
If no filters are set, it shows "All entries"
  • Loading branch information
juuz0 committed Mar 19, 2023
1 parent 4aef47b commit 30620a5
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 9 deletions.
3 changes: 2 additions & 1 deletion static/skin/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
, "magnet-alt-text": "download magnet"
, "torrent-download-link-text": "Torrent file"
, "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}}\""
, "stop-filtering-by-tag": "Stop filtering by tag \"{{TAG}}\""
, "library-opds-feed-parametirized": "Library OPDS Feed - Only for {{#LANG}}language: {{LANG}} {{/LANG}}{{#CATEGORY}}category: {{CATEGORY}} {{/CATEGORY}}{{#TAG}}tag: {{TAG}} {{/TAG}}{{#Q}}matching {{Q}} {{/Q}}"
}
3 changes: 2 additions & 1 deletion static/skin/i18n/test.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
, "magnet-alt-text": "download [I18N TESTING] magnet"
, "torrent-download-link-text": "Torrent [I18N TESTING] file"
, "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}}\""
, "stop-filtering-by-tag": "[I18N] Stop filtering [TESTING] by tag \"{{TAG}}\""
, "library-opds-feed-parametirized": "[I18N] Library OPDS Feed - [TESTING] Only for {{#LANG}}language: {{LANG}} {{/LANG}}{{#CATEGORY}}category: {{CATEGORY}} {{/CATEGORY}}{{#TAG}}tag: {{TAG}} {{/TAG}}{{#Q}}matching {{Q}} {{/Q}} [I18N TESTING]"
}
29 changes: 24 additions & 5 deletions static/skin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
const feedLink = `${root}/catalog/v2/entries?${filteredParams.toString()}`;
document.querySelector('#headFeedLink').href = feedLink;
document.querySelector('#feedLink').href = feedLink;
setFeedToolTip();
}

function changeUILanguage() {
Expand Down Expand Up @@ -496,18 +497,36 @@

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-parametirized', paramObj);
}

function updateUIText() {
footer.innerHTML = $t("powered-by-kiwix-html");
const searchText = $t("search");
document.getElementById('searchFilter').placeholder = searchText;
document.getElementById('searchButton').value = searchText;
document.getElementById('categoryFilter').children[0].innerHTML = $t("book-filtering-all-categories");
document.getElementById('languageFilter').children[0].innerHTML = $t("book-filtering-all-languages");
const feedLogoElem = document.getElementById('feedLogo');
const libraryOpdsFeedHint = $t("library-opds-feed");
for (const attr of ["alt", "aria-label", "title"] ) {
feedLogoElem.setAttribute(attr, libraryOpdsFeedHint);
}
setFeedToolTip();
}

async function onload() {
Expand Down
4 changes: 2 additions & 2 deletions test/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const ResourceCollection resources200Compressible{
{ DYNAMIC_CONTENT, "/ROOT%23%3F/skin/index.css" },
{ STATIC_CONTENT, "/ROOT%23%3F/skin/index.css?cacheid=3ddd8b6e" },
{ 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=77db5d73" },
{ DYNAMIC_CONTENT, "/ROOT%23%3F/skin/iso6391To3.js" },
{ STATIC_CONTENT, "/ROOT%23%3F/skin/iso6391To3.js?cacheid=ecde2bb3" },
{ DYNAMIC_CONTENT, "/ROOT%23%3F/skin/isotope.pkgd.min.js" },
Expand Down Expand Up @@ -284,7 +284,7 @@ R"EXPECTEDRESULT( href="/ROOT%23%3F/skin/index.css?cacheid=3ddd8b6e"
<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/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=77db5d73" defer></script>
<img src="/ROOT%23%3F/skin/feed.svg?cacheid=055b333f"
<img src="/ROOT%23%3F/skin/langSelector.svg?cacheid=00b59961"
)EXPECTEDRESULT"
Expand Down

0 comments on commit 30620a5

Please sign in to comment.