Skip to content
GitLab
Menu
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Velibor Najdovski
BrainsterProjects_VeliborNajdovski_FullStack14
Commits
1e18c3c3
Commit
1e18c3c3
authored
11 months ago
by
Velibor Najdovski
Browse files
Options
Download
Email Patches
Plain Diff
Removed filter logic from index.php and put it in a separate javascript file bookFilter.js
parent
8734a41e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bookFilter.js
+22
-0
bookFilter.js
index.php
+1
-25
index.php
with
23 additions
and
25 deletions
+23
-25
bookFilter.js
0 → 100644
+
22
-
0
View file @
1e18c3c3
let
selectedCategories
=
new
Set
();
function
filterBooks
(
categoryId
,
element
)
{
categoryId
=
categoryId
.
toString
();
if
(
selectedCategories
.
has
(
categoryId
))
{
selectedCategories
.
delete
(
categoryId
);
element
.
classList
.
remove
(
element
.
getAttribute
(
'
data-bg-color
'
));
element
.
classList
.
add
(
'
bg-white
'
);
}
else
{
selectedCategories
.
add
(
categoryId
);
element
.
classList
.
remove
(
'
bg-white
'
);
element
.
classList
.
add
(
element
.
getAttribute
(
'
data-bg-color
'
));
}
const
books
=
document
.
querySelectorAll
(
'
.book-card
'
);
books
.
forEach
(
book
=>
{
if
(
selectedCategories
.
size
===
0
||
selectedCategories
.
has
(
book
.
getAttribute
(
'
data-category
'
)))
{
book
.
style
.
display
=
''
;
}
else
{
book
.
style
.
display
=
'
none
'
;
}
});
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
index.php
+
1
-
25
View file @
1e18c3c3
...
...
@@ -80,31 +80,7 @@
</div>
</footer>
<script
src=
"footer.js"
></script>
<script>
let
selectedCategories
=
new
Set
();
function
filterBooks
(
categoryId
,
element
)
{
categoryId
=
categoryId
.
toString
();
if
(
selectedCategories
.
has
(
categoryId
))
{
selectedCategories
.
delete
(
categoryId
);
element
.
classList
.
remove
(
element
.
getAttribute
(
'
data-bg-color
'
));
element
.
classList
.
add
(
'
bg-white
'
);
}
else
{
selectedCategories
.
add
(
categoryId
);
element
.
classList
.
remove
(
'
bg-white
'
);
element
.
classList
.
add
(
element
.
getAttribute
(
'
data-bg-color
'
));
}
const
books
=
document
.
querySelectorAll
(
'
.book-card
'
);
books
.
forEach
(
book
=>
{
if
(
selectedCategories
.
size
===
0
||
selectedCategories
.
has
(
book
.
getAttribute
(
'
data-category
'
)))
{
book
.
style
.
display
=
''
;
}
else
{
book
.
style
.
display
=
'
none
'
;
}
});
}
</script>
<script
src =
"bookFilter.js"
></script>
</body>
</html>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets