Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tjchambers/e150acfccfac1e94fbcd99c43a4cc5c7 to your computer and use it in GitHub Desktop.
Save tjchambers/e150acfccfac1e94fbcd99c43a4cc5c7 to your computer and use it in GitHub Desktop.
searchable logic
/**
* Created by tj on 12/26/14.
*/
function ds(text) {
searchless(text);
$('.searchable').each(function () {
if (text.length < 2 || $(this).html().replace(/<\/?[^>]+>/gi, '|').search(r) >= 0) {
$(this).show();
} else {
$(this).hide();
}
});
$(".CLRow").each(function () {
$(this).show();
if ($(this).children("table").children("tbody").children(":visible").length <= 0) {
$(this).hide()
} else {
$(this).show();
}
});
}
function searchless(text) {
r = new RegExp(text, "i");
if (text.length > 1) {
$('.searchless').hide();
} else {
$('.searchless').show();
}
}
function dsc(text) {
searchless(text);
$('.searchable').each(function () {
if (text.length < 2 || $(this).html().replace(/<\/?[^>]+>/gi, '|').search(r) >= 0) {
$(this).show();
this.childNodes[0].childNodes[0].disabled = false;
} else {
$(this).hide();
this.childNodes[0].childNodes[0].disabled = true;
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment