burnCaloriesCalculatormain.tsx3 matches
13};
1415function CalorieCalculator() {
16const [weight, setWeight] = useState('');
17const [exercise, setExercise] = useState('walking');
87}
8889function client() {
90createRoot(document.getElementById("root")).render(<CalorieCalculator />);
91}
92if (typeof document !== "undefined") { client(); }
9394export default async function server(request: Request): Promise<Response> {
95return new Response(`
96<html>
huntTheWumpusWebVersionmain.tsx6 matches
8const MAX_ARROWS = 3;
910function generateMap() {
11const map = Array(ROOMS).fill(null);
12
40}
4142function getAdjacentRooms(room) {
43const row = Math.floor(room / GRID_SIZE);
44const col = room % GRID_SIZE;
54}
5556function checkNearbyHazards(map, playerRoom) {
57const adjacentRooms = getAdjacentRooms(playerRoom);
58const hazards = adjacentRooms.map(room => map[room]).filter(Boolean);
64}
6566function WumpusGame() {
67const [game, setGame] = useState(() => generateMap());
68const [message, setMessage] = useState("Welcome to Hunt the Wumpus! Kill the Wumpus to reveal the treasure!");
517}
518519function client() {
520createRoot(document.getElementById("root")).render(<WumpusGame />);
521}
523if (typeof document !== "undefined") { client(); }
524525export default async function server(request: Request): Promise<Response> {
526return new Response(`
527<html>
BadmintonMatchMakerAppmain.tsx3 matches
115}
116117function App() {
118const [players, setPlayers] = useState<Player[]>([]);
119const [name, setName] = useState('');
242}
243244function client() {
245createRoot(document.getElementById("root")).render(<App />);
246}
247if (typeof document !== "undefined") { client(); }
248249export default async function server(request: Request): Promise<Response> {
250return new Response(`
251<html>
4* @returns SVG string for avatar
5*/
6export function generateAvatar(email: string): string {
7const hash = hashEmail(email);
8const hue = parseInt(hash.slice(0, 3), 16) % 360;
31* @returns Hexadecimal hash string
32*/
33export function hashEmail(email: string): string {
34const encoder = new TextEncoder();
35const data = encoder.encode(email.toLowerCase().trim());
44* @returns Base32 encoded secret
45*/
46export function generateTOTPSecret(): string {
47const array = new Uint8Array(20);
48crypto.getRandomValues(array);
61* @returns Boolean indicating code validity
62*/
63export function validateTOTPCode(secret: string, userCode: string): boolean {
64// Simplified TOTP validation
65const currentTime = Math.floor(Date.now() / 30000);
sqLiteDatabasemain.tsx5 matches
5* Includes users, login attempts, and verification tokens
6*/
7export async function initializeDatabase() {
8// Use the val's unique identifier as a prefix for tables
9const KEY = "sqLiteDatabase";
6768/**
69* Utility function to reset or clean up database
70* Use with caution in production
71*/
72export async function resetDatabase() {
73const KEY = "sqLiteDatabase";
74const SCHEMA_VERSION = 3;
9495/**
96* Utility function to perform database migrations
97* Call this when schema changes are needed
98*/
99export async function migrateDatabase() {
100const KEY = "sqLiteDatabase";
101const SCHEMA_VERSION = 3;
big5PersonalityTestmain.tsx20 matches
1export default async function server(request: Request): Promise<Response> {
2const { blob } = await import("https://esm.town/v/std/blob");
3const QUIZ_KEY = "big5PersonalityTest" + "_quiz_data";
168169<script>
170document.addEventListener('DOMContentLoaded', function() {
171// Debugging function to log errors
172function logError(message, error) {
173console.error(message, error);
174alert(message + ': ' + (error ? error.toString() : 'Unknown error'));
226var barChart = document.getElementById('bar-chart');
227228function displayQuestion() {
229if (currentQuestionIndex >= questions.length) {
230showResultsBtn.style.display = 'block';
239240radioOptions.innerHTML = '';
241[1, 2, 3, 4, 5].forEach(function(rating) {
242var label = document.createElement('label');
243var radio = document.createElement('input');
246radio.value = rating;
247
248var existingResponse = responses.find(function(r) { return r.index === currentQuestionIndex; });
249if (existingResponse && existingResponse.response === rating) {
250radio.checked = true;
251}
252253radio.addEventListener('change', function() { handleResponse(rating); });
254255label.appendChild(radio);
261}
262263function handleResponse(rating) {
264var currentQuestion = questions[currentQuestionIndex];
265
266responses = responses.filter(function(r) { return r.index !== currentQuestionIndex; });
267
268responses.push({
272});
273274responses.sort(function(a, b) { return a.index - b.index; });
275276currentQuestionIndex++;
283}
284285function completeQuiz() {
286fetch('/submit', {
287method: 'POST',
293var scoringDetails = [];
294
295responses.forEach(function(item) {
296var adjustedScore = item.response;
297if (item.code < 0) {
311});
312313var totalScore = scoreTotals.reduce(function(a, b) { return a + b; }, 0);
314315var percentageScores = scoreTotals.map(function(score) {
316return totalScore > 0 ? Math.round((score / totalScore) * 100) : 0;
317});
319barChart.innerHTML = '';
320321percentageScores.forEach(function(score, index) {
322var barRow = document.createElement('div');
323barRow.className = 'bar-row';
357}
358359startButton.addEventListener('click', function() {
360// Use absolute URL for fetching questions
361fetch(window.location.origin + '/questions')
362.then(function(response) {
363console.log('Fetch response status:', response.status);
364if (!response.ok) {
367return response.json();
368})
369.then(function(loadedQuestions) {
370console.log('Loaded questions:', loadedQuestions);
371questions = loadedQuestions;
374displayQuestion();
375})
376.catch(function(error) {
377logError('Error fetching questions', error);
378});
createMovieSitemain.tsx4 matches
4const app = new Hono();
56async function fetchMovies(page = 1, limit = 20) {
7const cacheKey = `movies_page_${page}_limit_${limit}`;
839const movieCache = new Map();
4041// Utility function to generate movie poster URL
42function getMoviePosterUrl(movie) {
43return movie.poster_path
44? `https://image.tmdb.org/t/p/w300${movie.poster_path}`
172<script src="https://cdnjs.cloudflare.com/ajax/libs/flowbite/2.2.1/flowbite.min.js"></script>
173<script>
174// Ensure modal close functionality
175document.addEventListener('DOMContentLoaded', () => {
176const modal = document.getElementById('movieModal');
plantIdentifierAppmain.tsx7 matches
5354// Plant Detail Card Component
55function PlantDetailCard({ plant, confidence }) {
56return (
57<div className="bg-white shadow-lg rounded-2xl p-6 animate-slide-up">
112}
113114// Plant Identification Function
115async function identifyPlant(file) {
116return new Promise(async (resolve, reject) => {
117try {
212213// Main Plant Identifier Application Component
214function PlantIdentifierApp() {
215const [selectedImage, setSelectedImage] = useState(null);
216const [plantInfo, setPlantInfo] = useState(null);
473}
474475// Client-side rendering function
476function client() {
477createRoot(document.getElementById("root")).render(<PlantIdentifierApp />);
478}
484485// Server-side response handler
486export default async function server(request: Request): Promise<Response> {
487return new Response(`
488<html>
3import { createRoot } from "https://esm.sh/react-dom/client";
45/** Utility functions */
6function generateValidRoll(): number {
7return Math.floor(Math.random() * 6) + 1;
8}
910function getDiceEmoji(roll: number): string {
11const diceEmojis = [
12'⚀', // 1
20}
2122function formatTime(timestamp: number): string {
23const date = new Date(timestamp);
24return date.toLocaleTimeString(undefined, {
36}
3738function App() {
39const [roll, setRoll] = useState(generateValidRoll());
40const [isRolling, setIsRolling] = useState(false);
234}
235236function client() {
237createRoot(document.getElementById("root")).render(<App />);
238}
239if (typeof document !== "undefined") { client(); }
240241export default async function server(request: Request): Promise<Response> {
242const roll = generateValidRoll();
243
23// Fetches a random joke.
4async function fetchRandomJoke() {
5const response = await fetch(
6"https://official-joke-api.appspot.com/random_joke",