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/$%7Burl%7D?q=function&page=83&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 28445 results for "function"(4654ms)

learnwithgidiblogmain.tsx1 match

@GidiAi•Updated 1 day ago
2import { renderToString } from "npm:react-dom/server";
3
4export default async function(req: Request) {
5 return new Response(
6 renderToString(

linkInBioTemplatemain.tsx1 match

@GidiAi•Updated 1 day ago
2import { renderToString } from "npm:react-dom/server";
3
4export default async function(req: Request) {
5 return new Response(
6 renderToString(

Altaroc-main-scriptmain.tsx67 matches

@valentinNCF•Updated 1 day ago
90]);
91
92function hideLoader() {
93 if (loader) {
94 loader.style.display = "none";
95 }
96}
97function showLoader() {
98 if (loader) {
99 loader.style.display = "flex";
101}
102
103function resetAll() {
104 // clean les user prefs
105 ResetUserPref();
108}
109// INTERNATIONAL POPUP
110function showUnauthorizedPopup() {
111 document.querySelectorAll("[availability]")[0].style.display = "block";
112 document.body.style.overflow = "hidden";
117}
118
119function instantTranslate_itl(lang) {
120 const instantTrads = document.querySelectorAll("[instant-trad]");
121 instantTrads.forEach(element => {
129 "languageTo": lang,
130 },
131 function(destTxt) {
132 console.log(destTxt[0]);
133 element.textContent = destTxt[0];
137}
138
139function ApplyCurrentLang() {
140 currentLang.forEach(element => {
141 element.textContent = Weglot.getCurrentLang();
143}
144
145function getElements() {
146 // 1) declaration des variable vitales
147 loader = document.getElementsByClassName("loader")[0];
194 changeCountries.forEach(element => {
195 element.addEventListener("click", () => {
196 ResetUserPref(); // Call the toto function on click
197 });
198 });
321 ChoosenTermsValue = document.querySelectorAll("[choosenTermsValue]")[0].innerText;
322
323 itlBtnStart.addEventListener("click", function() {
324 itlPopupTopBar.style.opacity = 1;
325 popupItlStep = 1;
328 });
329
330 itlPopupPrev.addEventListener("click", function() {
331 if (popupItlStep === 2) {
332 popupItlStep = 1;
361}
362
363function writeCountryPref() {
364 const countryCode = localStorage.userCountry;
365 const fullCountry = document.querySelectorAll("[itl-choice-country=" + countryCode + "]")[0].childNodes[1].innerText;
371 filterSpokenLangs(spokenL);
372}
373function writeProfile() {
374 const userProfile = localStorage.userProfile;
375 applyChosenProfile(userProfile);
376}
377
378function writeLang(l) {
379 document.querySelectorAll("[current-lang]")[0].textContent = l;
380}
381
382function setItlPopupInitLang() {
383 // Get the browser's language and extract the two-letter code
384 const browserLanguage = navigator.language || navigator.userLanguage;
393}
394
395function ApplyChosenCountry(c) {
396 ChoosenCountry.forEach(element => {
397 element.innerText = c;
401}
402
403function filterSpokenLangs(langs) {
404 console.log(langs);
405 console.log(spokenLangsOrder);
416}
417
418function filterAndOrderSpokenLangs(langs) {
419 console.log(spokenLangsOrder);
420 spokenLangsOrder.forEach(lang => {
436}
437
438function applyChosenLang(l) {
439 ChoosenLang.forEach(element => {
440 element.innerText = l;
443 CheckStep2.style.opacity = 1;
444}
445function applyChosenProfile(p) {
446 ChoosenProfile.forEach(element => {
447 element.innerText = p;
453}
454
455function applyChosenTerms(t) {
456 if (popupItlStep === 4) {
457 ChoosenTerms.forEach(element => {
467}
468
469function WatchFullCgvRead() {
470 if (Webflow.env("editor")) {
471 console.log("mut observer disabled");
472 } else {
473 // Créer un IntersectionObserver avec une fonction de callback qui authorize la validation
474 var observer = new IntersectionObserver(function(entries) {
475 // `entries` contient les éléments observés et leurs états d'intersection
476 entries.forEach(entry => {
497}
498
499function authorizeValidation() {
500 itlPopupValidate.classList.remove("disabled");
501 console.log("disabled remove");
502 itlPopupValidate.addEventListener("click", function() {
503 StorePopupChoices(UserCountry, UserLang, UserProfile);
504
519}
520
521function handleStepStyles() {
522 // Select all elements with the attribute itl-popup-step
523 const elements = document.querySelectorAll("[itl-popup-step]");
539// 2) declaration des fonction vitales
540
541function showItlPopup() {
542 setItlPopupInitLang();
543 popupItlStep = 0;
544 document.addEventListener("keydown", function(event) {
545 if (event.key === "Enter" && popupItlStep === 0) {
546 itlBtnStart.click();
560}
561
562function flyToStep(step) {
563 itlPopupContainer.scrollTo({
564 top: step.offsetTop - 120,
567}
568
569function BackToStep1() {
570 flyToStep(step1);
571 popupItlStep = 1;
576 step3.scrollTop = 0;
577}
578function BackToStep2() {
579 if (popupItlStep > 1) {
580 flyToStep(step2);
588}
589
590function BackToStep3() {
591 if (popupItlStep > 2) {
592 flyToStep(step3);
600}
601
602function scrollToEnd() {
603 step4.scrollTop = step4.scrollHeight;
604}
605
606function filterCgv() {
607 // Select all elements with the attributes itl-cgv-country and itl-cgv-lang
608 const elements = document.querySelectorAll("[itl-cgv-country][itl-cgv-lang]");
627}
628
629function StorePopupChoices(country, lang, profile) {
630 localStorage.setItem("userCountry", country);
631 localStorage.setItem("userLang", lang);
634}
635
636function ResetUserPref() {
637 localStorage.removeItem("userCountry");
638 localStorage.removeItem("userLang");
643}
644
645function scrollTop() {
646 window.scrollTo(0, 0);
647}
648
649function checkLocalStorage() {
650 getElements();
651 console.log("elementsGot");
669 getAuthorizedVehiclesByCountry(localStorage.userCountry);
670 LocalizeStaticPage();
671 // Check if env is "preprod" before running the function
672 if (env === "staging") {
673 console.log("Environment is preprod. Running LocaliseCMSdata...");
690}
691
692function calcDestinationSubFolder() {
693 if (localStorage.userLang === "fr") {
694 subfolder = "";
699
700// Definition des fonction vitales
701function findUrl(slug, country) {
702 // First, search in the specified country
703 const match = urlTable.find(entry => entry[country] === slug);
739}
740
741function AdaptStaticPage(slug) {
742 if (!slug) {
743 masterSlug = findMasterPage();
765}
766
767function findMasterPage() {
768 baseUrl = window.location.origin;
769
799
800// permet de find le best resource match Ă  partir d'un type et d'un name
801function findResource(resourceType, resourceMasterName, country, lang) {
802 console.log(country + " " + lang);
803 const alternativeResources = externalResourceTable.filter(resource =>
846
847// dynamic checks
848function getAuthorizedVehiclesByCountry(countryCode) {
849 if (vehicleTable) {
850 // Find the authorized vehicle list for the given country code
860}
861
862function CheckVehicle_overlap(involved) {
863 // Split and normalize the involved string into an array (lowercase and trimmed)
864 const involvedArray = involved
880 }
881}
882function AdaptDynamicPage() {
883 const involvedVehicles = document.querySelectorAll("meta[involvedvehicles]")[0].getAttribute("involvedvehicles");
884 const b = document.querySelectorAll("meta[blacklist]")[0].getAttribute("blacklist");
910}
911// var cmsItems;
912function deleteOverLimitCms() {
913 // managing cms lists with limit indicated in attribute data-limit
914 const cmsLists = document.querySelectorAll("[data-limit]");
926}
927
928function LocaliseCMSdata() {
929 // Select all elements with the "vehicles" attribute
930 const elements = document.querySelectorAll("[vehicles]");
964}
965
966function checkWhitelist(w) {
967 const array = w
968 .split(",")
972}
973
974function checkBlacklist(b) {
975 const array = b
976 .split(",")
980}
981
982function AdaptSwipers() {
983 // Sélectionne tous les conteneurs Swiper sur la page
984 const swiperContainers = document.querySelectorAll(".swiper");
993}
994
995function AdaptGrids() {
996}
997
998function AdaptExternalResources() {
999 const elements = document.querySelectorAll("[externalresourcetype][externalresourcename]");
1000 // itere parmis les elements qui ont les attributes externalRessource
1022}
1023
1024function addhsform(target, formId, instance) {
1025 // console.log("add hsform");
1026 // console.log(instance+1);
1035 formId: formId,
1036 target: "[hs-externalresource='" + formId + "_" + instance + "']", // Directly reference the target div
1037 onFormSubmit: function(form) {
1038 // Show the success div block.
1039 // success();
1045 }
1046}
1047function addhsfile(div, url) {
1048 console.log("add hs file");
1049 div.href = url;
1050}
1051function addhscal(element, id) {
1052 console.log("add hscal");
1053 console.log(element);
1071}
1072/// hotfix du bug Hubspot calendar
1073function fix_hscal() {
1074 const badurl = document.querySelectorAll("[data-src]")[0].firstChild.src;
1075 const cleanurl = badurl.replace(/(parentPageUrl=[^&]+)&/, "$1?");
1079
1080// LAUNCH EXTERNAL RESSOURCES
1081async function LoadExternalResources() {
1082 try {
1083 const response = await fetch(apiBaseUrl + "/api:_aqWQ_f_/ListAllRessourcesExternes", fetchOptions);
1090}
1091
1092// Function to run vital and then the dependent function
1093async function LocalizeExternalResources() {
1094 await LoadExternalResources(); // Wait for vital to complete
1095 AdaptExternalResources(); // Run the dependent function
1096}
1097
1098// LAUNCH STATIC RESOURCES
1099async function LoadStaticTable() {
1100 try {
1101 const response = await fetch(apiBaseUrl + "/api:_aqWQ_f_/ListAllStaticPages", fetchOptions);
1107 }
1108}
1109// Function to run vital and then the dependent function
1110async function LocalizeStaticPage() {
1111 if (document.querySelectorAll("meta[involvedvehicles]").length !== 0) {
1112 // Run AdaptDynamicPage() ;
1146
1147// Fonction pour vérifier et masquer les sections vides
1148function checkSectionsToHide() {
1149 console.log("checking sections to hide");
1150 const sections = document.querySelectorAll("[data-collection-ref][ncf-display-type=\"conditionnal\"]");

quoteValmain.tsx1 match

@pirez007•Updated 1 day ago
1/** @jsxImportSource https://esm.sh/react@18.2.0 */
2import { renderToString } from "npm:react-dom@18.2.0/server";
3export default async function() {
4 const quotes = [
5 "The more you read, the more things you will know, the more that you learn, the more places you'll go. - Dr. Seuss",

TownieValTownLogo.tsx1 match

@faithyz•Updated 1 day ago
1/** @jsxImportSource https://esm.sh/react@18.2.0?dev */
2
3export function ValTownLogo () {
4 return (
5 <svg

TownieuseUser.tsx1 match

@faithyz•Updated 1 day ago
3const USER_ENDPOINT = "/api/user";
4
5export function useUser() {
6 const [data, setData] = useState<any>(null);
7 const [loading, setLoading] = useState(true);

TownieuseUsageStats.ts1 match

@faithyz•Updated 1 day ago
1import { useEffect } from "react";
2
3export function useUsageStats(messages: any[], usages: any[]) {
4 useEffect(() => {
5 if (!messages?.length) return;

TownieuseScrollToBottom.tsx3 matches

@faithyz•Updated 1 day ago
7 *
8 * @param {Array} dependencies - Array of dependencies that trigger scrolling when changed
9 * @returns {Object} An object containing containerRef and scrollToBottom function
10 */
11export function useScrollToBottomContainer(dependencies = []) {
12 const containerRef = useRef(null);
13
28
29// body scroll version
30export function useScrollToBottom(dependencies = []) {
31 const bottomRef = useRef(null);
32

Townieuser-summary.ts1 match

@faithyz•Updated 1 day ago
6 * This includes a fallback to inference calls data when usage data is missing
7 */
8export async function getUserSummary() {
9 // First, get the standard grouped data from the usage table
10 const groupedUsageData = await sqlite.execute(`

TownieuseProject.tsx1 match

@faithyz•Updated 1 day ago
4const FILES_ENDPOINT = "/api/project-files";
5
6export function useProject(projectId: string, branchId?: string) {
7 const [data, setData] = useState<any>(null);
8 const [loading, setLoading] = useState(true);

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.