forked from DishpitDev/Slopify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
335 lines (297 loc) · 11.2 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Slopify</title>
<style>
body {
font-family: Arial, sans-serif;
line-height: 1.6;
margin: 0;
padding: 0;
background-color: #282828;
color: #ebdbb2;
}
header {
background: #3c3836;
color: #ebdbb2;
padding: 20px 0;
text-align: center;
}
header h1 {
margin: 0;
font-size: 2.5rem;
}
main {
padding: 20px;
max-width: 800px;
margin: 0 auto;
}
footer {
text-align: center;
padding: 10px 0;
background: #3c3836;
color: #ebdbb2;
margin-top: 20px;
}
a {
color: #b8bb26;
text-decoration: underline;
}
a:hover {
color: #83a598
}
.fishtank-container {
position: relative;
width: 100%;
height: 400px;
margin: 20px 0;
overflow: hidden;
background: rgba(40, 40, 40, 0.5);
border-radius: 8px;
}
.fishtank-canvas {
width: 100%;
height: 100%;
cursor: crosshair;
}
@media (max-width: 768px) {
.fishtank-container {
height: 300px;
}
}
@media (max-width: 480px) {
.fishtank-container {
height: 250px;
}
}
/* Optional loading placeholder */
.fishtank-placeholder {
position: absolute;
inset: 0;
background: #3c3836;
display: flex;
align-items: center;
justify-content: center;
transition: opacity 0.3s ease-out;
}
#frog {
width: 400px;
}
#stock_img {
width: 400px;
heigh: 400px;
}
</style>
</head>
<body>
<header>
<h1>Slopify</h1>
<p><em>"The <a href="https://www.newmanmentalism.com/blog/a-mentalist-explains-how-ouija-boards-work-and-the-ideomotor-effect" target="_blank">ideomotor effect</a> of software"</em></p>
<image id="frog" src="static/images/frog.webp"></image>
</header>
<main>
<section>
<h2>About Slopify</h2>
<p>Slopify is a 100% community-built open-source website and product. Its unique premise invites contributors to:</p>
<ul>
<li>Commit whatever code they want</li>
<li>Add whatever features they desire</li>
<li>Write in whatever language they prefer</li>
</ul>
<p>The only rules? Everything must work together and remain legal.</p>
</section>
<canvas id="glCanvas" width="400" height="400"></canvas>
<script>
const canvas = document.getElementById('glCanvas');
const gl = canvas.getContext('webgl2');
if (!gl) {
console.error('WebGL2 not supported');
throw new Error('WebGL2 not supported');
}
const vertexShader = gl.createShader(gl.VERTEX_SHADER);
gl.shaderSource(vertexShader, `#version 300 es
in vec4 position;
in vec4 color;
out vec4 vColor;
uniform mat4 mvp;
void main() {
vColor = color;
gl_Position = mvp * position;
}`);
gl.compileShader(vertexShader);
const fragmentShader = gl.createShader(gl.FRAGMENT_SHADER);
gl.shaderSource(fragmentShader, `#version 300 es
precision mediump float;
in vec4 vColor;
out vec4 fragColor;
void main() {
fragColor = vColor;
}`);
gl.compileShader(fragmentShader);
const program = gl.createProgram();
gl.attachShader(program, vertexShader);
gl.attachShader(program, fragmentShader);
gl.linkProgram(program);
gl.useProgram(program);
const positions = new Float32Array([
// Front
-0.5, -0.5, 0.5,
0.5, -0.5, 0.5,
0.5, 0.5, 0.5,
-0.5, 0.5, 0.5,
// Back
-0.5, -0.5, -0.5,
0.5, -0.5, -0.5,
0.5, 0.5, -0.5,
-0.5, 0.5, -0.5,
]);
const colors = new Float32Array([
// Front - red
1.0, 0.0, 0.0, 1.0,
1.0, 0.0, 0.0, 1.0,
1.0, 0.0, 0.0, 1.0,
1.0, 0.0, 0.0, 1.0,
// Back - green
0.0, 1.0, 0.0, 1.0,
0.0, 1.0, 0.0, 1.0,
0.0, 1.0, 0.0, 1.0,
0.0, 1.0, 0.0, 1.0,
]);
const indices = new Uint16Array([
// Front
0, 1, 2, 0, 2, 3,
// Back
4, 5, 6, 4, 6, 7,
// Top
3, 2, 6, 3, 6, 7,
// Bottom
0, 1, 5, 0, 5, 4,
// Right
1, 2, 6, 1, 6, 5,
// Left
0, 3, 7, 0, 7, 4
]);
const positionBuffer = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer);
gl.bufferData(gl.ARRAY_BUFFER, positions, gl.STATIC_DRAW);
const colorBuffer = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, colorBuffer);
gl.bufferData(gl.ARRAY_BUFFER, colors, gl.STATIC_DRAW);
const indexBuffer = gl.createBuffer();
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexBuffer);
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, indices, gl.STATIC_DRAW);
const vao = gl.createVertexArray();
gl.bindVertexArray(vao);
const positionLoc = gl.getAttribLocation(program, 'position');
gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer);
gl.enableVertexAttribArray(positionLoc);
gl.vertexAttribPointer(positionLoc, 3, gl.FLOAT, false, 0, 0);
const colorLoc = gl.getAttribLocation(program, 'color');
gl.bindBuffer(gl.ARRAY_BUFFER, colorBuffer);
gl.enableVertexAttribArray(colorLoc);
gl.vertexAttribPointer(colorLoc, 4, gl.FLOAT, false, 0, 0);
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexBuffer);
gl.enable(gl.DEPTH_TEST);
gl.viewport(0, 0, canvas.width, canvas.height);
const mvpLoc = gl.getUniformLocation(program, 'mvp');
let rotation = 0;
function render() {
rotation += 0.01;
const aspect = canvas.width / canvas.height;
const projectionMatrix = mat4.create();
mat4.perspective(projectionMatrix, Math.PI/4, aspect, 0.1, 100.0);
const modelViewMatrix = mat4.create();
mat4.translate(modelViewMatrix, modelViewMatrix, [0, 0, -4]);
mat4.rotateY(modelViewMatrix, modelViewMatrix, rotation);
mat4.rotateX(modelViewMatrix, modelViewMatrix, rotation * 0.5);
const mvpMatrix = mat4.create();
mat4.multiply(mvpMatrix, projectionMatrix, modelViewMatrix);
gl.uniformMatrix4fv(mvpLoc, false, mvpMatrix);
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
gl.drawElements(gl.TRIANGLES, indices.length, gl.UNSIGNED_SHORT, 0);
requestAnimationFrame(render);
}
// Include gl-matrix library for matrix operations
const script = document.createElement('script');
script.src = 'https://cdnjs.cloudflare.com/ajax/libs/gl-matrix/2.8.1/gl-matrix-min.js';
script.onload = () => {
gl.clearColor(0.0, 0.0, 0.0, 1.0);
render();
};
document.head.appendChild(script);
</script>
<section class="fishtank-container">
<div class="fishtank-placeholder">
<div class="loading-spinner">Loading...</div>
</div>
<canvas id="main-fishtank" class="fishtank-canvas"></canvas>
</section>
<section>
<h2>Stockify</h2>
<p>Throw your money to the wind with random stock decisions!</p>
<p><span id="stock_ticker" style="color:yellow;"></span><span id="stock_msg"></span></p>
<img src="" id="stock_img">
</section>
</main>
<footer>
<p>© 2024 DishpitDev. <a href="https://github.com/dishpitdev/slopify">Built by the community</a>, for the community.</p>
</footer>
<script src="fishtank.js"></script>
<script>
document.addEventListener('DOMContentLoaded', function() {
const container = document.querySelector('.fishtank-container');
function initFishtank() {
const projectTank = new FishTank('main-fishtank', {
fishCount: 8,
minSpeed: 0.3,
maxSpeed: 1.5,
buffer: 50,
});
projectTank.initialize();
// Remove placeholder after initialization
const placeholder = container.querySelector('.fishtank-placeholder');
if (placeholder) {
placeholder.style.opacity = '0';
setTimeout(() => placeholder.remove(), 300);
}
}
initFishtank();
// Handle window resize
window.addEventListener('resize', () => {
const width = container.clientWidth;
const canvas = document.getElementById('main-fishtank');
canvas.width = width;
canvas.height = width < 480 ? 250 : width < 768 ? 300 : 400;
});
});
</script>
<script type="text/javascript">
var stock_url = "https://raw.githubusercontent.com/rreichel3/US-Stock-Symbols/main/all/all_tickers.txt";
var stock_list;
var ticker;
var buy = Math.random() < 0.5;
fetch(stock_url).then(function(resp) {
resp.text().then(function(text) {
stock_list = text.split("\n");
stock_list.pop();
ticker = stock_list[Math.floor(Math.random() * stock_list.length)];
done();
});
});
function done() {
var msg = "";
if (buy) {
msg = " to the moon! BUY BUY BUY";
document.getElementById("stock_img").src = "static/images/wojak_stock_up.webp";
} else {
msg = " down the toilet! SELL SELL SELL";
document.getElementById("stock_img").src = "static/images/wojak_stock_down.gif";
}
document.getElementById("stock_ticker").textContent = ticker;
document.getElementById("stock_msg").textContent = msg;
}
</script>
</body>
</html>