social-proofscript.js19 matches
1(function () {
2"use strict";
32829// Inject CSS styles for purchase notifications
30function injectStyles() {
31if (document.getElementById("social-proof-styles")) return;
32396397// Create notification container
398function createNotificationContainer() {
399let container = document.getElementById("social-proof-container");
400if (container) return container;
409410// Sanitize HTML
411function sanitizeHtml(str) {
412if (typeof str !== "string") return "";
413423424// Validate and sanitize config
425function validateConfig(config) {
426const sanitized = { ...config };
427482483// Validate and sanitize product IDs
484function validateProductIds(productIdsString) {
485if (!productIdsString || typeof productIdsString !== "string") {
486return [];
496497// Format time ago
498function formatTimeAgo(dateString) {
499const date = new Date(dateString);
500const now = new Date();
512513// Create purchase notification element
514function createPurchaseNotification(purchase) {
515const notification = document.createElement("div");
516notification.className = "social-proof-notification";
555556// Create event signup notification element
557function createEventSignupNotification(
558eventName,
559signupCount,
640641// Stack existing notifications
642function stackNotifications(container) {
643const notifications = container.querySelectorAll(
644".social-proof-notification",
672673// Show purchase notification
674function showPurchaseNotification(purchase) {
675if (!isActive || displayCount >= config.maxDisplayCount) return;
676703704// Show event signup notification
705function showEventSignupNotification(
706eventName,
707signupCount,
742743// Hide notification
744function hideNotification(notification) {
745// Add smooth exit animation
746notification.style.transition = "all 0.4s ease";
760761// Fetch recent purchases
762async function fetchRecentPurchases(productIds) {
763try {
764const productIdsParam = Array.isArray(productIds)
782783// Fetch event signup data (count and first signup time)
784async function fetchEventSignupData(eventName) {
785try {
786if (
837838// Show one-time event signup notification on page load
839async function showEventSignupOnLoad(eventName) {
840try {
841const { signupCount, firstSignupTime } = await fetchEventSignupData(
855856// Start showing purchase notifications
857function startPurchaseNotifications(productIds) {
858if (!productIds || !isActive) return;
859873874// Show next purchase notification in queue
875function showNextPurchaseNotification() {
876if (
877!isActive || notificationQueue.length === 0 ||
891892// Initialize social proof
893function initSocialProof() {
894injectStyles();
895
3import module_path from "./module_path.tsx"
45async function main() {
6const shader = await (await fetch(`${module_path}/shader.wgsl`)).text();
751};
5253function render() {
54renderPassDescriptor.colorAttachments[0].view =
55context.getCurrentTexture().createView();
85}
8687function fail(msg: string) {
88alert(msg);
89}
webgpu_2server.tsx1 match
1import module_path from "./module_path.tsx"
23export default function (_req: Request): Response {
4return new Response(
5`
45- Ask clarifying questions when requirements are ambiguous
6- Provide complete, functional solutions rather than skeleton implementations
7- Test your logic against edge cases before presenting the final solution
8- Ensure all code follows Val Town's specific platform requirements
17- **Never bake in secrets into the code** - always use environment variables
18- Include comments explaining complex logic (avoid commenting obvious operations)
19- Follow modern ES6+ conventions and functional programming practices if possible
2021## Types of triggers
2829```ts
30export default async function (req: Request) {
31return new Response("Hello World");
32}
4243```ts
44export default async function () {
45// Scheduled task code
46}
5657```ts
58export default async function (email: Email) {
59// Process email
60}
66## Val Town Standard Libraries
6768Val Town provides several hosted services and utility functions.
6970### Blob Storage
120```
121122## Val Town Utility Functions
123124Val Town provides several utility functions to help with common project tasks.
125126### Importing Utilities
200โ โโโ database/
201โ โ โโโ migrations.ts # Schema definitions
202โ โ โโโ queries.ts # DB query functions
203โ โ โโโ README.md
204โ โโโ routes/ # Route modules
219โโโ shared/
220โโโ README.md
221โโโ utils.ts # Shared types and functions
222```
223226- Hono is the recommended API framework
227- Main entry point should be `backend/index.ts`
228- **Static asset serving:** Use the utility functions to read and serve project files:
229```ts
230import { readFile, serveFile } from "https://esm.town/v/std/utils@85-main/index.ts";
260- Run migrations on startup or comment out for performance
261- Change table names when modifying schemas rather than altering
262- Export clear query functions with proper TypeScript typing
263264## Common Gotchas and Solutions
1/// <reference types="npm:@webgpu/types" />
23async function main() {
4const shader = await (await fetch("https://esm.town/v/saolsen/webgpu_1/shader.wgsl")).text();
549};
5051function render() {
52renderPassDescriptor.colorAttachments[0].view =
53context.getCurrentTexture().createView();
83}
8485function fail(msg: string) {
86alert(msg);
87}
eventsCalendarserver.ts4 matches
2Use with bookmarklet:
34javascript: (function () {
5var HOST = "https://extract-event-data.val.run";
6var TOKEN = "<REPLACE>";
209});
210211function update(stream: SSEStreamingApi, payload: any) {
212return stream.writeSSE({
213event: "update",
219}
220221function complete(
222stream: SSEStreamingApi,
223state: "success" | "error",
232}
233234function fail(
235stream: SSEStreamingApi,
236message?: string,
webgpu_1server.tsx1 match
1export default function (_req: Request): Response {
2return new Response(
3`
45- Ask clarifying questions when requirements are ambiguous
6- Provide complete, functional solutions rather than skeleton implementations
7- Test your logic against edge cases before presenting the final solution
8- Ensure all code follows Val Town's specific platform requirements
17- **Never bake in secrets into the code** - always use environment variables
18- Include comments explaining complex logic (avoid commenting obvious operations)
19- Follow modern ES6+ conventions and functional programming practices if possible
2021## Types of triggers
2829```ts
30export default async function (req: Request) {
31return new Response("Hello World");
32}
4243```ts
44export default async function () {
45// Scheduled task code
46}
5657```ts
58export default async function (email: Email) {
59// Process email
60}
66## Val Town Standard Libraries
6768Val Town provides several hosted services and utility functions.
6970### Blob Storage
120```
121122## Val Town Utility Functions
123124Val Town provides several utility functions to help with common project tasks.
125126### Importing Utilities
200โ โโโ database/
201โ โ โโโ migrations.ts # Schema definitions
202โ โ โโโ queries.ts # DB query functions
203โ โ โโโ README.md
204โ โโโ routes/ # Route modules
219โโโ shared/
220โโโ README.md
221โโโ utils.ts # Shared types and functions
222```
223226- Hono is the recommended API framework
227- Main entry point should be `backend/index.ts`
228- **Static asset serving:** Use the utility functions to read and serve project files:
229```ts
230import { readFile, serveFile } from "https://esm.town/v/std/utils@85-main/index.ts";
260- Run migrations on startup or comment out for performance
261- Change table names when modifying schemas rather than altering
262- Export clear query functions with proper TypeScript typing
263264## Common Gotchas and Solutions
4};
56// Helper functions to create Result instances
7export function ok<Data>(data: Data): Result<Data, never> {
8return ({
9ok: true,
80const CACHE_DURATION = 60 * 60 * 1000; // 1 hour
8182async function fetchBlogPosts(): Promise<Post[]> {
83const cacheKey = "blog-posts";
84const cached = cache.get(cacheKey);
120}
121122async function resolveHandleToDID(handle: string): Promise<string> {
123const cacheKey = `did-${handle}`;
124const cached = cache.get(cacheKey);
168}
169170async function resolvePDS(handle: string): Promise<string> {
171const cacheKey = `pds-${handle}`;
172const cached = cache.get(cacheKey);
225}
226227async function fetchBookRecords(): Promise<{ books: Book[]; pdsUrl: string }> {
228const cacheKey = "book-records";
229const cached = cache.get(cacheKey);
299}
300301async function fetchCheckins(): Promise<CheckinWithAddress[]> {
302const cacheKey = "checkins";
303const cached = cache.get(cacheKey);
390}
391392export default async function handler() {
393console.log("=== Handler starting ===");
394const [posts, bookData, checkins] = await Promise.all([