(albumName)
| 80 | // snippet-start:[s3.JavaScript.s3_PhotoViewer.viewAlbum] |
| 81 | // Show the photos that exist in an album. |
| 82 | function viewAlbum(albumName) { |
| 83 | var albumPhotosKey = encodeURIComponent(albumName) + "/"; |
| 84 | s3.listObjects({ Prefix: albumPhotosKey }, function (err, data) { |
| 85 | if (err) { |
| 86 | return alert("There was an error viewing your album: " + err.message); |
| 87 | } |
| 88 | // 'this' references the AWS.Request instance that represents the response |
| 89 | var href = this.request.httpRequest.endpoint.href; |
| 90 | var bucketUrl = href + albumBucketName + "/"; |
| 91 | |
| 92 | var photos = data.Contents.map(function (photo) { |
| 93 | var photoKey = photo.Key; |
| 94 | var photoUrl = bucketUrl + encodeURIComponent(photoKey); |
| 95 | return getHtml([ |
| 96 | "<span>", |
| 97 | "<div>", |
| 98 | "<br/>", |
| 99 | '<img style="width:128px;height:128px;" src="' + photoUrl + '"/>', |
| 100 | "</div>", |
| 101 | "<div>", |
| 102 | "<span>", |
| 103 | photoKey.replace(albumPhotosKey, ""), |
| 104 | "</span>", |
| 105 | "</div>", |
| 106 | "</span>", |
| 107 | ]); |
| 108 | }); |
| 109 | var message = photos.length |
| 110 | ? "<p>The following photos are present.</p>" |
| 111 | : "<p>There are no photos in this album.</p>"; |
| 112 | var htmlTemplate = [ |
| 113 | "<div>", |
| 114 | '<button onclick="listAlbums()">', |
| 115 | "Back To Albums", |
| 116 | "</button>", |
| 117 | "</div>", |
| 118 | "<h2>", |
| 119 | "Album: " + albumName, |
| 120 | "</h2>", |
| 121 | message, |
| 122 | "<div>", |
| 123 | getHtml(photos), |
| 124 | "</div>", |
| 125 | "<h2>", |
| 126 | "End of Album: " + albumName, |
| 127 | "</h2>", |
| 128 | "<div>", |
| 129 | '<button onclick="listAlbums()">', |
| 130 | "Back To Albums", |
| 131 | "</button>", |
| 132 | "</div>", |
| 133 | ]; |
| 134 | document.getElementById("viewer").innerHTML = getHtml(htmlTemplate); |
| 135 | document |
| 136 | .getElementsByTagName("img")[0] |
| 137 | .setAttribute("style", "display:none;"); |
| 138 | }); |
| 139 | } |
nothing calls this directly
no test coverage detected