mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-23 17:27:19 +00:00
Issue 2310: Release filter on component page (#2646)
* * removed duplicated code * give the search field focus on page load for faster interaction * introduced filter-by-version
This commit is contained in:
parent
9a73e00636
commit
14109cf5c3
@ -36,9 +36,9 @@ Support for these components is provided by the Home Assistant community.
|
||||
<div class="filter-button-group">
|
||||
<a href='#all' class="btn">All ({{tot}})</a>
|
||||
<a href='#featured' class="btn featured">Featured</a>
|
||||
<a href='#added_in_current_version' class="btn added_in_current_version">Added in {{ current_version }} ({{ current_version_components_count }})</a>
|
||||
<a href='#added_one_version_ago' class="btn added_one_version_ago">Added in {{ added_one_ago_version }} ({{ one_ago_version_components_count }})</a>
|
||||
<a href='#added_two_versions_ago' class="btn added_two_versions_ago">Added in {{ added_two_ago_version }} ({{ two_ago_version_components_count }})</a>
|
||||
<a href='#version/{{ current_version }}' class="btn added_in_current_version">Added in {{ current_version }} ({{ current_version_components_count }})</a>
|
||||
<a href='#version/{{ added_one_ago_version }}' class="btn added_one_version_ago">Added in {{ added_one_ago_version }} ({{ one_ago_version_components_count }})</a>
|
||||
<a href='#version/{{ added_two_ago_version }}' class="btn added_two_versions_ago">Added in {{ added_two_ago_version }} ({{ two_ago_version_components_count }})</a>
|
||||
|
||||
{% for category in categories %}
|
||||
{% if category and category != 'Other' %}
|
||||
@ -87,16 +87,14 @@ Support for these components is provided by the Home Assistant community.
|
||||
{% endraw %}
|
||||
|
||||
<script type="text/javascript">
|
||||
var current_minor_version = {{site.current_minor_version}};
|
||||
var added_one_ago_minor_version = {{added_one_ago_minor_version}};
|
||||
var added_two_ago_minor_version = {{added_two_ago_minor_version}};
|
||||
// This object contains all components we have
|
||||
var allComponents = [
|
||||
{% for component in components %}
|
||||
{% if component.ha_category %}
|
||||
{% assign sliced_version = component.ha_release | split: '.' %}
|
||||
{% assign minor_version = sliced_version[1]|plus: 0 %}
|
||||
{url:"{{ component.url }}", title:"{{component.title}}", cat:"{{component.ha_category | slugify}}", featured: {% if component.featured %}true{% else %}false{% endif %}, v: {{minor_version}}, logo: "{{component.logo}}"},
|
||||
{% assign major_version = sliced_version[0]|plus: 0 %}
|
||||
{url:"{{ component.url }}", title:"{{component.title}}", cat:"{{component.ha_category | slugify}}", featured: {% if component.featured %}true{% else %}false{% endif %}, v: "{{major_version}}.{{minor_version}}", logo: "{{component.logo}}"},
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
false
|
||||
@ -175,15 +173,11 @@ allComponents.pop(); // remove placeholder element at the end
|
||||
return comp.featured;
|
||||
};
|
||||
|
||||
} else if(hash === '#added_in_current_version' || hash === '#added_one_version_ago' || hash === '#added_two_versions_ago') {
|
||||
} else if(hash.indexOf('#version/') === 0) {
|
||||
// compare against a version
|
||||
search = current_minor_version;
|
||||
if (hash === '#added_one_version_ago') {
|
||||
search = added_one_ago_minor_version;
|
||||
} else if (hash === '#added_two_versions_ago') {
|
||||
search = added_two_ago_minor_version;
|
||||
}
|
||||
search = decodeURIComponent(hash).substring(9).toLowerCase();
|
||||
filter = function(comp) {
|
||||
// compare version string against version js
|
||||
return comp.v === search;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user