This question is based on this Question/Answer: Filter accurately with BOTH checkboxes AND dropdown menus at the same time
Hi!
(NOTE, the simplified question and code is in the codepen or the snippet below, here I'm just explaining the context.)
Image of the simplified question, for which I actually need the answer:

My reference image PHP gallery is progressing nicely: https://manu.mymaterial.org (Watch out, it includes NSFW material, Fine Art painting by Andrew Loomis, in the front page ATM.)
And that brings me to this question.
How can I have that "Display NSFW material" to NOT show ANY of the images that have the NSFW tag in them when the "Display NSFW material" checkbox is UNCHECKED, no matter what other filtering options I do?
I have a feeling that it is a simple if-statement in Javascript, but I'm uncertain where to put it exactly and if it breaks other things.
At the moment the NSFW checkbox displays ONLY the NSFW material (yellow box) and nothing else. This is not desired.
So, in other words, I have tags for all of the material to be shown in various ways - but now the NSFW tag should HIDE stuff when included into a div. Or in my case, it's just an image file that gets processed by PHP and into a div: Andrew_Loomis; Traditional_Characters_Realistic_Color_NSFW.jpg
Codepen project: https://codepen.io/manujarvinen/pen/wvdzeQv
Thank you all, this is a fine place.
var $filterCheckboxes = $('input[type="checkbox"]');
var $filtermenues = $('.grid1');
var filterFunc = function () {
var selectedFilters = [];
$filtermenues.find(":selected").each(function () {
var v = this.value;
if (selectedFilters.indexOf(v) === -1 && v)
selectedFilters.push(v);
});
$('.animal' && '.filterDiv')
.hide()
.filter(
function (_, a) {
var itemCat = $(a).data('category').split(' ');
if (itemCat.indexOf("showAll") > -1)
return;
return selectedFilters.every(
function (c) {
return itemCat.indexOf(c) > -1;
})
})
.show();
$filterCheckboxes.filter(':checked').each(function () {
var v = this.value;
if (selectedFilters.indexOf(v) === -1)
selectedFilters.push(v);
});
$('.animal' && '.filterDiv')
.hide()
.filter(
function (_, a) {
var itemCat = $(a).data('category').split(' ');
return selectedFilters.every(
function (c) {
return itemCat.indexOf(c) > -1;
})
})
.show();
}
$filterCheckboxes.on('change', filterFunc);
$('select').on('change', filterFunc);
body {
width: 100%;
text-align: center;
background-color: black;
color: white;
font-family: sans-serif;
}
.grid {
width: 300px;
margin: 50px auto;
display: grid;
grid-template-columns: 1fr 1fr 1fr;
}
.grid1 {
width: 300px;
margin: 50px auto;
display: grid;
grid-template-columns: 1fr 1fr 1fr;
}
.filterDiv {
width: 100px;
height: 100px;
padding-top: 20px;
color: black;
font-weight: bold;
}
<!-- Help needed in this URL: https://stackoverflow.com/q/68334085/4383420 -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class=grid1>
<select>
<option value="">--</option>
<option value="violet">violet</option>
</select>
<select>
<option value="">--</option>
<option value="blue">blue</option>
</select>
<select>
<option value="">--</option>
<option value="yellow">yellow</option>
</select>
</div>
<div class=grid>
<label>VIOLET
<input type="checkbox" value="violet" />
<span class="checkmark"></span>
</label>
<label>BLUE
<input type="checkbox" value="blue" />
<span class="checkmark"></span>
</label>
<label>YELLOW
<input type="checkbox" value="yellow" />
<span class="checkmark"></span>
</label>
</div>
<div class=grid>
<div class="filterDiv" data-category="violet blue" style="background-color: blue">Tags: <br />violet <br />blue</div>
<div class="filterDiv" data-category="violet red MVP" style="background-color: red">Tags: <br />violet <br />red <br />MVP</div>
<div class="filterDiv" data-category="yellow NSFW MVP" style="background-color: yellow">Tags: <br />yellow <br />NSFW<br />MVP</div>
</div>
<div>
<label>Most Valuable Players (MVP)
<input type="checkbox" value="MVP" />
<span class="checkmark"></span>
</label>
</div>
<div>
<label>Display NSFW material also
<input type="checkbox" value="NSFW" />
<span class="checkmark"></span>
</label>
</div>
<div style="width:400px; text-align: left; margin: 60px auto;">
What I need:
<p>By default, NSFW material checkbox is OFF and YELLOW shouldn't be seen at all in ANY situation.</p>
<p>When NSFW material checkbox is checked, ALSO YELLOW should be seen, but follow rest of the rules.</p>
</div>
