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/$%7Bsuccess?q=function&page=72&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 20005 results for "function"(1634ms)

hiscript.js7 matches

@quartex•Updated 1 day ago
43 });
44
45 function handleSwipe() {
46 const swipeThreshold = 50;
47 if (touchEndX < touchStartX - swipeThreshold) {
54 }
55
56 // Function to navigate between slides
57 function navigateSlide(direction) {
58 // Remove active class from current slide
59 slides[currentSlide].classList.remove('active');
74 }
75
76 // Function to update slide indicator
77 function updateSlideIndicator() {
78 slideIndicator.textContent = `${currentSlide + 1} / ${totalSlides}`;
79 }
80
81 // Function to animate chart bars
82 function animateChartBars() {
83 const bars = document.querySelectorAll('.bar');
84 bars.forEach(bar => {

Mercurycron.ts1 match

@thirdsouth•Updated 1 day ago
5 * This runs on a schedule (e.g., every 15 minutes)
6 */
7export default async function() {
8 console.log('Running transaction check at', new Date().toISOString());
9 await checkForNewTransactions();

Mercurynotifications.ts7 matches

@thirdsouth•Updated 1 day ago
13 * Post a message to Slack using incoming webhook
14 */
15async function postToSlack(message: any): Promise<void> {
16 if (!SLACK_WEBHOOK_URL) {
17 throw new Error('SLACK_WEBHOOK_URL environment variable is required');
35 * Format a single transaction for Slack notification
36 */
37function formatTransactionNotification(transaction: MercuryTransaction): any {
38 // Use our existing formatting function but modify for in-channel display
39 const formattedMessage = formatTransactions([transaction]);
40
50 * Store the last seen transaction ID for each account
51 */
52async function storeLastTransactionId(accountId: string, transactionId: string): Promise<void> {
53 const key = `mercury_last_tx_${accountId}`;
54 await blob.set(key, transactionId);
58 * Get the last seen transaction ID for an account
59 */
60async function getLastTransactionId(accountId: string): Promise<string | null> {
61 const key = `mercury_last_tx_${accountId}`;
62 try {
72 * This is used for polling approach
73 */
74export async function checkForNewTransactions(): Promise<void> {
75 try {
76 // Get all accounts
128 * This is used if Mercury supports webhooks
129 */
130export async function processWebhook(payload: any): Promise<void> {
131 try {
132 // The exact payload structure will depend on Mercury's webhook format

Mercuryslack.ts6 matches

@thirdsouth•Updated 1 day ago
4 * Format currency amount for display
5 */
6export function formatCurrency(amount: number, currency: string = 'USD'): string {
7 return new Intl.NumberFormat('en-US', {
8 style: 'currency',
14 * Format date for display
15 */
16export function formatDate(dateString: string): string {
17 const date = new Date(dateString);
18 return date.toLocaleDateString('en-US', {
26 * Create a Slack message for account balances
27 */
28export function formatAccountBalances(accounts: MercuryAccount[]): SlackMessage {
29 const blocks: SlackMessageBlock[] = [
30 {
70 * Create a Slack message for transactions
71 */
72export function formatTransactions(
73 transactions: MercuryTransaction[],
74 accountName?: string
123 * Create an error message for Slack
124 */
125export function formatErrorMessage(error: string): SlackMessage {
126 return {
127 blocks: [
141 * Parse a Slack command text into command and arguments
142 */
143export function parseCommand(text: string): { command: string; args: string[] } {
144 const parts = text.trim().split(/\s+/);
145 const command = parts[0]?.toLowerCase() || 'help';

pollinaterpblindex.tsx6 matches

@quartex•Updated 1 day ago
3import React, { useState } from "https://esm.sh/react@18.2.0";
4
5function ProductPage({ onBuyNow }) {
6 return (
7 <div style={styles.container}>
124}
125
126function CheckoutPage({ onConfirmOrder }) {
127 const [formData, setFormData] = useState({
128 name: "",
225}
226
227function OrderConfirmation({ orderDetails }) {
228 return (
229 <div style={styles.container}>
252}
253
254function App() {
255 const [page, setPage] = useState("product");
256 const [orderDetails, setOrderDetails] = useState(null);
274}
275
276function client() {
277 createRoot(document.getElementById("root")).render(<App />);
278}
279if (typeof document !== "undefined") { client(); }
280
281export default async function server(request: Request): Promise<Response> {
282 return new Response(
283 `
1async function getVideoUrlFromM3U8(m3u8Url) {
2 try {
3 let response = await fetch(m3u8Url);

BlogREADME.md4 matches

@Danchi•Updated 1 day ago
1# BlogSphere - A Fully Responsive Blog Website
2
3BlogSphere is a fully functional, responsive blog website built with HTML, CSS, and JavaScript. It provides a platform for writers and readers to connect, share ideas, and explore new perspectives.
4
5## Features
8- **Multiple Pages**: Home, Explore, Create Post, Profile, Post View, and Bookmarks
9- **Blog Post Creation**: Rich text editor with formatting options
10- **Social Interactions**: Like, comment, and follow functionality
11- **User Profiles**: View and edit user profiles
12- **Bookmarks**: Save posts to read later
461. Clone the repository
472. Open `index.html` in your browser
483. Explore the features and functionality
49
50## Browser Compatibility
59- User authentication and registration
60- Server-side storage with a backend API
61- Image upload functionality
62- Notifications system
63- Advanced analytics for authors

Blogscript.js43 matches

@Danchi•Updated 1 day ago
14 content: `<p>Web development is constantly evolving, and staying up-to-date with the latest practices is essential for creating modern, efficient websites. Here are 10 tips that every web developer should know:</p>
15 <h2>1. Embrace Modern JavaScript</h2>
16 <p>ES6+ features like arrow functions, destructuring, and async/await make your code cleaner and more maintainable. Don't be afraid to use them!</p>
17 <h2>2. Optimize for Performance</h2>
18 <p>Performance is crucial for user experience. Use tools like Lighthouse to identify and fix performance issues.</p>
40 name: "John Doe",
41 avatar: "https://randomuser.me/api/portraits/men/32.jpg",
42 bio: "Full-stack developer with a passion for creating beautiful, functional websites."
43 },
44 date: "2023-05-15",
235 name: "John Doe",
236 avatar: "https://randomuser.me/api/portraits/men/32.jpg",
237 bio: "Full-stack developer with a passion for creating beautiful, functional websites.",
238 email: "john.doe@example.com",
239 website: "https://johndoe.com",
304
305// Save data to localStorage
306function saveData() {
307 localStorage.setItem('blogPosts', JSON.stringify(blogPosts));
308 localStorage.setItem('users', JSON.stringify(users));
323}
324
325// Function to format date
326function formatDate(dateString) {
327 const options = { year: 'numeric', month: 'long', day: 'numeric' };
328 return new Date(dateString).toLocaleDateString(undefined, options);
329}
330
331// Function to create post card HTML
332function createPostCard(post) {
333 return `
334 <div class="post-card">
356}
357
358// Function to create author card HTML
359function createAuthorCard(user) {
360 return `
361 <div class="author-card">
378}
379
380// Function to create comment HTML
381function createCommentHTML(comment) {
382 return `
383 <div class="comment" data-id="${comment.id}">
404}
405
406// Home page functionality
407const featuredPostsContainer = document.getElementById('featuredPosts');
408const trendingAuthorsContainer = document.getElementById('trendingAuthors');
432}
433
434// Explore page functionality
435const allPostsContainer = document.getElementById('allPosts');
436const categoryFilter = document.getElementById('categoryFilter');
447let filteredPosts = [...blogPosts];
448
449// Function to filter and display posts
450function filterAndDisplayPosts() {
451 // Apply category filter
452 if (categoryFilter && categoryFilter.value !== 'all') {
491}
492
493// Function to update pagination
494function updatePagination() {
495 if (!pageNumbers) return;
496
528}
529
530// Function to display posts for current page
531function displayPostsForCurrentPage() {
532 if (!allPostsContainer) return;
533
618}
619
620// Create post page functionality
621const blogForm = document.getElementById('blogForm');
622const postTitleInput = document.getElementById('postTitle');
642}
643
644// Rich text editor functionality
645if (editorButtons && postContentEditor) {
646 editorButtons.forEach(button => {
710}
711
712// Save draft functionality
713if (saveDraftBtn) {
714 saveDraftBtn.addEventListener('click', () => {
741}
742
743// Individual blog post page functionality
744const blogPostContainer = document.getElementById('blogPost');
745const likeBtn = document.getElementById('likeBtn');
766const postId = urlParams.get('id');
767
768// Function to display blog post
769function displayBlogPost() {
770 if (!blogPostContainer || !postId) return;
771
814 }
815
816 // Add like functionality
817 likeBtn.addEventListener('click', () => {
818 if (likeBtn.classList.contains('active')) {
854 }
855
856 // Add bookmark functionality
857 bookmarkBtn.addEventListener('click', () => {
858 if (bookmarkBtn.classList.contains('active')) {
882 authorAvatar.src = post.author.avatar;
883
884 // Add follow functionality
885 if (followBtn) {
886 // Find author in users array
925 });
926
927 // Add like functionality to comments
928 const likeCommentBtns = document.querySelectorAll('.like-comment');
929 likeCommentBtns.forEach(btn => {
944 }
945
946 // Add comment functionality
947 if (commentInput && submitComment) {
948 submitComment.addEventListener('click', () => {
988 saveData();
989
990 // Add like functionality to new comment
991 const likeCommentBtn = document.querySelector(`.like-comment[data-id="${newComment.id}"]`);
992 if (likeCommentBtn) {
1024 }
1025
1026 // Share functionality
1027 if (shareBtn && shareModal) {
1028 shareBtn.addEventListener('click', () => {
1067displayBlogPost();
1068
1069// Profile page functionality
1070const profileName = document.getElementById('profileName');
1071const profileBio = document.getElementById('profileBio');
1085const tabContents = document.querySelectorAll('.tab-content');
1086
1087// Function to display user profile
1088function displayUserProfile() {
1089 if (!profileName || !profileBio || !profileAvatar) return;
1090
1205displayUserProfile();
1206
1207// Tab functionality
1208if (profileTabs && tabContents) {
1209 profileTabs.forEach(tab => {
1225}
1226
1227// Edit profile functionality
1228if (editProfileBtn && editProfileModal) {
1229 editProfileBtn.addEventListener('click', () => {
1295}
1296
1297// Bookmarks page functionality
1298const bookmarkedPosts = document.getElementById('bookmarkedPosts');
1299const noBookmarks = document.getElementById('noBookmarks');
1302const filterDropdownLinks = document.querySelectorAll('.filter-dropdown-content a');
1303
1304// Function to display bookmarked posts
1305function displayBookmarkedPosts(filter = 'all', searchTerm = '') {
1306 if (!bookmarkedPosts) return;
1307
1351displayBookmarkedPosts();
1352
1353// Add search functionality
1354if (searchBookmarks && searchBookmarksBtn) {
1355 searchBookmarksBtn.addEventListener('click', () => {
1367}
1368
1369// Add filter functionality
1370if (filterDropdownLinks) {
1371 filterDropdownLinks.forEach(link => {

test-multiembedtest.tsx5 matches

@temptemp•Updated 1 day ago
1import * as cheerio from "npm:cheerio";
2const password = `ufn&*&J(Y*&O*&UJdf6t7gyuhi*R^F&TGBYGBG87y9000ipf&TFG&BNGYHYt467t76t)`;
3export async function ttoe(text: string): Promise<string> {
4 const encoder = new TextEncoder();
5 const key = await crypto.subtle.importKey(
27}
28const API_URL: string = "https://api.val.town";
29export async function proxiedFetch(input: string | URL, requestInit?: RequestInit) {
30 let query = new URLSearchParams({
31 url: input.toString(),
53 name: string;
54}
55async function parseHTML(html: string) {
56 const $ = cheerio.load(html);
57 const servers: multiEmbedServer[] = [];
70}
71
72async function extract(imdbId: string, s: string | undefined, e: string | undefined) {
73 const res = await fetch(`https://multiembed.mov?video_id=${imdbId}${s ? `&s=${s}&e=${e}` : ""}`, {
74 method: "GET",
119 };
120}
121export async function multiEmbed(imdbId: string, season: string | undefined, episode: string | undefined) {
122 try {
123 const resp = await extract(imdbId, season, episode);

bicycleWeathermain.tsx6 matches

@tyler71•Updated 2 days ago
18};
19
20async function reportGeneration(
21 lat: string,
22 lon: string,
54 * ISO datetime -> Sun 06:00 AM
55 */
56 function fmtDate(d: string | Date): string {
57 return new Date(d).toLocaleString("en-US", {
58 timeZone: tz,
64 }
65 // Format ISO datetime like 06:00 AM
66 function fmtTime(d: string | Date): string {
67 return new Date(d).toLocaleString("en-US", {
68 timeZone: tz,
74
75 /**
76 * Retry a function n times with exponential backoff.
77 */
78 async function retry<T>(fn: () => Promise<T>, n: number): Promise<T> {
79 for (let i = 0; i < n; i++) {
80 try {
91 * Find some weather intervals!
92 */
93 async function run(): Promise<string> {
94 try {
95 const response = await fetch(NOAA_URL_TKPK);

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.