Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added nofilter attribute and iframe conditions #587

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions static/skin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
let noResultInjected = false;
let filters = getCookie(filterCookieName);
let params = new URLSearchParams(window.location.search || filters || '');
let noFilter = params.has('nofilter') && params.get('nofilter');
let inIframe = false;
let timer;

function queryUrlBuilder() {
Expand Down Expand Up @@ -101,7 +103,7 @@
<div class='book__description' title='${description}'>${description}</div>
<div class='book__languageTag'>${language.substr(0, 2).toUpperCase()}</div>
<div class='book__tags'><div class="book__tags--wrapper">${tagHtml}</div></div>
<div class='book__links'> <a href="${link}" data-hover="Preview">Preview</a>${downloadLink ? `&nbsp;|&nbsp;<span class="download" data-link=${downloadLink} class="modal-button">Download</span>` : ''} </div></div>`;
<div class='book__links'> ${!inIframe ? `<a href="${link}" data-hover="Preview">Preview</a>` : ''}${downloadLink ? `${!inIframe ? '&nbsp;|&nbsp;' : ''}<span class="download" data-link=${downloadLink} class="modal-button">Download</span>` : ''} </div></div>`;
return divTag;
}

Expand Down Expand Up @@ -336,6 +338,14 @@
window.addEventListener('scroll', loadSubset);

window.onload = async () => {
if (noFilter) {
document.getElementById('kiwixNav').remove();
}
if (window.location !== window.parent.location) {
document.getElementById('kiwixFooter').innerHTML = '';
document.getElementById('kiwixHomeBody').style.padding = '20px';
inIframe = true;
}
iso = new Isotope( '.book__list', {
itemSelector: '.book',
getSortData:{
Expand All @@ -351,7 +361,7 @@
rowHeight: '.book'
}
});
footer = document.getElementById('kiwixfooter');
footer = document.getElementById('kiwixFooter');
fadeOutDiv = document.getElementById('fadeOut');
loader = document.querySelector('.loader');
await loadAndDisplayBooks();
Expand All @@ -365,7 +375,7 @@
}
params.forEach((value, key) => {document.getElementsByName(key)[0].value = value});
document.getElementById('kiwixSearchForm').onsubmit = (event) => {event.preventDefault()};
if (!window.location.search) {
if (!window.location.search && !inIframe) {
const browserLang = navigator.language.split('-')[0];
const langFilter = document.getElementById('languageFilter');
langFilter.value = browserLang.length === 3 ? browserLang : iso6391To3[browserLang];
Expand Down
6 changes: 3 additions & 3 deletions static/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<script type="text/javascript" src="{{root}}/skin/index.js" defer></script>
</head>
<body>
<div class='kiwixNav'>
<div id='kiwixNav' class='kiwixNav'>
<div class="kiwixNav__filters">
<div class="kiwixNav__select">
<select name="lang" id="languageFilter" class='kiwixNav__kiwixFilter filter'>
Expand All @@ -63,13 +63,13 @@
<input type="submit" class="searchButton" value="Search"/>
</form>
</div>
<div class="kiwixHomeBody">
<div id="kiwixHomeBody" class="kiwixHomeBody">
<h3 class="kiwixHomeBody__results"></h3>
<div class="book__list"></div>
<div id="fadeOut" class="fadeOut"></div>
</div>
<div class="loader" style="position: absolute; top: 50%"><div class="loader-spinner"></div></div>
<div id="kiwixfooter" class="kiwixfooter">Powered by&nbsp;<a href="https://kiwix.org">Kiwix</a></div>
<div id="kiwixFooter" class="kiwixfooter">Powered by&nbsp;<a href="https://kiwix.org">Kiwix</a></div>
</body>
<script>
function closeModal() {
Expand Down