forked from bradjasper/ImportJSON
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImportCSVDialog.html
More file actions
40 lines (36 loc) · 1.01 KB
/
ImportCSVDialog.html
File metadata and controls
40 lines (36 loc) · 1.01 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
<!DOCTYPE html>
<html>
<head>
<script>
function onApiLoad() {
document.getElementById('file-input').addEventListener('change', readSingleFile, false);
}
function readSingleFile(e) {
var file = e.target.files[0];
if (!file)
return;
var reader = new FileReader();
reader.onload = function(e) {
google.script.run.withSuccessHandler(importOk).withFailureHandler(showResult).importCSVFactura(e.target.result);
};
reader.readAsText(file);
}
function importOk(contents) {
showResult(contents);
google.script.host.close();
}
function showResult(message) {
document.getElementById('result-header').innerHTML = "Result:"
document.getElementById('result').innerHTML = 'Error: ' + message;
}
</script>
</head>
<body>
<div>
<input type="file" id="file-input"/>
<h3 id="result-header"/>
<p id="result"/>
</div>
<script src="https://apis.google.com/js/api.js?onload=onApiLoad"></script>
</body>
</html>