-
Notifications
You must be signed in to change notification settings - Fork 0
/
ui.html
47 lines (28 loc) · 960 Bytes
/
ui.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
<h1>Echo AI</h1>
<form id="pluginForm">
<fieldset>
<legend>What if you said...</legend>
<p>
<input type="textarea" id="promptedText" name="promptedText" value="this is the new text">
</p>
</fieldset>
<button id="generate">Generate</button>
<button id="cancel">Cancel</button>
</form>
<script>
document.getElementById('generate').onclick = (event) => {
//Get the form
let pluginForm = document.querySelector('#pluginForm')
//Get field data from the form
let pluginFormData = new FormData(pluginForm)
//Create an object and populate it with form data
let formDataObj = {}
for (let [key, value] of pluginFormData) {
formDataObj[key] = value
}
parent.postMessage({ pluginMessage: { type: 'actionGenerate', formDataObj } }, '*')
}
document.getElementById('cancel').onclick = (event) => {
parent.postMessage({ pluginMessage: { type: 'actionExit' } }, '*')
}
</script>