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/image-url.jpg%20%22Optional%20title%22?q=function&page=75&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 33110 results for "function"(4486ms)

vs-selectmain.tsx2 matches

@join•Updated 6 days ago
1export default async function(req: Request) {
2 const sourceUrl = `https://${new URL(req.url).hostname}`;
3
13 ];
14
15 function generateHtml(characters, sourceUrl) {
16 return `<!DOCTYPE html>
17<html lang="en">

chroniclemain.tsx4 matches

@join•Updated 6 days ago
60];
61
62async function initializeDatabase() {
63 await sqlite.execute(`
64 CREATE TABLE IF NOT EXISTS schema_meta (
152`;
153
154function extractJson(rawContent: string): any {
155 const jsonMatch = rawContent.match(/```json\n([\s\S]*?)\n```/);
156 if (jsonMatch && jsonMatch[1]) {
160}
161
162function generateHtml(sourceUrl: string) {
163 const apiBaseUrl = sourceUrl.endsWith("/") ? `${sourceUrl}api` : `${sourceUrl}/api`;
164
437
438<script>
439(function() {
440 const API_BASE_URL = '${apiBaseUrl}';
441 const gameWindow = document.getElementById('game-window');

bsides-redirectmain.tsx1 match

@captn3m0•Updated 6 days ago
1export default async function(req: Request): Promise<Response> {
2 return Response.redirect("file:///var/flag/flag.txt.");
3}

rssplusmain.tsx3 matches

@edict•Updated 6 days ago
1export default handler;
2export async function handler(request) {
3 const uri = new URL(request.url);
4 let url = uri.searchParams.get("url");
25
26
27export function findRSS(url, res = undefined) {
28 const feeds = [];
29 function add(title, link) {
30 feeds.push({
31 "title": title,

monolithmain.tsx16 matches

@join•Updated 6 days ago
12
13const CONDUCT_POST_MORTEM_PROMPT = `
14You are the Monolith's core analyst. You will receive a JSON object containing a user's work history, including protocols and logged outputs from timed work blocks. Your function is to conduct a post-mortem analysis.
151. Calculate and present key performance indicators: total time focused, number of blocks completed, and average output per block where applicable.
162. Provide a dispassionate summary of performance, noting patterns of consistency or deviation.
21// --- APPLICATION SCAFFOLDING & UI ---
22
23function generateHtml(sourceUrl) {
24 const safeSourceUrl = sourceUrl.endsWith("/") ? sourceUrl : `${sourceUrl}/`;
25 return `<!DOCTYPE html>
219
220<script>
221(function() {
222 const STORE_KEY = 'monolith_data_v1';
223 const API_URL = '${safeSourceUrl}';
231 const setStore = data => localStorage.setItem(STORE_KEY, JSON.stringify(data));
232
233 function formatDuration(ms) {
234 if (!ms) return '0h 0m';
235 const totalMinutes = Math.floor(ms / 60000);
239 }
240
241 function renderProtocols() {
242 const listEl = $('#protocol-list');
243 if (!listEl) return;
273 }
274
275 function renderModal(content) {
276 const modalContainer = $('#modal-container');
277 modalContainer.innerHTML = \`<div class="modal-overlay"><div class="modal-content">\${content}</div></div>\`;
279 }
280
281 function closeModal() {
282 $('#modal-container').classList.add('hidden');
283 $('#modal-container').innerHTML = '';
284 }
285
286 async function handleNewProtocolSubmit(e) {
287 e.preventDefault();
288 const form = e.target;
318 }
319
320 function showNewProtocolForm() {
321 renderModal(\`
322 <h2>Define New Protocol</h2>
334 }
335
336 function startWorkBlock(protocolId) {
337 const protocol = state.protocols.find(p => p.id === protocolId);
338 if (!protocol) return;
347 }
348
349 function showFocusMode(protocolText) {
350 const appContainer = $('#app-container');
351 appContainer.classList.add('hidden');
375 }
376
377 function endWorkBlock() {
378 if (!state.activeWorkBlock) return;
379 clearInterval(state.activeWorkBlock.timerInterval);
419 }
420
421 async function showPostMortem() {
422 renderModal('<h2>Conducting Post-Mortem Analysis...</h2>');
423 try {
457 }
458
459 function bindEventListeners() {
460 $('#new-protocol-btn').addEventListener('click', showNewProtocolForm);
461 $('#post-mortem-btn').addEventListener('click', showPostMortem);
480 }
481
482 function init() {
483 state = getStore();
484 renderProtocols();
494
495// --- BACKEND LOGIC ---
496export default async function(req: Request) {
497 const url = new URL(req.url);
498 const action = url.searchParams.get("action");

untitled-2418main.tsx5 matches

@join•Updated 6 days ago
38];
39
40async function initializeDatabase() {
41 await sqlite.execute(`
42 CREATE TABLE IF NOT EXISTS schema_meta (
99`;
100
101function extractJson(rawContent: string): any {
102 const jsonMatch = rawContent.match(/```json\n([\s\S]*?)\n```/);
103 if (jsonMatch && jsonMatch[1]) {
109
110// --- HTML & FRONTEND ---
111function generateHtml(sourceUrl: string) {
112 return `<!DOCTYPE html>
113<html lang="en">
385
386<script>
387(function() {
388 const API_BASE_URL = '${sourceUrl.endsWith("/") ? sourceUrl : sourceUrl + "/"}';
389 const gameWindow = document.getElementById('game-window');
408 };
409
410 // Main render function based on application state
411 const render = async (state) => {
412 switch (state.view) {

simpletrickmain.tsx4 matches

@join•Updated 6 days ago
7// --- DATABASE INITIALIZATION ---
8// Establishes the necessary database tables upon initial val execution.
9async function initializeDatabase() {
10 await sqlite.batch([
11 `CREATE TABLE IF NOT EXISTS users (
97
98// --- HTML & FRONTEND ---
99function generateHtml(sourceUrl: string) {
100 return `
101 <!DOCTYPE html>
220
221 <script>
222 (function() {
223 const topicDisplay = document.getElementById('topic-display');
224 const trickContainer = document.getElementById('trick-container');
229 let isGenerating = false;
230
231 async function fetchAndDisplayTrick() {
232 if (isGenerating) return;
233 isGenerating = true;

geotourmain.tsx14 matches

@join•Updated 6 days ago
17
18// --- DATABASE INITIALIZATION & SEEDING ---
19async function initializeDatabase() {
20 await sqlite.batch([
21 `CREATE TABLE IF NOT EXISTS tours (
238
239// --- UI: HTML & FRONTEND ---
240function generateHtml(baseURL: string) {
241 return `<!DOCTYPE html>
242<html lang="en">
313 </div>
314<script>
315 (function() {
316 // --- STATE MANAGEMENT ---
317 const state = {
342 const USER_ID_KEY = 'geo_narrate_user_id';
343
344 function showLoader(show) { elements.loader.classList.toggle('hidden', !show); }
345 function showError(message) {
346 console.error(message);
347 elements.errorMessage.textContent = message;
350 }
351
352 async function apiRequest(endpoint, options) {
353 const response = await fetch(\`\${API_BASE}\${endpoint}\`, options);
354 if (!response.ok) {
360
361 // --- RENDERING LOGIC ---
362 function renderTourList() {
363 let content = '<h2>Nearby Tours</h2>';
364 if (state.nearbyTours.length === 0) {
385 }
386
387 function renderTourDetail(tour) {
388 state.currentTour = tour;
389 const isPurchased = state.purchasedTours.has(tour.id);
427
428 // --- CORE LOGIC & EVENT HANDLERS ---
429 async function init() {
430 showLoader(true);
431 state.audioPlayer = elements.audioPlayer;
454 }
455
456 function setupMapAndFetchTours() {
457 const { latitude, longitude } = state.userCoords;
458 state.map = L.map(elements.mapContainer).setView([latitude, longitude], 14);
464 }
465
466 async function fetchPurchasedTours() {
467 try {
468 const response = await apiRequest(\`/purchases/\${state.userId}\`, { method: 'GET' });
474 }
475
476 async function fetchNearbyTours(lat, lon) {
477 try {
478 const response = await apiRequest('/tours', {
498 }
499
500 async function purchaseTour(tourId) {
501 showLoader(true);
502 try {
514 }
515
516 async function playNarration(poi) {
517 showLoader(true);
518 elements.player.classList.remove('hidden');

networkmain.tsx15 matches

@join•Updated 6 days ago
17
18// --- DATABASE INITIALIZATION & SEEDING ---
19async function initializeDatabase() {
20 await sqlite.batch([
21 `CREATE TABLE IF NOT EXISTS tours (
247
248// --- HTML & FRONTEND ---
249function generateHtml(baseURL: string) {
250 return `<!DOCTYPE html>
251<html lang="en">
306
307<script>
308 (function() {
309 const API_BASE = '${baseURL}api';
310 const USER_ID_KEY = 'geo_narrate_user_id';
329 const $ = id => document.getElementById(id);
330
331 function showLoader(show) {
332 if (show) {
333 $('affirmation').textContent = affirmations[Math.floor(Math.random() * affirmations.length)];
336 }
337
338 async function apiRequest(endpoint, options) {
339 const response = await fetch(\`\${API_BASE}\${endpoint}\`, options);
340 if (!response.ok) {
345 }
346
347 async function init() {
348 audioPlayer = $('audio-player');
349 showLoader(true);
363 }
364
365 function setupMap(lat, lon) {
366 map = L.map('map').setView([lat, lon], 14);
367 L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
371 }
372
373 async function fetchPurchasedTours() {
374 try {
375 const response = await apiRequest(\`/purchases/\${userId}\`, { method: 'GET' });
381 }
382
383 async function fetchNearbyTours(lat, lon) {
384 try {
385 const response = await apiRequest('/tours', {
396 }
397
398 function renderTours(tours) {
399 const listEl = $('tour-list');
400 listEl.innerHTML = '<h2>Nearby Tours</h2>';
422 }
423
424 function selectTour(tour) {
425 currentTour = tour;
426 const listEl = $('tour-list');
446 }
447
448 function renderPoiList(tour) {
449 const poiListEl = $('poi-list');
450 poiListEl.innerHTML = '<h3>Points of Interest</h3>';
459 }
460
461 async function purchaseTour(tourId) {
462 showLoader(true);
463 try {
476 }
477
478 async function playNarration(poi) {
479 showLoader(true);
480 $('player').classList.remove('hidden');
502 }
503
504 function showError(message) {
505 console.error(message);
506 showLoader(false);

birdfactsindex.html19 matches

@greasegum•Updated 6 days ago
258 const API_BASE = window.location.origin;
259
260 async function getRandomBird() {
261 const region = document.getElementById('regionInput').value.trim();
262 const lat = document.getElementById('latInput').value.trim();
277 }
278
279 async function getBirdByName() {
280 const birdName = document.getElementById('birdNameInput').value.trim();
281 if (!birdName) {
288 }
289
290 async function fetchAndDisplayBird(url) {
291 const loading = document.getElementById('loading');
292 const results = document.getElementById('results');
315 }
316
317 function displayBirdFact(bird) {
318 const results = document.getElementById('results');
319
368 }
369
370 async function getQuickFacts() {
371 const count = document.getElementById('countSelect').value;
372 const category = document.getElementById('categorySelect').value;
403 }
404
405 async function getFactsStats() {
406 try {
407 const response = await fetch(`${API_BASE}/api/facts/stats`);
419 }
420
421 async function triggerCollection() {
422 if (!confirm('This will trigger a manual facts collection. It may take a few minutes. Continue?')) {
423 return;
447 }
448
449 function displayQuickFacts(data) {
450 const results = document.getElementById('results');
451
502 }
503
504 function displayFactsStats(stats) {
505 const results = document.getElementById('results');
506
549 results.insertBefore(statsCard, results.firstChild);
550 }
551 function getMyLocation() {
552 if (!navigator.geolocation) {
553 alert('Geolocation is not supported by this browser');
601 }
602
603 async function getTopSuperlativeFacts() {
604 const count = document.getElementById('superlativeCountSelect').value;
605
630 }
631
632 async function getSuperlativeStats() {
633 try {
634 const response = await fetch(`${API_BASE}/api/facts/superlative/stats`);
646 }
647
648 function displaySuperlativeFacts(data) {
649 const results = document.getElementById('results');
650
718 }
719
720 function displayTopSuperlativeFacts(data) {
721 const results = document.getElementById('results');
722
745 }
746
747 function displaySuperlativeStats(stats) {
748 const results = document.getElementById('results');
749
808 results.insertBefore(statsCard, results.firstChild);
809 }
810 async function testLLMSimple() {
811 const loading = document.getElementById('loading');
812 const results = document.getElementById('results');
835 }
836
837 function displaySimpleLLMTest(data) {
838 const results = document.getElementById('results');
839
920 results.insertBefore(testCard, results.firstChild);
921 }
922 async function testLLMFiltering() {
923 if (!confirm('This will run a comprehensive test of the LLM filtering system. It may take 2-3 minutes. Continue?')) {
924 return;
989 }
990
991 async function showAPIResponse() {
992 try {
993 const response = await fetch(`${API_BASE}/api/birds/random`);

discordWebhook2 file matches

@stevekrouse•Updated 3 days ago
Helper function to send Discord messages
tuna

tuna9 file matches

@jxnblk•Updated 4 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.