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//%22https:/www.reddeeradvocate.com/news/educator-with-a-vision-7034417/%22?q=function&page=1&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 40463 results for "function"(1446ms)

untitled-8327main.ts1 match

@emarrefUpdated 13 mins ago
1// Learn more: https://docs.val.town/vals/http/
2export default function (req: Request): Promise<Response> {
3 const [, statusCode] = "/200".match(/\/([0-9]*)/);
4

spotymain.ts1 match

@skirtownerUpdated 23 mins ago
1export default async function handler(req: Request) {
2 if (req.method !== "GET") {
3 return new Response("Method Not Allowed", { status: 405 });

eventsCalendartmp.ts1 match

@roopUpdated 1 hour ago
3import { marked } from "npm:marked";
4
5export default async function (req: Request) {
6 const vt = new ValTown();
7 const val_id = "4cbcd1ae-8b94-11f0-b01a-0224a6c84d84";

eventsCalendarserver.ts4 matches

@roopUpdated 1 hour ago
2Use with bookmarklet:
3
4javascript: (function () {
5 var HOST = "https://extract-event-data.val.run";
6 var TOKEN = "<REPLACE>";
209});
210
211function update(stream: SSEStreamingApi, payload: any) {
212 return stream.writeSSE({
213 event: "update",
219}
220
221function complete(
222 stream: SSEStreamingApi,
223 state: "success" | "error",
232}
233
234function fail(
235 stream: SSEStreamingApi,
236 message?: string,
130
131 // Load free version
132 document.getElementById('loadFreeVersion').addEventListener('click', function() {
133 nicheIframe.src = 'free-input-iframe.html';
134 toolContainer.classList.remove('hidden');
138
139 // Load premium version
140 document.getElementById('loadPremiumVersion').addEventListener('click', function() {
141 nicheIframe.src = 'premium-input-iframe.html';
142 toolContainer.classList.remove('hidden');
146
147 // Clear tool
148 document.getElementById('clearTool').addEventListener('click', function() {
149 toolContainer.classList.add('hidden');
150 outputContainer.classList.add('hidden');
156
157 // Listen for messages from iframe
158 window.addEventListener('message', function(event) {
159 // Security check - in production, verify event.origin
160
175
176 // Generate output page
177 function generateOutputPage(data) {
178 try {
179 currentOutputData = data;
200
201 // Download HTML file
202 document.getElementById('downloadPage').addEventListener('click', function() {
203 if (!currentOutputHTML) {
204 alert('No page generated yet!');
225
226 // Preview page
227 document.getElementById('previewPage').addEventListener('click', function() {
228 if (!currentOutputHTML) {
229 alert('No page generated yet!');
242
243 // Copy HTML code
244 document.getElementById('copyCode').addEventListener('click', function() {
245 if (!currentOutputHTML) {
246 alert('No page generated yet!');
248 }
249
250 navigator.clipboard.writeText(currentOutputHTML).then(function() {
251 updateStatus('📋 HTML code copied to clipboard!');
252
263 btn.classList.add('bg-purple-600');
264 }, 2000);
265 }).catch(function(err) {
266 console.error('Failed to copy: ', err);
267 updateStatus('❌ Failed to copy to clipboard');
270
271 // Close preview modal
272 document.getElementById('closePreview').addEventListener('click', function() {
273 previewModal.classList.add('hidden');
274 previewFrame.src = '';
276
277 // Close modal on background click
278 previewModal.addEventListener('click', function(e) {
279 if (e.target === previewModal) {
280 previewModal.classList.add('hidden');
284
285 // Update status message
286 function updateStatus(message) {
287 document.getElementById('outputStatus').textContent = message;
288 console.log('Status:', message);

TopTenVideosoutput-generator.js7 matches

@pmapowerUpdated 2 hours ago
261
262 // Show video details
263 function showVideoDetails(videoId) {
264 const video = videos.find(v => v.id === videoId);
265 if (!video) return;
305
306 // Track ad clicks
307 function trackAdClick(adId, url) {
308 analytics.clicks[adId] = (analytics.clicks[adId] || 0) + 1;
309 updateAnalytics();
312
313 // Track ad impressions
314 function trackAdImpression(adId) {
315 analytics.impressions[adId] = (analytics.impressions[adId] || 0) + 1;
316 updateAnalytics();
319
320 // Update analytics display
321 function updateAnalytics() {
322 const totalImpressions = Object.values(analytics.impressions).reduce((a, b) => a + b, 0);
323 const totalClicks = Object.values(analytics.clicks).reduce((a, b) => a + b, 0);
358 js += `
359 // Initialize page
360 document.addEventListener('DOMContentLoaded', function() {
361 // Auto-select first video
362 if (videos.length > 0) {
390
391 // Display single ad
392 function displayAd(ad) {
393 const content = document.getElementById('advertisementContent');
394 if (!content) return;
431
432 // Start ad rotation
433 function startAdRotation() {
434 if (weightedAds.length === 0) return;
435

TopTenVideospremium-input-iframe.html10 matches

@pmapowerUpdated 2 hours ago
234 }
235
236 function getNextWeekReset() {
237 const now = new Date();
238 const nextWeek = new Date(now);
242 }
243
244 function updateDashboard() {
245 const resetDate = new Date(premiumData.weeklyReset);
246 const now = new Date();
293
294 // Handle main niche selection
295 nicheSelect.addEventListener('change', function() {
296 const selectedValue = this.value;
297
319
320 // Ad slot management
321 document.getElementById('addAdSlot').addEventListener('click', function() {
322 if (adSlotCounter >= 5) {
323 alert('Maximum 5 ad slots allowed');
332 });
333
334 function createAdSlot(slotNumber) {
335 const slotDiv = document.createElement('div');
336 slotDiv.className = 'ad-slot mb-4 p-3 border border-gray-200 rounded-lg';
364 `;
365
366 // Add remove functionality
367 slotDiv.querySelector('.remove-ad-slot').addEventListener('click', function() {
368 slotDiv.remove();
369 updateRemoveButtons();
374 }
375
376 function updateRemoveButtons() {
377 const slots = document.querySelectorAll('.ad-slot');
378 slots.forEach(slot => {
383
384 // Handle form submission
385 form.addEventListener('submit', function(e) {
386 e.preventDefault();
387
460
461 // Auto-resize iframe
462 function resizeIframe() {
463 const height = document.body.scrollHeight;
464 parent.postMessage({

TopTenVideosfree-input-iframe.html3 matches

@pmapowerUpdated 2 hours ago
194
195 // Handle main niche selection
196 nicheSelect.addEventListener('change', function() {
197 const selectedValue = this.value;
198
218
219 // Handle form submission
220 form.addEventListener('submit', function(e) {
221 e.preventDefault();
222
271
272 // Auto-resize iframe
273 function resizeIframe() {
274 const height = document.body.scrollHeight;
275 parent.postMessage({

TopTenVideosVERSION-COMPARISON.md2 matches

@pmapowerUpdated 2 hours ago
92### **Free Version:**
93- **Lead Generation** - Capture interested users
94- **Feature Demonstration** - Show core functionality
95- **Upgrade Conversion** - Clear premium benefits
96- **Viral Sharing** - Easy to share and try
107
108### **Free-to-Premium Funnel:**
1091. **Free users** experience core functionality
1102. **Upgrade prompts** highlight premium benefits
1113. **Weekly limits** create urgency for premium

TopTenVideosfree-version.html6 matches

@pmapowerUpdated 2 hours ago
298
299 // Handle main niche selection
300 nicheSelect.addEventListener('change', function() {
301 const selectedValue = this.value;
302
324
325 // Handle form submission
326 form.addEventListener('submit', function(e) {
327 e.preventDefault();
328
365
366 // Show video results (simplified version)
367 function showVideoResults(niche, subNiche, adConfig) {
368 const videoResults = document.getElementById('videoResults');
369 const nicheDisplay = document.getElementById('nicheDisplay');
496 // Add click handlers
497 document.querySelectorAll('.video-item').forEach(item => {
498 item.addEventListener('click', function() {
499 const videoId = this.dataset.videoId;
500 const video = sampleVideos.find(v => v.id == videoId);
513
514 // Show video description
515 function showVideoDescription(video) {
516 const descriptionPanel = document.getElementById('descriptionPanel');
517
549
550 // Show basic advertisement
551 function showBasicAdvertisement(adConfig) {
552 const advertisementSection = document.getElementById('advertisementSection');
553 const advertisementContent = document.getElementById('advertisementContent');

ratelimit4 file matches

@unkeyUpdated 1 month ago
Rate limit your serverless functions

discordWebhook2 file matches

@stevekrouseUpdated 2 months ago
Helper function to send Discord messages
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.