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?q=function&page=24&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 35006 results for "function"(1794ms)

judgeWordsmain.tsx4 matches

@alexwein•Updated 2 days ago
7} from "https://esm.sh/react@18.2.0";
8
9function NamePrompt({ onSubmit }) {
10 const [name, setName] = useState("");
11 const [error, setError] = useState("");
38}
39
40function App() {
41 const [cards, setCards] = useState([]);
42 const [currentCardIndex, setCurrentCardIndex] = useState(0);
217}
218
219function client() {
220 createRoot(document.getElementById("root")).render(<App />);
221}
222if (typeof document !== "undefined") client();
223
224export default async function server(request: Request): Promise<Response> {
225 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
226

ffxivserver.ts23 matches

@jjwon•Updated 2 days ago
512
513 // Fetch data from API
514 async function fetchInstanceData() {
515 try {
516 const response = await fetch(API_URL);
527
528 // Render the instance data to the page with tabs
529 function render(data) {
530 const container = document.getElementById('instance-container');
531 container.innerHTML = '';
641
642 // Switch between tabs
643 function switchTab(expansionName) {
644 // Update tab buttons
645 document.querySelectorAll('.tab-button').forEach(button => {
659
660 // Save state to localStorage
661 function saveState() {
662 const stateObject = {};
663 const checkboxes = document.querySelectorAll('input[type="checkbox"][data-instance-id]');
678
679 // Load state from localStorage
680 function loadState() {
681 try {
682 const savedState = localStorage.getItem('ffxivCompletionState');
704 }
705
706 // Search functionality
707 function setupSearch() {
708 const searchBar = document.getElementById('search-bar');
709
730
731 // Event listeners
732 function setupEventListeners() {
733 const container = document.getElementById('instance-container');
734
774
775 // Update custom checkbox visual state
776 function updateCustomCheckbox(checkbox) {
777 const label = checkbox.closest('.checkbox-label');
778 const customCheckbox = label.querySelector('.custom-checkbox');
783
784 // Handle row selection
785 function handleRowSelection(checkbox) {
786 const instanceId = checkbox.dataset.instanceId;
787 const row = checkbox.closest('.instance-row');
799
800 // Update selection toolbar visibility and count
801 function updateSelectionToolbar() {
802 const toolbar = document.getElementById('selection-toolbar');
803 const countSpan = document.getElementById('selection-count');
814
815 // Initialize
816 async function init() {
817 console.log('Initializing FFXIV Completion Tracker...');
818
839
840 // Selection-based bulk actions
841 function markSelectedAsUnlocked() {
842 selectedRows.forEach(instanceId => {
843 const checkbox = document.querySelector(\`input[data-instance-id="\${instanceId}"][data-type="unlocked"]\`);
850 }
851
852 function markSelectedAsCompleted() {
853 selectedRows.forEach(instanceId => {
854 const checkbox = document.querySelector(\`input[data-instance-id="\${instanceId}"][data-type="completed"]\`);
861 }
862
863 function clearSelectedProgress() {
864 selectedRows.forEach(instanceId => {
865 const unlockedCheckbox = document.querySelector(\`input[data-instance-id="\${instanceId}"][data-type="unlocked"]\`);
878 }
879
880 function clearSelection() {
881 // Clear all selected rows
882 document.querySelectorAll('.row-selector:checked').forEach(checkbox => {
897</html>`;
898
899// Helper function to convert text to APA title case
900function toTitleCase(str: string): string {
901 // APA style - lowercase articles, prepositions, and conjunctions unless they're first/last words
902 const minorWords = ['a', 'an', 'and', 'as', 'at', 'but', 'by', 'for', 'if', 'in', 'into', 'is', 'it', 'nor', 'of', 'on', 'or', 'so', 'the', 'to', 'up', 'yet'];
920}
921
922// Helper function to make content type singular
923function makeSingular(contentType: string): string {
924 const singularMap: Record<string, string> = {
925 'Dungeons': 'Dungeon',
943
944// Fetch FFXIV instance data from XIVAPI
945async function fetchFFXIVData() {
946 const allInstances: any[] = [];
947 const baseUrl = 'https://xivapi.com/instancecontent?columns=ID,Name,ContentType.Name,ContentFinderCondition.Name,ContentFinderCondition.ClassJobLevelRequired,UnlockQuest.Name';
1188
1189// API handler for instance data
1190async function handleInstanceAPI(): Promise<Response> {
1191 const corsHeaders = {
1192 'Access-Control-Allow-Origin': '*',
1236
1237// Request handler
1238async function handler(request: Request): Promise<Response> {
1239 const url = new URL(request.url);
1240

ffxivTODO.md8 matches

@jjwon•Updated 2 days ago
20Note on Pagination: XIVAPI results are paginated (e.g., 100 results per page). Your script must loop through all pages to collect every instance.
21
22Task 1.2: Create the Val Town "Val" (Function).
23
24Create a new val in your Val Town workspace (e.g., ffxivInstanceList).
88Task 3.1: Fetch and Render Data.
89
90In script.js, write an async function to fetch data from your Val Town URL.
91
92Once you have the JSON data, write a render(data) function.
93
94This function will:
95
96Get the <main id="instance-container"> element.
106Task 3.2: Implement State Persistence.
107
108Saving: Create a saveState() function. This function will find all checkboxes on the page, loop through them, and build a JSON object like { "instance_id_123": { unlocked: true, completed: false }, ... }. It will then save this object to localStorage.setItem('ffxivCompletionState', JSON.stringify(stateObject)).
109
110Loading: Create a loadState() function. This function will get the item from localStorage, parse it, and then loop through the rendered checkboxes on the page, setting their checked property to true or false based on the loaded data.
111
112Binding: Call loadState() after you first render the list. Add an event listener to the main instance-container that listens for change events on the checkboxes. When an event occurs, call saveState().
116Add an input event listener to the #search-bar.
117
118Inside the listener function, get the search bar's current value (and convert to lowercase).
119
120Get all the .instance-row elements.
124If it matches, set row.style.display = ''. If not, set row.style.display = 'none'.
125
126At the end of this phase, your application will be fully functional on Val town.
127
128// July 20 2025 //

onet2main.tsx4 matches

@real•Updated 2 days ago
814// --- AI SYSTEM PROMPTS ---
815const PROMPT_REFINER_SYSTEM_PROMPT =
816 `You operate as a specialized prompt engineer to generate {{variable}} meta prompts. Your function is to transmute raw, structured occupational data into an elaborate, efficacious, and long-form directive for a target AI. You will be given an "Occupation," "Task," and ancillary data fields. Your generated prompts must be comprehensive, detailed, and structured as a professional brief, suitable for guiding an advanced AI agent.
817
818# Core Rule
819This is the most critical mandate of your function. YOU MUST RETURN A PROMPT THAT HAS {{variables}} IN IT!! Your purpose is not to create a static prompt, but a reusable **template**. Your primary goal is to identify the most important, undefined, or abstract entities and concepts within the user's \`Task\` description and convert them all into descriptive, double-curly-braced {{placeholders}} or {{variables}} . You MUST include at least 2 placeholder variables in your response. For example, if the task is "Analyze data on market conditions to identify potential sales of a product or service," the key undefined entity is "a product or service," which you MUST turn into a placeholder like \`{{product_or_service}}\`. Other examples include specific documents ("a report" -> \`{{report_topic}}\`), timeframes ("in the coming quarter" -> \`{{target_quarter}}\`), or clients ("for the client" -> \`{{client_name}}\`). A generated prompt template that fails to create appropriate \`{{placeholders}}\` for all such undefined entities is considered a failure. You must always create at least one.
820
821# Instructions
898
899// --- FRONTEND ---
900function generateHtml(sourceUrl: string) {
901 return `
902 <!DOCTYPE html>
1020 let formFieldsState = [];
1021
1022 function renderLatexDocument(latexSource, targetElement) {
1023 if (!latexSource || !targetElement) return;
1024

agent-examplemain.tsx1 match

@shlmt•Updated 2 days ago
6import { DynamicTool } from 'npm:@langchain/core/tools'
7
8export async function agentExample() {
9
10 const llm = new OpenAI()

url-projectserver.tsx1 match

@ZuriaTahir•Updated 2 days ago
9} from "./backend/database/queries.ts";
10
11export default async function(request: Request) {
12 const url = new URL(request.url);
13 const path = url.pathname;

url-projectREADME.md1 match

@ZuriaTahir•Updated 2 days ago
3This directory contains code that is shared between the frontend and backend.
4
5- `utils.ts` - Utility functions and shared types

url-projectlayout.tsx1 match

@ZuriaTahir•Updated 2 days ago
3import { type loader } from "./layout.server.ts";
4
5export default function Layout() {
6 let data = useLoaderData<typeof loader>();
7

url-projectlayout.server.ts3 matches

@ZuriaTahir•Updated 2 days ago
1import { ActionFunctionArgs, type LoaderFunctionArgs } from "npm:react-router";
2
3let db = { message: "Hello world!" };
4
5export async function loader(args: LoaderFunctionArgs) {
6 await new Promise(resolve => setTimeout(resolve, 200));
7 return { message: db.message };
8}
9
10export async function action({ request }: ActionFunctionArgs) {
11 let formData = await request.formData();
12 db.message = String(formData.get("message"));

url-projectlayout.client.ts3 matches

@ZuriaTahir•Updated 2 days ago
1import { type LoaderFunctionArgs } from "npm:react-router";
2
3export async function loader({ request }: LoaderFunctionArgs) {
4 let url = new URL(request.url);
5 let res = await fetch(url, {
12}
13
14export async function action({ request }: LoaderFunctionArgs) {
15 let url = new URL(request.url);
16 // call the server action

discordWebhook2 file matches

@stevekrouse•Updated 2 weeks ago
Helper function to send Discord messages
tuna

tuna9 file matches

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