-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathstream.html
60 lines (47 loc) · 1.73 KB
/
stream.html
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
<!doctype html>
<html lang="en">
<head>
<title>Stream — Pryv JS lib example</title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto+Condensed:300,400,700" type="text/css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,400italic" type="text/css">
<link rel="stylesheet" type="text/css" href="https://api.pryv.com/style/pryv.min.css">
<!-- Paths assume we're in dist/examples/ (update as needed) -->
<script src="../pryv.js"></script>
</head>
<body>
<div class="container container-narrow">
<h1>Example: Stream</h1>
<h5>Actions</h5>
<button onClick='getStreamEvents()'>StreamEvents</button>
<div class="clearfix"></div>
<h3>Console</h3>
<textarea id='console'></textarea>
</div>
</body>
<script>
var $console = document.getElementById('console');
const apiEndpoint = 'https://[email protected]';
// will handle the connection
var connection = new pryv.Connection(apiEndpoint);;
function getStreamEvents() {
var params = { limit: 10000 };
function foreachEvent(event) {
// logToConsole(JSON.stringify(event));
console.log('.');
}
connection.getEventsStreamed(params, foreachEvent).then(function (res, err) {
logToConsole('*** DONE ****: ' + JSON.stringify(res));
});
}
function logToConsole(text) {
$console.value += text + '\n';
$console.scrollTop = $console.scrollHeight;
}
function display(obj, $textArea) {
$textArea.value = JSON.stringify(obj, null, 2);
}
</script>
</html>