additional checks for when the faculty count is less than the default page size

This commit is contained in:
tworrall 2013-05-08 15:59:25 -04:00
parent 06c7dcfabd
commit 71d21c4999

View file

@ -23,7 +23,13 @@ $(document).ready(function(){
var rowStart = Math.floor((Math.random()*facultyMemberCount)+1)-1; var rowStart = Math.floor((Math.random()*facultyMemberCount)+1)-1;
var diff; var diff;
var pageSize = 4; // the number of faculty to display on the home page var pageSize = 4; // the number of faculty to display on the home page
if ( facultyMemberCount < 5 ) {
pageSize = facultyMemberCount;
}
else {
pageSize = 4; // our default number; could have fewer than 4 in a test or dev environment
}
// in case the random number is equal to or within 3 of the facultyMemberCount // in case the random number is equal to or within 3 of the facultyMemberCount
if ( (rowStart + (pageSize-1)) > facultyMemberCount ) { if ( (rowStart + (pageSize-1)) > facultyMemberCount ) {
diff = (rowStart + (pageSize-1)) - facultyMemberCount; diff = (rowStart + (pageSize-1)) - facultyMemberCount;
@ -34,6 +40,9 @@ $(document).ready(function(){
rowStart = rowStart - diff; rowStart = rowStart - diff;
} }
} }
if ( rowStart < 0 ) {
rowStart = 0;
}
var dataServiceUrl = urlsBase + "/dataservice?getRandomSolrIndividualsByVClass=1&vclassId="; var dataServiceUrl = urlsBase + "/dataservice?getRandomSolrIndividualsByVClass=1&vclassId=";
var url = dataServiceUrl + encodeURIComponent("http://vivoweb.org/ontology/core#FacultyMember"); var url = dataServiceUrl + encodeURIComponent("http://vivoweb.org/ontology/core#FacultyMember");