2
3/**
4 * You can supply these options as a second argument to the `proxy` function.
5 * These options are used to configure the frontend.
6 */
146
147export const proxy = (url: string, options?: FrontendOptions) => {
148 return async function(req: Request): Promise<Response> {
149 if (req.method === "OPTIONS") {
150 return new Response("ok", { headers: structuredClone(CORS_HEADERS) });
65}
66
67export default async function (req: Request): Promise<Response> {
68 const schema: Schema = {
69 components: {
379
380 for (i = 0; i < coll.length; i++) {
381 coll[i].addEventListener("click", function() {
382 this.classList.toggle("active");
383 var content = this.nextElementSibling;
3import { createRoot } from "https://esm.sh/react-dom/client";
4
5// Utility function to generate a unique 16-character ID
6function generateUniqueID() {
7 return Math.random().toString(36).substring(2, 10)
8 + Math.random().toString(36).substring(2, 10);
9}
10
11function Proposition({ prop, userChoice, onChoiceChange }) {
12 return (
13 <div className="border-t-2 md:border-2 border-black bg-white sm:rounded-md p-6 relative">
45}
46
47function App() {
48 const [stateProps, setStateProps] = useState([]);
49 const [userChoices, setUserChoices] = useState({});
61
62 // Load props data from API
63 async function loadProps() {
64 const statePropsData = await fetch("/api/state-props").then(res => res.json());
65 setStateProps(statePropsData);
71 useEffect(() => {
72 // Load user choices from server
73 async function loadUserChoices() {
74 const choices = await fetch(`/api/user-choices?id=${userID}`).then(res => res.json());
75 setUserChoices(choices);
155}
156
157function client() {
158 createRoot(document.getElementById("root")).render(<App />);
159}
161if (typeof document !== "undefined") { client(); }
162
163export default async function server(request: Request): Promise<Response> {
164 const { blob } = await import("https://esm.town/v/std/blob");
165
3import { createRoot } from "https://esm.sh/react-dom/client";
4
5function App() {
6 const [question, setQuestion] = useState("");
7 const [answer, setAnswer] = useState("");
72}
73
74function client() {
75 createRoot(document.getElementById("root")).render(<App />);
76}
78if (typeof document !== "undefined") { client(); }
79
80export default async function server(request: Request): Promise<Response> {
81 return new Response(`
82 <html>
13must contain your board server API key.
14
15To use, create an HTTP val, then import the `proxy` function from this script and call it like this:
16
17```ts
14let colorIndex: number
15
16export function setup() {
17 console.log("setup")
18 // variables
77}
78
79function hexagon(x, y, r, c) {
80 let hx = (i) => x + sin((i * 2 * PI) / 6) * (i < 0 ? 0 : r)
81 let hy = (i) => y + cos((i * 2 * PI) / 6) * (i < 0 ? 0 : r)
201}
202
203function drawBorder(border, strokeW = 0) {
204 strokeWeight(0)
205 rect(0, 0, border, height)
216}
217
218export function draw() {}
219
220export function keyPressed() {
221 if (key == "i") {
222 saveCanvas("p5js-" + new Date().getTime(), "png")
226 }
227}
228// export function touchEnded() {
229// saveCanvas("p5js-" + new Date().getTime(), "png");
230// }
5export default sketch(import.meta.url, title)
6
7export function setup() {
8 // console.log("setup", window.innerWidth, window.innerHeight);
9 // createCanvas(window.innerWidth, window.innerHeight);
11}
12
13export function draw() {
14 background(0)
15 if (mouseIsPressed) {
21}
22
23export function keyPressed() {
24 if (key == "i") {
25 saveCanvas("p5js-" + new Date().getTime(), "png")
29 }
30}
31// export function touchEnded() {
32// saveCanvas("p5js-" + new Date().getTime(), "png");
33// }
15}
16
17async function redditSearch({
18 query,
19}: RedditSearchOptions): Promise<ThreadResult[]> {
32}
33
34function constructSearchUrl(query: string): string {
35 const encodedQuery = encodeURIComponent(query);
36 return `https://www.reddit.com/search.json?q=${encodedQuery}&sort=new&t=week&limit=25`;
37}
38
39async function processPostData(posts: any[]): Promise<ThreadResult[]> {
40 const processedData: ThreadResult[] = [];
41
57}
58
59function App() {
60 const [query, setQuery] = useState("");
61 const [results, setResults] = useState<ThreadResult[]>([]);
99}
100
101function client() {
102 createRoot(document.getElementById("root")).render(<App />);
103}
107}
108
109export default async function server(request: Request): Promise<Response> {
110 return new Response(`
111 <html>
4const ADMIN_PASSWORD = Deno.env.get("ADMIN_PASSWORD") || "defaultpassword"; // Set this in your Val Town environment variables
5
6async function initializeDatabase() {
7 await sqlite.execute(`
8 CREATE TABLE IF NOT EXISTS ${KEY}_emails (
14}
15
16async function addEmail(email: string) {
17 await sqlite.execute(`INSERT OR IGNORE INTO ${KEY}_emails (email) VALUES (?)`, [email]);
18}
19
20async function getEmails() {
21 const result = await sqlite.execute(`SELECT * FROM ${KEY}_emails ORDER BY timestamp DESC`);
22 return result.rows;
23}
24
25export default async function server(request: Request): Promise<Response> {
26 await initializeDatabase();
27 const url = new URL(request.url);
290 <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.9.1/gsap.min.js"></script>
291 <script>
292 document.getElementById('email-form').addEventListener('submit', async function(e) {
293 e.preventDefault();
294 const email = document.getElementById('email').value;
3import request from "npm:request";
4
5export default async function(interval: Interval) {
6 // Cookies and Tokens -> use `mitmweb` to navigate to NYTimes.com to grab cookie. Repeat for my.remarkable.com
7
63 },
64 })
65 .then(function(response) {
66 var rmMetadata = { "parent": rmFolderGuid, "file_name": puzzleFriendlyName };
67