-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
230 lines (202 loc) · 7.67 KB
/
index.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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-JPZZ5CWW1Y"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-JPZZ5CWW1Y');
</script>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>0plot</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.62.0/codemirror.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.62.0/codemirror.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.62.0/mode/python/python.min.js"></script>
<script src="https://cdn.jsdelivr.net/pyodide/v0.22.1/full/pyodide.js"></script>
<script src="script.js" defer></script>
<style>
#loading-overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
display: flex;
justify-content: center;
align-items: center;
z-index: 9999;
}
#loading-text {
font-size: 24px;
color: white;
}
#loading-init {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
display: flex;
justify-content: center;
align-items: center;
z-index: 9999;
}
#loading-init-text {
font-size: 24px;
color: white;
}
.hidden {
display: none !important;
}
#main-container {
display: flex;
}
#code-container {
display: flex;
flex-direction: column;
margin-right: 20px;
}
#code-and-error-container {
display: flex;
flex-wrap: nowrap;
justify-content: flex-start;
/* Add this to align the items to the start */
max-width: 100%;
/* Add this to prevent overflow */
}
#python-code,
#python-error {
flex: 0 1 auto;
/* Change this to 0 1 auto */
}
#plot-container {
flex: 1;
/* Add this to make the plot container take up the remaining space */
}
#python-error {
white-space: pre-wrap;
color: red;
padding-left: 20px;
}
#plot-and-explanation-container {
flex: 0 1 auto;
/* Change this to 0 1 auto */
}
#chatbot-question {
width: 500px;
height: 120px;
resize: none;
overflow: auto;
font-size: 1.1em;
/* Add this line to make the font slightly bigger */
font-weight: bold;
/* Add this line to make the font bold */
}
#explanation {
width: 500px;
}
#error-container {
display: flex;
flex-direction: column;
max-height: 600px; /* Add this line to set a fixed height */
overflow-y: auto; /* Add this line to make the container scrollable */
}
#footer {
text-align: left;
margin-top: 20px;
}
#error-container {
display: flex;
flex-direction: column;
}
#header {
display: flex;
align-items: center;
}
#logo {
margin-right: 10px;
}
#fix-error {
width: 200px;
}
.btn-dark {
background-color: #10a37f;
border-color: #10a37f;
color: #fff;
}
.btn-dark:hover {
background-color: #008966;
border-color: #008966;
color: #fff;
}
.btn-dark:active,
.btn-dark:focus {
background-color: #10a37f !important;
border-color: #10a37f !important;
box-shadow: none !important;
}
#run-code {
width: 50px;
margin-top: 15px;
}
.content-container {
padding-left: 15px;
}
</style>
</head>
<body>
<div class="content-container">
<div id="header">
<!-- Add this div to wrap the logo and title --> <img src="logo.png" id="logo" height="60px" width="60px" class="img-fluid me-2">
<h1>0plot</h1>
</div>
<div id="loading-overlay" class="hidden">
<div id="loading-text">Waiting for GPT<span id="ellipsis">.</span></div>
</div>
<div id="loading-init">
<div id="loading-init-text">Loading... This takes ~4 seconds<span id="init-ellipsis">...</span></div>
</div>
<div id="content" class="hidden">
<div class="mb-3"> <label for="api-key" class="form-label">OpenAI API Key:</label> <input type="text" id="api-key" name="api-key" class="form-control" placeholder="This is a client-side web app, your API key will not be shared with us." style="width: 525px;"> </div>
<div class="mb-3"> <label for="chatbot-question" class="form-label">Current Command:</label> <textarea id="chatbot-question" name="chatbot-question" class="form-control" placeholder="In natural language, describe what you want to plot or how you want to modify the existing plot. We'll then use GPT to automatically write the code for that. You can also modify the code it returns manually."></textarea> </div>
<div id="main-container">
<div id="code-container">
<div id="code-and-error-container">
<div id="python-code"></div>
<div id="error-container">
<div id="python-error"></div> <br> <button id="fix-error" class="btn btn-dark hidden">Try to fix this automatically with GPT</button>
</div>
</div> <button id="run-code" class="btn btn-dark">GO</button>
<div class="d-inline-flex align-items-center">
<label for="model-selector" class="form-label me-2">Model:</label>
<select id="model-selector" class="form-select" style="width: auto;">
<option value="gpt-3.5-turbo" selected>ChatGPT (3.5-turbo)</option>
<option value="gpt-4">GPT-4</option>
</select>
</div>
</div>
<div id="plot-and-explanation-container">
<div id="plot-container"></div>
<div id="explanation"></div>
</div>
</div>
<div id="footer"> Created by <a href="https://ofir.io/about">Ofir Press</a>. Open source on <a href="https://github.com/ofirpress/0plot">GitHub</a>. </div>
</div>
<script>
document.getElementById("api-key").addEventListener("input", function() {
if (this.value.length > 0) {
this.type = "password";
} else {
this.type = "text";
}
});
</script>
</div>
</body>
</html>