-
Notifications
You must be signed in to change notification settings - Fork 4
/
settings.html
39 lines (35 loc) · 996 Bytes
/
settings.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
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<link rel="stylesheet" href="https://ssl.gstatic.com/docs/script/css/add-on.css">
</head>
<body>
<div class="sidebar branding-below">
<form>
<div class="block">
<label for="apiKey">OpenAI API Key</label>
<input type="password" id="apiKey" class="input-field">
</div>
<div class="block">
<button type="button" class="blue" id="saveButton">Save</button>
</div>
</form>
</div>
<script>
document.getElementById('saveButton').addEventListener('click', saveApiKey);
function saveApiKey() {
const apiKey = document.getElementById('apiKey').value;
google.script.run
.withSuccessHandler(function() {
google.script.host.close();
console.log('API key saved successfully');
})
.withFailureHandler(function(error) {
console.error('Failed to save API key:', error);
})
.saveApiKey(apiKey);
}
</script>
</body>
</html>