Skip to content
This repository has been archived by the owner on Sep 2, 2024. It is now read-only.

Commit

Permalink
added tag searching functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
Sectimus committed Dec 20, 2019
1 parent 04b93f8 commit 77839ef
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 8 deletions.
2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ <h4 class="over card-text lead pb-2" style="display:inline-block; ">
<div class="tags flex-wrap d-flex">

{{#tags}}
<span class="tag over px-1"><a href="/view/talks/tags/{{.}}" class="badge badge-primary tag" data-toggle="tooltip" data-placement="top" title="{{.}}">{{.}}</a></span>
<span class="tag over px-1"><a talk="tag" href="/view/talks/tags/{{.}}" class="badge badge-primary tag" data-toggle="tooltip" data-placement="top" title="{{.}}">{{.}}</a></span>
{{/tags}}
<span class="new over px-1">
<form class="input-group mb-3" for="newtags" action="/talks/tag/{{id}}" method="post" style="display:none;">
Expand Down
38 changes: 31 additions & 7 deletions public/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ $(document).ready(function() {
});
//load the page by url
loadByUrl();
//setup the filters
setupFilters();
});

Expand All @@ -323,12 +324,6 @@ function setupFilters() {
//check which filter is active
switch (shownFilter.attr("filter")) {
case "talks": {
//filter speaker

//filter session

//filter tags

//sort by
$(this)
.serializeArray()
Expand Down Expand Up @@ -357,7 +352,36 @@ function setupFilters() {
case "session": {
break;
}
case "tag": {
case "tags": {
//if the tag is wanting to be searched
if (formdata.value) {
//split the tags
var tags = formdata.value.split(",");
//for each element
content.forEach(element => {
element = $(element);
var $tags = element.find("[talk='tag']");
//for each tag element that is being searched
var found = false;
$tags.each(function() {
//for each tag the user entered

tags.forEach(tag => {
if (
$(this)
.text()
.toLowerCase()
.trim() == tag.toLowerCase().trim()
) {
found = true;
}
});
});
if (!found) {
element.hide();
}
});
}
break;
}
case "sort": {
Expand Down

0 comments on commit 77839ef

Please sign in to comment.