| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * Global variable containing the query we'd like to pass to Flickr. In this | 6 * Global variable containing the query we'd like to pass to Flickr. In this |
| 7 * case, kittens! | 7 * case, kittens! |
| 8 * | 8 * |
| 9 * @type {string} | 9 * @type {string} |
| 10 */ | 10 */ |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 'per_page=20', | 30 'per_page=20', |
| 31 | 31 |
| 32 /** | 32 /** |
| 33 * Sends an XHR GET request to grab photos of lots and lots of kittens. The | 33 * Sends an XHR GET request to grab photos of lots and lots of kittens. The |
| 34 * XHR's 'onload' event is hooks up to the 'showPhotos_' method. | 34 * XHR's 'onload' event is hooks up to the 'showPhotos_' method. |
| 35 * | 35 * |
| 36 * @public | 36 * @public |
| 37 */ | 37 */ |
| 38 requestKittens: function() { | 38 requestKittens: function() { |
| 39 var req = new XMLHttpRequest(); | 39 var req = new XMLHttpRequest(); |
| 40 req.open("GET", this.kittensOnFlickr_, true); | 40 req.open("GET", this.searchOnFlickr_, true); |
| 41 req.onload = this.showPhotos_.bind(this); | 41 req.onload = this.showPhotos_.bind(this); |
| 42 req.send(null); | 42 req.send(null); |
| 43 }, | 43 }, |
| 44 | 44 |
| 45 /** | 45 /** |
| 46 * Handle the 'onload' event of our kitten XHR request, generated in | 46 * Handle the 'onload' event of our kitten XHR request, generated in |
| 47 * 'requestKittens', by generating 'img' elements, and stuffing them into | 47 * 'requestKittens', by generating 'img' elements, and stuffing them into |
| 48 * the document for display. | 48 * the document for display. |
| 49 * | 49 * |
| 50 * @param {ProgressEvent} e The XHR ProgressEvent. | 50 * @param {ProgressEvent} e The XHR ProgressEvent. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 74 "/" + photo.getAttribute("id") + | 74 "/" + photo.getAttribute("id") + |
| 75 "_" + photo.getAttribute("secret") + | 75 "_" + photo.getAttribute("secret") + |
| 76 "_s.jpg"; | 76 "_s.jpg"; |
| 77 } | 77 } |
| 78 }; | 78 }; |
| 79 | 79 |
| 80 // Run our kitten generation script as soon as the document's DOM is ready. | 80 // Run our kitten generation script as soon as the document's DOM is ready. |
| 81 document.addEventListener('DOMContentLoaded', function () { | 81 document.addEventListener('DOMContentLoaded', function () { |
| 82 kittenGenerator.requestKittens(); | 82 kittenGenerator.requestKittens(); |
| 83 }); | 83 }); |
| OLD | NEW |