diff --git a/_includes/overview.html b/_includes/overview.html index a760330e5f8b9c9c96a0924eed7ef35bb207e4ee..f35ac540e90ae59dd4aab2b148d4fe247671cdd9 100644 --- a/_includes/overview.html +++ b/_includes/overview.html @@ -10,9 +10,9 @@ {% for c in cat %} {% capture ID %}{{ site.data.categories[c].ID }}{% endcapture %} - <li class="li-tags li-tag-{{ID}}" title="{{ ID }}" onclick="get_by_tag(['{{ID}}'])">{{ site.data.categories[c].title[include.ln] }} [{{ site.tags[ID] | size }}]</li> + <li class="li-tags li-tag-{{ID}}" title="{{ ID }}" onclick="getByTag(['{{ID}}'])">{{ site.data.categories[c].title[include.ln] }} [{{ site.tags[ID] | size }}]</li> {% for tag in site.data.categories[c].Tags %} - <tags class="li-subtags li-subtag-of-{{ID}} d-none li-tag-{{tag[0]}}" title="{{ tag[0] }}" onclick="get_by_tag(['{{ID}}', '{{tag[0]}}'])"><span class="feather-icon icon-tag"></span>{{ tag[1] | map: include.ln }}</tags> + <tags class="li-subtags li-subtag-of-{{ID}} d-none li-tag-{{tag[0]}}" title="{{ tag[0] }}" onclick="getByTag(['{{ID}}', '{{tag[0]}}'])"><span class="feather-icon icon-tag"></span>{{ tag[1] | map: include.ln }}</tags> {% endfor %} {% endfor %} </ul> @@ -45,7 +45,7 @@ <a href="{{ o.git-repo }}/blob/master/{{ o.order-title }}" target="git-order"><u>{{ o.headline | truncate: 32 }}</u></a> <a href="{{ o.git-profile }}" target="git-profile"><span class="feather-icon icon-user"></span></a> <a href="{{ o.git-repo }}/issues/new?issue[title]={{ o.order-title }}" target="git-contact"><span class="feather-icon icon-mail"></span></a><br> <small><lang><span class="feather-icon icon-tag"></span>{{ o.language-code }}</lang> <a href="https://www.latlong.net/c/?lat={{ o.latitude }}&long={{ o.longitude }}" target="latlong" title="latitude:{{ o.latitude }} | longitude: {{ o.longitude }}"><span class="d-none distance-data">{{ o.latitude }},{{ o.longitude }},{{ o.country-code }}</span> <span class="distance"></span></a> <used><span class="feather-icon icon-tag"></span>{{ o.condition }}</used> {% for tag in o.tags %} - <tags class="li-tags li-tag-{{ tag }} clickable" title="{{ tag }}" onclick="get_by_tag( ['{{ o.tags[0] }}', '{{ tag }}'] )"><span class="feather-icon icon-tag"></span> + <tags class="li-tags li-tag-{{ tag }} clickable" title="{{ tag }}" onclick="getByTag( ['{{ o.tags[0] }}', '{{ tag }}'] )"><span class="feather-icon icon-tag"></span> {% if forloop.index == 1 %} {{ site.data.categories | map: o.tags[0] | map: "title" | map: include.ln }} {% else %} @@ -68,6 +68,6 @@ </div> <script> $( document ).ready(function() { - get_distances_tags(); + getDistancesTags(); }); </script> diff --git a/assets/js/script.js b/assets/js/script.js index c7811e0363fdce1b22ec63df94f05f88ce9238ce..474185e7fd8667887cc20d0d00a96abe3f457f2d 100644 --- a/assets/js/script.js +++ b/assets/js/script.js @@ -16,28 +16,35 @@ function deg2rad(deg) { return deg * (Math.PI/180) } -function get_by_tag(tags){ +function getByTag(tags){ - $('.orderlist-div').toggleClass('d-none',true); - $('.li-tags').toggleClass('active', false ); - $('.li-subtags').toggleClass('active', false ).toggleClass('d-none',true); + if( tags[0] == undefined ){ + $('.orderlist-div').toggleClass('d-none',false); + var tag=''; + var subtag=''; + } else { + $('.orderlist-div').toggleClass('d-none',true); + $('.li-tags').toggleClass('active', false ); + $('.li-subtags').toggleClass('active', false ).toggleClass('d-none',true); - var tag_class=''; + var tag_class=''; - tags.forEach( - function(v,i){ - tag_class+='.tag-'+v; - $('.li-tag-'+v).toggleClass('active',true); - $('.li-subtag-of-'+v).toggleClass('d-none', false); - } - ); + tags.forEach( + function(v,i){ + tag_class+='.tag-'+v; + $('.li-tag-'+v).toggleClass('active',true); + $('.li-subtag-of-'+v).toggleClass('d-none', false); + } + ); - $(tag_class).toggleClass('d-none',false); + $(tag_class).toggleClass('d-none',false); + var tag=tags[0]; + var subtag=tags[1]; + } var p=['tag','subtag','lat','long']; - var tag=tags[0]; - var subtag=tags[1]; + var lat=undefined; var long=undefined; @@ -50,14 +57,17 @@ function get_by_tag(tags){ } else { var pp=getQueryVariable(v); } - if( pp != undefined ) param.push(v + '='+pp); + if( pp != undefined ){ + if( pp != '' ){ + param.push(v + '='+pp); + } + } } ); - ChangeUrl( '', (( param != '' ) ? '?' : '' )+param.join('&') ); } -function get_distances_tags(){ +function getDistancesTags(){ var url_string = window.location.href; var url = new URL(url_string); @@ -66,7 +76,7 @@ function get_distances_tags(){ var tag = url.searchParams.get('tag'); var subtag = url.searchParams.get('subtag'); - get_by_tag([ tag, subtag ]); + getByTag([ tag, subtag ]); if( lat == null || long == null ){ lat=-100; @@ -153,7 +163,9 @@ function getQueryVariable(variable) } function ChangeUrl(page, query ) { - console.log( query ); + if( query == '' ){ + query=window.location.pathname; + } if (typeof (history.replaceState) != "undefined") { var obj = { Page: page, Url: query }; history.replaceState(obj, obj.Page, obj.Url);