Skip to content
Open
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
2 changes: 1 addition & 1 deletion _includes/body.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<p class="no-results">{{ site.data.trans[page.lang].noresults }} <a href='https://github.com/jdm-contrib/jdm'>{{ site.data.trans[page.lang].noresultshelp }}</a>.</p>

{% for entry in site.data.sites %}
<section class="site-block {{ entry.difficulty }}"{% if entry.meta == 'popular' %} data-popular{% endif %}>
<section class="site-block {{ entry.difficulty }}"{% if entry.meta == 'popular' %} data-popular{% endif %}{% if entry.domains %} data-domains='{{ entry.domains | jsonify }}'{% endif %}>
{% capture lang_url %}url_{{ page.lang }}{% endcapture %}
<a class="site-header" href="{% if entry[lang_url] %}{{ entry[lang_url] }}{% else %}{{entry.url}}{% endif %}">
<span class="name">{{ entry.name }}</span>
Expand Down
20 changes: 18 additions & 2 deletions assets/js/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,26 @@ $(function(){
var siteHeader = $(this).find(".site-header")[0];
var siteTitle = siteHeader.innerText.trim().toLowerCase();
var siteUrl = siteHeader.href.toLowerCase();
var siteDomains = $(this).data("domains") || [];
var lowerTerm = term.toLowerCase();
var normalizedDomains = siteDomains.map(function(domain) {
return domain.toLowerCase();
});

var startsWithDomain = normalizedDomains.some(function(domain) {
return domain.indexOf(lowerTerm) === 0;
});

if (startsWithDomain) {
return false;
}

var domainMatch = normalizedDomains.some(function(domain) {
return domain.indexOf(lowerTerm) !== -1;
});

// returns true if lowerTerm isn't found in site title or URL
return Math.max(siteTitle.indexOf(lowerTerm), siteUrl.indexOf(lowerTerm)) === -1;
// returns true if lowerTerm isn't found in site title or URL or domains
return siteTitle.indexOf(lowerTerm) === -1 && siteUrl.indexOf(lowerTerm) === -1 && !domainMatch;
});

// Insert the term into the search field
Expand Down
Loading