-
Notifications
You must be signed in to change notification settings - Fork 2
Add Search feature to Browse and Download Pages #39
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -73,6 +73,7 @@ const Filtering = class { | |
| order_dir = 'desc'; | ||
| only_lang = ''; | ||
| only_category = ''; | ||
| only_search = ''; | ||
|
|
||
| constructor(order_by, order_dir, only_lang, only_category) { | ||
| this.order_by = order_by || this.order_by; | ||
|
|
@@ -86,6 +87,7 @@ const Filtering = class { | |
| this.order_dir = 'desc'; | ||
| this.only_lang = ''; | ||
| this.only_category = ''; | ||
| this.only_search = ''; | ||
| } | ||
|
|
||
| toString() { | ||
|
|
@@ -146,6 +148,13 @@ const Filtering = class { | |
| visible = false; | ||
| if (visible && this.only_category && this.only_category != category) | ||
| visible = false; | ||
| if (visible && this.only_search.trim() !== '') { | ||
| const nameAttr = elems[i].getAttribute('data-name').toLowerCase(); | ||
| const descAttr = elems[i].getAttribute('data-desc') ? elems[i].getAttribute('data-desc').toLowerCase() : ''; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you retrieve the description from the DOM below instead? This would force duplicating the descriptions |
||
| if (!nameAttr.includes(this.only_search.toLowerCase()) && !descAttr.includes(this.only_search.toLowerCase())) { | ||
| visible = false; | ||
| } | ||
| } | ||
|
|
||
| if (visible) | ||
| removeClass(elems[i], 'hidden'); | ||
|
|
@@ -334,6 +343,11 @@ function run() { | |
|
|
||
| live('#reset-filters', 'click', resetMobileFiltersButtonClick) | ||
|
|
||
| live('#search-bar', 'input', function(el, ev) { | ||
| filter.only_search = el.value; | ||
| filter.render(true); | ||
| }); | ||
|
|
||
| filter.render(true); | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -249,7 +249,7 @@ | |||||
| >Languages</label> | ||||||
| <select | ||||||
| id="languages-list" | ||||||
| class="select select-bordered select-sm max-w-[10rem]" | ||||||
| class="select select-bordered select-sm dropdown max-w-[10rem]" | ||||||
| > | ||||||
| <option value="">All</option> | ||||||
| {% for code, name in languages.items() %}<option value="{{ code }}">{{ name }}</option>{% endfor %} | ||||||
|
|
@@ -262,12 +262,24 @@ | |||||
| >Categories</label> | ||||||
| <select | ||||||
| id="categories-list" | ||||||
| class="select select-bordered select-sm max-w-xs dm-sans" | ||||||
| class="select select-bordered select-sm dropdown max-w-xs dm-sans" | ||||||
| > | ||||||
| <option value="">All</option> | ||||||
| {% for category in categories %}<option value="{{ category }}">{{ category }}</option>{% endfor %} | ||||||
| </select> | ||||||
| </div> | ||||||
| <div class="text-start ml-[2em] xl:ml-[4em]"> | ||||||
| <label | ||||||
| for="search-bar" | ||||||
| class="hidden lg:inline-block kiwix-{{page }}-filter-label text-[0.9em] me-[1em] dm-sans" | ||||||
| >Search</label> | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||
| <input | ||||||
| id="search-bar" | ||||||
| type="text" | ||||||
| placeholder="Search..." | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| class="select select-bordered select-sm max-w-xs dm-sans h-[2.25rem]" | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We cannot have |
||||||
| /> | ||||||
| </div> | ||||||
| {% endif %} | ||||||
| </nav> | ||||||
| </div> | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -58,7 +58,9 @@ | |
| data-category="{{ package.category }}" | ||
| data-langs="{% if package.langs %}{% for lang in package.langs %}{{ lang.alpha_3 }} {% endfor %}{% endif %}" | ||
| data-name="{{ package.title }}" | ||
| data-size="{% if package.download and package.download.size %}{{ package.download.size }}{% else %}0{% endif %}"> | ||
| data-size="{% if package.download and package.download.size %}{{ package.download.size }}{% else %}0{% endif %}" | ||
| data-desc="{{ package.description|default('')|escape }}" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See comment above |
||
| > | ||
|
|
||
| <div | ||
| data-tip="{{ package.title }}" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -67,6 +67,7 @@ | |
| data-langs="{% if package.langs %}{% for lang in package.langs %}{{ lang.alpha_3 }} {% endfor %}{% endif %}" | ||
| data-name="{{ package.title }}" | ||
| data-size="{% if package.download and package.download.size %}{{ package.download.size }}{% else %}0{% endif %}" | ||
| data-desc="{{ package.description|default('')|escape }}" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See comment above |
||
| > | ||
| <div class=" | ||
| flex | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename to
only_patternwhich is more clear