worldclockserver.js1 match
1import { readFile } from "https://esm.town/v/std/utils@85-main/index.ts";
23export default async function(req) {
4const url = new URL(req.url);
5const path = url.pathname;
spreadchatapp.js6 matches
29* Initialize the x-spreadsheet instance
30*/
31function initializeSpreadsheet() {
32// Create spreadsheet with options
33const spreadsheet = new window.xspreadsheet('#spreadsheet', {
103* Set up all event listeners for the application
104*/
105function setupEventListeners(spreadsheet) {
106// Cell selection event
107spreadsheet.on('cell-selected', (cell, ri, ci) => {
171* Update the selected cell information display
172*/
173function updateSelectedCellInfo(spreadsheet, cell, ri, ci) {
174// Get cell reference (e.g., A1, B2)
175const colLabel = String.fromCharCode(65 + ci); // A, B, C, ...
212* This allows parent pages to listen for cell selection
213*/
214function emitCellSelectionEvent(cellRef, cellData) {
215const event = new CustomEvent('val-spreadsheet-cell-selected', {
216detail: {
231* This allows external code to interact with the spreadsheet
232*/
233function exposeSpreadsheetAPI(spreadsheet) {
234// Create API object
235window.valSpreadsheet = {
274* Parse cell reference (e.g., A1, B2) into column and row indices
275*/
276function parseCellReference(cellRef) {
277const match = cellRef.match(/^([A-Z]+)(\d+)$/);
278if (!match) return [null, null];
spreadchatsheets-import.ts4 matches
1// This file would contain the actual Google Sheets import functionality
2// For a complete implementation, we would need to:
3// 1. Use the Google Sheets API to fetch sheet data
8// using the Google Sheets API and SheetJS for data conversion
910export async function importFromGoogleSheets(sheetUrl: string) {
11try {
12// Extract the sheet ID from the URL
51}
5253// Helper function to extract sheet ID from Google Sheets URL
54function extractSheetId(url: string): string | null {
55try {
56// Google Sheets URLs are typically in the format:
spreadchatREADME.md4 matches
3A fully featured spreadsheet application built for Val Town with the following capabilities:
45- Full spreadsheet functionality (cells, formulas, editing)
6- Events that emit selected cells and their data to the wider page
7- Import functionality from Google Sheets
89## Project Structure
12โโโ backend/
13โ โโโ index.ts # Main HTTP entry point
14โ โโโ sheets-import.ts # Google Sheets import functionality
15โโโ frontend/
16โ โโโ index.html # Main HTML template
31This project uses:
32- [x-spreadsheet](https://github.com/myliang/x-spreadsheet) for the spreadsheet UI
33- [SheetJS](https://sheetjs.com/) for Google Sheets import functionality
34- Custom event handling to expose spreadsheet state to the parent page
worldclockserver-backup.js1 match
1import { readFile } from "https://esm.town/v/std/utils@85-main/index.ts";
23export default async function(req) {
4const url = new URL(req.url);
5const path = url.pathname;
worldclockREADME.md1 match
2425- `index.html` - Main HTML file with the clock display and timezone selector
26- `script.js` - JavaScript to handle the clock functionality and timezone selection
27- `style.css` - Additional CSS styles beyond Tailwind
28- `server.js` - Server-side code to handle HTTP requests and serve the static files
worldclockMAP-FEATURE-README.md3 matches
8- Visual representation of the current timezone location
9- Responsive design that works on both mobile and desktop
10- Feature flag to enable/disable the map functionality
1112## Implementation Details
2021- `index-with-map.html` - HTML file with map component added
22- `script-with-map.js` - JavaScript file with map functionality
23- `server-with-map.js` - Updated server file with feature flag support
2444- Add day/night visualization overlay
45- Allow clicking on the map to select the nearest timezone
46- Add search functionality for locations
worldclockscript-with-map.js5 matches
10
11// Initialize the map
12function initMap() {
13// Create the map with a default view
14map = L.map('map').setView([0, 0], 2);
21
22// Prevent scrolling the page when scrolling the map
23map.getContainer().addEventListener('wheel', function(e) {
24e.stopPropagation();
25});
84
85// Update the map based on selected timezone
86function updateMap(timezone) {
87if (!map) return;
88
205206// Populate timezone dropdown with optgroups
207function populateTimezoneSelect() {
208// Clear existing options
209timezoneSelect.innerHTML = '';
245246// Update the clock display
247function updateClock() {
248const selectedTimezone = timezoneSelect.value;
249const now = new Date();
UnescapeJsonindex.js2 matches
13* Handles common escape sequences without requiring JSON validity
14*/
15function unescapeString(str) {
16return str
17.replace(/\\n/g, '\n') // newline
29}
30
31function updateOutput() {
32// Get input and unescape it
33const input = inputArea.value;
UnescapeJsonutils.ts1 match
1/**
2* Shared utility functions and types for the Escape Sequence Visualizer
3*/
4