File indexing completed on 2024-12-22 05:35:27
0001 export function getNumberOfItemsPerRow(browseListType,isMobile,containerWidth){ 0002 let itemsPerRow; 0003 if (isMobile){ 0004 if (browseListType === "skills") itemsPerRow = 1; 0005 else itemsPerRow = 2; 0006 } 0007 else { 0008 if (browseListType === "music" || browseListType === "music-test") itemsPerRow = getAdujustItemsPerRow(7,containerWidth,160 + 14) 0009 else if (browseListType === "books") itemsPerRow = getAdujustItemsPerRow(6,containerWidth,180 + 14) 0010 else if (browseListType === "apps") itemsPerRow = getAdujustItemsPerRow(7,containerWidth,160 + 14) 0011 else if (browseListType === "comics") itemsPerRow = getAdujustItemsPerRow(7,containerWidth,160 + 14) 0012 else if (browseListType === "phone-pictures") itemsPerRow = getAdujustItemsPerRow(5,containerWidth,210) 0013 else if (browseListType === "favorites" ) itemsPerRow = getAdujustItemsPerRow(1,containerWidth,containerWidth - 1); 0014 else itemsPerRow = getAdujustItemsPerRow(3,containerWidth,250 + 14) 0015 } 0016 return itemsPerRow; 0017 } 0018 0019 function getAdujustItemsPerRow(itemsPerRow,containerWidth,minWidth){ 0020 if (containerWidth / itemsPerRow > minWidth) return itemsPerRow; 0021 else { 0022 itemsPerRow = itemsPerRow - 1; 0023 if (containerWidth / itemsPerRow > minWidth) return itemsPerRow; 0024 else { 0025 itemsPerRow = itemsPerRow - 1; 0026 if (containerWidth / itemsPerRow > minWidth) return itemsPerRow; 0027 else { 0028 itemsPerRow = itemsPerRow - 1; 0029 if (containerWidth / itemsPerRow > minWidth) return itemsPerRow; 0030 else { 0031 itemsPerRow = itemsPerRow - 1; 0032 if (containerWidth / itemsPerRow > minWidth) return itemsPerRow; 0033 else { 0034 itemsPerRow = itemsPerRow - 1; 0035 if (containerWidth / itemsPerRow > minWidth) return itemsPerRow; 0036 } 0037 } 0038 } 0039 } 0040 } 0041 } 0042 0043 export function chunkArray(myArray, chunk_size){ 0044 var index = 0; 0045 var arrayLength = myArray.length; 0046 var tempArray = []; 0047 0048 for (index = 0; index < arrayLength; index += chunk_size) { 0049 const myChunk = myArray.slice(index, index+chunk_size); 0050 // Do something if you want with the group 0051 tempArray.push(myChunk); 0052 } 0053 return tempArray; 0054 } 0055 0056 export function getItemWidth(browseListType,containerWidth,itemsInRow){ 0057 let itemWidth; 0058 if (browseListType === "music" || browseListType === "music-test") itemWidth = 160 + 14; 0059 else if (browseListType === "apps") itemWidth = 160 + 14; 0060 else if (browseListType === "comics") itemWidth = 160 + 14; 0061 else if (browseListType === "books") itemWidth = 180 + 14; 0062 else itemWidth = containerWidth / itemsInRow; 0063 return itemWidth; 0064 } 0065 0066 export function getImageHeight(browseListType,itemWidth){ 0067 0068 let itemHeightDivider, imgHeight; 0069 0070 itemWidth = itemWidth - 14; 0071 0072 if (browseListType === "music" || browseListType === "music-test"){ 0073 imgHeight = 155; 0074 } 0075 else if (browseListType === "apps"){ 0076 imgHeight = 155; 0077 } 0078 else if (browseListType === "phone-pictures"){ 0079 itemHeightDivider = .5; 0080 imgHeight = itemWidth / itemHeightDivider; 0081 } 0082 else if (browseListType === "comics"){ 0083 imgHeight = 220; 0084 } 0085 else if (browseListType === "books"){ 0086 imgHeight = 220; 0087 } 0088 else if (browseListType === "favorites"){ 0089 imgHeight = 167; 0090 } 0091 else { 0092 itemHeightDivider = 1.85; 0093 imgHeight = itemWidth / itemHeightDivider; 0094 } 0095 return imgHeight; 0096 } 0097 0098 export function getImageUrl(p,itemWidth,imgHeight){ 0099 let imgUrl = ""; 0100 if (p.image_small && p.image_small.indexOf('https://') > -1 || p.image_small && p.image_small.indexOf('http://') > -1 ) imgUrl = p.image_small; 0101 else { 0102 imgUrl = json_server_images; 0103 imgUrl += "/cache/400x400/img/" + p.image_small; 0104 } 0105 return imgUrl; 0106 } 0107 0108 export function ConvertObjectToArray(object,key){ 0109 let newArray = []; 0110 for (var i in object){ 0111 const newObject = { 0112 tag:object[i], 0113 id:i 0114 } 0115 newArray.push(newObject); 0116 } 0117 return newArray; 0118 }