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=1745&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 20677 results for "function"(1446ms)

52let tries = 0;
53
54function checkGuess() {
55 const guess = document.getElementById('wordle-input').value.trim().toLowerCase();
56
45 let guesses = 0;
46
47 function checkWord() {
48 const guess = document.getElementById("word").value.toLowerCase();
49
52 let guessedWord = "_____";
53
54 function checkGuess() {
55 const guess = document.querySelector(".input").value.toLowerCase();
56 if (guess.length !== 5 || new Set(guess).size !== 5) {
78 }
79
80 function resetGame() {
81 guessedWord = "_____";
82 document.querySelector(".word").textContent = guessedWord;
60 const word = "apple"; // Assumes the word to guess is "apple"
61
62 function checkGuess() {
63 const guess = document.getElementById("guess").value.toLowerCase();
64 let count = 0;
74 }
75
76 function displayResult(count) {
77 let resultText = "";
78

VALLEmain.tsx8 matches

@pomdtr•Updated 10 months ago
27the simplest way to achieve the goal, though you can add some inline comments to explain your
28reasoning (not for every line, but for major groups of lines). Don't use any environment variables
29unless strictly necessary, for example use APIs that don't require a key, prefer internal function
30imports (using esm.town), and prefer putting API keys as inline variables. Use built-in Deno
31functions where possible. Unless specified, don't add error handling,
32make sure that errors bubble up to the caller.
33There should be no comments like "more content here", it should be complete and directly runnable.
35
36// Your response should start with \`\`\`ts and end with \`\`\`.
37// The val should create a "export default async function main() {" which
38// is the main function that gets executed, without any arguments. Don't return a Response object,
39// just return a plain Javascript object, array, or string.
40
68 const writer = writable.getWriter();
69 const textEncoder = new TextEncoder();
70 function write(text) {
71 writer.write(textEncoder.encode(text));
72 }
115 </div>
116 <script>
117 function openTab(tab) {
118 const tabButtonCode = document.getElementById("tab-button-code");
119 const tabButtonPreview = document.getElementById("tab-button-preview");
139 (() => {
140 const scrollingElement = document.getElementById("conversation-container");
141 const callback = function (mutationsList, observer) {
142 scrollingElement.scrollTo({ left: 0, top: scrollingElement.scrollHeight, behavior: "instant" });
143 };
213 document.getElementById("code-textarea").value = "";
214 let fullStr = "";
215 window.addToken = function(str) {
216 fullStr += str;
217 const code = fullStr.replaceAll("\`\`\`ts\\n", "").replaceAll("\`\`\`", "");
5// The CSS will add the weird and fun styling parts.
6
7export default async function wordleGame() {
8 const html = `
9 <!DOCTYPE html>
4 */
5
6export default async function(wordleGame(req: Request): Promise<Response> {
7 const html = `
8<!DOCTYPE html>
72 const input = document.getElementById('guess-input');
73
74 function createBoard() {
75 for (let i = 0; i < 30; i++) {
76 const cell = document.createElement('div');
80 }
81
82 function makeGuess() {
83 const guess = input.value.toLowerCase();
84 if (guess.length !== 5) return alert("Guess should be 5 letters!");
53`;
54
55export default async function(req: Request): Promise<Response> {
56 const html = `<html>
57 <head>
117 let currentRow = 0;
118
119 function inputKey(key) {
120 if (currentGuess.length < 5) {
121 currentGuess += key;
124 }
125
126 function deleteKey() {
127 currentGuess = currentGuess.slice(0, -1);
128 updateBoard();
129 }
130
131 function submitGuess() {
132 if (currentGuess.length === 5) {
133 const rowTiles = [...document.querySelectorAll('.row')][currentRow].children;
151 }
152
153 function updateBoard() {
154 const rowTiles = [...document.querySelectorAll('.row')][currentRow].children;
155 for (let i = 0; i < 5; i++) {
104 });
105
106 function handleKeyPress(letter) {
107 if (currentCol < 5) {
108 const cell = gridElement.children[currentRow * 5 + currentCol];
112 }
113
114 function handleSubmit() {
115 if (currentCol === 5) {
116 const guess = [];
134 }
135
136 function handleBackspace() {
137 if (currentCol > 0) {
138 currentCol--;
1export default async function(req: Request): Promise<Response> {
2 const html = `
3 <!DOCTYPE html>

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.