This repository has been archived by the owner on Jul 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 69
/
Copy pathindex.html
93 lines (83 loc) · 2.84 KB
/
index.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
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
<html>
<head>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
<style>
#drop_zone {
border: 2px dashed #bbb;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
padding: 25px;
text-align: center;
font: 20pt bold 'Helvetica';
color: #bbb;
}
</style>
</head>
<body>
<span id="signin">
<span
class="g-signin"
data-callback="signinCallback"
data-clientid="692008307570.apps.googleusercontent.com"
data-cookiepolicy="single_host_origin"
data-scope="https://www.googleapis.com/auth/drive.file">
</span>
</span>
<div id="drop_zone" style="display:none;">Drop files here</div>
<div id="results"/>
<script src="upload.js"></script>
<script type="text/javascript">
var accessToken = null;
/**
* Callback for G+ Sign-in. Swaps views if login successful.
*/
function signinCallback(result) {
if(result.access_token) {
accessToken = result.access_token;
document.getElementById('signin').style.display = 'none';
document.getElementById('drop_zone').style.display = null;
}
}
/**
* Called when files are dropped on to the drop target. For each file,
* uploads the content to Drive & displays the results when complete.
*/
function handleFileSelect(evt) {
evt.stopPropagation();
evt.preventDefault();
var files = evt.dataTransfer.files; // FileList object.
var output = [];
for (var i = 0, f; f = files[i]; i++) {
var uploader = new MediaUploader({
file: f,
token: accessToken,
onComplete: function(data) {
var element = document.createElement("pre");
element.appendChild(document.createTextNode(data));
document.getElementById('results').appendChild(element);
}
});
uploader.upload();
}
}
/**
* Dragover handler to set the drop effect.
*/
function handleDragOver(evt) {
evt.stopPropagation();
evt.preventDefault();
evt.dataTransfer.dropEffect = 'copy';
}
/**
* Wire up drag & drop listeners once page loads
*/
document.addEventListener('DOMContentLoaded', function () {
var dropZone = document.getElementById('drop_zone');
dropZone.addEventListener('dragover', handleDragOver, false);
dropZone.addEventListener('drop', handleFileSelect, false);
});
</script>
<script src="https://apis.google.com/js/client:plusone.js"></script>
</body>
</html>