23// Fetches a random joke.
4async function fetchRandomJoke() {
5const response = await fetch(
6"https://official-joke-api.appspot.com/random_joke",
uploadImagemain.tsx2 matches
4* @returns {string} - uploaded image url
5*/
6export async function uploadImage(image: Blob): Promise<string> {
7const fd = new FormData();
8fd.append(
23return data.result.variants[0];
24}
25async function getUploadURL(): Promise<string> {
26const data = await (await fetch("https://www.val.town/api/trpc/generateImageUploadUrl", {
27"headers": {
StripeCheckoutDemomain.tsx8 matches
81`;
8283function Instructions() {
84return (
85<div className="mb-4">
95}
9697function TipList({ tips, selectedDate, sortOrder, setSortOrder }) {
98const filteredTips = tips.filter((tip) => {
99const tipDate = new Date(tip.timestamp);
145}
146147function DateSelector({ selectedDate, setSelectedDate }) {
148const [isCalendarOpen, setIsCalendarOpen] = useState(false);
149const today = new Date();
232}
233234function App({ initialTips }) {
235const [amount, setAmount] = useState(20);
236const [name, setName] = useState("");
354}
355356function Confetti() {
357useEffect(() => {
358confetti({
366}
367368function SuccessPage({ payments }) {
369return (
370<div className="min-h-screen bg-white text-black flex flex-col items-center justify-center p-4">
391}
392393function client() {
394const root = document.getElementById("root");
395if (root.dataset.page === "success") {
406}
407408export default async function server(req: Request): Promise<Response> {
409const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
410const SCHEMA_VERSION = 2;
diacomDemomain.tsx4 matches
3import { createRoot } from "https://esm.sh/react-dom/client";
45function App() {
6const [imageId, setImageId] = useState(null);
7const [file, setFile] = useState(null);
12let cornerstone, cornerstoneWADOImageLoader, dicomParser;
1314async function loadLibraries() {
15cornerstone = (await import("https://esm.sh/cornerstone-core")).default;
16cornerstoneWADOImageLoader = (await import("https://esm.sh/cornerstone-wado-image-loader")).default;
80}
8182function client() {
83createRoot(document.getElementById("root")).render(<App />);
84}
86if (typeof document !== "undefined") { client(); }
8788export default async function server(request: Request): Promise<Response> {
89return new Response(`
90<html>
bricklesGamemain.tsx10 matches
3import { createRoot } from "https://esm.sh/react-dom/client";
45function App() {
6const canvasRef = useRef(null);
7const [score, setScore] = useState(0);
36document.addEventListener('keyup', (e) => keys[e.key] = false);
3738function drawBall() {
39ctx.beginPath();
40ctx.arc(ball.x, ball.y, ball.radius, 0, Math.PI * 2);
44}
4546function drawPaddle() {
47ctx.beginPath();
48ctx.rect(paddle.x, paddle.y, paddle.width, paddle.height);
52}
5354function drawBricks() {
55for (let c = 0; c < brickColumnCount; c++) {
56for (let r = 0; r < brickRowCount; r++) {
70}
7172function drawParticles() {
73particles.forEach((particle, index) => {
74particle.life--;
87}
8889function createParticles(x, y) {
90for (let i = 0; i < 10; i++) {
91particles.push({
100}
101102function collisionDetection() {
103for (let c = 0; c < brickColumnCount; c++) {
104for (let r = 0; r < brickRowCount; r++) {
118}
119120function draw() {
121ctx.clearRect(0, 0, canvas.width, canvas.height);
122drawBricks();
187}
188189function client() {
190createRoot(document.getElementById("root")).render(<App />);
191}
192if (typeof document !== "undefined") { client(); }
193194export default async function server(request: Request): Promise<Response> {
195return new Response(`
196<html>
StripeDemomain.tsx4 matches
4import { createRoot } from "https://esm.sh/react-dom/client";
56function App() {
7const [tipAmount, setTipAmount] = useState(5);
8const paymentLinks = {
63}
6465function Success() {
66useEffect(() => {
67confetti({
81}
8283function client() {
84const root = document.getElementById("root");
85if (root) {
94if (typeof document !== "undefined") { client(); }
9596export default async function server(request: Request): Promise<Response> {
97const url = new URL(request.url);
98
handleDiscordNewUsermain.tsx1 match
3// # New Val Town User (on Clerk) -> Val Town Discord notification
4// Translates one kind of webhook (Clerk) into another (Discord)
5export async function handleDiscordNewUser(req: Request): Promise<Response> {
6// check custom auth secret sent from clerk
7if (req.headers.get("auth") !== Deno.env.get("clerkNonSensitive"))
jokeGeneratorValmain.tsx1 match
23// Fetches a random joke.
4async function fetchRandomJoke() {
5const response = await fetch(
6"https://official-joke-api.appspot.com/random_joke",
6);
78export async function uptimeCheck(url: string) {
9let reason: string, status: number, end: number;
10let ok = true;
5import { renderToString } from "npm:react-dom/server";
67function StatusRow({ rows }) {
8return (
9<div className="w-full flex flex-col space-y-2">
28}
2930function StatusSection({ url, rows }) {
31const sectionRows = rows.filter(row => row[0] === url);
32const percentUp = Math.round((sectionRows.filter(row => row[1]).length / sectionRows.length) * 100);
44}
4546export default async function(req: Request): Promise<Response> {
47const { rows } = await sqlite.execute(
48"select url, ok, duration, timestamp from uptime order by timestamp desc limit 200",