-
Notifications
You must be signed in to change notification settings - Fork 6
/
sidebar.html
206 lines (163 loc) · 7.73 KB
/
sidebar.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
<html><head>
<meta charset="utf-8">
<link rel="stylesheet" href="https://ssl.gstatic.com/docs/script/css/add-ons.css">
<link href="https://fonts.googleapis.com/css?family=Roboto:400,700" rel="stylesheet">
<style type="text/css">
body {
font-family: 'Roboto', sans-serif;
}
.top-logo {margin-bottom:50px;}
</style>
</head>
<body bgcolor="#44546D">
<div class="sidebar">
<form name="customerInfo" id="customerInfo">
<div class="block form-group">
<span style="color:white"><b>OCLC API Key</b></span>
<br>
<input type="password" id="apiKey" name="apiKey" placeholder="api key (required)" value=""/>
<br>
</div>
<br>
<span style="color:white"><b>Select tab that contains ISBNs</b></span>
<br>
<div class="block form-group">
<select name="searchForTab" style="text-align:left !important" id="searchForTab" onfocus="google.script.run.withSuccessHandler(showTabsInSidebar).getTabs()">
</select>
</div>
<br>
<span style="color:white"><b>Select search criteria tab</b></span>
<br>
<div class="block form-group">
<select name="tabSelection" style="text-align:left !important" id="tabSelection" onfocus="google.script.run.withSuccessHandler(showTabsInSidebar).getTabs()">
</select>
</div>
<br>
<span style="color:white"><b>Select first record when no match?</b></span>
<br>
<div class="block form-group">
<input type="checkbox" id="selectFirstRecord" name="selectFirstRecord" value="true">
</div>
<br>
<span style="color:white"><b>Start search at row#</b></span>
<br>
<div class="block form-group">
<input type="text" id="rowNumber" name="rowNumber" placeholder="rowNumber" value=""/>
<br>
<span style="color:white">(optional)</span>
</div>
<br>
<div class="block form-group">
<input type="button" class="action" value="Start Search" onclick="startSearch()" />
</div>
<br><hr>
<span style="color:white"><b>After you have performed the search you can receive an email of records (that will contain new fields you've setup in the spreadsheet).</b></span>
<br>
<span style="color:white"><b>Create MARC record file and mail to:</b></span>
<br>
<div class="block form-group">
<input type="text" id="emailAddress" name="emailAddress" placeholder="email address" value=""/>
</div>
<br>
<span style="color:white"><b>001 Value is in field:</b></span>
<div class="block form-group">
<input type="text" id="oclcNumber" name="oclcNumber" placeholder="column number?" value=""/>
</div>
<br>
<span style="color:white"><b>Start with record at row#</b></span>
<br>
<div class="block form-group">
<input type="text" id="rowNumberForEmail" name="rowNumberForEmail" placeholder="row number" value=""/>
<br>
<span style="color:white">(optional)</span>
</div>
<br>
<div class="block form-group">
<input type="button" class="action" value="email MARC file" onclick="startEmail();" />
</div>
<br><br>
<hr>
<div class="block form-group">
<input type="button" class="action" value="Click to initialize sample tabs" onclick="google.script.run.withSuccessHandler(showTabsInSidebar).initSampleData();" />
</div>
<br>
</form>
<br>
<span style="color:white"><b>v. 16</b></span>
<br>
<span style="color:white"><b><a style="color:white" href="https://github.com/suranofsky/tech-services-g-sheets-addon/blob/master/README.md#Versions" target="new">github repo.</a></b></span>
</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>
function startSearch() {
//IF BOTH DROP-DOWNS CONTAIN THE SAME TAB - SHOW AN ERROR
//searchForTab AND tabSelection
var searchCriteria = document.getElementById("searchForTab");
var selectionCriteria = document.getElementById("tabSelection");
if (searchCriteria.selectedIndex == selectionCriteria.selectedIndex) {
alert("The two drop-down boxes contain the same tab name");
}
else {
google.script.run.startLookup(document.getElementById('customerInfo'));
}
}
function startEmail() {
google.script.run.sendMARCRecordByEmail(document.getElementById('customerInfo'));
}
</script>
<script>
// The code in this function runs when the page is loaded.
// getTabs is a server side function in Code.gs
$(function() {
google.script.run.withSuccessHandler(showTabsInSidebar).getTabs();
google.script.run.withSuccessHandler(setKey).getStoredAPIKey();
google.script.run.withSuccessHandler(setEmail).getStoredEmailAddress();
google.script.run.withSuccessHandler(setOclcCol).getStoredOclcColNumber();
});
function setOclcCol(oclcColNumber) {
if (oclcColNumber == null || oclcColNumber == undefined) oclcColNumber = "";
document.getElementById('oclcNumber').value=oclcColNumber;
}
function setEmail(emailAddress) {
if (emailAddress == null || emailAddress == undefined) emailAddress = "";
document.getElementById('emailAddress').value=emailAddress;
}
function setKey(apiKey){
if (apiKey == null || apiKey === undefined) apiKey = "";
document.getElementById('apiKey').value=apiKey;
}
function showTabsInSidebar(tabs) {
//alert("test");
var select = document.getElementById("tabSelection");
var searchFor = document.getElementById("searchForTab");
var currentSelect = null;
var currentSearchForIndex = null;
try {
var currentSelectIndex = document.getElementById("tabSelection").selectedIndex;
var currentSearchForIndex = document.getElementById("searchForTab").selectedIndex;
currentSelect = document.getElementById("tabSelection").options[currentSelectIndex].value;
currentSearchForIndex = document.getElementById("searchForTab").options[currentSearchForIndex].value;
}
catch(err) {
//FINE - MAY NOT BE POPULATED YET
}
$('#tabSelection').empty();
$('#searchForTab').empty();
//ADD TABS TO DROP DOWN BOXES
for (var i = 0; i < tabs.length; i++) {
var option = document.createElement('option');
option.text = option.value = tabs[i];
select.add(option, 0);
if (currentSelect == option.text) option.selected = true;
}
for (var i = 0; i < tabs.length; i++) {
var option = document.createElement('option');
option.text = option.value = tabs[i];
searchFor.add(option, 0);
if (currentSearchForIndex == option.text) option.selected = true;
}
}
</script>
</body>
</html>