From 71d21c4999634b51ebcc7f7b26a312d56e243918 Mon Sep 17 00:00:00 2001 From: tworrall Date: Wed, 8 May 2013 15:59:25 -0400 Subject: [PATCH] additional checks for when the faculty count is less than the default page size --- productMods/js/homePageUtils.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/productMods/js/homePageUtils.js b/productMods/js/homePageUtils.js index cdf2cd1a..d50dd0ac 100644 --- a/productMods/js/homePageUtils.js +++ b/productMods/js/homePageUtils.js @@ -23,7 +23,13 @@ $(document).ready(function(){ var rowStart = Math.floor((Math.random()*facultyMemberCount)+1)-1; var diff; 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 if ( (rowStart + (pageSize-1)) > facultyMemberCount ) { diff = (rowStart + (pageSize-1)) - facultyMemberCount; @@ -34,6 +40,9 @@ $(document).ready(function(){ rowStart = rowStart - diff; } } + if ( rowStart < 0 ) { + rowStart = 0; + } var dataServiceUrl = urlsBase + "/dataservice?getRandomSolrIndividualsByVClass=1&vclassId="; var url = dataServiceUrl + encodeURIComponent("http://vivoweb.org/ontology/core#FacultyMember");