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.val.town/x/moe/MiniAppStarter/%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 40460 results for "function"(1166ms)

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 20 mins 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 22 mins 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 23 mins 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 25 mins 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 26 mins 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');

TopTenVideospremium-version.html9 matches

@pmapowerUpdated 31 mins ago
343 }
344
345 function getNextWeekReset() {
346 const now = new Date();
347 const nextWeek = new Date(now);
351 }
352
353 function updateDashboard() {
354 const resetDate = new Date(premiumData.weeklyReset);
355 const now = new Date();
375 }
376
377 function showPreviousPages() {
378 const previousPages = document.getElementById('previousPages');
379 const pagesList = document.getElementById('pagesList');
407 }
408
409 function requestExtraPage() {
410 alert('🎯 Contact support to request additional pages for this week!\n\nEmail: support@nicheselector.com\nSubject: Extra Page Request - Premium User');
411 }
412
413 function viewPage(index) {
414 const page = premiumData.createdPages[index];
415 // Simulate loading the page data
417 }
418
419 function deletePage(index) {
420 if (confirm('Are you sure you want to delete this page?')) {
421 premiumData.createdPages.splice(index, 1);
460
461 // Handle main niche selection
462 nicheSelect.addEventListener('change', function() {
463 const selectedValue = this.value;
464
486
487 // Handle form submission
488 form.addEventListener('submit', function(e) {
489 e.preventDefault();
490
571 });
572
573 // Include all the original premium JavaScript functions here...
574 // (showVideoResults, ad management, analytics, etc.)
575 // This would be the same code from the original index.html

TopTenVideosindex.html27 matches

@pmapowerUpdated 39 mins ago
423
424 // Initialize ad slot management
425 function initializeAdSlots() {
426 const addAdSlotBtn = document.getElementById('addAdSlot');
427 const adSlotsContainer = document.getElementById('adSlotsContainer');
428
429 // Add new ad slot
430 addAdSlotBtn.addEventListener('click', function() {
431 if (adSlotCounter >= 5) {
432 alert('Maximum 5 ad slots allowed');
446
447 // Create new ad slot HTML
448 function createAdSlot(slotNumber) {
449 const slotDiv = document.createElement('div');
450 slotDiv.className = 'ad-slot mb-6 p-4 border border-gray-200 rounded-lg';
502
503 // Attach event listeners to ad slot
504 function attachAdSlotListeners(slotElement) {
505 const imageInput = slotElement.querySelector('.ad-image-input');
506 const clickInput = slotElement.querySelector('.ad-click-input');
508 const removeBtn = slotElement.querySelector('.remove-ad-slot');
509
510 // Preview functionality
511 function updateSlotPreview() {
512 const preview = slotElement.querySelector('.ad-preview');
513 const previewContent = slotElement.querySelector('.ad-preview-content');
539 titleInput.addEventListener('input', updateSlotPreview);
540
541 // Remove slot functionality
542 removeBtn.addEventListener('click', function() {
543 slotElement.remove();
544 updateRemoveButtons();
547
548 // Update remove button visibility
549 function updateRemoveButtons() {
550 const slots = document.querySelectorAll('.ad-slot');
551 slots.forEach((slot, index) => {
555 }
556
557 // Analytics tracking functions
558 function trackAdImpression(adId) {
559 adAnalytics.impressions[adId] = (adAnalytics.impressions[adId] || 0) + 1;
560 console.log(`Ad Impression: ${adId}`, adAnalytics.impressions);
570 }
571
572 function trackAdClick(adId, clickUrl) {
573 adAnalytics.clicks[adId] = (adAnalytics.clicks[adId] || 0) + 1;
574 console.log(`Ad Click: ${adId} -> ${clickUrl}`, adAnalytics.clicks);
585
586 // Handle main niche selection
587 nicheSelect.addEventListener('change', function() {
588 const selectedValue = this.value;
589
615
616 // Handle form submission
617 form.addEventListener('submit', function(e) {
618 e.preventDefault();
619
689 });
690
691 // Function to show video results with sample data
692 async function showVideoResults(niche, subNiche, headerUrl, adConfig) {
693 const videoResults = document.getElementById('videoResults');
694 const headerContent = document.getElementById('headerContent');
836 // Add click handlers for video items
837 document.querySelectorAll('.video-item').forEach(item => {
838 item.addEventListener('click', function() {
839 const videoId = this.dataset.videoId;
840 const video = sampleVideos.find(v => v.id == videoId);
853 }
854
855 // Function to display advertisements with rotation
856 function showAdvertisements(adConfig) {
857 const advertisementSection = document.getElementById('advertisementSection');
858 const advertisementContent = document.getElementById('advertisementContent');
896
897 // Display a single advertisement
898 function displaySingleAd(ad, trackingId) {
899 const advertisementContent = document.getElementById('advertisementContent');
900
970
971 // Handle ad clicks with tracking
972 function handleAdClick(adId, clickUrl) {
973 trackAdClick(adId, clickUrl);
974 window.open(clickUrl, '_blank', 'noopener,noreferrer');
976
977 // Show analytics panel
978 function showAnalyticsPanel(adSlots) {
979 const existingPanel = document.getElementById('analyticsPanel');
980 if (existingPanel) existingPanel.remove();
1020
1021 // Update analytics display
1022 function updateAnalyticsDisplay() {
1023 const totalImpressions = Object.values(adAnalytics.impressions).reduce((a, b) => a + b, 0);
1024 const totalClicks = Object.values(adAnalytics.clicks).reduce((a, b) => a + b, 0);
1053
1054 // Toggle analytics details
1055 function toggleAnalytics() {
1056 const details = document.getElementById('analyticsDetails');
1057 if (details) {
1061
1062 // Initialize everything when page loads
1063 document.addEventListener('DOMContentLoaded', function() {
1064 initializeAdSlots();
1065 updateRemoveButtons();
1066 });
1067
1068 // Function to show video description
1069 function showVideoDescription(video) {
1070 const descriptionPanel = document.getElementById('descriptionPanel');
1071

untitled-2035main.ts12 matches

@chatgotUpdated 1 hour ago
17};
18
19export default async function (req: Request): Promise<Response> {
20 const url = new URL(req.url);
21
414 };
415
416 // Then in your main function, after getting fantasy data:
417 const realLeaders = await getRealNFLLeaders(currentWeek);
418
453 }
454
455 // Build narrative hints with new functions
456 const narrativeHints = {
457 mainStory: determineMainStory(nflGames, fantasyMatchups),
694}
695
696// Helper functions
697function calculateBenchPain(team, week) {
698 if (!team?.roster?.entries) return null;
699
727}
728
729function getPositionName(posId) {
730 const positions = ["QB", "RB", "WR", "TE", "K", "DST"];
731 return positions[posId - 1] || "FLEX";
732}
733
734function isGameTime() {
735 const now = new Date();
736 const day = now.getDay();
743}
744
745function determineMainStory(nflGames, fantasyMatchups) {
746 // NFL shootout
747 const shootout = nflGames.find((g) => {
764}
765
766function determineVibe(nfl, fantasy) {
767 const blowouts = fantasy.filter((m) => m.isBlowout).length;
768 const closeGames =
777}
778
779function findWorstDecision(benchPain) {
780 if (!benchPain.length) return null;
781
791}
792
793function compileMustMentions(nfl, fantasy, benchPain) {
794 const mentions = [];
795
808}
809
810function getCurrentWeek() {
811 const seasonStart = new Date("2025-09-04");
812 const now = new Date();

PixelPixelApiMonitormain.ts2 matches

@selfire1Updated 2 hours ago
1export default async function (_interval: Interval) {
2 const SLACK_TOKEN = Deno.env.get("SLACK_TOKEN");
3 const channel = "C060TG0KLQJ";
28 }
29
30 async function sendSlackMessage(text: string) {
31 return await fetch("https://slack.com/api/chat.postMessage", {
32 headers: {

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.