-
Notifications
You must be signed in to change notification settings - Fork 1
/
gdrive.html
48 lines (40 loc) · 1.68 KB
/
gdrive.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<title>Nodesphere Demo</title>
<link rel="stylesheet" type="text/css" href="styles/app.css">
</head>
<body>
<div id="message"></div>
<div><pre id="rawData"></pre></div>
<script src="nodesphere.js"></script>
<script defer="true">
// to run from localhost, use http://localhost:8080
// to run from another domain, create a new client ID here: https://console.developers.google.com/
var GDRIVE_CLIENT_ID = '240536525529-mgoi35jr7ead3ks85q1m5dr2jcsq0v3o.apps.googleusercontent.com'
var DEMO_GDRIVE_FOLDER = '0B3Va7rwgRKG2d3EwU0NFOURxUTg'
var folderId = window.location.hash.slice(1) || DEMO_GDRIVE_FOLDER
var url = 'https://drive.google.com/drive/u/0/folders/' + folderId
message.innerHTML =
'Fetching Google Drive folder from <a href="' + url + '">' + url + '</a>...'
window.loadGoogleDriveFolder = function () {
var GoogleDrive = Nodesphere.adaptors.GoogleDrive
GoogleDrive.create({client_id: GDRIVE_CLIENT_ID})
.then(function(source) {
return source.fetch({
rootNodeId: folderId
})
}).then (function(sphere) {
message.innerHTML += '<br /><br />' +
'Retrieved data, printing resulting nodesphere:'
rawData.innerHTML = sphere.toJson({space: 4})
}).catch (function(error) {
console.error('ERROR: ' + error)
})
}
</script>
<script src="//apis.google.com/js/client.js?onload=loadGoogleDriveFolder"></script>
</body>
</html>