1async function fetchContributionData() {
2 try {
3 const response = await fetch('https://ejfox-allvals.web.val.run');
13}
14
15function processContributionData(vals) {
16 try {
17 const today = new Date();
39}
40
41function getColorIntensity(count) {
42 if (count === 0) return '#ebedf0';
43 if (count < 5) return '#9be9a8';
47}
48
49function drawContributionChart(ctx, contributionData, width, height) {
50 try {
51 const cellSize = 10;
78}
79
80async function server(request: Request): Promise<Response> {
81 try {
82 console.log('Fetching contribution data...');
116 });
117 } catch (error) {
118 console.error('Error in server function:', error);
119 return new Response(`Error generating contribution chart: ${error.message}`, { status: 500 });
120 }
7import { createRoot } from "https://esm.sh/react-dom/client";
8
9function App() {
10 const [contributionData, setContributionData] = useState({});
11 const [loading, setLoading] = useState(true);
96}
97
98function client() {
99 createRoot(document.getElementById("root")).render(<App />);
100}
102if (typeof document !== "undefined") { client(); }
103
104async function server(request: Request): Promise<Response> {
105 return new Response(`
106 <html>
85<script src="https://cdn.jsdelivr.net/gh/philfung/add-to-homescreen@1.9/dist/add-to-homescreen.min.js"></script>
86<script>
87document.addEventListener('DOMContentLoaded', function () {
88 window.AddToHomeScreenInstance = new window.AddToHomeScreen({
89 appName: 'ValPush',
10const SUGGESTIONS = ["Quantum Computing", "Renaissance Art", "Climate Change", "Artificial Intelligence", "Space Exploration"];
11
12function App() {
13 const [topic, setTopic] = useState("");
14 const [content, setContent] = useState("");
134}
135
136function client() {
137 createRoot(document.getElementById("root")).render(<App />);
138}
142}
143
144async function server(request: Request): Promise<Response> {
145 if (request.method === "POST" && new URL(request.url).pathname === "/generate") {
146 const { topic, prompt, direction } = await request.json();
44}
45
46function parseCsv(csv: string): TaxBracket[] {
47 const lines = csv.trim().split("\n");
48 const headers = lines.shift()?.split(",");
59}
60
61function calculateTax(
62 income: number,
63 filingStatus: string,
91};
92
93function generateHtml(taxBrackets: TaxBracket[], selectedFilingStatus: string): string {
94 let tableRows = "";
95 for (let income = 0; income <= 1000000; income += 1000) {
147}
148
149export default async function main(req: Request): Promise<Response> {
150 const taxBrackets = parseCsv(csvData);
151 const url = new URL(req.url);
85<script src="https://cdn.jsdelivr.net/gh/philfung/add-to-homescreen@1.9/dist/add-to-homescreen.min.js"></script>
86<script>
87document.addEventListener('DOMContentLoaded', function () {
88 window.AddToHomeScreenInstance = new window.AddToHomeScreen({
89 appName: 'ValPush',
9 * @param val Define which val should open. Defaults to the root reference
10 */
11export function modifyHtmlString(
12 bodyText: string,
13 { val, style, variant }: { val?: ValRef; style?: string; variant?: 'default' | 'green' } = {},
40 * @param val Define which val should open
41 */
42export function modifyFetchHandler(
43 handler: (req: Request) => Response | Promise<Response>,
44 { val, style, variant }: { val?: ValRef; style?: string; variant?: 'default' | 'green' } = {},
49### Linking to the val
50
51These functions infer the val using the call stack or the request URL. If the inference isn't working, or if you want to ensure it links to a specific val, pass the `val` argument:
52
53- `modifyFetchHandler(handler, {val: { handle: "andre", name: "foo" }})`
49### Linking to the val
50
51These functions infer the val using the call stack or the request URL. If the inference isn't working, or if you want to ensure it links to a specific val, pass the `val` argument:
52
53- `modifyFetchHandler(handler, {val: { handle: "andre", name: "foo" }})`
9 * @param val Define which val should open. Defaults to the root reference
10 */
11export function modifyHtmlString(
12 bodyText: string,
13 { val, style }: { val?: ValRef; style?: string } = {},
40 * @param val Define which val should open
41 */
42export function modifyFetchHandler(
43 handler: (req: Request) => Response | Promise<Response>,
44 { val, style }: { val?: ValRef; style?: string } = {},