From 2fe37e551a84339dc2e5a9ac3a972d6ad3cb3d00 Mon Sep 17 00:00:00 2001 From: hudajkhan Date: Fri, 15 Nov 2013 16:28:24 -0500 Subject: [PATCH] updating department display on home page to not repeat index and removing some spaces in the research category uri checks --- productMods/js/homePageUtils.js | 22 +++++++++++++++---- .../freemarker/lib/lib-home-page.ftl | 2 +- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/productMods/js/homePageUtils.js b/productMods/js/homePageUtils.js index 1be45d5b..1341292b 100644 --- a/productMods/js/homePageUtils.js +++ b/productMods/js/homePageUtils.js @@ -123,11 +123,25 @@ $(document).ready(function(){ + i18nStrings.noDepartmentsFound + "

"; } else if ( deptNbr > 6 ) { - for ( var i=0;i<6;i++) { - html += "
  • " - + academicDepartments[index].name + "
  • "; + //if there are more than 6 departments, we want to choose a random subset and display + //and also to make sure the same department is not repeated twice + var indicesUsed = {};//utilizing a hash since easier + var indicesCount = 0; + while(indicesCount < 6) { index = Math.floor((Math.random()*deptNbr)+1)-1; + //if the index has already been used, this will be true + var indexFound = (index in indicesUsed); + //Check to see if this index hasn't already been employed + if(!indexFound) { + //if this index hasn't already been employed then utilize it + html += "
  • " + + academicDepartments[index].name + "
  • "; + //add this index to the set of already used indices + indicesUsed[index] = true; + //keep count + indicesCount++; + } } } else { diff --git a/productMods/templates/freemarker/lib/lib-home-page.ftl b/productMods/templates/freemarker/lib/lib-home-page.ftl index 7235a394..21596902 100644 --- a/productMods/templates/freemarker/lib/lib-home-page.ftl +++ b/productMods/templates/freemarker/lib/lib-home-page.ftl @@ -125,7 +125,7 @@ <#if (group.individualCount > 0) && group.displayName == "research" > <#assign foundClassGroup = true /> <#list group.classes as class> - <#if (class.individualCount > 0) && (class.uri?contains("Academic Article") || class.uri?contains("Book") || class.uri?contains("Chapter") ||class.uri?contains("Conference Paper") || class.uri?contains("Proceedings") || class.uri?contains("Report")) > + <#if (class.individualCount > 0) && (class.uri?contains("AcademicArticle") || class.uri?contains("Book") || class.uri?contains("Chapter") ||class.uri?contains("ConferencePaper") || class.uri?contains("Proceedings") || class.uri?contains("Report")) >
  • ${class.individualCount!}