Ms_Spanglermain.tsx11 matches
153const typingIndicator = document.querySelector('.typing-indicator');
154155function addMessage(content, type) {
156const messageElement = document.createElement('div');
157messageElement.classList.add('message', type);
161}
162163function loadChatHistories() {
164try {
165const savedChatsRaw = localStorage.getItem('chatHistories');
167
168chatHistorySelect.innerHTML = '';
169savedChats.forEach(function(chat, index) {
170const option = document.createElement('option');
171option.value = index;
178}
179180function saveChat() {
181try {
182const chatName = prompt('Enter a name for this chat history:') || ('Chat ' + Date.now());
183const messages = Array.from(chatMessages.children).map(function(msg) {
184return {
185content: msg.textContent,
200}
201202function loadSelectedChat() {
203try {
204const selectedIndex = chatHistorySelect.value;
211if (selectedChat) {
212chatMessages.innerHTML = '';
213selectedChat.messages.forEach(function(msg) {
214addMessage(msg.content, msg.type === 'user' ? 'user-message' : 'ai-message');
215});
221}
222223function deleteSelectedChat() {
224try {
225const selectedIndex = chatHistorySelect.value;
239}
240241async function sendMessage() {
242const message = messageInput.value.trim();
243if (!message) return;
270loadButton.addEventListener('click', loadSelectedChat);
271deleteButton.addEventListener('click', deleteSelectedChat);
272messageInput.addEventListener('keypress', function(e) {
273if (e.key === 'Enter') sendMessage();
274});
308} catch (error) {
309console.error("OpenAI error:", error);
310return c.json({ response: "Neural networks malfunctioning. Try again, human." });
311}
312});
gameplay_agentmain.tsx5 matches
83/** The name of the agent. */
84agentname: string;
85/** The agent function. */
86agent: Connect4Agent<T> | Connect4AsyncAgent<T>;
87}
99/** The name of the agent. */
100agentname: string;
101/** The agent function. */
102agent: PokerAgent<T> | PokerAsyncAgent<T>;
103}
121* a variety of different http server libraries.
122*
123* To see how to write the agent functions,
124* see the {@link Connect4Agent} and {@link PokerAgent}
125*
134* used with an http server that supports the fetch interface.
135*/
136export function agentHandler<
137T extends Json = Json,
138>(
139agents: AgentSpec<T>[],
140): (req: Request) => Promise<Response> {
141return async function(request: Request): Promise<Response> {
142if (request.method === "GET") {
143return Response.json({
whoIsHiringmain.tsx3 matches
7import About from "https://esm.town/v/vawogbemi/whoIsHiringAbout";
89function App() {
10const tabs = { "/": "Home", "/about": "About" };
11const [activeTab, setActiveTab] = useState("/");
335}
336337function ServerApp() {
338return (
339<html>
358}
359360export default async function(req: Request): Promise<Response> {
361const url = new URL(req.url);
362if (url.pathname === "/api/stories") {
3import { createRoot } from "https://esm.sh/react-dom/client";
45function App() {
6const [numPeople, setNumPeople] = useState(4);
7const [numRecipes, setNumRecipes] = useState(1);
229}
230231function client() {
232createRoot(document.getElementById("root")).render(<App />);
233}
234if (typeof document !== "undefined") { client(); }
235236function extractJSONFromMarkdown(markdown: string): string {
237const jsonMatch = markdown.match(/```json\n([\s\S]*?)\n```/);
238return jsonMatch ? jsonMatch[1] : "";
239}
240241export default async function server(request: Request): Promise<Response> {
242if (request.method === "POST" && new URL(request.url).pathname === "/recipes") {
243const { OpenAI } = await import("https://esm.town/v/std/openai");
338}
339340async function generateImage(recipeName: string): Promise<string> {
341const response = await fetch(`https://maxm-imggenurl.web.val.run/${encodeURIComponent(recipeName)}`);
342if (!response.ok) {
savvyTealCardinalmain.tsx7 matches
4import React, { useEffect, useRef, useState } from "https://esm.sh/react@18.2.0";
56function ConfirmationModal({ isOpen, onClose }) {
7if (!isOpen) return null;
818}
1920function App() {
21const [sport, setSport] = useState("");
22const [skillLevel, setSkillLevel] = useState("");
396}
397398function client() {
399createRoot(document.getElementById("root")).render(<App />);
400}
735`;
736737async function server(request: Request): Promise<Response> {
738if (request.method === "POST" && new URL(request.url).pathname === "/generate-training") {
739const YOUTUBE_API_KEY = Deno.env.get("YOUTUBE_API_KEY2");
826const { email } = await import("https://esm.town/v/std/email");
827828// Function to insert YouTube links into the training plan
829const insertYouTubeLinks = (plan, links) => {
830let modifiedPlan = plan;
891}
892893async function getYouTubeVideoId(query, sport, apiKey, useApiKey = true) {
894if (useApiKey) {
895try {
913}
914915function getFallbackYouTubeLink(query, sport) {
916const searchQuery = encodeURIComponent(`${sport} ${query}`);
917return `https://www.youtube.com/results?search_query=${searchQuery}`;
getWeathermain.tsx3 matches
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
23export async function getWeather(location: string): Promise<WeatherResponse> {
4return fetchJSON(`https://wttr.in/${location}?format=j1`);
5}
124}
125126export default async function server(request: Request): Promise<Response> {
127const url = new URL(request.url);
128const location = url.searchParams.get('location') || 'New York';
295var coll = document.getElementsByClassName("collapsible");
296for (var i = 0; i < coll.length; i++) {
297coll[i].addEventListener("click", function() {
298this.classList.toggle("active");
299var content = this.nextElementSibling;
getWeatherREADME.md1 match
1## Get Weather
23Simple function to get weather data from the free [wttr.in](https://wttr.in/:help) service.
45```ts
twitterAlertmain.tsx2 matches
8.join(" OR ") + " " + excludes;
910function relevant(t: Tweet) {
11if (keywords.some(k => t.full_text?.includes(k))) return true;
12return t.entities.urls?.some(u => keywords.some(k => u.expanded_url?.includes(k)));
17const isProd = true;
1819export async function twitterAlert({ lastRunAt }: Interval) {
20// search
21const since = isProd
getSiteMetadatamain.tsx1 match
4import { z } from "npm:zod";
56export async function getUrlMetadata(url: string) {
7try {
8const metadata = await urlMetadata(url);
3// Fetches a random joke.
4// Fetches a random joke.
5async function fetchRandomJoke() {
6const response = await fetch(
7"https://official-joke-api.appspot.com/random_joke",