I’ve got a search function working right now on pulling from a dataset on site, but right now it’s pulling from every character application on site whether there’s a faceclaim name filling that spot or not. This has led to an enormous gap in my scroll of just empty space from all the blanks in the applications not using them.
a scrollbar with plenty of space and no listed items
the same scrollbar scrolled 60% down to where the alphabetical order begins
The search function code is below:
function getFaceClaims() {
$.get(
"/index.php?act=Members&max_results=1000&sort_key=joined&sort_order=asc",
function (data) {
var doc = new DOMParser().parseFromString(data, "text/html");
var faces = $(
".grabbyhands:not(.g_3):not(.g_4):not(.g_5):not(.g_10)",
doc
);
var sortedFaces = [];
faces.each(function () {
let $this = $(this);
let $charprofile = $this.find(".whodafuk");
sortedFaces.push([$charprofile.text(), $charprofile]);
});
sortedFaces.sort(function (a, b) {
return a[0].localeCompare(b[0]);
});
sortedFaces.forEach(function (face) {
$("#faceclaimgods").append(face[1]);
});
$("#scanning").on("input", function () {
var searchFaces = $(this).val().toLowerCase();
sortedFaces.forEach(function (face) {
var $charprofile = face[1];
var faceclaim = face[0].toLowerCase();
if (faceclaim.includes(searchFaces)) {
$charprofile.show();
} else {
$charprofile.hide();
}
});
});
}
);
}
getFaceClaims();
I’ve tried a couple of .trim()’s to remove blank spaces but that kills the code entirely. I’m still learning JavaScript/JQuery and most of my stuff is scavenged from around the internet and piecemealed together with the knowledge I do have so I’d love to learn along the way the why of something working when suggestions are made! This code was scraped from my friend’s first iteration so it’s the ultimate Frankenstein at the moment, so other feedback in terms of order of processes or cleaning it up are also welcome. Thank you! ( :
Experimental Error is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.