-
Notifications
You must be signed in to change notification settings - Fork 0
/
librarian.html
50 lines (40 loc) · 1.63 KB
/
librarian.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
<!-- Use this CSS stylesheet to ensure that add-ons styling
matches the default Google Docs styles -->
<link href="https://ssl.gstatic.com/docs/script/css/add-ons.css"
rel="stylesheet">
<!-- The sidebar will have a input box and the search button -->
<div class="sidebar">
<!-- The search box for Google Maps -->
<div class="block form-group">
<input type="text" id="search" placeholder="Enter ISBN... " />
<button class="blue" id="load_maps">Search Google Books</button>
</div>
<!-- The container for the Google Maps static image -->
<div id='maps'></div>
</div>
<!-- Load the jQuery library from the Google CDN -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js">
</script>
<script>
// Attach click handlers after the Sidebar has loaded in Google Docs
$(function() {
// Use Static Maps to generate an image of the address entered by the user
$('#load_maps').click(function() {
var mapURL = 'https://maps.googleapis.com/maps/api/staticmap?center='
+ encodeURIComponent($('#search').val())
+ '&zoom=14&size=200x400&sensor=false';
$('#maps').html('<img src=" ' + mapURL + ' "/>');
});
// If the user presses the Enter key in the search box, perform a search
$('#search').keyup(function(e) {
if (e.keyCode === 13) {
$('#load_maps').click();
}
});
// When a user clicks the thumbnail image in the sidebar, call
// insertGoogleMap to insert the maps image in the current document
$('#maps').click(function() {
google.script.run.insertGoogleMap($('#search').val());
});
});
</script>