-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.html
76 lines (72 loc) · 3.61 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Tribune Geocoder</title>
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.2/css/bootstrap.min.css" rel="stylesheet">
<link href="/style.css" rel="stylesheet">
</head>
<body>
<div class="site-wrapper">
<div class="site-wrapper-inner">
<div class="cover-container">
<div class="masthead clearfix">
<div class="inner">
<h3 class="masthead-brand">Tribune Geocoder</h3>
</div>
</div>
<div class="inner cover">
<h1 class="cover-heading">Upload a file containing addresses to geocode</h1>
<input type="file" id="file-chooser" class="lead btn btn-default" />
<br><br>
<input type="email" id="email" class="lead" placeholder="Your email address"/>
<br><br>
<button id="upload-button" class="lead btn btn-default">Upload</button>
<br><br>
<div id="results" class="lead"></div>
</div>
<div class="mastfoot">
<div class="inner">
<p>Chicago Tribune News Applications, 2015</p>
</div>
</div>
</div>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.2/js/bootstrap.min.js"></script>
<script src="https://sdk.amazonaws.com/js/aws-sdk-2.1.10.min.js"></script>
<script type="text/javascript">
AWS.config.region = 'us-east-1';
AWS.config.credentials = new AWS.CognitoIdentityCredentials({
IdentityPoolId: 'us-east-1:c615602e-7d05-45bd-80bc-9bab7e0015c5'
});
// Shamelessly stolen from AWS JS SDK docs
var bucket = new AWS.S3({params: {Bucket: 'geo.tribapps.com'}}),
fileChooser = document.getElementById('file-chooser');
$('#upload-button').click(function() {
var file = fileChooser.files[0];
if (file) {
$('#results').html('');
var email = $('#email').val();
var params = {
Key: 'geocode_awaiting_submission/' + file.name,
ContentType: file.type,
Body: file,
Metadata: { Email: email }
};
var success = 'File successfully uploaded.<br><br>Results, when ready, will be available <a href="/geocode_finished_jobs/' + file.name + '">here</a>.<br><br>We\'ll send ' + email + ' an email when they\'re done; expect to wait at least 15 minutes for smaller jobs, a bit longer for much larger ones.';
bucket.upload(params, function (err, data) {
if (err)
console.log(err, data);
$('#results').html(err ? 'Error uploading file.' : success);
});
} else {
$('#results').html('Nothing to upload.');
}
});
</script>
</body>
</html>