Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

script.js 16 KB

You have to be logged in to leave a comment. Sign In
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
  1. function parseCSV(csv) {
  2. const lines = csv.split("\n");
  3. const headers = lines[0]
  4. .split(",")
  5. .map((header) => header.replace(/"/g, "").trim());
  6. return lines
  7. .slice(1)
  8. .map((line) => {
  9. const values = line.match(/(".*?"|[^",\s]+)(?=\s*,|\s*$)/g) || [];
  10. const entry = {};
  11. headers.forEach((header, index) => {
  12. let value = values[index] ? values[index].replace(/"/g, "").trim() : "";
  13. // Remove backticks from the act/title
  14. if (header === "app") {
  15. value = value.replace(/`/g, "");
  16. }
  17. entry[header] = value;
  18. });
  19. return entry;
  20. })
  21. .filter((entry) => entry.app && entry.prompt);
  22. }
  23. // Load prompts from CSV
  24. async function loadPrompts() {
  25. const response = await fetch('/vibeprompts.csv');
  26. const text = await response.text();
  27. return parseCSV(text);
  28. }
  29. // Update prompt count
  30. function updatePromptCount(filteredCount, totalCount) {
  31. const countElement = document.getElementById('promptCount');
  32. const countNumber = countElement.getElementsByClassName('count-number')[0];
  33. if (countElement) {
  34. countNumber.textContent = `${filteredCount}`;
  35. }
  36. }
  37. // Render prompts in the main content area
  38. async function renderMainPrompts() {
  39. const prompts = await loadPrompts();
  40. const container = document.querySelector('#promptContent');
  41. if (container) {
  42. container.innerHTML = `<div class="prompts-grid">
  43. <div class="prompt-card contribute-card">
  44. <a href="https://github.com/f/awesome-chatgpt-prompts/pulls" target="_blank" style="text-decoration: none; color: inherit; height: 100%; display: flex; flex-direction: column;">
  45. <div class="prompt-title" style="display: flex; align-items: center; gap: 8px;">
  46. <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  47. <circle cx="12" cy="12" r="10"></circle>
  48. <line x1="12" y1="8" x2="12" y2="16"></line>
  49. <line x1="8" y1="12" x2="16" y2="12"></line>
  50. </svg>
  51. Add Your Vibe Prompt
  52. </div>
  53. <p class="prompt-content" style="flex-grow: 1;">
  54. Share your vibe prompts with the community! Submit a pull request to add your prompts to the collection.
  55. </p>
  56. <span class="contributor-badge">Contribute Now</span>
  57. </a>
  58. </div>
  59. ${prompts.map(({ app, prompt, contributor, techstack }) => `
  60. <div class="prompt-card">
  61. <div class="prompt-title">
  62. ${app}
  63. <div class="action-buttons">
  64. <button class="copy-button" title="Copy prompt" onclick="copyPrompt(this, '${encodeURIComponent(prompt)}')">
  65. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  66. <path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"></path>
  67. <rect x="8" y="2" width="8" height="4" rx="1" ry="1"></rect>
  68. </svg>
  69. </button>
  70. </div>
  71. </div>
  72. <p class="prompt-content">${prompt.replace(/\\n/g, '<br>')}</p>
  73. <div class="card-footer">
  74. <div class="techstack-badges">
  75. ${techstack.split(',').map(tech => `<span class="tech-badge">${tech.trim()}</span>`).join('')}
  76. </div>
  77. <a href="https://github.com/${contributor.replace('@', '')}" class="contributor-badge" target="_blank" rel="noopener">${contributor}</a>
  78. </div>
  79. </div>
  80. `).join('')}</div>`;
  81. // Add click handlers for modal
  82. const cards = container.querySelectorAll('.prompt-card:not(.contribute-card)');
  83. cards.forEach((card, index) => {
  84. card.addEventListener('click', (e) => {
  85. // Don't open modal if clicking on buttons or links
  86. if (!e.target.closest('.copy-button') && !e.target.closest('.contributor-badge')) {
  87. const promptData = prompts[index];
  88. showModal(promptData.app, promptData.prompt, promptData.contributor);
  89. }
  90. });
  91. });
  92. }
  93. updatePromptCount(prompts.length, prompts.length);
  94. }
  95. // Render prompts in the sidebar
  96. async function renderSidebarPrompts() {
  97. const prompts = await loadPrompts();
  98. const searchResults = document.getElementById('searchResults');
  99. if (searchResults) {
  100. searchResults.innerHTML = prompts.map(({ app }) => `
  101. <li class="search-result-item" onclick="scrollToPrompt('${app}')">${app}</li>
  102. `).join('');
  103. }
  104. }
  105. // Scroll to prompt card function
  106. function scrollToPrompt(title, prompt) {
  107. // Find the prompt card with matching title
  108. const cards = document.querySelectorAll('.prompt-card');
  109. const targetCard = Array.from(cards).find(card => {
  110. const cardTitle = card.querySelector('.prompt-title').textContent
  111. .replace(/\s+/g, ' ') // Normalize whitespace
  112. .replace(/[\n\r]/g, '') // Remove newlines
  113. .trim();
  114. const searchTitle = title
  115. .replace(/\s+/g, ' ') // Normalize whitespace
  116. .replace(/[\n\r]/g, '') // Remove newlines
  117. .trim();
  118. return cardTitle.toLowerCase().includes(searchTitle.toLowerCase()) ||
  119. searchTitle.toLowerCase().includes(cardTitle.toLowerCase());
  120. });
  121. if (targetCard) {
  122. // Remove highlight from all cards
  123. cards.forEach(card => {
  124. card.style.transition = 'all 0.3s ease';
  125. card.style.transform = 'none';
  126. card.style.boxShadow = 'none';
  127. card.style.borderColor = '';
  128. });
  129. // Different scroll behavior for mobile and desktop
  130. const isMobile = window.innerWidth <= 768;
  131. const headerHeight = document.querySelector('.site-header').offsetHeight;
  132. if (isMobile) {
  133. // On mobile, scroll the window
  134. const cardRect = targetCard.getBoundingClientRect();
  135. const scrollTop = window.pageYOffset + cardRect.top - headerHeight - 20;
  136. window.scrollTo({
  137. top: scrollTop,
  138. behavior: 'smooth'
  139. });
  140. } else {
  141. // On desktop, scroll the main-content container
  142. const mainContent = document.querySelector('.main-content');
  143. const cardRect = targetCard.getBoundingClientRect();
  144. const scrollTop = mainContent.scrollTop + cardRect.top - headerHeight - 20;
  145. mainContent.scrollTo({
  146. top: scrollTop,
  147. behavior: 'smooth'
  148. });
  149. }
  150. // Add highlight effect after scrolling completes
  151. setTimeout(() => {
  152. targetCard.style.transform = 'scale(1.02)';
  153. targetCard.style.boxShadow = '0 0 0 2px var(--accent-color)';
  154. targetCard.style.borderColor = 'var(--accent-color)';
  155. // Remove highlight after animation
  156. setTimeout(() => {
  157. targetCard.style.transform = 'none';
  158. targetCard.style.boxShadow = 'none';
  159. targetCard.style.borderColor = '';
  160. }, 2000);
  161. }, 500); // Wait for scroll to complete
  162. }
  163. }
  164. // Search functionality
  165. function setupSearch() {
  166. const searchInput = document.getElementById('searchInput');
  167. const searchResults = document.getElementById('searchResults');
  168. if (searchInput && searchResults) {
  169. searchInput.addEventListener('input', async (e) => {
  170. const query = e.target.value.toLowerCase();
  171. const prompts = await loadPrompts();
  172. const filtered = prompts.filter(({ app, prompt }) =>
  173. app.toLowerCase().includes(query) || prompt.toLowerCase().includes(query)
  174. );
  175. // Update prompt count
  176. updatePromptCount(filtered.length, prompts.length);
  177. // Show filtered results
  178. if (window.innerWidth <= 768 && !query.trim()) {
  179. searchResults.innerHTML = ''; // Clear results on mobile if no search query
  180. } else {
  181. searchResults.innerHTML = filtered.length === 0
  182. ? `<div class="search-result-item add-prompt">
  183. <a href="https://github.com/f/awesome-chatgpt-prompts/pulls" target="_blank" style="text-decoration: none; color: inherit; display: flex; align-items: center; gap: 8px;">
  184. <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  185. <circle cx="12" cy="12" r="10"></circle>
  186. <line x1="12" y1="8" x2="12" y2="16"></line>
  187. <line x1="8" y1="12" x2="16" y2="12"></line>
  188. </svg>
  189. Add this prompt
  190. </a>
  191. </div>`
  192. : filtered.map(({ app, prompt }) => `
  193. <li class="search-result-item" onclick="scrollToPrompt('${app}', '${prompt}')">
  194. ${app}
  195. </li>
  196. `).join('');
  197. }
  198. });
  199. }
  200. }
  201. // Fetch GitHub stars
  202. async function fetchGitHubStars() {
  203. try {
  204. const response = await fetch("https://api.github.com/repos/f/awesome-chatgpt-prompts");
  205. const data = await response.json();
  206. const stars = data.stargazers_count;
  207. const starCount = document.getElementById("starCount");
  208. if (starCount) {
  209. starCount.textContent = stars.toLocaleString();
  210. }
  211. } catch (error) {
  212. console.error("Error fetching star count:", error);
  213. const starCount = document.getElementById("starCount");
  214. if (starCount) {
  215. starCount.textContent = "129k+";
  216. }
  217. }
  218. }
  219. // Initialize on page load
  220. document.addEventListener('DOMContentLoaded', () => {
  221. renderMainPrompts();
  222. renderSidebarPrompts();
  223. setupSearch();
  224. fetchGitHubStars();
  225. });
  226. // Dark mode toggle
  227. function toggleDarkMode() {
  228. document.body.classList.toggle('dark-mode');
  229. const isDark = document.body.classList.contains('dark-mode');
  230. localStorage.setItem('dark-mode', isDark);
  231. }
  232. // Initialize dark mode from localStorage
  233. const savedDarkMode = localStorage.getItem('dark-mode') === 'true';
  234. if (savedDarkMode) {
  235. document.body.classList.add('dark-mode');
  236. }
  237. // Copy prompt to clipboard
  238. async function copyPrompt(button, encodedPrompt) {
  239. try {
  240. const promptText = decodeURIComponent(encodedPrompt);
  241. await navigator.clipboard.writeText(promptText);
  242. const originalHTML = button.innerHTML;
  243. button.innerHTML = `
  244. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  245. <polyline points="20 6 9 17 4 12"></polyline>
  246. </svg>
  247. `;
  248. setTimeout(() => {
  249. button.innerHTML = originalHTML;
  250. }, 2000);
  251. } catch (err) {
  252. console.error("Failed to copy text: ", err);
  253. }
  254. }
  255. // Open prompt in AI chat
  256. function openInChat(button, encodedPrompt) {
  257. const promptText = decodeURIComponent(encodedPrompt);
  258. const platform = document.querySelector(".platform-tag.active");
  259. if (!platform) return;
  260. const baseUrl = platform.dataset.url;
  261. let url;
  262. switch (platform.dataset.platform) {
  263. case "github-copilot":
  264. url = `${baseUrl}?prompt=${encodeURIComponent(promptText)}`;
  265. break;
  266. case "chatgpt":
  267. url = `${baseUrl}?prompt=${encodeURIComponent(promptText)}`;
  268. break;
  269. case "grok":
  270. url = `${baseUrl}&q=${encodeURIComponent(promptText)}`;
  271. break;
  272. case "claude":
  273. url = `${baseUrl}?q=${encodeURIComponent(promptText)}`;
  274. break;
  275. case "perplexity":
  276. url = `${baseUrl}/search?q=${encodeURIComponent(promptText)}`;
  277. break;
  278. case "mistral":
  279. url = `${baseUrl}?q=${encodeURIComponent(promptText)}`;
  280. break;
  281. default:
  282. url = `${baseUrl}?q=${encodeURIComponent(promptText)}`;
  283. }
  284. window.open(url, "_blank");
  285. }
  286. // Add modal functionality
  287. function showModal(app, prompt, contributor) {
  288. let modalOverlay = document.getElementById('modalOverlay');
  289. if (!modalOverlay) {
  290. // Create modal if it doesn't exist
  291. const modalHTML = `
  292. <div class="modal-overlay" id="modalOverlay">
  293. <div class="modal">
  294. <div class="modal-header">
  295. <h2 class="modal-title"></h2>
  296. <div class="modal-actions">
  297. <button class="modal-copy-button" title="Copy prompt">
  298. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  299. <rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect>
  300. <path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path>
  301. </svg>
  302. </button>
  303. <button class="modal-close" title="Close">
  304. <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  305. <line x1="18" y1="6" x2="6" y2="18"></line>
  306. <line x1="6" y1="6" x2="18" y2="18"></line>
  307. </svg>
  308. </button>
  309. </div>
  310. </div>
  311. <div class="modal-content">
  312. <div class="modal-hint">
  313. Copy and paste this onto <a href="https://code.visualstudio.com/docs/copilot/overview" target="_blank">VSCode Copilot</a>,
  314. <a href="https://codeium.com/windsurf" target="_blank">Windsurf</a> or
  315. <a href="https://cursor.com" target="_blank">Cursor</a>
  316. </div>
  317. <div class="content-well">
  318. <pre><code></code></pre>
  319. </div>
  320. </div>
  321. <div class="modal-footer">
  322. <div class="modal-footer-left">
  323. <a class="modal-contributor" target="_blank" rel="noopener"></a>
  324. </div>
  325. <div class="modal-footer-right">
  326. <button class="modal-chat-button">
  327. <svg class="terminal-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  328. <polyline points="4 17 10 11 4 5"></polyline>
  329. <line x1="12" y1="19" x2="20" y2="19"></line>
  330. </svg>
  331. Run on AI IDE
  332. </button>
  333. </div>
  334. </div>
  335. </div>
  336. </div>
  337. `;
  338. document.body.insertAdjacentHTML('beforeend', modalHTML);
  339. modalOverlay = document.getElementById('modalOverlay');
  340. // Add event listeners
  341. const modalClose = modalOverlay.querySelector('.modal-close');
  342. modalClose.addEventListener('click', hideModal);
  343. modalOverlay.addEventListener('click', (e) => {
  344. if (e.target === modalOverlay) {
  345. hideModal();
  346. }
  347. });
  348. // Add copy functionality
  349. const modalCopyButton = modalOverlay.querySelectorAll('.modal-copy-button, .modal-chat-button');
  350. modalCopyButton.forEach(button => {
  351. button.addEventListener('click', () => {
  352. // TODO: Add open in chat functionality
  353. copyPrompt(button, encodeURIComponent(prompt));
  354. if (button.classList.contains('modal-chat-button')) {
  355. alert('Now you can paste the prompt into your AI IDE, deeplinks to AI IDEs are coming soon (I hope)! — IDE devs, please DM me!');
  356. }
  357. });
  358. });
  359. }
  360. const modalTitle = modalOverlay.querySelector('.modal-title');
  361. const modalCode = modalOverlay.querySelector('.modal-content code');
  362. const modalContributor = modalOverlay.querySelector('.modal-contributor');
  363. modalTitle.textContent = app;
  364. modalCode.innerHTML = prompt.replace(/\\n/g, '<br>');
  365. if (contributor) {
  366. modalContributor.href = `https://github.com/${contributor.replace('@', '')}`;
  367. modalContributor.textContent = `Contributed by ${contributor}`;
  368. }
  369. modalOverlay.style.display = 'block';
  370. document.body.style.overflow = 'hidden';
  371. }
  372. function hideModal() {
  373. const modalOverlay = document.getElementById('modalOverlay');
  374. if (!modalOverlay) return;
  375. modalOverlay.style.display = 'none';
  376. document.body.style.overflow = '';
  377. }
  378. // Add global event listener for Escape key
  379. document.addEventListener('keydown', (e) => {
  380. if (e.key === 'Escape') {
  381. hideModal();
  382. }
  383. });
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...