-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGoogleSearchJSON.xml
70 lines (61 loc) · 1.96 KB
/
GoogleSearchJSON.xml
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?xml version="1.0" encoding="UTF-8"?>
<Module>
<ModulePrefs
title="Full Text Search Results (beta) - powered by Google">
<Require feature="pubsub" />
<Require feature="dynamic-height" />
</ModulePrefs>
<Content type="html"><![CDATA[<!--HTML-->
<!-- #includes -->
<!DOCTYPE html>
<div id="content"></div>
<script>
function getPersonId(link) {
var vars = link.split("?")[1].split("&");
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split("=");
if (pair[0] == 'Person') {
return pair[1];
}
}
return '';
};
function navigateToPerson(personid) {
gadgets.pubsub.publish("profile", personid);
};
function hndlr(response) {
var cnt = 0;
var channel = 'profile';
for (var i = 0; i < response.items.length; i++) {
var item = response.items[i];
// in production code, item.htmlTitle should have the HTML entities escaped.
document.getElementById("content").innerHTML += (cnt > 0 ? '<hr>' : '') + '<a href="#" onclick="navigateToPerson(' +
getPersonId(item.link) + ');return false;">' + item.htmlTitle + '</a></p>' + item.htmlSnippet;
cnt++;
}
if (cnt) {
gadgets.pubsub.publish("status", "GREEN:" + cnt + " UCSF Profile Pages found");
}
};
function handleResponse(obj) {
// eval(obj.data);
eval(obj.text);
gadgets.window.adjustHeight();
};
function makeRequest(url, postdata) {
var params = {};
postdata = gadgets.io.encodeValues(postdata);
params[gadgets.io.RequestParameters.METHOD] = gadgets.io.MethodType.GET;
gadgets.io.makeRequest(url + "?" + postdata, handleResponse, params);
};
var data = {
key : "AIzaSyAcJMeD2sqbtJYZ1Udkxnvayqm0ICSDKpQ",
cx : "016654132415451954564:o_v7w23054u",
q: gadgets.util.getUrlParameters()['keyword'],
callback: "hndlr"
};
makeRequest("https://www.googleapis.com/customsearch/v1", data);
</script>
]]>
</Content>
</Module>