-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
439 lines (396 loc) · 14.5 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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Gartic Diffusion</title>
<meta content="Gartic Diffusion" property="og:title" />
<meta content="like Gartic Phone but with more art theft" property="og:description" />
<meta content="https://garticdiffusion.kotob.dev/logo2.png" property="og:image" />
<style>
/*Some CSS (and the general style) taken from cobalt.tools! Been my style of choice for hacky projects for a while*/
/*(technically came from an old project called Colonthree that took it from cobalt but whatever)*/
body {
font-family: 'Courier New', monospace;
background-color: #000;
color: #fff;
margin: 0;
padding: 20px;
}
.button {
display: inline-block;
padding: 10px 20px;
font-family: inherit;
font-size: 16px;
font-weight: bold;
text-decoration: none;
background-color: rgb(0, 0, 0);
color: rgb(255, 255, 255);
border: 0.1rem solid #fff;
border-radius: 0px;
transition: background-color 0.3s ease, color 0.3s ease;
}
.button:hover {
background-color: rgb(255, 255, 255);
color: rgb(0, 0, 0);
cursor: pointer;
}
.smallh2 {
color: rgb(127, 127, 127);
font-size: 12px;
font-family: 'Courier New', monospace;
margin: 10px;
}
.normh2 {
color: rgb(127, 127, 127);
font-size: 18px;
font-family: 'Courier New', monospace;
}
.title {
color: rgb(255, 255, 255);
font-size: 86pt;
font-family: 'Courier New', monospace;
margin: 10px;
}
/*message box: white, rounded, black text inside*/
.message-box {
background-color: #fff;
border-radius: 8px;
color: #000;
padding: 20px;
margin: 20px;
align-self: flex-start;
}
/*text for text box*/
.message-box .text {
font-size: 16px;
font-family: 'Courier New', monospace;
}
.checkbox {
display: inline-block;
width: 20px;
height: 20px;
border: 2px solid #fff;
background-color: #000;
transition: background-color 0.3s ease;
}
.checkbox:checked {
background-color: #fff;
}
/*Global div: centers all elements inside horizontally and vertically (stacked on top of each other)*/
.main-center {
margin:0;
display: flex;
justify-content: center;
align-items: center;
height:100vh;
flex-direction: column;
}
.end-center {
margin:0;
display: flex;
justify-content: center;
align-items: center;
flex-direction: row;
}
/*MessageWIndow: A box for displaying multiple "messages": .end-image and .message-box. Thin white outline, rounded.*/
.message-window {
display: flex;
flex-direction: column;
align-items: flex-end;
border-radius: 8px;
background-color: rgb(0, 0, 0);
border: 0.1rem solid #ffffff;
/*width: 80%;*/
height: 50%;
box-shadow: 0 0 0px #ffffff; /* Adjust color and size as needed */
margin: 10px;
overflow-y: auto;
}
.main-image {
position: relative;
overflow: hidden;
border-radius: 8px;
background-color: rgb(255, 255, 255);
aspect-ratio: 1;
width: 60vh;
height: 60vh;
box-shadow: 0 0 10px #ffffff; /* Adjust color and size as needed */
}
.main-image img {
width: 100%;
height: 100%;
object-fit:cover;
transition: transform 0.3s ease;
}
.end-image {
position: relative;
overflow: hidden;
border-radius: 8px;
background-color: rgb(255, 255, 255);
aspect-ratio: 1;
width: 35%;
height: 30%;
margin: 5%;
box-shadow: 0 0 25px #ffffff; /* Adjust color and size as needed */
align-self: end;
}
.end-image img {
width: 100%;
height: 100%;
object-fit:cover;
transition: transform 0.3s ease;
}
.input-bar {
font-family:inherit;
border-radius: 0px;
border-bottom: .1rem solid var(--accent-unhover);
transition: border-image 0.5s;
padding: 32px;
width: 50%;
}
.input-bar input[type="text"] {
font-family:inherit;
padding: 8px;
font-size: 16px;
color: white;
background: none;
border-radius: 0px;
border: 1px;
border-image: linear-gradient(0.25turn, white, white, white);
border-image-slice: 1;
border-bottom: 0.1rem solid transparent;
width: 100%;
transition: border-image 0.5s;
}
.input-bar input[type="text"]:focus {
outline-width: 0px;
outline: none;
border-bottom: 0.1rem solid transparent;
border-image: linear-gradient(0.25turn, rgb(255, 255, 255), rgba(56,2,155,0));
border-image-slice: 1;
}
.hidden {
opacity: 0;
transition: opacity 0.5s ease-in-out; /* Adjust the duration and easing as needed */
}
.hidden2 {
display: none;
}
.visible {
opacity: 1;
transition: opacity 0.5s ease-in-out; /* Adjust the duration and easing as needed */
}
.visible2 {
display: flex;
}
/*dropdown class with a similar visual style*/
.dropdown {
margin: 10px;
font-family: 'Courier New', monospace;
color: #fff;
}
</style>
</head>
<div class="main-center" id="login">
<h1 class="title">Gartic Diffusion</h1>
<h2 class="normh2">like Gartic Phone but with more art theft</h2>
<div class="input-bar" style="width: 20%">
<input type="text" placeholder="your name here :3" id="nameinput">
</div>
<button class="button" onclick="addUser()" id="initButton">Initialize</button>
</div>
<div class="main-center hidden hidden2" id="whar">
<div class="main-image">
<img src="test.jpg" id="realimagemain">
</div>
<div class="input-bar">
<input type="text" placeholder="What will you generate?" id="maininput">
</div>
<!--
<div class="message-window">
<div class="message-box">
<div class="text">what</div>
</div>
</div>
<div class="end-image">
<img src="test.jpg">
</div>
</div>
-->
<div style="display: flex; justify-content: space-between;">
<!--<div class="dropdown">
<label for="sample-mode">Sample Mode:</label>
<select id="sample-mode">
<option value="default">Default</option>
<option value="artsy">Artsy</option>
</select>
</div>-->
<div class="dropdown">
<label for="gen-mode">"Easy" Mode:</label>
<select id="gen-mode">
<option value="disabled">Disabled</option>
<option value="enabled">Enabled</option>
</select>
</div>
</div>
<button class="button" onclick="generate()" id="genButton">Submit</button>
<div class="smallh2" id="extrainfo">extra info here xddddddddd</div>
</div>
<!--websocket example script-->
<script>
//this is terrible practice but idc if i get this working at all im happy
var username = ''
var url = "garticdiffusion.kotob.dev";
var ws = new WebSocket("wss://gdws.kotob.dev/");
ws.onopen = function() {
console.log("Connected");
};
ws.onmessage = function(evt) {
//console.log(evt.data);
//var data = JSON.parse(evt.data);
//if data is json, parse it, else, just set data to evt.data
var data = evt.data;
try {
data = JSON.parse(evt.data);
} catch (e) {
console.log("Not JSON");
}
if (data.type == "newRoundImage")
{
document.getElementById("realimagemain").src = data.url;
document.getElementById("extrainfo").textContent = `New image!`
document.getElementById("maininput").value = ``;
document.getElementById("genButton").style.display = "inline-block"
}
if (data.type == 'roundOver')
{
document.getElementById("extrainfo").textContent = `Round is over! Waiting for generation...`
}
if (data.type == 'PromptSubmitted' && document.getElementById("extrainfo").textContent != `Round is over! Waiting for generation...`)
{
document.getElementById("extrainfo").textContent = `Prompt submitted! Waiting for others...`
document.getElementById("genButton").style.display = "none";
}
if (data.type == 'gameOver')
{
document.getElementById("extrainfo").textContent = `Game over!`
addImages(data.message);
}
};
ws.onclose = function() {
console.log("Disconnected");
document.getElementById("extrainfo").textContent = `HEY YOU GOT DISCONNECTEWD LMAOAOOOOOO`
};
function generate() {
var prompt = document.getElementById("maininput").value;
if(document.getElementById("gen-mode").value == "enabled")
{
prompt += ", photography, render, detailed, masterpiece, 8k, (realistic, UE5, deviantart),"
}
var data = {
type: "promptSubmit",
name: username,
message: prompt
}
ws.send(JSON.stringify(data));
}
function addUser() {
username = document.getElementById("nameinput").value
var data = {
type: "login",
name: username,
message: ``
}
ws.send(JSON.stringify(data));
//delete name input
//document.getElementById("nameinput").remove()
//delete initialize button
//document.getElementById("initButton").remove()
showMainPage();
document.getElementById("extrainfo").textContent = `Successfully initialized! You are now ${username}!`
}
function addImages(json) {
var data = JSON.parse(json);
var processedData = [];
var processedPositions = [];
console.log(data)
//for each element in data, check the .position. create a new array containing every element with the same .position as each other
//or smth idk chatgpt did it s own thing
for (var i = 0; i < data.length; i++) {
var position = data[i].position;
// Check if the position has already been processed
if (processedPositions.includes(position)) {
continue;
}
var tempArray = [];
// Find all elements with the same position
for (var j = 0; j < data.length; j++) {
if (data[j].position == position) {
tempArray.push(data[j]);
}
}
processedData.push(tempArray);
processedPositions.push(position);
}
console.log(processedData)
var newWhar = document.createElement("div");
newWhar.id = "newWhar";
newWhar.className = "end-center";
document.body.appendChild(newWhar);
var orderedData = [];
console.log("ordered data: " + orderedData)
for (var j = 0; j < processedData.length; j++)
{
//create new message-window
var newWindow = document.createElement("div");
newWindow.className = "message-window";
for(var i = 0; i < processedData[j].length; i++)
{
var newDiv = document.createElement("div");
newDiv.className = "message-box";
newDiv.innerHTML = `<div class="text"><b>${processedData[j][i].username}</b></div>\n<div class="text">${processedData[j][i].prompt}</div>`;
newWindow.appendChild(newDiv);
newDiv.classList.add("hidden");
orderedData.push(newDiv);
var newImg = document.createElement("img");
newImg.src = processedData[j][i].url;
newImg.className = "end-image";
newWindow.appendChild(newImg);
newImg.classList.add("hidden");
orderedData.push(newImg);
}
newWhar.appendChild(newWindow);
}
document.getElementById("whar").classList.add("hidden");
document.getElementById("whar").classList.add("hidden2");
//create a loop where every five seconds, remove .hidden from element i in orderedData
var i = 0;
var interval = setInterval(function() {
console.log("wsg")
if (i >= orderedData.length)
{
clearInterval(interval);
return;
}
orderedData[i].classList.remove("hidden");
i++;
}, 4000);
}
function showMainPage() {
var loginPage = document.getElementById('login');
var mainPage = document.getElementById('whar');
// Fade out the login page
loginPage.classList.add('hidden');
// Delay the display of the main page to allow the fade-out effect
setTimeout(function () {
mainPage.classList.remove('hidden2');
mainPage.classList.remove('hidden');
loginPage.classList.add('hidden2');
// Remove the 'hidden' class from the main page, triggering fade-in
mainPage.classList.add('visible');
}, 500); // Should match the transition duration in milliseconds
}
</script>
</body>
</html>