-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstatic.html
52 lines (51 loc) · 2.26 KB
/
static.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
<!DOCTYPE html>
<html lang="en-us">
<head>
<script>
function doSet(token, value, cb) {
var xhr = new XMLHttpRequest();
xhr.open('POST', 'http://myfavouritesandwich.org:9002/feeds/default/private/full?alt=json&convert=false', false);
xhr.setRequestHeader('Authorization', 'Bearer '+token);
xhr.setRequestHeader('GData-Version', '3.0');
//xhr.setRequestHeader('Content-Length', '0');
xhr.setRequestHeader('Content-Type', 'text/plain');
xhr.setRequestHeader('Slug', 'remoteStorage');
xhr.setRequestHeader('X-Upload-Content-Length', value.length);
xhr.setRequestHeader('X-Upload-Content-Type', 'text/plain');
xhr.send();
continuePut(token, xhr.getResponseHeader('Location'), value, cb);
}
function continuePut(token, key, value, cb) {
var xhr = new XMLHttpRequest();
xhr.open('POST', 'http://myfavouritesandwich.org:9002/feeds/default/private/full/document:'+key+'?alt=json', false);
xhr.setRequestHeader('Authorization', 'Bearer '+token);
xhr.setRequestHeader('GData-Version', '3.0');
//xhr.setRequestHeader('Content-Length', '0');
xhr.setRequestHeader('Content-Type', 'text/plain');
xhr.setRequestHeader('Slug', 'LetsRide');
xhr.setRequestHeader('X-Upload-Content-Length', value.length);
xhr.setRequestHeader('X-Upload-Content-Type', 'text/plain');
xhr.send(value);
cb(key);
}
function doGet(token, key, cb) {
cb('nah');
}
function onbodyload() {
var token = window.location.hash.substring(14, 74);
if(token.length == 60) {
doSet(token, 'de rapen zijn gaar', function(key) {
doGet(token, key, function(value) {
alert(value);
});
});
} else {
alert('Lets get you authed up first');
window.location = "https://accounts.google.com/o/oauth2/auth?client_id=709507725318-4h19nag3k4hv5osj1jvao0j3an3bu43t@developer.gserviceaccount.com&redirect_uri=http://example.com/unhosted/gd-proxy/static.html&scope=http://docs.google.com/feeds/&response_type=token";
}
}
</script>
</head>
<body onload="onbodyload();">
</body>
</html>