Skip to content

Commit

Permalink
Filter HTML Content with Javascript 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabian Gärtner committed Jul 5, 2017
1 parent 9b9b27d commit 83157f4
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 48 deletions.
58 changes: 28 additions & 30 deletions Tutorial/06 Filter HTML Content with Javascript/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,15 @@ def write_prologue(self):
"""

head = """
<script src="mixitup.min.js"></script>
<script src="jquery-3.2.1.min.js"></script>
<script type="text/javascript">
{javascript}
</script>
"""
#js = """
#//empty
#"""

js = """
//empty
"""

#js = """
#$(function(){
Expand All @@ -166,43 +166,41 @@ def write_prologue(self):

#js = """
#$(function(){
# var mixer = mixitup('#content')
# search = $(".filter-input input[type='search']")
# search.keyup(function(){
# inputText = search.val().toLowerCase()
# matchings = []
# $('.mix').each(function() {
# if($(this).text().toLowerCase().match(inputText) ) {
# matchings.push(this)
# $(this).show()
# }
# else {
# $(this).hide()
# }
# });
# mixer.filter(matchings)
# })
#})
#"""

js = """
checkY = function(){
$('.year').each(function() {
if ($("."+$(this).text()+ ".mix").is(":visible")) $(this).show()
else $(this).hide()
});
}
$(function(){
var mixer = mixitup('#content')
search = $(".filter-input input[type='search']")
search.keyup(function(){
inputText = search.val().toLowerCase()
matchings = []
$('.mix').each(function() {
if($(this).text().toLowerCase().match(inputText) ) {
matchings.push(this)
}
});
mixer.filter(matchings,checkY)
})
})
"""
#js = """
#$(function(){
# search = $(".filter-input input[type='search']")
# search.keyup(function(){
# inputText = search.val().toLowerCase()
# $('.mix').each(function() {
# if($(this).text().toLowerCase().match(inputText) ) {
# $(this).show()
# }
# else {
# $(this).hide()
# }
# });
# $('.year').each(function() {
# if ($("."+$(this).text()+ ".mix").is(":visible")) $(this).show()
# else $(this).hide()
# });
# })
#})
#"""

head = head.format(javascript= js)

Expand Down

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion Tutorial/06 Filter HTML Content with Javascript/out_1.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Bibliography</title>

<script src="mixitup.min.js"></script>
<script src="jquery-3.2.1.min.js"></script>
<script type="text/javascript">

Expand Down
1 change: 0 additions & 1 deletion Tutorial/06 Filter HTML Content with Javascript/out_2.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Bibliography</title>

<script src="mixitup.min.js"></script>
<script src="jquery-3.2.1.min.js"></script>
<script type="text/javascript">

Expand Down
9 changes: 4 additions & 5 deletions Tutorial/06 Filter HTML Content with Javascript/out_3.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,21 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Bibliography</title>

<script src="mixitup.min.js"></script>
<script src="jquery-3.2.1.min.js"></script>
<script type="text/javascript">

$(function(){
var mixer = mixitup('#content')
search = $(".filter-input input[type='search']")
search.keyup(function(){
inputText = search.val().toLowerCase()
matchings = []
$('.mix').each(function() {
if($(this).text().toLowerCase().match(inputText) ) {
matchings.push(this)
$(this).show()
}
else {
$(this).hide()
}
});
mixer.filter(matchings)
})
})

Expand Down
19 changes: 8 additions & 11 deletions Tutorial/06 Filter HTML Content with Javascript/out_4.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,25 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Bibliography</title>

<script src="mixitup.min.js"></script>
<script src="jquery-3.2.1.min.js"></script>
<script type="text/javascript">

checkY = function(){
$('.year').each(function() {
if ($("."+$(this).text()+ ".mix").is(":visible")) $(this).show()
else $(this).hide()
});
}
$(function(){
var mixer = mixitup('#content')
search = $(".filter-input input[type='search']")
search.keyup(function(){
inputText = search.val().toLowerCase()
matchings = []
$('.mix').each(function() {
if($(this).text().toLowerCase().match(inputText) ) {
matchings.push(this)
$(this).show()
}
else {
$(this).hide()
}
});
$('.year').each(function() {
if ($("."+$(this).text()+ ".mix").is(":visible")) $(this).show()
else $(this).hide()
});
mixer.filter(matchings,checkY)
})
})

Expand Down

0 comments on commit 83157f4

Please sign in to comment.