-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathexample.html
More file actions
292 lines (230 loc) · 9.61 KB
/
example.html
File metadata and controls
292 lines (230 loc) · 9.61 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="http://getbootstrap.com/favicon.ico">
<script src="http://code.jquery.com/jquery-1.11.2.min.js"></script>
<script src="https://cdn.socket.io/socket.io-1.2.0.js"></script>
<title>WO API Examples</title>
<!-- Bootstrap core CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<!-- Custom styles for this template
<link href="css/cover.css" rel="stylesheet">-->
<!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
<!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
<!--<script src="./Cover Template for Bootstrap_files/ie-emulation-modes-warning.js"></script>-->
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<!--<script type="text/javascript" charset="utf-8" src="http://rawgit.com/xgfd/wo-api-js/master/wo.js"> </script>-->
<script type="text/javascript" charset="utf-8" src="wo.js"> </script>
</head>
<body>
<div class="site-wrapper">
<div class="site-wrapper-inner">
<div class="cover-container">
<div class="masthead clearfix">
<div class="inner">
<h3 class="masthead-brand">Web Observatory</h3>
<nav>
<ul class="nav masthead-nav">
<li class="active"><a href="http://webobservatory.soton.ac.uk">Web Observatory</a>
</li>
<li><a href="https://github.com/xgfd/NUS-tul">Github Entry</a>
</li>
<li><a href="http://webobservatory.soton.ac.uk/wo/visualisation#5489d93e5d38cda3271d843d">More info</a>
</li>
</ul>
</nav>
</div>
</div>
<div class="inner cover">
<h1 class="cover-heading">Basic example</h1>
<p class="lead">Click to see results</p>
<p class="lead">
<button href="#" id='authButton' class="btn btn-lg btn-default connect">Connect</button>
<p class="lead result"></p>
</div>
<div class="inner cover">
<textarea class="form-control" rows="3" id="querybox"></textarea>
<button href="#" id='strqueryButton' class="btn btn-lg btn-default connect">Query(str)</button><button href="#" id='objqueryButton' class="btn btn-lg btn-default connect">Query(Obj)</button>
</div>
<button href="#" id='streamButton' class="btn btn-lg btn-default connect">Stream</button><button href="#" id='liststreamButton' class="btn btn-lg btn-default connect">List Stream</button>
<button href="#" id='closedatasetButton' class="btn btn-lg btn-default connect">Close Dataset</button>
<button href="#" id='closestreamButton' class="btn btn-lg btn-default connect">Close Last Stream</button>
<script type="text/javascript" charset="utf-8" >
var client = new WO("webobservatory.soton.ac.uk","55197ade2a80faff1366c49e"); //new client
$('#authButton').click(client.login); // assign the button to login
//document.getElementById("authButton").addEventListener("click",client.login);
var hash = window.location.hash; //getting the access token after the hash after login.
if (hash.match(/access_token/g))
{
$('#authButton').text('Logged in');
$('#authButton').prop('disabled',true);
}
var cb = function(err, data)
{
if (!err)
{
console.log(data);
}
else
{
console.log(err);
}
};
//stream callback
var scb = function(err, data, stream)
{
if (!err)
{
console.log("stream data: ");
console.log(data);
console.log("stream object:");
console.log(stream);
//stream.emit("stop");
}
else
{
console.log(err);
}
};
//string query function example:
var queryfunc = function()
{
var querystring = "SELECT * WHERE { ?subject rdf:type ?class} LIMIT 10";
if ($('#querybox').val()) //use the query in the text box if specified
{
querystring = $('#querybox').val();
}
console.log(querystring);
client.query('52e19220bef627683c79c3a6',querystring,cb);
}
$('#strqueryButton').click(queryfunc); //assign the query function to query button
//object query function example:
var objqueryfunc = function()
{
var q = {
collection:"abuse_entries_2014_12",
query:'{}',
limit:1,
skip:0
};
if ($('#querybox').val()) //use the query in the text box if specified
{
q.query = $('#querybox').val();
}
client.query("54eb0a1d590ea23530f24644",q,cb);
}
$('#objqueryButton').click(objqueryfunc); //assign the query function to query button
//open stream function example:
var openstreamfunc = function()
{
var q = {
query:"logs",
};
// if ($('#querybox').val()) //use the query in the text box if specified
// {
// q.query = $('#querybox').val();
// }
//console.log(q);
//console.log(scb);
client.openStream("54eb13d7590ea23530f24645",q,scb);
// client.openStream("54eb13d7590ea23530f24645","logs",scb);
}
$('#streamButton').click(openstreamfunc); //assign the query function to query button
var liststreamfunc = function()
{
//console.log(client.listStream('54eb13d7590ea23530f24645'));
console.log(client.listStream());
}
$('#liststreamButton').click(liststreamfunc);
var closestreamfunc = function()
{
//console.log(client.listStream('54eb13d7590ea23530f24645'));
client.closeStream(client.listStream()[0],function(err){console.log(err);});
}
$('#closestreamButton').click(closestreamfunc);
var closedatasetfunc = function()
{
//console.log(client.listStream('54eb13d7590ea23530f24645'));
client.closeStream('54eb13d7590ea23530f24645',function(err){console.log(err);});
}
$('#closedatasetButton').click(closedatasetfunc);
</script>
<div class="mastfoot">
<div class="inner">
<p>Cover template for <a href="http://getbootstrap.com/">Bootstrap</a>, by <a href="https://twitter.com/mdo">@mdo</a>.</p>
</div>
</div>
</div>
</div>
</div>
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster
<script src="./Cover Template for Bootstrap_files/jquery.min.js"></script>-->
<script type="text/javascript" charset="utf-8">
/*
//do your business here
$(function()
{
//an example
var options = {
//things you'd like to do AFTER having the access token
after: function(token)
{
alert('Your access token is ' + token); // show your access token
},
//things you'd like to do BEFORE having the access token
before: function(authUrl)
{
$("a.connect").attr("href", authUrl); //display a link to
}
};
var client = WO("webobservatory.soton.ac.uk","53cd0826eaba57bd64ffa6fb"); //new client
console.log(client);
$('#authButton').click(client.login);
var queryopt = {
query:
{
modname: "tweets", //mongodb collection name, required
query: "{}", //mongodb query, required
limit: 20, //query modifier, optional
skip: 0 //query modifier, optional
},
//dataset id of interest, required
dataset: "548047c832582f2c45520ce7" //ebola mongodb
};
//callback function, what you'd like to do with the results, stored in response
var nowIhaveData = function(data)
{
var container = $('p.result');
if (data)
{
alert(data);
//$('a.connect').fadeOut();
//container.text(data);
}
else
{
alert("Error occured");
//container.text("An error occurred.");
}
};
client.query(queryopt, nowIhaveData);
});
*/
</script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<!--<script src="./Cover Template for Bootstrap_files/docs.min.js"></script>-->
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<!--<script src="./Cover Template for Bootstrap_files/ie10-viewport-bug-workaround.js"></script>-->
</body>
</html>