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/$%7Bart_info.art.src%7D?q=function&page=143&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 22849 results for "function"(1551ms)

SEA-ICE-GROUPindex.html7 matches

@devthom_studios•Updated 4 days ago
461
462 // Fetch and display research projects
463 async function loadResearch() {
464 try {
465 const response = await fetch('/api/research');
498
499 // Fetch and display team members
500 async function loadTeam() {
501 try {
502 const response = await fetch('/api/team');
532
533 // Fetch and display publications
534 async function loadPublications() {
535 try {
536 const response = await fetch('/api/publications');
562
563 // Fetch and display news
564 async function loadNews() {
565 try {
566 const response = await fetch('/api/news');
619
620 // Load and display sea ice extent data
621 async function loadSeaIceData() {
622 try {
623 const response = await fetch('/api/data/sea-ice-extent');
678 tooltip: {
679 callbacks: {
680 label: function(context) {
681 return `${context.dataset.label}: ${context.raw} million km²`;
682 }
707
708 // Handle contact form submission
709 document.getElementById('contact-form').addEventListener('submit', function(e) {
710 e.preventDefault();
711

SEA-ICE-GROUPutils.ts7 matches

@devthom_studios•Updated 4 days ago
1// Shared utility functions and types for the Sea Ice Research Group website
2
3// Team member interface
38}
39
40// Format date function
41export function formatDate(dateString: string): string {
42 const date = new Date(dateString);
43 return date.toLocaleDateString('en-US', {
48}
49
50// Truncate text function
51export function truncateText(text: string, maxLength: number): string {
52 if (text.length <= maxLength) return text;
53 return text.slice(0, maxLength) + '...';
54}
55
56// Generate citation function
57export function generateCitation(publication: Publication): string {
58 return `${publication.authors} (${publication.year}). ${publication.title}. ${publication.journal}. DOI: ${publication.doi}`;
59}

TyappValqueries.ts5 matches

@oluwa_ty•Updated 4 days ago
4
5// Job posting queries
6export async function getAllJobPostings(): Promise<JobPosting[]> {
7 const result = await sqlite.execute(
8 `SELECT * FROM ${JOBS_TABLE} ORDER BY createdAt DESC`
11}
12
13export async function getJobPostingById(id: number): Promise<JobPosting | null> {
14 const result = await sqlite.execute(
15 `SELECT * FROM ${JOBS_TABLE} WHERE id = ?`,
19}
20
21export async function createJobPosting(job: JobPostingFormData): Promise<JobPosting> {
22 const createdAt = new Date().toISOString();
23 const result = await sqlite.execute(
31
32// Chat message queries
33export async function getAllChatMessages(limit = 50): Promise<ChatMessage[]> {
34 const result = await sqlite.execute(
35 `SELECT * FROM ${CHAT_TABLE} ORDER BY createdAt DESC LIMIT ?`,
39}
40
41export async function createChatMessage(message: ChatMessageFormData): Promise<ChatMessage> {
42 const createdAt = new Date().toISOString();
43 const result = await sqlite.execute(

TyappValmigrations.ts1 match

@oluwa_ty•Updated 4 days ago
5export const CHAT_TABLE = 'chat_messages_v1';
6
7export async function runMigrations() {
8 // Create jobs table
9 await sqlite.execute(`

TastkItindex.ts1 match

@diegoivo•Updated 4 days ago
3
4// Exportar a função fetch para o Val Town
5export default async function(req: Request) {
6 try {
7 return await app.fetch(req);

pokedexnew-file-4416.tsx12 matches

@tallesjp•Updated 4 days ago
1export default async function upgradedPokemonPanel(req: Request): Promise<Response> {
2 // Tenta obter a cor predominante do Pokémon para usar no tema.
3 // Esta é uma simplificação, a cor exata pode vir de speciesData.color.name
428 };
429
430 function translateTerm(term, type = 'label') {
431 const lowerTerm = term ? String(term).toLowerCase().replace(/-/g, ' ') : 'unknown';
432 if (type === 'value' && translations[lowerTerm]) {
438
439 // Função para normalizar texto (remover acentos, caracteres especiais)
440 function normalizeText(text) {
441 return text.toLowerCase()
442 .normalize("NFD").replace(/[\u0300-\u036f]/g, "") // Remove acentos
446
447 // Função para converter nomes de Pokémon do português para inglês
448 function convertPokemonNameToEnglish(name) {
449 // Normaliza o nome para facilitar a busca
450 const normalizedName = normalizeText(name);
466 }
467
468 async function translateTextWithMyMemory(text, sourceLang = 'en', targetLang = 'pt-BR') {
469 if (!text || text.trim() === translations.unknown || text.trim() === translations.no_evolution) return text;
470 try {
486 }
487
488 function getLocalizedTextEntry(entries, fieldName = 'flavor_text', langOrder = ['pt', 'en']) {
489 if (!entries || entries.length === 0) return translations.unknown;
490 for (const lang of langOrder) {
520 });
521
522 function setupThemeSelectors() {
523 const themeOptions = document.querySelectorAll('.theme-option');
524 themeOptions.forEach(option => {
537 }
538
539 function setTheme(theme) {
540 // Remover tema anterior
541 document.body.removeAttribute('data-theme');
552 pokemonNameInput.addEventListener('keypress', (event) => event.key === 'Enter' && fetchPokemonDetails());
553
554 async function fetchPokemonDetails() {
555 const pokemonIdentifier = pokemonNameInput.value.toLowerCase().trim();
556 if (!pokemonIdentifier) {
579 }
580
581 function clearPreviousData() {
582 detailsDiv.innerHTML = '';
583 detailsDiv.classList.remove('loaded');
600 }
601
602 function showError(message) {
603 errorDiv.textContent = message;
604 errorDiv.style.display = 'block';
606 }
607
608 async function displayPokemonInfo(speciesData, pokemonData) {
609 const accentHex = pokemonColorHexMap[speciesData.color.name.toLowerCase()] || '${accentColor}';
610 pokedexPanel.style.setProperty('--panel-accent-color', accentHex);

TastkItqueries.ts19 matches

@diegoivo•Updated 4 days ago
4
5// Função simples para hash de senha
6async function hashPassword(password: string): Promise<string> {
7 // Em produção, use uma biblioteca de hash mais segura
8 // Esta é uma implementação básica para demonstração
15
16// Função para verificar senha
17async function verifyPasswordHash(password: string, hash: string): Promise<boolean> {
18 const calculatedHash = await hashPassword(password);
19 return calculatedHash === hash;
22// ==================== Funções de Usuário ====================
23
24export async function createUser(input: CreateUserInput): Promise<User> {
25 try {
26 // Verificar novamente se o email ou username já existem (para evitar condições de corrida)
55}
56
57export async function getUserByUsername(username: string): Promise<User | null> {
58 const result = await sqlite.execute(
59 `SELECT id, username, email, password_hash, created_at, updated_at
66}
67
68export async function getUserByEmail(email: string): Promise<User | null> {
69 const result = await sqlite.execute(
70 `SELECT id, username, email, password_hash, created_at, updated_at
77}
78
79export async function getUserById(id: number): Promise<User | null> {
80 const result = await sqlite.execute(
81 `SELECT id, username, email, created_at, updated_at
88}
89
90export async function verifyPassword(plainPassword: string, hashedPassword: string): Promise<boolean> {
91 return await verifyPasswordHash(plainPassword, hashedPassword);
92}
94// ==================== Funções de Projeto ====================
95
96export async function createProject(input: CreateProjectInput): Promise<Project> {
97 const result = await sqlite.execute(
98 `INSERT INTO ${PROJECTS_TABLE} (name, color, user_id)
105}
106
107export async function getProjectsByUserId(userId: number): Promise<Project[]> {
108 const result = await sqlite.execute(
109 `SELECT id, name, color, user_id, created_at, updated_at
117}
118
119export async function getProjectById(id: number, userId: number): Promise<Project | null> {
120 const result = await sqlite.execute(
121 `SELECT id, name, color, user_id, created_at, updated_at
128}
129
130export async function updateProject(id: number, userId: number, name: string, color?: string): Promise<Project | null> {
131 const updateFields = [];
132 const params = [];
162}
163
164export async function deleteProject(id: number, userId: number): Promise<boolean> {
165 const result = await sqlite.execute(
166 `DELETE FROM ${PROJECTS_TABLE}
174// ==================== Funções de Tarefa ====================
175
176export async function createTask(input: CreateTaskInput): Promise<Task> {
177 const result = await sqlite.execute(
178 `INSERT INTO ${TASKS_TABLE} (title, description, due_date, priority, project_id, user_id)
192}
193
194export async function getTasksByProjectId(projectId: number, userId: number): Promise<Task[]> {
195 const result = await sqlite.execute(
196 `SELECT id, title, description, due_date, priority, completed, project_id, user_id, created_at, updated_at
211}
212
213export async function getTasksByUserId(userId: number): Promise<Task[]> {
214 const result = await sqlite.execute(
215 `SELECT id, title, description, due_date, priority, completed, project_id, user_id, created_at, updated_at
230}
231
232export async function getTaskById(id: number, userId: number): Promise<Task | null> {
233 const result = await sqlite.execute(
234 `SELECT id, title, description, due_date, priority, completed, project_id, user_id, created_at, updated_at
241}
242
243export async function updateTask(id: number, userId: number, input: UpdateTaskInput): Promise<Task | null> {
244 const updateFields = [];
245 const params = [];
295}
296
297export async function toggleTaskCompletion(id: number, userId: number): Promise<Task | null> {
298 const result = await sqlite.execute(
299 `UPDATE ${TASKS_TABLE}
308}
309
310export async function deleteTask(id: number, userId: number): Promise<boolean> {
311 const result = await sqlite.execute(
312 `DELETE FROM ${TASKS_TABLE}
Oronet11

Oronet1101_script.tsx1 match

@oronet11•Updated 4 days ago
1// This script returns a random fun fact
2// You can run scripts manually in this view or call it from other vals.
3export default function getRandomFact() {
4 const funFacts = [
5 "Honey never spoils.",

OroOroNet1 match

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

Oroindex.ts5 matches

@oronet11•Updated 4 days ago
2
3// Fetch top cryptocurrencies data from CoinGecko API
4async function fetchCryptoData(limit = 50) {
5 try {
6 // CoinGecko has rate limits, so we need to add a delay and retry mechanism
29
30// Mock data for testing when API fails
31function getMockCryptoData(limit = 10) {
32 const mockCoins = [
33 {
157
158// Fetch detailed data for a specific cryptocurrency
159async function fetchCryptoDetails(id: string) {
160 try {
161 const response = await fetch(
183
184// Mock data for testing when API fails
185function getMockCryptoDetails(id: string) {
186 const mockDetails: Record<string, any> = {
187 "bitcoin": {
259}
260
261export default async function(req: Request) {
262 const url = new URL(req.url);
263

getFileEmail4 file matches

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

tuna8 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.