angular.module("knimbusLib").controller("SearchResultCtrl",function($scope,$http,$uibModal,$location,PromiseAjax,$routeParams,$cookieStore,$window,$rootScope,$filter,$interval){$(document).ready(function(){$(document).scrollTop(185)});$scope.contentTypeCountForSrc=[];if(sessionStorage.searchQuery==undefined&&$location.search().category==null)$location.path("/home");else if($location.search().category!=null){if(sessionStorage.searchQuery!=null)$scope.sourceQuery=JSON.parse(sessionStorage.searchQuery);
if(!($scope.sourceQuery!=null&&$scope.sourceQuery.category=="Content Type"&&$location.search().category=="content"&&$scope.sourceQuery.searchTermFilter==$location.search().searchId))$rootScope.accessLandingPage($location.search().category,$location.search().searchId,$location.search().sectionId)}var pubList={"IEEE":"PUB_1","Proquest":"PUB_10","EBSCO":"PUB_11","RSC":"PUB_12","Sage":"PUB_13","Taylor and Francis":"PUB_14","ASTM":"PUB_16","SIAM":"PUB_17","Oxford University Press":"PUB_18","Annual Reviews":"PUB_19",
"Cambridge University Press":"PUB_2","APS":"PUB_20","ASCE":"PUB_21","ASME":"PUB_22","ACM Digital Library":"PUB_23","AIP":"PUB_24","ACS":"PUB_25","Nature Publishing Groups":"PUB_26","Optical Society of America":"PUB_27","Emerald":"PUB_3","IOP":"PUB_4","Science Direct":"PUB_5","Springer":"PUB_6","Wiley":"PUB_7","World Scientific":"PUB_8","JSTOR":"PUB_9","Knimbus Open Journals":"PUB_02","Knimbus Open ebooks":"PUB_01","eBooks Premium":"PUB_03"};$scope.getPubImage=function(pubSource){return"ico_rect_"+
pubList[pubSource]};$scope.getPubImg=function(pubSource){return pubList[pubSource]};$scope.hasPubImage=function(pubSource){return pubList[pubSource]==null||pubList[pubSource]==undefined?false:true};$scope.getPubImageLV=function(pubSource){return"ico_LV_rect_"+pubList[pubSource]};$scope.landingPageDetail=sessionStorage.landingAssetsDetail!=null&&sessionStorage.landingAssetsDetail!=undefined?JSON.parse(sessionStorage.landingAssetsDetail):null;$rootScope.search=JSON.parse(sessionStorage.searchResults);
if((sessionStorage.searchPrimaryFieldResults!=null||sessionStorage.searchPrimaryFieldResults!="null")&&sessionStorage.searchPrimaryFieldResults!=undefined)$rootScope.searchPrimaryFieldResults=JSON.parse(sessionStorage.searchPrimaryFieldResults);$scope.resultType_val=JSON.parse(sessionStorage.result_type);if(JSON.parse(sessionStorage.searchKeyword))$scope.searchterm=JSON.parse(sessionStorage.searchKeyword);else if(!JSON.parse(sessionStorage.searchKeyword)&&$location.search().searchId&&JSON.parse(sessionStorage.searchQuery)["searchedFrom"]==
"searchBar"){sessionStorage.thirdpartySearchKey=$location.search().searchId;$scope.searchterm=$location.search().searchId}else if(!JSON.parse(sessionStorage.searchKeyword)&&$location.search().searchId==""&&JSON.parse(sessionStorage.searchQuery)["searchedFrom"]=="searchBar")$scope.searchterm=sessionStorage.thirdpartySearchKey;else $scope.searchterm="All Documents";$scope.sourceQuery=JSON.parse(sessionStorage.searchQuery);$scope.added_type=null;$scope.showMoreAuthorBlock=false;$rootScope.filterMap=
{};$scope.showMoreAuthorBlockSec=function(id){if(document.getElementById(id).classList.contains("ng-hide")){document.getElementById(id).classList.remove("ng-hide");window.setTimeout(function(){document.getElementById(id).classList.add("ng-hide")},1E4)}else document.getElementById(id).classList.add("ng-hide")};$scope.checkForOrgId=function(result){$scope.orgIdList=result;return result!=null&&$scope.orgIdList.indexOf($rootScope.orgId)!=-1?true:false};$scope.checkForConsortiumId=function(result){$scope.consortiumIdList=
result;var isConsortiumMapped=false;if(result!=null&&$rootScope.consotiumIds!=null)for(var i=0;i<$rootScope.consotiumIds.length;i++)isConsortiumMapped=isConsortiumMapped||($scope.consortiumIdList.indexOf($rootScope.consotiumIds[i])!=-1?true:false);return isConsortiumMapped};$scope.isIntranetIP=function(resultURL){var ip=resultURL.split("/")[2].split(".")[0];var isIpIntranet;if(ip=="10"||ip=="172"||ip=="192")isIpIntranet=true;else isIpIntranet=false;return isIpIntranet};$scope.showOpacInfoModal=function(){$("#offCampusOpacModal").modal("show")};
$scope.contentTypeCountFunction=function(){angular.forEach($scope.landingPageDetail,function(key,value){if(key.resultType!=null&&key.facetMap!=null)if($scope.contentTypeCountForSrc.length==0)angular.forEach(key.facetMap.source_type_code,function(fmRow){$scope.contentTypeCountForSrc.push(fmRow)});else{var flag=false;angular.forEach(key.facetMap.source_type_code,function(fmRow){for(var i=0;i<$scope.contentTypeCountForSrc.length;i++)if(fmRow.value==$scope.contentTypeCountForSrc[i].value){fmRow.count=
fmRow.count+$scope.contentTypeCountForSrc[i].count;$scope.contentTypeCountForSrc.splice(i,1);$scope.contentTypeCountForSrc.push(fmRow);flag=true;break}if(!flag)$scope.contentTypeCountForSrc.push(fmRow)})}})};$scope.sourcePageTabsAvailibility=function(){$scope.ecatalogData={};$scope.multimediaData={};$scope.sourceAccessTypeData={};$scope.sourceOpenDataAvailable=false;$scope.sourceSubscribedDataAvailable=false;$scope.ecatalogData=$scope.landingPageDetail.ecatalogSr.facetMap.publisher_source;if($scope.landingPageDetail.preIndexedSr!=
null&&$scope.landingPageDetail.preIndexedSr!=undefined)$scope.multimediaData=$scope.landingPageDetail.preIndexedSr.facetMap.publisher_source;$scope.sourceAccessTypeData=$scope.landingPageDetail.ecatalogSr.facetMap.access_type;angular.forEach($scope.sourceAccessTypeData,function(result){if(result.value=="Open"&&result.count>0)$scope.sourceOpenDataAvailable=true;if(result.value=="Subscribed"&&result.count>0)$scope.sourceSubscribedDataAvailable=true})};$scope.sourceTypeCodeToName=function(srcTypeCode){var sourceTypeCodeName=
"";switch(srcTypeCode){case "10":return sourceTypeCodeName="Library Holding";break;case "11":return sourceTypeCodeName="Journal";break;case "12":return sourceTypeCodeName="eBook";break;case "13":return sourceTypeCodeName="News";break;case "14":return sourceTypeCodeName="Course Material";break;case "15":return sourceTypeCodeName="Thesis";break;case "16":return sourceTypeCodeName="Presentation";break;case "17":return sourceTypeCodeName="Patent";break;case "18":return sourceTypeCodeName="Video";break;
case "19":return sourceTypeCodeName="Clinical Trial";break;case "20":return sourceTypeCodeName="Standard";break;case "21":return sourceTypeCodeName="Statistical Data";break;case "23":return sourceTypeCodeName="Job";break;case "24":return sourceTypeCodeName="Web Content";break;case "25":return sourceTypeCodeName="Dissertation";break;case "26":return sourceTypeCodeName="Project";break;case "27":return sourceTypeCodeName="Guide";break;case "30":return sourceTypeCodeName="Other";break;case "40":return sourceTypeCodeName=
"Proceeding";break;case "45":return sourceTypeCodeName="Case Study";break;case "50":return sourceTypeCodeName="Report";break;case "55":return sourceTypeCodeName="Database";break;case "60":return sourceTypeCodeName="Magazine";break;case "65":return sourceTypeCodeName="Question Paper";break;case "66":return sourceTypeCodeName="Dataset";break;case "100":return sourceTypeCodeName="Article";break;default:return sourceTypeCodeName="Other"}};$scope.readMoreLetterLimit=300;$scope.readMoreValue=true;$scope.readMoreToggle=
function(boxClass){if(boxClass=="opened"){$scope.readMoreValue=false;$scope.readMoreLetterLimit=1E11}else{$scope.readMoreValue=true;$scope.readMoreLetterLimit=300}};$scope.videoTypeCheck=function(results){if(results.source_type_name!=undefined&&results.source_type_name!=null&&results.source_type_name=="Video"&&results.publication_url!=undefined&&results.publication_url[0].indexOf("youtube")!=-1&&results.publication_url[0].indexOf("watch?v")!=-1||results.da_format!=undefined&&results.da_format[0]&&
results.da_format[0]=="video"&&results.publication_url!=undefined&&results.publication_url[0].indexOf("youtube")!=-1&&results.publication_url[0].indexOf("watch?v")!=-1||results.source_type_code!=undefined&&results.source_type_code[0]=="18"&&results.publication_url!=undefined&&results.publication_url[0].indexOf("youtube")!=-1&&results.publication_url[0].indexOf("watch?v")!=-1||results.source_type_code!=undefined&&results.source_type_code[0]=="18"&&results.publication_url!=undefined&&results.publication_url[0].indexOf("youtube")!=
-1&&results.publication_url[0].indexOf("embed")!=-1)return true;else return false};$rootScope.pubIdForRA="";$scope.fetchRaResources=function(pubId){$rootScope.pubIdForRA=pubId;$("#raModal").modal("show")};PromiseAjax.getData("/ws/getAllSection?orgId\x3d"+$rootScope.orgId,"GET").then(function(data){$rootScope.sectionTitleData=data}).catch(function(error){console.error("error: "+error)});$scope.isOpacRefreshRequired=true;$scope.initSearchPage=function(){$scope.selectSubjectOrPublisherCategory=$scope.sourceQuery.category==
"Subject"?"sub_category_name":$scope.sourceQuery.category=="Publisher"?"publisher_source":"";if($scope.sourceQuery.category=="Publisher"){$scope.contentTypeCountFunction();$scope.sourcePageTabsAvailibility()}angular.forEach($location.search(),function(key,value){if("searchId"!=value&&"curPage"!=value&&"layout"!=value&&"index"!=value&&"xIndex"!=value&&"_t"!=value&&"resultTab"!=value&&"itemTitle"!=value&&"topresult"!=value&&"sortFieldId"!=value&&"category"!=value&&"sectionId"!=value&&"sectionName"!=
value)angular.forEach(key.split(","),function(key1,value1){if($scope.filterMap[value]){var filter=$scope.filterMap[value];filter.value.push('"'+key1+'"')}else{var filter=new Filter(value,'"'+key1+'"');$scope.filterMap[value]=filter}})});$scope.tabArr=["ECATALOGUE_BASED","RSS_FEEDS","REAL_TIME","PRE_INDEXED","SECTION_CONTENT","OPAC_REAL_TIME"];$scope.tabSelectionstatus={};angular.forEach($rootScope.search,function(searchResult){if(searchResult!=""&&searchResult!=null&&searchResult.documentList.totalHits>
0||(searchResult.resultType=="REAL_TIME"||searchResult.resultType=="OPAC_REAL_TIME"))$scope.tabSelectionstatus[searchResult.resultType]=true;else $scope.tabSelectionstatus[searchResult.resultType]=false});var keepGoing=true;if(!$scope.tabSelectionstatus[$scope.resultType_val])angular.forEach($scope.tabArr,function(tabToSelect){if(keepGoing)if($scope.tabSelectionstatus[tabToSelect]){$scope.resultType_val=tabToSelect;sessionStorage.result_type=JSON.stringify($scope.resultType_val);keepGoing=false}});
$scope.curPage=$location.search().curPage==undefined?0:parseInt($location.search().curPage);$scope.layout=$location.search().layout!=undefined?$location.search().layout:$scope.resultType_val=="ECATALOGUE_BASED"||$scope.resultType_val=="PRE_INDEXED"||$scope.resultType_val=="SECTION_CONTENT"||$scope.resultType_val=="FI"?"grid":"list";$scope.itemTitle=$location.search().itemTitle==undefined?null:$location.search().itemTitle;$scope.topresult=$location.search().topresult==undefined?false:$location.search().topresult;
$scope.itemIndex=$location.search().index==undefined?null:parseInt($location.search().index);$rootScope.sectionName=$location.search().sectionName!=undefined?$location.search().sectionName:null;$rootScope.sectionId=$location.search().sectionId!=undefined?$location.search().sectionId:null;$scope.selectSubPubSourceTypeNameCategory=$scope.topresult==true||$scope.topresult=="true"?"source_type_name":null;$scope.sortFieldId=$location.search().sortFieldId==undefined?"none":$location.search().sortFieldId;
$scope.sectionPrimaryFiled=$scope.landingPageDetail==null||$location.search()[$scope.landingPageDetail.primaryField]==undefined?null:$location.search()[$scope.landingPageDetail.primaryField];if($location.search().sortFieldId==undefined&&$scope.sourceQuery.searchedFrom=="advancedSearch"&&$scope.sourceQuery.connectorIds.length==1)$scope.sortFieldId="connector_name";if($scope.resultType_val=="ECATALOGUE_BASED"&&$location.search().sortFieldId==undefined)$scope.sortFieldId="none";$scope.initFilterData();
if(($scope.sourceQuery.searchedFrom=="searchBar"||$scope.sourceQuery.searchedFrom=="advancedSearch")&&$scope.resultType_val=="REAL_TIME")$scope.onloadStartPolling();if($scope.sourceQuery.searchedFrom=="searchBar"&&$scope.resultType_val=="OPAC_REAL_TIME")$scope.onloadStartOpacPolling();$scope.getSectionFilter()};$scope.initFilterData=function(){var filterItems={searchId:$scope.sourceQuery.searchTermFilter,curPage:$scope.curPage,layout:$scope.layout,sortFieldId:$scope.sortFieldId,topresult:$scope.topresult};
angular.forEach($scope.filterMap,function(key,value){var checkfilterStr=key.getFilterStr();if(checkfilterStr!=null&&checkfilterStr!="")if(key.value!=null&&key.value.length>0)angular.forEach(key.value,function(key1,value1){if(filterItems[value])filterItems[value]=filterItems[value]+","+JSON.parse(key1);else filterItems[value]=JSON.parse(key1)})});sessionStorage.filterMapData=JSON.stringify(filterItems)};$scope.publication_year=[];$scope.publisher_source=[];$scope.filterObj={"filter":[]};$rootScope.displayNamesMap=
{};$scope.addToMap=function(result){angular.forEach(result,function(key,value){$rootScope.displayNamesMap[value]=key})};$scope.userPortalDisplayNames=function(){sessionStorage.displayNamesMap="";PromiseAjax.getData("/ws/getDisplayNames?orgId\x3d"+$rootScope.orgId,"GET").then(function(result){if(result!=""){$scope.addToMap(result);sessionStorage.displayNamesMap=JSON.stringify($rootScope.displayNamesMap);$scope.assignConstant()}$rootScope.hideloader()}).catch(function(error){$rootScope.hideloader();
console.error("error: "+error)})};$scope.userPortalDisplayNames();$scope.assignConstant=function(){$scope.CONSTANT={publication_year:$rootScope.filterLabelList[4].displayName,sub_category_name:$rootScope.displayNamesMap["Subject"],source_type_code:$rootScope.displayNamesMap["Content"],access_type:$rootScope.filterLabelList[0].displayName,product_id:$rootScope.filterLabelList[5].displayName,publisher_source:$rootScope.displayNamesMap["Source"],connector_name:$rootScope.displayNamesMap["Source"],publication_name:$rootScope.filterLabelList[3].displayName,
author:$rootScope.filterLabelList[2].displayName,package_name:"Package",aToz:"By Title",added_type:"Type",LP:"Web \x26 Multimedia",TAG:"Repository",tag:$scope.resultType_val=="ECATALOGUE_BASED"?"ABDC Journal Rating":"Repository",listname:$scope.resultType_val=="REAL_TIME"||$scope.resultType_val=="OPAC_REAL_TIME"?"Branch":$rootScope.displayNamesMap["Section"],ir_book_name:"Book",ir_chapter_name:"Chapter",ir_company_name:$rootScope.displayNamesMap["Source"],ir_course_name:$rootScope.displayNamesMap["Course"],
ir_unit_name:"Unit",ir_year:"Year",ir_dept:"Department",ir_f9:"State",ir_f10:"Category",ir_f11:"Region",ir_f12:"Semester",ir_f13:"Classes",sjrrank:$rootScope.filterLabelList[1].displayName,original_pub_id:$rootScope.filterLabelList[6].displayName,epage:$rootScope.filterLabelList[7].displayName,content:"Drilldown to",content_tkn:"Drilldown to",search_within:"Drilldown to",collection_id:"Collection",da_format:"Refine by",coverage_depth:"Coverage Depth",language:"Language"}};$scope.assignConstant();
$scope.SORT_FIELD={none:"Best Matched",publication_year:"Newest First",connector_name:"Source",sequence:"Sequence",doc_title_str:"Alphabetically",sjrrank:"SJR Rank"};$scope.getSortFieldDisplayValue=function(id){if($scope.SORT_FIELD[id])return $scope.SORT_FIELD[id]};$scope.getFiterTitleValue=function(category){if($scope.CONSTANT[category])return $scope.CONSTANT[category];else return category};function Filter(fieldId,value){this.fieldId=fieldId;this.value=[value];this.operator="\x3d";this.joinOperator=
"OR";this.getFilterStr=function(){if(this.fieldId=="added_type"&&this.value=='"LP"'){$scope.added_type="LP";return""}else{$scope.added_type=null;return'"'+this.fieldId+'":{"type":"string","filter":{"'+this.fieldId+'":{"operations":{"'+this.operator+'":{"values":['+this.value+'],"joinOpr":"'+this.joinOperator+'"}}}}}'}}}$scope.changeLayout=function(layout){$scope.layout=layout};$scope.onEnterKeyPress=function(event,searchText){var keyCode=event.which||event.keyCode;if(keyCode===8)event.preventDefault();
if(keyCode===13)if(searchText==""||searchText==undefined||searchText==null)event.preventDefault();else $scope.searchWithinFilter(searchText)};$scope.sectionPFieldFilter=function($event,category,value){if($event!=null)if($event.currentTarget.checked){$scope.curPage=0;var filter=new Filter(category,'"'+value+'"');$scope.filterMap[category]=filter;$scope.pagination()}};$scope.searchFilterNew=function($event,category,value){$scope.curPage=0;if($event!=null)if($scope.filterMap[category]){var filter=$scope.filterMap[category];
if($event.currentTarget.checked)filter.value.push('"'+value+'"');else{var index=filter.value.indexOf('"'+value+'"');filter.value.splice(index,1)}}else{var filter=new Filter(category,'"'+value+'"');$scope.filterMap[category]=filter}$scope.pagination()};$scope.sourceAccessTypeFilter=function($event,category,value){$scope.layout="grid";$scope.sortFieldId="doc_title_str";var filCategory=null;angular.forEach($scope.filterMap,function(key,value){filCategory=value;if(key.value!=null&&key.value.length>0)$scope.filterMap[filCategory].value=
[]});if($event!=null){$scope.curPage=0;var filter=new Filter(category,'"'+value+'"');$scope.filterMap[category]=filter;$scope.pagination()}};$scope.sourceAccessTypeNoFilter=function(gridVal,sortByVal){$scope.layout=gridVal;$scope.sortFieldId=sortByVal;$scope.removeAllFilters()};$scope.searchRealTimeFilter=function($event,category,value){$scope.curPage=0;if($event!=null)if($scope.filterMap[category]){var filter=$scope.filterMap[category];if($event.currentTarget.checked)filter.value.push('"'+value+
'"');else{var index=filter.value.indexOf('"'+value+'"');filter.value.splice(index,1)}}else{var filter=new Filter(category,'"'+value+'"');$scope.filterMap[category]=filter}$scope.pagination()};$scope.searchWithinFilter=function(value){if(!(value==""||value==undefined||value==null)){$scope.curPage=0;var field="search_within";value=value.trim().replaceAll('"',"");var filter=new Filter(field,'"'+value+'"');$scope.filterMap[field]=filter;$scope.isSearchWithin=true;$scope.searchWithinText=value;$scope.pagination()}};
$scope.pageSize=10;$scope.getTrendingDataPagination=function(){$rootScope.showloader();$scope.searchTerm="";var searctermFilter="Trending";sessionStorage.result_type=JSON.stringify("FI");sessionStorage.searchKeyword=JSON.stringify(searctermFilter);var param={"type":"FI","orgId":$rootScope.orgId};sessionStorage.searchQuery=JSON.stringify(param);var searchUrl="ws/getDocsFromLcBeforeLogin?type\x3dFI\x26orgId\x3d"+$rootScope.orgId+"\x26offset\x3d"+$scope.curPage*10+"\x26limit\x3d10";PromiseAjax.getData(searchUrl,
"GET").then(function(searchResponse){if(searchResponse=="Search error"){$scope.strMessage="Search error";$("#alertBoxModal").modal("show")}else{sessionStorage.result_type=JSON.stringify("FI");sessionStorage.searchKeyword=JSON.stringify(searctermFilter);var allData=[];var trendingDataVar={"facetMap":{},"resultType":"FI","documentList":searchResponse};allData.push(trendingDataVar);sessionStorage.searchResults=JSON.stringify(allData);$location.path("/searchresult").search({searchId:searctermFilter,curPage:$scope.curPage,
_t:(new Date).getTime()});$rootScope.search=JSON.parse(sessionStorage.searchResults);$scope.repeatedData($rootScope.search);$rootScope.hideloader()}$rootScope.hideloader()}).catch(function(error){console.error("error: "+error)})};$scope.pagination=function(pollStatus){if($scope.resultType_val=="FI"){window.scrollTo(0,0);$scope.getTrendingDataPagination()}else{$scope.pollingGetMoreOffset=sessionStorage.pollingGetMoreOffset==null?0:parseInt(JSON.parse(sessionStorage.pollingGetMoreOffset));$scope.pollingOpacGetMoreOffset=
sessionStorage.pollingOpacGetMoreOffset==null?0:parseInt(JSON.parse(sessionStorage.pollingOpacGetMoreOffset));window.scrollTo(0,0);$rootScope.showloader();$scope.filterObj={"filter":[]};$scope.searchData=[];$scope.searchData.push(JSON.parse(sessionStorage.searchQuery));$scope.filterObj.category=$scope.searchData[0].category;if(JSON.parse(sessionStorage.searchQuery)["searchTermFilter"])$scope.filterObj.searchTermFilter=$scope.searchData[0].searchTermFilter;if(JSON.parse(sessionStorage.searchQuery)["searchField"])$scope.filterObj.searchField=
$scope.searchData[0].searchField;else if(!JSON.parse(sessionStorage.searchQuery)["searchTermFilter"]&&!sessionStorage.thirdpartysearch&&$scope.searchData[0].searchedFrom=="searchBar"){sessionStorage.thirdpartysearch=$location.search().searchId;$scope.filterObj.searchTermFilter=$location.search().searchId}else if(sessionStorage.thirdpartysearch&&$scope.searchData[0].searchedFrom=="searchBar")$scope.filterObj.searchTermFilter=sessionStorage.thirdpartysearch;else $scope.filterObj.searchTermFilter=$scope.searchData[0].searchTermFilter;
$scope.filterObj.searchedFrom=$scope.searchData[0].searchedFrom;$scope.filterObj.isPremiumEbooks=$scope.searchData[0].isPremiumEbooks;if($scope.searchData[0].original_publisher)$scope.filterObj.original_publisher=$scope.searchData[0].original_publisher;if($scope.searchData[0].category=="Publisher"||$scope.searchData[0].category=="Subject"){if($scope.searchData[0].source_type_name!=null)$scope.filterObj.source_type_name=$scope.searchData[0].source_type_name;if($scope.searchData[0].article!=null)$scope.filterObj.article=
$scope.searchData[0].article}$scope.filterObj.offset=$scope.curPage*10;$scope.filterObj.limit=10;$scope.filterObj.facetLimit=1E3;if($scope.sortFieldId=="publication_year")$scope.filterObj.sortBy=[{"publication_year":"desc"}];else if($scope.sortFieldId=="connector_name")$scope.filterObj.sortBy=[{"connector_name":"asc"}];else if($scope.sortFieldId=="sequence")$scope.filterObj.sortBy=[{"sequence":"asc"}];else if($scope.sortFieldId=="doc_title_str")$scope.filterObj.sortBy=[{"doc_title_str":"asc"}];else if($scope.sortFieldId==
"sjrrank")$scope.filterObj.sortBy=[{"sjrrank":"desc"}];var filterStr="";var filterItems={searchId:$scope.searchData[0].searchTermFilter,curPage:$scope.curPage,layout:$scope.layout,sortFieldId:$scope.sortFieldId,topresult:$scope.topresult,resultTab:$scope.tabName};angular.forEach($scope.filterMap,function(key,value){if(key.fieldId=="search_within"&&(key.value!=null&&key.value.length>0)){$scope.filterObj.isSearchWithin=true;$scope.filterObj.searchWithinText=key.value[0].trim().replaceAll('"',"")}var checkfilterStr=
key.getFilterStr();if(checkfilterStr!=null&&checkfilterStr!=""){filterStr+=key.getFilterStr()+",";if(key.value!=null&&key.value.length>0)angular.forEach(key.value,function(key1,value1){if(filterItems[value])filterItems[value]=filterItems[value]+","+JSON.parse(key1);else filterItems[value]=JSON.parse(key1)})}});if($scope.isSearchWithin==true){$scope.filterObj.isSearchWithin=true;$scope.filterObj.searchWithinText=$scope.searchWithinText}filterStr="{"+filterStr.substr(0,filterStr.lastIndexOf(","))+"}";
$scope.filterObj.filter.push(filterStr);sessionStorage.filterMapData=JSON.stringify(filterItems);var searchPath="/ws/search/getSearchData";if($scope.topresult==true||$scope.topresult=="true"){$scope.filterObj.viewAll=true;searchPath="/ws/search/getTopEcatalogContentByType";$scope.filterObj.source_type_name=$scope.searchData[0].source_type_name}else if($scope.filterObj.category=="none"&&($scope.filterObj.searchedFrom=="searchBar"||$scope.filterObj.searchedFrom=="advancedSearch")){searchPath="/ws/search/getDataFromSearchOrAdvSearch";
if($scope.pollingStatus=="REFRESH"&&$scope.resultType_val=="REAL_TIME"){$scope.pollingStatus="GET_MORE_RESULT";$scope.curPage=0;sessionStorage.pollingStatus=JSON.stringify("GET_MORE_RESULT")}if($scope.pollingOpacStatus=="REFRESH"&&$scope.resultType_val=="OPAC_REAL_TIME"&&$scope.filterObj.searchedFrom=="searchBar"){$scope.pollingOpacStatus="GET_MORE_RESULT";$scope.curPage=0;sessionStorage.pollingOpacStatus=JSON.stringify("GET_MORE_RESULT")}if($scope.filterObj.searchedFrom=="advancedSearch"){filterItems.searchId=
$location.search().searchId;$scope.filterObj.connectorIds=$scope.searchData[0].connectorIds;$scope.filterObj.connectorNames=$scope.searchData[0].connectorNames;$scope.filterObj.contentItems=$scope.searchData[0].contentItems;if($scope.searchData[0].products!=undefined)$scope.filterObj.products=$scope.searchData[0].products;if($scope.searchData[0].from!=undefined)$scope.filterObj.from=$scope.searchData[0].from;if($scope.searchData[0].to!=undefined)$scope.filterObj.to=$scope.searchData[0].to;if($scope.searchData[0].access!=
undefined)$scope.filterObj.access=$scope.searchData[0].access}if($scope.resultType_val=="REAL_TIME"&&$scope.pollingGetMoreOffset!=undefined&&$scope.pollingGetMoreOffset!=null)$scope.filterObj.RTSEARCH_OFFSET=$scope.pollingGetMoreOffset;if($scope.resultType_val=="REAL_TIME"&&$scope.pollingStatus=="GET_MORE_RESULT")sessionStorage.pollingTotalHits=null;if($rootScope.hasOpacConnector==true&&$scope.filterObj.searchedFrom=="searchBar"){if($scope.pollingOpacGetMoreOffset!=undefined&&$scope.pollingOpacGetMoreOffset!=
null)$scope.filterObj.OPAC_RTSEARCH_OFFSET=$scope.pollingOpacGetMoreOffset;if($scope.pollingOpacStatus=="GET_MORE_RESULT")sessionStorage.pollingOpacTotalHits=null}}else if($scope.filterObj.category=="none"&&$scope.filterObj.searchedFrom=="aToz")searchPath="/ws/search/getAToZData";else if($scope.filterObj.category=="none"&&$scope.filterObj.searchedFrom=="home"){filterItems.sectionId=$rootScope.sectionId;filterItems.sectionName=$rootScope.sectionName;$scope.filterObj.sectionId=$rootScope.sectionId;
$scope.filterObj.added_type=$scope.added_type;searchPath="/ws/getAToZSectionData"}else if($scope.filterObj.category=="Content Type"&&$scope.filterObj.searchedFrom=="homePage"&&$scope.filterObj.isPremiumEbooks==true)searchPath="/ws/search/getDataByContentType";PromiseAjax.getData(searchPath,"POST",$scope.filterObj).then(function(searchResponse){if(searchResponse=="Search error"){$scope.strMessage="Search error";$("#alertBoxModal").modal("show")}else if($scope.filterObj.category=="none"&&$scope.filterObj.searchedFrom==
"aToz"){sessionStorage.searchResults=JSON.stringify(searchResponse.ATOZ);$scope.updatePathInPagination(filterItems)}else if($scope.filterObj.category=="none"&&$scope.filterObj.searchedFrom=="home"){sessionStorage.searchResults=JSON.stringify(searchResponse.SECTION_CONTENT);$scope.updatePathInPagination(filterItems)}else if($rootScope.hasOpacConnector==true&&$scope.filterObj.searchedFrom=="searchBar"){$scope.opacFilterObj=angular.copy($scope.filterObj);if($scope.resultType_val!="OPAC_REAL_TIME")$scope.opacFilterObj.filter=
["{}"];PromiseAjax.getData("/ws/search/getOpacDataFromSearchOrAdvSearch","POST",$scope.opacFilterObj).then(function(opacSearchResponse){if(opacSearchResponse!="Search error"){sessionStorage.searchResults=JSON.stringify(searchResponse.concat(opacSearchResponse));$scope.isOpacRefreshRequired=true}else{sessionStorage.searchResults=JSON.stringify(searchResponse);$scope.isOpacRefreshRequired=false}$scope.pollingOpacStatus=JSON.parse(sessionStorage.pollingOpacStatus);$scope.updatePathInPagination(filterItems)})}else{sessionStorage.searchResults=
JSON.stringify(searchResponse);if($scope.resultType_val=="REAL_TIME"&&($scope.filterObj.searchedFrom=="searchBar"||$scope.filterObj.searchedFrom=="advancedSearch"))$scope.pollingStatus=JSON.parse(sessionStorage.pollingStatus);$scope.updatePathInPagination(filterItems)}}).catch(function(error){console.error("error: "+error)})}};$scope.updatePathInPagination=function(itemFilter){$rootScope.search=JSON.parse(sessionStorage.searchResults);$scope.repeatedData($rootScope.search);$location.path("/searchresult").search(itemFilter);
$rootScope.hideloader()};$scope.sourceFilterTab={};$scope.sourceUrlParam=function(){var srcPageURL=window.location.href.split("?")[1];var params=srcPageURL.split("\x26");var keyAr=[];var valAr=[];for(var i=0;i<params.length;i++){keyAr.push(params[i].split("\x3d")[0]);valAr.push(params[i].split("\x3d")[1])}var result=valAr.reduce(function(result,field,index){result[keyAr[index]]=field;return result},{});$scope.sourceFilterTab=result};$scope.sourceUrlParam();$scope.sorting=function(value){$scope.sortFieldId=
value;$scope.curPage=0;$scope.pagination()};$scope.saveSearch=function(searchTerm){$rootScope.showloader();var param={"saved_search_keyword":searchTerm,"org_id":$rootScope.orgId,"author":$rootScope.userName,"user_id":$rootScope.loginId};PromiseAjax.getData("/ws/saveSearch","POST",param).then(function(searchResponse){$rootScope.hideloader();if(searchResponse){$scope.strMessage="Search has been saved successfully. Please note that it may take a short while to be visible in the saved list.";$("#alertBoxModal").modal("show")}}).catch(function(error){console.error("error: "+
error);$rootScope.hideloader()})};$scope.sectionFilterHeadings={};$scope.getSectionFilter=function(){if($scope.resultType_val=="SECTION_CONTENT")PromiseAjax.getData("/ws/getSectionFilterList?orgId\x3d"+$rootScope.orgId,"GET").then(function(result){if(result.response!=""&&result.response.responseCode==100)$scope.sectionFilterHeadings=result.data}).catch(function(error){console.error("error: "+error)})};$scope.filterDataLength=0;$scope.checkSectionfacetMapLength=function(){angular.forEach($rootScope.search,
function(resultData){if(resultData.resultType=="SECTION_CONTENT"){$scope.filterDataLength=0;angular.forEach(resultData.facetMap,function(key,value){if(key.length>0)$scope.filterDataLength=$scope.filterDataLength+1})}});return $scope.filterDataLength};$scope.isEmpty1=function(obj){for(var key in obj)if(obj.hasOwnProperty(key))return false;return true};$scope.getSectionFiterTitleValue=function(category){if($scope.sectionFilterHeadings[category])return $scope.sectionFilterHeadings[category];else return category};
$scope.getSectionTitle=function(categoryDet){var catName=categoryDet;angular.forEach($rootScope.sectionTitleData,function(section){if(section.sectionId==categoryDet)catName=section.sectionName});return catName};$scope.numberOfPages=function(){if($rootScope.search.length>0&&$scope.resultType_val!=""){var noOfPages=0;angular.forEach($rootScope.search,function(key,value){if($scope.resultType_val=="REAL_TIME"&&key.resultType=="REAL_TIME")noOfPages=key.documentList!=null&&key.documentList.totalHits>0?
Math.ceil(key.documentList.totalHits/$scope.pageSize):0;if($scope.resultType_val=="OPAC_REAL_TIME"&&key.resultType=="OPAC_REAL_TIME")noOfPages=key.documentList!=null&&key.documentList.totalHits>0?Math.ceil(key.documentList.totalHits/$scope.pageSize):0;if($scope.resultType_val=="PRE_INDEXED"&&key.resultType=="PRE_INDEXED")noOfPages=key.documentList!=null&&key.documentList.totalHits>0?Math.ceil(key.documentList.totalHits/$scope.pageSize):0;if($scope.resultType_val=="RSS_FEEDS"&&key.resultType=="RSS_FEEDS")noOfPages=
key.documentList!=null&&key.documentList.totalHits>0?Math.ceil(key.documentList.totalHits/$scope.pageSize):0;if($scope.resultType_val=="ECATALOGUE_BASED"&&key.resultType=="ECATALOGUE_BASED")noOfPages=key.documentList!=null&&key.documentList.totalHits>0?Math.ceil(key.documentList.totalHits/$scope.pageSize):0;if($scope.resultType_val=="SECTION_CONTENT"&&key.resultType=="SECTION_CONTENT")noOfPages=key.documentList!=null&&key.documentList.totalHits>0?Math.ceil(key.documentList.totalHits/$scope.pageSize):
0;if($scope.resultType_val=="FI"&&key.resultType=="FI")noOfPages=key.documentList!=null&&key.documentList.totalHits>0?Math.ceil(key.documentList.totalHits/$scope.pageSize):0});return noOfPages}else return 0};$scope.setCurrentFilterCategory=function(filterCategory){$rootScope.isAppied=false;$rootScope.selectedCategoryTemp=filterCategory};$scope.addSelectedFilterInTemp=function($event,category,value){if($scope.filterMapTemp[category]){var filter=$scope.filterMapTemp[category];if($event.currentTarget.checked)filter.value.push('"'+
value+'"');else{var index=filter.value.indexOf('"'+value+'"');filter.value.splice(index,1)}}else{var filter=new Filter(category,'"'+value+'"');$scope.filterMapTemp[category]=filter}};$scope.addSelectedFilterInTempSrc=function($event,category,value){var filter=$scope.filterMapTemp[category];filter.value.push('"'+value+'"')};$scope.bindHtmlDataWithSeperator=function(value,index){value=JSON.parse(value);if(index>0)value=", "+value;return value};$scope.removeAllFilters=function(){var category=null;angular.forEach($scope.filterMap,
function(key,value){category=value;if(key.value!=null&&key.value.length>0)$scope.filterMap[category].value=[]});if(category!=null){if($scope.sourceQuery.searchedFrom=="aToz"&&$scope.sourceQuery.searchTermFilter!="")$scope.removeAToZFilter($scope.sourceQuery.searchTermFilter,"ClearAll");$scope.removeFilterItem(category)}if(category==null&&$scope.sourceQuery.searchedFrom=="aToz"&&$scope.sourceQuery.searchTermFilter!="")$scope.removeAToZFilter($scope.sourceQuery.searchTermFilter)};$scope.removeAllFiltersSrcPage=
function(){var category=null;angular.forEach($scope.filterMap,function(key,value){category=value;if(key.value!=null&&key.value.length>0)$scope.filterMap[category].value=[]});if($scope.sourceFilterTab.access_type=="Subscribed")$scope.sourceAccessTypeFilter("click","access_type","Subscribed");else if($scope.sourceFilterTab.access_type=="Open")$scope.sourceAccessTypeFilter("click","access_type","Open");else if($scope.sourceFilterTab.access_type=="OPAC")$scope.sourceAccessTypeFilter("click","access_type",
"OPAC");else $scope.sourceAccessTypeNoFilter("grid","doc_title_str")};$scope.removeFilterItem=function(category,applyAllFiter){if(applyAllFiter==null)$scope.filterMap[category].value=[];$scope.pagination($scope.curPage=0)};$scope.clearAllOrCategoryOnViewAllFilters=function(category){if(category==null)angular.forEach($scope.filterMapTemp,function(key,value){if(key.value!=null&&key.value.length>0)$scope.filterMapTemp[value].value=[]});else $scope.filterMapTemp[category].value=[]};$scope.clearAllOrCategoryOnViewAllFiltersForSrc=
function(category){if(category==null)angular.forEach($scope.filterMapTemp,function(key,value){if(key.value!=null&&key.value.length>0)$scope.filterMapTemp[value].value=[]});else $scope.filterMapTemp[category].value=[];if($scope.sourceFilterTab.access_type=="Subscribed")$scope.addSelectedFilterInTempSrc("click","access_type","Subscribed");else if($scope.sourceFilterTab.access_type=="Open")$scope.addSelectedFilterInTempSrc("click","access_type","Open");else if($scope.sourceFilterTab.access_type=="OPAC")$scope.addSelectedFilterInTempSrc("click",
"access_type","OPAC")};$scope.validateSelectedValue=function(arr,value){return arr!=null?arr.indexOf(JSON.stringify(value)):-1};$scope.bindHtmlData=function(value){value=JSON.parse(value);return value};$scope.isEmptyViewFilter=function(obj){var noFilterData=true;angular.forEach(obj,function(key,value){if(key.value!=null&&key.value.length>0)noFilterData=false});return noFilterData};$scope.isEmptyViewFilterForSrc=function(obj){var noFilterDataSrc=true;var categoryForSrc=null;angular.forEach(obj,function(key,
value){categoryForSrc=value;if(categoryForSrc=="access_type"&&$scope.sourceQuery.category=="Publisher")noFilterDataSrc=true;else if(key.value!=null&&key.value.length>0)noFilterDataSrc=false});return noFilterDataSrc};$scope.checkFilterLength=function(sectionPFvalue){var dataLen;angular.forEach($rootScope.searchPrimaryFieldResults[0].facetMap,function(key,value){if(value==sectionPFvalue)dataLen=key.length});return dataLen};$scope.applyViewAllFilters=function(){$rootScope.isAppied=true;$rootScope.filterMap=
angular.copy($rootScope.filterMapTemp);$scope.sortFieldId=angular.copy($rootScope.sortFieldIdTemp);$scope.removeFilterItem($rootScope.selectedCategoryTemp,"apply")};$scope.getSearchResultTotalHits=function(searchData){var totalPages=0;angular.forEach(searchData,function(key,value){if($scope.resultType_val=="REAL_TIME"&&key.resultType=="REAL_TIME")totalPages=key.documentList!=null&&key.documentList.totalHits>0?key.documentList.totalHits:0;if($scope.resultType_val=="OPAC_REAL_TIME"&&key.resultType==
"OPAC_REAL_TIME")totalPages=key.documentList!=null&&key.documentList.totalHits>0?key.documentList.totalHits:0;if($scope.resultType_val=="PRE_INDEXED"&&key.resultType=="PRE_INDEXED")totalPages=key.documentList!=null&&key.documentList.totalHits>0?key.documentList.totalHits:0;if($scope.resultType_val=="RSS_FEEDS"&&key.resultType=="RSS_FEEDS")totalPages=key.documentList!=null&&key.documentList.totalHits>0?key.documentList.totalHits:0;if($scope.resultType_val=="ECATALOGUE_BASED"&&key.resultType=="ECATALOGUE_BASED")totalPages=
key.documentList!=null&&key.documentList.totalHits>0?key.documentList.totalHits:0;if($scope.resultType_val=="SECTION_CONTENT"&&key.resultType=="SECTION_CONTENT")totalPages=key.documentList!=null&&key.documentList.totalHits>0?key.documentList.totalHits:0;if($scope.resultType_val=="FI"&&key.resultType=="FI")totalPages=key.documentList!=null&&key.documentList.totalHits>0?key.documentList.totalHits:0});if(totalPages>0)$scope.videocall();return totalPages};$scope.fiterSettingObj=function(index,itemTitle){$scope.searchData=
[];$scope.searchData.push(JSON.parse(sessionStorage.searchQuery));var filterItems={searchId:$scope.searchData[0].searchTermFilter,curPage:$scope.curPage,layout:$scope.layout,sortFieldId:$scope.sortFieldId,topresult:$scope.topresult};if(index!=undefined&&itemTitle!=undefined&&index!=null&&itemTitle!=null)filterItems={searchId:$scope.searchData[0].searchTermFilter,curPage:$scope.curPage,layout:$scope.layout,index:index,itemTitle:itemTitle,sortFieldId:$scope.sortFieldId,topresult:$scope.topresult};angular.forEach($scope.filterMap,
function(key,value){if(key.value!=null&&key.value.length>0)angular.forEach(key.value,function(key1,value1){if(filterItems[value])filterItems[value]=filterItems[value]+","+JSON.parse(key1);else filterItems[value]=JSON.parse(key1)})});return filterItems};$scope.viewDetail=function(index,uniqueid,searchResultType){sessionStorage.searchResultTypeIndex=JSON.stringify(index);$location.path("/viewDetail").search({searchResultType:searchResultType,unique_id:uniqueid,sectionid:$rootScope.sectionId,sectionName:$rootScope.sectionName})};
$scope.setRefreshCall=function(){$scope.isRefreshed=true;return $scope.isRefreshed};$scope.changeViewPubOrContent=function(selectedTab){$scope.tabName=selectedTab;if(selectedTab=="Catalogue"){$rootScope.filterMap={};$scope.curPage=0;$scope.resultType_val="ECATALOGUE_BASED";$scope.layout="grid";sessionStorage.result_type=JSON.stringify($scope.resultType_val);$scope.sortFieldId="doc_title_str";$scope.pagination()}else if(selectedTab=="Research")angular.forEach($rootScope.search,function(key,value){if(key.resultType!=
null&&(key.resultType=="RSS_FEEDS"||key.resultType=="REAL_TIME")){$rootScope.filterMap={};$scope.curPage=0;$scope.layout="list";$scope.resultType_val=key.resultType;sessionStorage.result_type=JSON.stringify($scope.resultType_val);$scope.sortFieldId="none";if(($scope.sourceQuery.searchedFrom=="searchBar"||$scope.sourceQuery.searchedFrom=="advancedSearch")&&key.resultType=="REAL_TIME"){if($scope.sourceQuery.searchedFrom=="advancedSearch"&&$scope.sourceQuery.connectorIds.length==1)$scope.sortFieldId=
"connector_name";$scope.pollingStatus=JSON.parse(sessionStorage.pollingStatus);if($scope.pollingStatus=="REFRESH"){$scope.pollingStatus=$scope.pollingTotalHits!="null"&&$scope.pollingTotalHits!=null&&$scope.pollingTotalHits>$scope.getSearchResultTotalHits($scope.search)?"REFRESH":"GET_MORE_RESULT";sessionStorage.pollingStatus=JSON.stringify($scope.pollingStatus)}sessionStorage.pollingTotalHits=null}$scope.pagination()}});else if(selectedTab=="N\x26M"){$rootScope.filterMap={};$scope.curPage=0;$scope.resultType_val=
"PRE_INDEXED";$scope.layout="grid";sessionStorage.result_type=JSON.stringify($scope.resultType_val);$scope.sortFieldId="none";$scope.pagination()}else if(selectedTab=="Sections"){$rootScope.filterMap={};$scope.curPage=0;$scope.resultType_val="SECTION_CONTENT";$scope.layout="grid";sessionStorage.result_type=JSON.stringify($scope.resultType_val);$scope.sortFieldId="publication_year";$scope.pagination()}else if(selectedTab=="opac"&&$scope.sourceQuery.searchedFrom=="searchBar")angular.forEach($rootScope.search,
function(key,value){if(key.resultType!=null&&key.resultType=="OPAC_REAL_TIME"){$rootScope.filterMap={};$scope.curPage=0;$scope.layout="list";$scope.resultType_val=key.resultType;sessionStorage.result_type=JSON.stringify($scope.resultType_val);$scope.sortFieldId="none";if(key.resultType=="OPAC_REAL_TIME"){$scope.pollingOpacStatus=JSON.parse(sessionStorage.pollingOpacStatus);if($scope.pollingOpacStatus=="REFRESH"){$scope.pollingOpacStatus=$scope.pollingOpacTotalHits!="null"&&$scope.pollingOpacTotalHits!=
null&&$scope.pollingOpacTotalHits>$scope.getSearchResultTotalHits($scope.search)?"REFRESH":"GET_MORE_RESULT";sessionStorage.pollingOpacStatus=JSON.stringify($scope.pollingOpacStatus)}sessionStorage.pollingOpacTotalHits=null}$scope.pagination()}})};$scope.isShowTab=function(tabType){var showTab=false;angular.forEach($rootScope.search,function(key,value){if(key.resultType!=null&&key.resultType==tabType||tabType=="REAL_TIME"||tabType=="OPAC_REAL_TIME")showTab=true});return showTab};$scope.resetUnselectedFilters=
function(filterSubCategory,selectedFilters){if(selectedFilters!=undefined&&filterSubCategory!=undefined){var filterSubCategoryNew=[];angular.forEach(filterSubCategory,function(key,value){if(selectedFilters.indexOf(JSON.stringify(key.value))==-1)filterSubCategoryNew.push(key)});return filterSubCategoryNew}else return filterSubCategory};$scope.aTozSearch=function($event){var searchTermFilter=$event.target.text;sessionStorage.searchKeyword=JSON.stringify(searchTermFilter);$scope.sourceQuery.searchTermFilter=
searchTermFilter;sessionStorage.searchQuery=JSON.stringify($scope.sourceQuery);$scope.pagination($scope.curPage=0)};$scope.removeAToZFilter=function(oldAToZFilterVal,fromClearAll){if(oldAToZFilterVal!=""){var searchTermFilter="";sessionStorage.searchKeyword=JSON.stringify(searchTermFilter);$scope.sourceQuery.searchTermFilter=searchTermFilter;sessionStorage.searchQuery=JSON.stringify($scope.sourceQuery);if(fromClearAll==undefined&&fromClearAll==null)$scope.pagination($scope.curPage=0)}};$scope.videocall=
function(){var div,n,v=document.getElementsByClassName("youtube-player");for(n=0;n<v.length;n++)if(v[n].hasChildNodes()==false){div=document.createElement("div");div.setAttribute("data-id",v[n].dataset.id);div.innerHTML=$scope.labnolThumb(v[n].dataset.id);div.onclick=$scope.labnolIframe;v[n].appendChild(div)}};$scope.labnolThumb=function(id){var thumb='\x3cimg src\x3d"https://i.ytimg.com/vi/ID/hqdefault.jpg"\x3e',play='\x3cdiv class\x3d"play"\x3e\x3c/div\x3e';return thumb.replace("ID",id)+play};$scope.labnolIframe=
function(){var iframe=document.createElement("iframe");var embed="https://www.youtube.com/embed/ID?autoplay\x3d1";iframe.setAttribute("src",embed.replace("ID",this.dataset.id));iframe.setAttribute("frameborder","0");iframe.setAttribute("allowfullscreen","1");this.parentNode.replaceChild(iframe,this)};$scope.getVideoUniqueId=function(videoPath){if(videoPath!=null&&videoPath!=undefined&&videoPath.indexOf("?")>-1)return videoPath.split("?")[1].split("\x3d")[1];else if(videoPath!=null&&videoPath!=undefined&&
videoPath.indexOf("embed")>-1)return videoPath.split("embed")[1].split("/")[1];else return""};$scope.getVideoUniqueIdFromPublication=function(videoPath){if(videoPath!=null&&videoPath!=undefined&&videoPath.indexOf("embed")>-1)return videoPath.split("embed")[1].split("/")[1];else return""};$scope.coverImageGenerator=function(src,code){var coverImage="https://d2ctavleamkpz.cloudfront.net/images/API_CoverImage/";if(src!=undefined&&code!=undefined||src!=null&&code!=null||src!=undefined&&code!=null||src!=
null&&code!=undefined)if(src=="EBSCO"||src=="Proquest"||src=="Springer"||src=="IEEE"||src=="JSTOR"||src=="Science Direct"||src=="Cambridge University Press"||src=="Wiley"||src=="Taylor and Francis"||src=="McGraw Hill"||src=="Knimbus Open ebooks"||src=="Knimbus Open Journals"||src=="Knimbus Multimedia")coverImage=coverImage+src+"_"+code+".jpg";else coverImage=coverImage+"Default"+"_"+code+".jpg";else coverImage=coverImage+"Default"+".jpg";return coverImage};$scope.pollingSearchResult=function(){if($scope.resultType_val==
"REAL_TIME"&&($scope.sourceQuery.searchedFrom=="searchBar"||$scope.sourceQuery.searchedFrom=="advancedSearch")){$scope.pollingStatus=JSON.parse(sessionStorage.pollingStatus);if($scope.pollingStatus=="STARTED")$rootScope.stopInterval=$interval(function(){PromiseAjax.getData("/ws/search/refreshForSearchOrAdvSearch","POST").then(function(searchResponse){if(searchResponse!=undefined&&JSON.stringify(searchResponse)=="true"){$scope.pollingTotalHits=JSON.parse(sessionStorage.pollingTotalHits);$scope.pollingMoreRecordCount=
JSON.parse(sessionStorage.pollingMoreRecordCount);$scope.getSearchRecordCount()}else{$scope.pollingTotalHits=searchResponse;$scope.pollingMoreRecordCount=parseInt($scope.pollingTotalHits)-parseInt($scope.getSearchResultTotalHits($scope.search));sessionStorage.pollingTotalHits=JSON.stringify($scope.pollingTotalHits);$scope.pollingMoreRecordCount=$scope.pollingMoreRecordCount>0?$scope.pollingMoreRecordCount:0;sessionStorage.pollingMoreRecordCount=JSON.stringify($scope.pollingMoreRecordCount)}})},3E3)}};
$scope.getSearchRecordCount=function(){PromiseAjax.getData("/ws/search/refreshForSearchOrAdvSearch?searchCount\x3dtrue","POST").then(function(searchResponse){if(searchResponse!=undefined&&JSON.stringify(searchResponse)!="true"){$scope.pollingTotalHits=searchResponse;$scope.pollingMoreRecordCount=parseInt($scope.pollingTotalHits)-parseInt($scope.getSearchResultTotalHits($scope.search));sessionStorage.pollingTotalHits=JSON.stringify($scope.pollingTotalHits);$scope.pollingMoreRecordCount=$scope.pollingMoreRecordCount>
0?$scope.pollingMoreRecordCount:0;sessionStorage.pollingMoreRecordCount=JSON.stringify($scope.pollingMoreRecordCount)}$scope.stopPolling()})};$scope.stopPolling=function(){if($rootScope.stopInterval!=undefined){$scope.pollingStatus=$scope.pollingTotalHits!=null&&$scope.pollingTotalHits!="null"&&$scope.pollingTotalHits>$scope.getSearchResultTotalHits($scope.search)?"REFRESH":"GET_MORE_RESULT";sessionStorage.pollingStatus=JSON.stringify($scope.pollingStatus);$interval.cancel($rootScope.stopInterval);
$rootScope.stopInterval=undefined}};$scope.pollingOpacSearchResult=function(){if($scope.resultType_val=="OPAC_REAL_TIME"&&$scope.sourceQuery.searchedFrom=="searchBar"){$scope.pollingOpacStatus=JSON.parse(sessionStorage.pollingOpacStatus);if($scope.pollingOpacStatus=="STARTED")$rootScope.stopInterval=$interval(function(){if($scope.isOpacRefreshRequired==true)PromiseAjax.getData("/ws/search/refreshForOpacSearchOrAdvSearch","POST").then(function(searchResponse){if(searchResponse!=undefined&&JSON.stringify(searchResponse)==
"true"){$scope.pollingOpacTotalHits=JSON.parse(sessionStorage.pollingOpacTotalHits);$scope.pollingOpacMoreRecordCount=JSON.parse(sessionStorage.pollingOpacMoreRecordCount);$scope.getOpacSearchRecordCount()}else{$scope.pollingOpacTotalHits=searchResponse;$scope.pollingOpacMoreRecordCount=parseInt($scope.pollingOpacTotalHits)-parseInt($scope.getSearchResultTotalHits($scope.search));sessionStorage.pollingOpacTotalHits=JSON.stringify($scope.pollingOpacTotalHits);$scope.pollingOpacMoreRecordCount=$scope.pollingOpacMoreRecordCount>
0?$scope.pollingOpacMoreRecordCount:0;sessionStorage.pollingOpacMoreRecordCount=JSON.stringify($scope.pollingOpacMoreRecordCount)}})},3E3)}};$scope.getOpacSearchRecordCount=function(){PromiseAjax.getData("/ws/search/refreshForOpacSearchOrAdvSearch?opacSearchCount\x3dtrue","POST").then(function(searchResponse){if(searchResponse!=undefined&&JSON.stringify(searchResponse)!="true"){$scope.pollingOpacTotalHits=searchResponse;$scope.pollingOpacMoreRecordCount=parseInt($scope.pollingOpacTotalHits)-parseInt($scope.getSearchResultTotalHits($scope.search));
sessionStorage.pollingOpacTotalHits=JSON.stringify($scope.pollingOpacTotalHits);$scope.pollingOpacMoreRecordCount=$scope.pollingOpacMoreRecordCount>0?$scope.pollingOpacMoreRecordCount:0;sessionStorage.pollingOpacMoreRecordCount=JSON.stringify($scope.pollingOpacMoreRecordCount)}$scope.stopOpacPolling()})};$scope.stopOpacPolling=function(){if($rootScope.stopInterval!=undefined){$scope.pollingOpacStatus=$scope.pollingOpacTotalHits!=null&&$scope.pollingOpacTotalHits!="null"&&$scope.pollingOpacTotalHits>
$scope.getSearchResultTotalHits($scope.search)?"REFRESH":"GET_MORE_RESULT";sessionStorage.pollingOpacStatus=JSON.stringify($scope.pollingOpacStatus);$interval.cancel($rootScope.stopInterval);$rootScope.stopInterval=undefined}};$scope.$on("$destroy",function(event){$interval.cancel($rootScope.stopInterval);$rootScope.stopInterval=undefined});$scope.refreshSearchResult=function(){if($scope.resultType_val=="REAL_TIME"&&($scope.sourceQuery.searchedFrom=="searchBar"||$scope.sourceQuery.searchedFrom=="advancedSearch")){$scope.pollingStatus=
JSON.parse(sessionStorage.pollingStatus);if($scope.pollingStatus=="REFRESH"){$scope.curPage=0;sessionStorage.pollingStatus=JSON.stringify("GET_MORE_RESULT");$scope.pagination("REFRESH")}else if($scope.pollingStatus=="STARTED"){$scope.curPage=0;$scope.pagination()}}};$scope.getMoreSearchResult=function(){$scope.isOpacRefreshRequired==false;if($scope.resultType_val=="REAL_TIME"&&($scope.sourceQuery.searchedFrom=="searchBar"||$scope.sourceQuery.searchedFrom=="advancedSearch")){$scope.pollingStatus=JSON.parse(sessionStorage.pollingStatus);
if($scope.pollingStatus=="GET_MORE_RESULT"){$scope.curPage=0;$scope.pollingGetMoreOffset=(sessionStorage.pollingGetMoreOffset==null||sessionStorage.pollingGetMoreOffset=="null"?0:parseInt(JSON.parse(sessionStorage.pollingGetMoreOffset)))+50;sessionStorage.pollingGetMoreOffset=JSON.stringify($scope.pollingGetMoreOffset);sessionStorage.pollingStatus=JSON.stringify("STARTED");sessionStorage.pollingMoreRecordCount=null;$scope.pollingMoreRecordCount=0;$scope.pagination();$scope.onloadStartPolling()}}};
$scope.onloadStartPolling=function(){$scope.pollingStatus=JSON.parse(sessionStorage.pollingStatus);if($scope.pollingStatus=="STARTED"||$scope.pollingStatus=="REFRESH"||$scope.pollingStatus=="GET_MORE_RESULT"){if(sessionStorage.pollingTotalHits==null||sessionStorage.pollingTotalHits=="null"){sessionStorage.pollingTotalHits=JSON.stringify($scope.getSearchResultTotalHits($scope.search));$scope.pollingTotalHits=JSON.parse(sessionStorage.pollingTotalHits)}else $scope.pollingTotalHits=JSON.parse(sessionStorage.pollingTotalHits);
if($scope.pollingStatus=="STARTED"){$scope.pollingMoreRecordCount=sessionStorage.pollingMoreRecordCount!=null&&sessionStorage.pollingMoreRecordCount!="null"?JSON.parse(sessionStorage.pollingMoreRecordCount):$scope.pollingMoreRecordCount;$scope.pollingSearchResult()}}};$scope.refreshOpacSearchResult=function(){$scope.isOpacRefreshRequired=true;if($scope.resultType_val=="OPAC_REAL_TIME"&&$scope.sourceQuery.searchedFrom=="searchBar"){$scope.pollingOpacStatus=JSON.parse(sessionStorage.pollingOpacStatus);
if($scope.pollingOpacStatus=="REFRESH"){$scope.curPage=0;sessionStorage.pollingOpacStatus=JSON.stringify("GET_MORE_RESULT");$scope.pagination("REFRESH")}else if($scope.pollingOpacStatus=="STARTED"){$scope.curPage=0;$scope.pagination()}}};$scope.getMoreOpacSearchResult=function(){$scope.isOpacRefreshRequired=false;if($scope.resultType_val=="OPAC_REAL_TIME"&&$scope.sourceQuery.searchedFrom=="searchBar"){$scope.pollingOpacStatus=JSON.parse(sessionStorage.pollingOpacStatus);if($scope.pollingOpacStatus==
"GET_MORE_RESULT"){$scope.curPage=0;$scope.pollingOpacGetMoreOffset=(sessionStorage.pollingOpacGetMoreOffset==null||sessionStorage.pollingOpacGetMoreOffset=="null"?0:parseInt(JSON.parse(sessionStorage.pollingOpacGetMoreOffset)))+50;sessionStorage.pollingOpacGetMoreOffset=JSON.stringify($scope.pollingOpacGetMoreOffset);sessionStorage.pollingOpacStatus=JSON.stringify("STARTED");sessionStorage.pollingOpacMoreRecordCount=null;$scope.pollingOpacMoreRecordCount=0;$scope.pagination();$scope.onloadStartOpacPolling()}}};
$scope.onloadStartOpacPolling=function(){$scope.pollingOpacStatus=JSON.parse(sessionStorage.pollingOpacStatus);if($scope.pollingOpacStatus=="STARTED"||$scope.pollingOpacStatus=="REFRESH"||$scope.pollingOpacStatus=="GET_MORE_RESULT"){if(sessionStorage.pollingOpacTotalHits==null||sessionStorage.pollingOpacTotalHits=="null"){sessionStorage.pollingOpacTotalHits=JSON.stringify($scope.getSearchResultTotalHits($scope.search));$scope.pollingOpacTotalHits=JSON.parse(sessionStorage.pollingOpacTotalHits)}else $scope.pollingOpacTotalHits=
JSON.parse(sessionStorage.pollingOpacTotalHits);if($scope.pollingOpacStatus=="STARTED"){$scope.pollingOpacMoreRecordCount=sessionStorage.pollingOpacMoreRecordCount!=null&&sessionStorage.pollingOpacMoreRecordCount!="null"?JSON.parse(sessionStorage.pollingOpacMoreRecordCount):$scope.pollingOpacMoreRecordCount;$scope.pollingOpacSearchResult()}}};$scope.goToSectionPage=function(){$location.path("/sectionDetail").search({sectionid:$rootScope.sectionId,sectionName:$rootScope.sectionName})};$scope.IRauthorDetailModal=
function(irAuthorUserid){$rootScope.irAuthorUserids=irAuthorUserid;$scope.animationsEnabled=true;var modalInstance=$uibModal.open({animation:$scope.animationsEnabled,templateUrl:"ng/IRauthorDetail",controller:"ModalInstanceCtrl",backdrop:"static",windowClass:"blustripAdd blustripCloseIcon",backdropClass:"modalCustomOpacity",size:"lg",resolve:{items:function(){$scope.getAuthorDetail();$scope.getAuthorPublicationData();$rootScope.filterMapTemp=angular.copy($scope.filterMap);$scope.filterMapDefault=
angular.copy($scope.filterMap);$rootScope.sortFieldIdTemp=angular.copy($scope.sortFieldId);return $scope.items}}});modalInstance.result.then(function(selectedItem){$scope.selected=selectedItem},function(){if(!$rootScope.isAppied)$rootScope.filterMap=angular.copy($scope.filterMapDefault)})};$scope.getAuthorDetail=function(){$rootScope.irAuthorDetailobj=null;$rootScope.showloader();PromiseAjax.getData("/ws/getUserDetail?userId\x3d"+$rootScope.irAuthorUserids,"GET").then(function(response){if(response.response!=
null&&response.response!="")if(response.response.responseCode==100){$rootScope.irAuthorDetailobj=response.data;$rootScope.workerExpArr=[];if($rootScope.irAuthorDetailobj.workExperience!=null&&$rootScope.irAuthorDetailobj.workExperience!=""){var workExpServerData=JSON.parse($rootScope.irAuthorDetailobj.workExperience);angular.forEach(workExpServerData,function(value,key){$rootScope.workerExpArr.push(value)})}$rootScope.eduDetailArr=[];if($rootScope.irAuthorDetailobj.education!=null&&$rootScope.irAuthorDetailobj.education!=
""){var eduDetailServerData=JSON.parse($rootScope.irAuthorDetailobj.education);angular.forEach(eduDetailServerData,function(value,key){$rootScope.eduDetailArr.push(value)})}$rootScope.fieldOfStudArr=[];if($rootScope.irAuthorDetailobj.fieldOfStudies!=null&&$rootScope.irAuthorDetailobj.fieldOfStudies!=""){var fStudyServerData=JSON.parse($rootScope.irAuthorDetailobj.fieldOfStudies);angular.forEach(fStudyServerData,function(value,key){$rootScope.fieldOfStudArr.push(value)})}}$rootScope.hideloader()}).catch(function(error){$rootScope.hideloader();
console.error("error: "+error)})};$rootScope.searchOffsetLimit=10;$rootScope.scrollCountFlag=0;$scope.getAuthorPublicationData=function(){$rootScope.irPublicationData=[];$rootScope.showloader();var param={"orgId":$rootScope.orgId,"author_email_id":$rootScope.irAuthorUserids,"type":"IR","limit":$rootScope.searchOffsetLimit,"offset":$rootScope.scrollCountFlag};PromiseAjax.getData("/ws/getAuthorPublicationData","POST",param).then(function(response){if(response!=""&&response!=undefined&&response!=null)if(response.response.responseCode==
100&&response.response.responseMessage=="SUCCESS"){angular.forEach(response.data.doclist,function(data){$rootScope.irPublicationData.push(data)});$rootScope.totalirPublicationData=response.data.totalHits}else if(response.response.responseCode==101)console.log("invalid input");else if(response.response.responseCode==500)console.log("server error");$rootScope.hideloader()}).catch(function(error){$rootScope.hideloader();console.error("error: "+error)})};$rootScope.showMoreDataOnScroll=function(divId){if(divId==
"divIRpublicationData"){$rootScope.scrollCountFlag++;if($rootScope.totalirPublicationData>parseInt($rootScope.scrollCountFlag)*parseInt($rootScope.searchOffsetLimit)){$rootScope.showloader();var param={"orgId":$rootScope.orgId,"author_email_id":$rootScope.irAuthorUserids,"type":"IR","offset":parseInt($rootScope.scrollCountFlag)*parseInt($rootScope.searchOffsetLimit),"limit":$rootScope.searchOffsetLimit};PromiseAjax.getData("/ws/getAuthorPublicationData","POST",param).then(function(response){if(response!=
""&&response!=undefined&&response!=null)if(response.response.responseCode==100&&response.response.responseMessage=="SUCCESS"){angular.forEach(response.data.doclist,function(data){$rootScope.irPublicationData.push(data)});$rootScope.totalirPublicationData=response.data.totalHits}$rootScope.hideloader()}).catch(function(error){console.error("error: "+error)})}}};$rootScope.letterLimit=200;$rootScope.myValue=true;$rootScope.showCompleteText=function(boxClass){if(boxClass=="opened"){$rootScope.myValue=
false;$rootScope.letterLimit=1E11}else{$rootScope.myValue=true;$rootScope.letterLimit=200}};$scope.openViewAllFilter=function(){$scope.animationsEnabled=true;var modalInstance=$uibModal.open({animation:$scope.animationsEnabled,templateUrl:"ng/viewAllFilter",controller:"ModalInstanceCtrl",backdrop:"static",windowClass:"blustripAdd  blustripCloseIcon redclass",openedClass:"modal-open",backdropClass:"modalCustomOpacity",size:"lg",resolve:{items:function(){$rootScope.filterMapTemp=angular.copy($scope.filterMap);
$scope.filterMapDefault=angular.copy($scope.filterMap);$rootScope.sortFieldIdTemp=angular.copy($scope.sortFieldId);$rootScope.selectSubjectOrPublisherCategoryTemp=angular.copy($scope.selectSubjectOrPublisherCategory);$rootScope.selectSubPubSourceTypeNameCategoryTemp=angular.copy($scope.selectSubPubSourceTypeNameCategory);$rootScope.reprintHeaderflagValue=sessionStorage.reprintsHeaderFlag;return $scope.items}}});modalInstance.result.then(function(selectedItem){$scope.selected=selectedItem},function(){if(!$rootScope.isAppied)$rootScope.filterMap=
angular.copy($scope.filterMapDefault)});$scope.toggleAnimation=function(){$scope.animationsEnabled=!$scope.animationsEnabled}};$scope.repeatedData=function(search){$scope.allISBN=[];$scope.checkDuplicateISBNORTitle=[];angular.forEach(search,function(item){if(item.resultType=="ECATALOGUE_BASED")for(var i=0;i<item.documentList.doclist.length;i++)if(item.documentList.doclist[i].docAttrs.isbn&&item.documentList.doclist[i].docAttrs.isbn[0]!="{EMPTY}")$scope.allISBN.push({"isbn":item.documentList.doclist[i].docAttrs.isbn[0],
"title":item.documentList.doclist[i].docAttrs.doc_title[0]});else if((!item.documentList.doclist[i].docAttrs.isbn||item.documentList.doclist[i].docAttrs.isbn[0]=="{EMPTY}")&&item.documentList.doclist[i].docAttrs.eissn&&item.documentList.doclist[i].docAttrs.eissn[0]!="{EMPTY}")$scope.allISBN.push({"eissn":item.documentList.doclist[i].docAttrs.eissn[0],"title":item.documentList.doclist[i].docAttrs.doc_title[0]});else if(item.documentList.doclist[i].docAttrs.doc_title)$scope.allISBN.push({"title":item.documentList.doclist[i].docAttrs.doc_title[0]})});
for(var i=0;i<$scope.allISBN.length;i++)for(var j=0;j<$scope.allISBN.length;j++)if(i==j)continue;else if($scope.allISBN[i].isbn&&$scope.allISBN[i].isbn==$scope.allISBN[j].isbn)$scope.checkDuplicateISBNORTitle.push($scope.allISBN[i].isbn);else if($scope.allISBN[i].eissn&&!$scope.allISBN[i].isbn&&$scope.allISBN[i].eissn==$scope.allISBN[j].eissn)$scope.checkDuplicateISBNORTitle.push($scope.allISBN[i].eissn);else if(Object.keys($scope.allISBN[i]).length==1&&Object.keys($scope.allISBN[i])[0]=="title"&&
(Object.keys($scope.allISBN[j]).length==1&&Object.keys($scope.allISBN[j])[0]=="title"))if($scope.allISBN[i].title&&$scope.allISBN[i].title==$scope.allISBN[j].title)$scope.checkDuplicateISBNORTitle.push($scope.allISBN[i].title)};$scope.repeatedData($rootScope.search)});angular.module("knimbusLib").directive("html5vfix",function(){return{restrict:"A",link:function(scope,element,attr){scope.$watch(function(){attr.$set("src",attr.vsrc)})}}});
angular.module("knimbusLib").directive("scrolly",function(){return{restrict:"A",link:function(scope,element,attrs){var raw=element[0];element.bind("scroll",function(){if(raw.scrollTop+raw.offsetHeight>=raw.scrollHeight)scope.$apply(attrs.scrolly)})}}});
angular.module("knimbusLib").filter("INRdigit",function($sce){return function(input){if(!isNaN(input)&&null!=input){var result=input.toString().split(".");var lastThree=result[0].substring(result[0].length-3);var otherNumbers=result[0].substring(0,result[0].length-3);if(otherNumbers!="")lastThree=","+lastThree;var output=otherNumbers.replace(/\B(?=(\d{2})+(?!\d))/g,",")+lastThree;if(result.length>1)output+="."+result[1];return output}}});