-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSearch.html
75 lines (73 loc) · 1.99 KB
/
Search.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
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<style>
body {
font-family: sans-serif;
font-size: 14px;
}
fieldset {
background-color: #eeeeee;
}
legend {
background-color: gray;
color: white;
padding: 5px 10px;
}
label {
display: inline-block;
width: 90px;
text-align: right;
}
input {
margin: 5px;
}
div.note {
font-size: 11px;
text-align: right;
}
div.submit {
text-align: center;
}
</style>
<script>
// Prevent forms from submitting natively (developers.google.com)
function preventFormSubmit() {
var form = document.getElementById('search_form');
form.addEventListener('submit', function(event) {
event.preventDefault();
});
}
window.addEventListener('load', preventFormSubmit);
function handleSearch(formObject) {
showMessage('Loading...');
google.script.run.withFailureHandler(onFailure).withSuccessHandler(onSuccess).SearchFredSeries(
formObject.search_text.value, formObject.limit.value);
}
function showMessage(msg) {
var div = document.getElementById('output');
div.innerHTML = msg;
}
function onFailure(error) {
showMessage(error.message);
}
function onSuccess(count) {
showMessage(`Done. ${count} result(s).`);
}
</script>
</head>
<body>
<form id="search_form" onsubmit="handleSearch(this)">
<fieldset>
<label for="search_text">Search terms:</label>
<input name="search_text" type="text" /><br>
<label for="limit">Limit:</label>
<input name="limit" type="text" /><br>
<div class="note">Results limited to 1000 series (default)</div>
<div class="submit"><input type="submit" value="Search" /></div>
</fieldset>
</form>
<div id="output"></div>
</body>
</html>