Skip to content

Instantly share code, notes, and snippets.

// This endpoint lives on my cloudflare worker
// It is called each time the user launches the DE.
// Note that we already have the user's access token from initial app install.
// The access token is stored in KV SITEID_SITE_INFO.
app.post('/resolve', async (c) => {
// Get the siteId and idToken from the request body
const body = await c.req.json();
const { siteId, idToken } = body;
// Check KV for access token and credits
@learyjk
learyjk / staging-vs-prod.js
Created March 16, 2024 00:41
Staging vs. Production Code
const currentDomain = window.location.hostname;
let scriptElement = document.createElement('script');
scriptElement.type = 'text/javascript';
if (currentDomain === 'staging.webflow.io') {
// staging
scriptElement.src = 'http://127.0.0.1/index.js';
} else if (currentDomain === 'www.example.com') {
// production
@learyjk
learyjk / matterJsBodyWithImage.js
Created January 4, 2024 16:25
How to add images to a Body in matter.js
let circle = Bodies.circle(i, 10, 30, {
friction: 0.3,
frictionAir: 0.00001,
restitution: 0.8,
render: {
sprite: {
texture: "your-image-link-here.jpg",
},
},
plugin: {
@learyjk
learyjk / webflowTimezones.js
Last active October 3, 2023 16:06
Converts times on the Webflow Conf website to users' timezone.
function isValidTimeFormat(timeStr) {
const twelveHourFormat = /^(\d{1,2}:\d{2} [AP]M)$/i;
const twentyFourHourFormat = /^([01]?[0-9]|2[0-3]):[0-5][0-9]$/;
if (twelveHourFormat.test(timeStr)) {
return { valid: true, is24HourFormat: false };
} else if (twentyFourHourFormat.test(timeStr)) {
return { valid: true, is24HourFormat: true };
} else {
return { valid: false, is24HourFormat: false };
function initialize() {
var markers = [];
var input = /** @type {HTMLInputElement} */
(document.getElementById('Address'));
var options = {
componentRestrictions: {
country: 'gb'
}
}
var autocomplete = new google.maps.places.Autocomplete(input,options);
// Define your attribute names here.
const ATTR_NAME = "wb-data";
const ATTR_ITEM_VALUE = "tab-item";
const ATTR_CONTENT_VALUE = "tab-content";
gsap.registerPlugin(ScrollTrigger);
function init() {
const tabItems = document.querySelectorAll(
`[${ATTR_NAME}="${ATTR_ITEM_VALUE}"]`
@learyjk
learyjk / ball-drop-with-setion-matter-js.markdown
Created March 20, 2022 04:37
Ball Drop with setion matter.js