-
Notifications
You must be signed in to change notification settings - Fork 0
/
popup.js
53 lines (47 loc) · 1.74 KB
/
popup.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
var req = new XMLHttpRequest();
req.open(
"GET",
"http://api.flickr.com/services/rest/?" +
"method=flickr.photos.search&" +
"api_key=90485e931f687a9b9c2a66bf58a3861a&" +
"text=hello%20world&" +
"safe_search=1&" + // 1 is "safe"
"content_type=1&" + // 1 is "photos only"
"sort=relevance&" + // another good one is "interestingness-desc"
"per_page=20",
true);
// req.onload = showPhotos;
req.onload = getUrl;
req.send(null);
function getUrl() {
document.getElementById('pageSummary').innerHTML = "<img src='loading.gif' />";
// chrome.tabs.query({active: true}, function(tab) {
chrome.tabs.getSelected(null, function(tab) { // DEPRECATED
chrome.tabs.sendMessage(tab.id, {askFor: "body"}, function(response) {
document.getElementById('pageSummary').innerHTML = response.docBody;
});
});
}
// PASS THE URL OF THE CURRENT TAB
// document.getElementById('currentLink').innerHTML = tab.url;
// });
// function showPhotos() {
// var photos = req.responseXML.getElementsByTagName("photo");
//
// for (var i = 0, photo; photo = photos[i]; i++) {
// var img = document.createElement("image");
// img.src = constructImageURL(photo);
// document.body.appendChild(img);
// }
// }
// See: http://www.flickr.com/services/api/misc.urls.html
// function constructImageURL(photo) {
// return "http://farm" + photo.getAttribute("farm") +
// ".static.flickr.com/" + photo.getAttribute("server") +
// "/" + photo.getAttribute("id") +
// "_" + photo.getAttribute("secret") +
// "_s.jpg";
// }