Val Town Code SearchReturn to Val Town

API Access

You can access search results via JSON API by adding format=json to your query:

https://codesearch.val.run/$%7Bsuccess?q=function&page=73&format=json

For typeahead suggestions, use the /typeahead endpoint:

https://codesearch.val.run/typeahead?q=function

Returns an array of strings in format "username" or "username/projectName"

Found 20027 results for "function"(614ms)

untitled-5703migrations.ts1 match

@angelaphiri•Updated 1 day ago
8 * Initialize database tables
9 */
10export async function initDatabase() {
11 // Create jobs table
12 await sqlite.execute(`

Mercuryindex.ts7 matches

@thirdsouth•Updated 1 day ago
15 * Verify that the request is coming from Slack
16 */
17function verifySlackRequest(request: Request): boolean {
18 // In a production environment, you should verify the request signature
19 // using the Slack signing secret. For simplicity, we're skipping that here.
33 * Handle the /mercury balance command
34 */
35async function handleBalanceCommand(): Promise<SlackMessage> {
36 try {
37 const accounts = await mercury.getAccounts();
46 * Handle the /mercury transactions command
47 */
48async function handleTransactionsCommand(args: string[]): Promise<SlackMessage> {
49 try {
50 console.log('Starting transactions command with args:', args);
98 * Handle the /mercury search command
99 */
100async function handleSearchCommand(args: string[]): Promise<SlackMessage> {
101 try {
102 if (args.length === 0) {
117 * Handle the /mercury help command
118 */
119function handleHelpCommand(): SlackMessage {
120 return {
121 blocks: [
153 * Process a Slack command and return the appropriate response
154 */
155async function processSlackCommand(slackCommand: SlackCommand): Promise<SlackMessage> {
156 const { command, args } = parseCommand(slackCommand.text);
157
172 * Main HTTP handler for Slack slash commands and Mercury webhooks
173 */
174export default async function(req: Request): Promise<Response> {
175 // Handle different HTTP methods
176 if (req.method === 'POST') {

beeAifrontend.html13 matches

@armadillomike•Updated 2 days ago
310 <script>
311 document.addEventListener('DOMContentLoaded', () => {
312 // Tab switching functionality
313 const chatTab = document.getElementById('chat-tab');
314 const imageTab = document.getElementById('image-tab');
330 });
331
332 // Chat functionality
333 const chatForm = document.getElementById('chat-form');
334 const userInput = document.getElementById('user-input');
335 const chatContainer = document.getElementById('chat-container');
336
337 // Function to add a message to the chat
338 function addMessage(content, isUser = false) {
339 const messageDiv = document.createElement('div');
340 messageDiv.className = `message-bubble ${isUser ? 'user-message' : 'ai-message'} p-4 shadow-sm`;
344 }
345
346 // Function to show loading indicator in chat
347 function showChatLoading() {
348 const loadingDiv = document.createElement('div');
349 loadingDiv.id = 'loading-indicator';
354 }
355
356 // Function to remove loading indicator from chat
357 function hideChatLoading() {
358 const loadingIndicator = document.getElementById('loading-indicator');
359 if (loadingIndicator) {
404 });
405
406 // Image Generator functionality
407 const imageForm = document.getElementById('image-form');
408 const imagePrompt = document.getElementById('image-prompt');
418 const errorTryAgain = document.getElementById('error-try-again');
419
420 // Function to reset the image generator form
421 function resetImageGenerator() {
422 imageResult.style.display = 'none';
423 imageForm.style.display = 'block';
458 const img = new Image();
459
460 img.onload = function() {
461 // Display the generated image
462 generatedImage.src = data.imageUrl;
469 };
470
471 img.onerror = function() {
472 // Show error if image can't be loaded
473 imageLoading.style.display = 'none';

ZenChatindex.ts1 match

@mehran•Updated 2 days ago
181
182// Broadcast a message to all connected clients
183function broadcastMessage(event: ChatEvent) {
184 const message = JSON.stringify(event);
185 console.log(`Broadcasting: ${message}`);

ZenChatindex.html2 matches

@mehran•Updated 2 days ago
106
107 // Check after 2 seconds if the main script has loaded
108 setTimeout(function() {
109 if (window.scriptFailed) {
110 console.error('Main script failed to load or execute properly');
131 <script>
132 // This will run after the module script
133 window.addEventListener('load', function() {
134 // Clear the flag if we got this far
135 window.scriptFailed = false;

ZenChatindex.js11 matches

@mehran•Updated 2 days ago
23
24// Initialize the app
25function init() {
26 console.log('Initializing app...');
27
54
55// Handle login form submission
56function handleLogin(event) {
57 event.preventDefault();
58 console.log('Login form submitted');
82
83// Handle message form submission
84function handleSendMessage(event) {
85 event.preventDefault();
86 const message = messageInput.value.trim();
99
100// Connect to WebSocket server
101function connectWebSocket() {
102 console.log('Connecting to WebSocket...');
103
161
162// Handle incoming WebSocket messages
163function handleWebSocketMessage(event) {
164 switch (event.type) {
165 case 'message':
188
189// Add a message to the chat
190function addMessageToChat(message) {
191 const messageElement = document.createElement('div');
192 const isMyMessage = message.username === username;
205
206// Add a system message to the chat
207function addSystemMessage(text) {
208 const messageElement = document.createElement('div');
209 messageElement.className = 'message-bubble system-message';
215
216// Show the chat screen
217function showChatScreen() {
218 console.log('Showing chat screen');
219
242
243// Utility: Scroll to the bottom of the messages container
244function scrollToBottom() {
245 messagesContainer.scrollTop = messagesContainer.scrollHeight;
246}
247
248// Utility: Format timestamp
249function formatTimestamp(timestamp) {
250 const date = new Date(timestamp);
251 return date.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
253
254// Utility: Escape HTML to prevent XSS
255function escapeHtml(unsafe) {
256 return unsafe
257 .replace(/&/g, "&amp;")

syllabus-todomain.tsx1 match

@rayyan•Updated 2 days ago
1export default async function (req: Request): Promise<Response> {
2 return Response.json({ ok: true })
3}

ZenChatREADME.md1 match

@mehran•Updated 2 days ago
8- `database/`: Database setup and queries
9 - `migrations.ts`: Schema definitions
10 - `queries.ts`: Database query functions
11
12## WebSocket Protocol

ZenChatqueries.ts4 matches

@mehran•Updated 2 days ago
4
5// User queries
6export async function createUser(username: string): Promise<User> {
7 const now = new Date().toISOString();
8
23}
24
25export async function getUserByUsername(username: string): Promise<User | null> {
26 const result = await sqlite.execute(
27 `SELECT id, username, created_at FROM ${USERS_TABLE} WHERE username = ?`,
41
42// Message queries
43export async function createMessage(userId: number, content: string): Promise<Message> {
44 const now = new Date().toISOString();
45
75}
76
77export async function getRecentMessages(limit = 50): Promise<Message[]> {
78 const result = await sqlite.execute(
79 `SELECT m.id, m.user_id, u.username, m.content, m.created_at

ZenChatmigrations.ts1 match

@mehran•Updated 2 days ago
5export const MESSAGES_TABLE = 'chat_messages';
6
7export async function runMigrations() {
8 // Create users table
9 await sqlite.execute(`

getFileEmail4 file matches

@shouser•Updated 3 weeks ago
A helper function to build a file's email
tuna

tuna8 file matches

@jxnblk•Updated 3 weeks ago
Simple functional CSS library for Val Town
lost1991
import { OpenAI } from "https://esm.town/v/std/openai"; export default async function(req: Request): Promise<Response> { if (req.method === "OPTIONS") { return new Response(null, { headers: { "Access-Control-Allow-Origin": "*",
webup
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.