//Given a thumbnail tag, separate the link from it by parsing it out from between the quotes of the url attribute. //thumbnailValue: The tag to parse. //mediaType: The type of media that a thumbnail is being retrieved for. //isFolder: Default false. Indicates whether the thumbnail is for a folder display or for media display. //originalWidth: Populated only for Photos. The original width of the image. //originalHeight: Populated only for Photos. The original height of the image. function getThumbnailLink(thumbnailValue, mediaType, isFolder, originalWidth, originalHeight){ var thumbnailObj = { "link": "", "scale": "", "clip": "" }; if (thumbnailValue) { var firstQuote = thumbnailValue.indexOf('"'); var endChar = (thumbnailValue.lastIndexOf('?') > -1) ? (thumbnailValue.lastIndexOf('?')) : (thumbnailValue.length); thumbnailObj.link = thumbnailValue.substring(firstQuote + 1, endChar); if (isFolder) { if (mediaType == "P") { // phibertron // thumbnailObj.link = photoFolderDefaultImg; var scaleData = getImageScale(originalWidth, originalHeight, folderWidth, folderHeight); thumbnailObj.scale = "?scale=" + scaleData.x + "x" + scaleData.y; thumbnailObj.clip = scaleData.clip; } else if (mediaType == "M") { // phibertron // thumbnailObj.link = musicFolderDefaultImg; // phibertron thumbnailObj.scale = "?scale=" + folderWidth + "x" + folderHeight; } else { // phibertron // thumbnailObj.link = videoFolderDefaultImg; thumbnailObj.scale = "?scale=" + folderWidth + "x" + folderHeight; } } else { switch (mediaType) { case "V": thumbnailObj.scale = "?scale=" + videoWidth + "x" + videoHeight; break; case "M": thumbnailObj.scale = "?scale=" + musicWidth + "x" + musicHeight; break; case "P": var scaleData = getImageScale(originalWidth, originalHeight, photoWidth, photoHeight); thumbnailObj.scale = "?scale=" + scaleData.x + "x" + scaleData.y; thumbnailObj.clip = scaleData.clip; break; } } return thumbnailObj; } } //Recursively navigate into a node until the first leaf node is identified, then set the thumbnail of that node //to an image. //image: The image to be updated when the thumbnail is identified. //id: The id to navigate into. function getFolderThumbnail(image, id){ makeGetRequest("/json/feed/" + id, { // phibertron //"start": 0, //"count": 1 }, function(response){ var json = parseJson(response); // phibertron if (json.containerContents.length > 0) { switch (json.containerContents[0].nodeType) { case "branch": getFolderThumbnail(image, json.containerContents[0].objId) break; case "leaf": // phibertron var ranNum= Math.floor(Math.random()*json.containerContents.length); var width; var height; var thumbnailData; if (json.containerContents[ranNum].objType == "P") { var resolutionPieces = json.containerContents[ranNum].resolution.split("x"); width = parseInt(resolutionPieces[0]); height = parseInt(resolutionPieces[1]); // phibertron thumbnailData = getThumbnailLink(json.containerContents[ranNum].thumbnail, json.containerContents[ranNum].objType, true, width, height); } else { // phibertron thumbnailData = getThumbnailLink(json.containerContents[ranNum].thumbnail, json.containerContents[ranNum].objType, true); } if (thumbnailData.link == videoDefaultImg || thumbnailData.link == musicDefaultImg || thumbnailData.link == photoDefaultImg) { // phibertron loadDefaultThumbnail(image, json.containerContents[ranNum].objType); } else { // phibertron if( json.containerContents[ranNum].objId.indexOf("M") == -1) { thumbnailData.link = thumbnailData.link.split("/").slice(3).join("/"); } // phibertron image.replaceWith(''); } break; } } }); }