2023-06-06 23:52:13 +00:00
|
|
|
import type { GlobalCal } from "./src/embed";
|
2023-03-28 18:17:40 +00:00
|
|
|
|
|
|
|
const Cal = window.Cal as GlobalCal;
|
|
|
|
const callback = function (e) {
|
|
|
|
const detail = e.detail;
|
2023-04-13 18:26:31 +00:00
|
|
|
console.log("Event: ", e.type, detail);
|
2023-03-28 18:17:40 +00:00
|
|
|
};
|
|
|
|
|
2023-07-18 16:46:35 +00:00
|
|
|
document.addEventListener("click", (e) => {
|
|
|
|
const target = e.target as HTMLElement;
|
|
|
|
if ("href" in target && typeof target.href === "string") {
|
|
|
|
const toUrl = new URL(target.href);
|
|
|
|
const pageUrl = new URL(document.URL);
|
|
|
|
for (const [name, value] of pageUrl.searchParams.entries()) {
|
|
|
|
if (toUrl.searchParams.get(name) === null) {
|
|
|
|
toUrl.searchParams.append(decodeURIComponent(name), value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
location.href = `?${toUrl.searchParams.toString()}#${toUrl.hash}`;
|
|
|
|
e.preventDefault();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2023-03-28 18:17:40 +00:00
|
|
|
const searchParams = new URL(document.URL).searchParams;
|
2023-06-06 23:52:13 +00:00
|
|
|
const only = searchParams.get("only");
|
2023-07-18 16:46:35 +00:00
|
|
|
const colorScheme = searchParams.get("color-scheme");
|
2023-10-10 03:10:04 +00:00
|
|
|
const prerender = searchParams.get("prerender");
|
2023-07-18 16:46:35 +00:00
|
|
|
if (colorScheme) {
|
|
|
|
document.documentElement.style.colorScheme = colorScheme;
|
|
|
|
}
|
2023-07-18 01:02:42 +00:00
|
|
|
const themeInParam = searchParams.get("theme");
|
|
|
|
const validThemes = ["light", "dark", "auto"] as const;
|
|
|
|
const theme = validThemes.includes((themeInParam as (typeof validThemes)[number]) || "")
|
|
|
|
? (themeInParam as (typeof validThemes)[number])
|
|
|
|
: null;
|
|
|
|
if (themeInParam && !theme) {
|
|
|
|
throw new Error(`Invalid theme: ${themeInParam}`);
|
|
|
|
}
|
|
|
|
|
|
|
|
const calLink = searchParams.get("cal-link");
|
2023-03-28 18:17:40 +00:00
|
|
|
|
|
|
|
if (only === "all" || only === "ns:default") {
|
|
|
|
Cal("init", {
|
|
|
|
debug: true,
|
|
|
|
calOrigin: "http://localhost:3000",
|
|
|
|
});
|
|
|
|
|
|
|
|
Cal("inline", {
|
|
|
|
elementOrSelector: "#cal-booking-place-default .place",
|
|
|
|
calLink: "pro?case=1",
|
|
|
|
config: {
|
|
|
|
iframeAttrs: {
|
|
|
|
id: "cal-booking-place-default-iframe",
|
|
|
|
},
|
|
|
|
name: "John",
|
|
|
|
email: "johndoe@gmail.com",
|
|
|
|
notes: "Test Meeting",
|
|
|
|
guests: ["janedoe@example.com", "test@example.com"],
|
|
|
|
theme: "dark",
|
|
|
|
},
|
|
|
|
});
|
|
|
|
Cal("on", {
|
|
|
|
action: "*",
|
|
|
|
callback,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
if (only === "all" || only === "ns:second") {
|
|
|
|
// Create a namespace "second". It can be accessed as Cal.ns.second with the exact same API as Cal
|
|
|
|
Cal("init", "second", {
|
|
|
|
debug: true,
|
|
|
|
origin: "http://localhost:3000",
|
|
|
|
});
|
|
|
|
|
2023-05-23 08:16:56 +00:00
|
|
|
Cal.ns.second(
|
2023-03-28 18:17:40 +00:00
|
|
|
"inline",
|
|
|
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
|
|
//@ts-ignore
|
|
|
|
{
|
|
|
|
elementOrSelector: "#cal-booking-place-second .place",
|
|
|
|
calLink: "pro?case=2",
|
|
|
|
config: {
|
|
|
|
iframeAttrs: {
|
|
|
|
id: "cal-booking-place-second-iframe",
|
|
|
|
},
|
2023-05-22 11:17:56 +00:00
|
|
|
theme: "auto",
|
2023-03-28 18:17:40 +00:00
|
|
|
},
|
2023-05-23 08:16:56 +00:00
|
|
|
}
|
|
|
|
);
|
2023-03-28 18:17:40 +00:00
|
|
|
Cal.ns.second("on", {
|
|
|
|
action: "*",
|
|
|
|
callback,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
if (only === "all" || only === "ns:third") {
|
|
|
|
// Create a namespace "third". It can be accessed as Cal.ns.second with the exact same API as Cal
|
|
|
|
Cal("init", "third", {
|
|
|
|
debug: true,
|
|
|
|
origin: "http://localhost:3000",
|
|
|
|
});
|
|
|
|
|
|
|
|
Cal.ns.third(
|
|
|
|
[
|
|
|
|
"inline",
|
|
|
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
|
|
//@ts-ignore
|
|
|
|
{
|
|
|
|
elementOrSelector: "#cal-booking-place-third .place",
|
|
|
|
calLink: "pro/30min",
|
|
|
|
config: {
|
|
|
|
iframeAttrs: {
|
|
|
|
id: "cal-booking-place-third-iframe",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"ui",
|
|
|
|
{
|
|
|
|
styles: {
|
|
|
|
body: {
|
|
|
|
background: "transparent",
|
|
|
|
},
|
|
|
|
branding: {
|
|
|
|
brandColor: "#81e61c",
|
|
|
|
lightColor: "#494545",
|
|
|
|
lighterColor: "#4c4848",
|
|
|
|
lightestColor: "#7c7777",
|
|
|
|
highlightColor: "#9b0e0e",
|
|
|
|
medianColor: "black",
|
|
|
|
},
|
|
|
|
enabledDateButton: {
|
|
|
|
backgroundColor: "red",
|
|
|
|
},
|
|
|
|
disabledDateButton: {
|
|
|
|
backgroundColor: "green",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
]
|
|
|
|
);
|
|
|
|
Cal.ns.third("on", {
|
|
|
|
action: "*",
|
|
|
|
callback,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
if (only === "all" || only === "ns:fourth") {
|
|
|
|
Cal("init", "fourth", {
|
|
|
|
debug: true,
|
|
|
|
origin: "http://localhost:3000",
|
|
|
|
});
|
|
|
|
Cal.ns.fourth(
|
|
|
|
[
|
|
|
|
"inline",
|
|
|
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
|
|
//@ts-ignore
|
|
|
|
{
|
|
|
|
elementOrSelector: "#cal-booking-place-fourth .place",
|
|
|
|
calLink: "team/seeded-team",
|
|
|
|
config: {
|
|
|
|
iframeAttrs: {
|
|
|
|
id: "cal-booking-place-fourth-iframe",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"ui",
|
|
|
|
{
|
|
|
|
styles: {
|
|
|
|
body: {
|
|
|
|
background: "transparent",
|
|
|
|
},
|
|
|
|
branding: {
|
|
|
|
brandColor: "#81e61c",
|
|
|
|
lightColor: "#494545",
|
|
|
|
lighterColor: "#4c4848",
|
|
|
|
lightestColor: "#7c7777",
|
|
|
|
highlightColor: "#9b0e0e",
|
|
|
|
medianColor: "black",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
]
|
|
|
|
);
|
|
|
|
Cal.ns.fourth("on", {
|
|
|
|
action: "*",
|
|
|
|
callback,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
if (only === "all" || only === "ns:fifth") {
|
|
|
|
Cal("init", "fifth", {
|
|
|
|
debug: true,
|
|
|
|
origin: "http://localhost:3000",
|
|
|
|
});
|
|
|
|
Cal.ns.fifth([
|
|
|
|
"inline",
|
|
|
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
|
|
//@ts-ignore
|
|
|
|
{
|
|
|
|
elementOrSelector: "#cal-booking-place-fifth .place",
|
|
|
|
calLink: "team/seeded-team/collective-seeded-team-event",
|
|
|
|
config: {
|
|
|
|
iframeAttrs: {
|
|
|
|
id: "cal-booking-place-fifth-iframe",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
]);
|
|
|
|
Cal.ns.fifth("on", {
|
|
|
|
action: "*",
|
|
|
|
callback,
|
|
|
|
});
|
|
|
|
}
|
2023-10-10 03:10:04 +00:00
|
|
|
|
2023-03-28 18:17:40 +00:00
|
|
|
if (only === "all" || only === "prerender-test") {
|
2023-10-10 03:10:04 +00:00
|
|
|
Cal("init", "e2ePrerenderLightTheme", {
|
2023-03-28 18:17:40 +00:00
|
|
|
debug: true,
|
|
|
|
origin: "http://localhost:3000",
|
|
|
|
});
|
2023-10-10 03:10:04 +00:00
|
|
|
Cal.ns.e2ePrerenderLightTheme("prerender", {
|
|
|
|
calLink: "free/30min",
|
|
|
|
type: "modal",
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (only === "all" || only === "preload-test") {
|
|
|
|
Cal("init", "preloadTest", {
|
|
|
|
debug: true,
|
|
|
|
origin: "http://localhost:3000",
|
|
|
|
});
|
|
|
|
Cal.ns.preloadTest("preload", {
|
|
|
|
calLink: "free/30min",
|
2023-03-28 18:17:40 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (only === "all" || only === "inline-routing-form") {
|
|
|
|
Cal("init", "inline-routing-form", {
|
|
|
|
debug: true,
|
|
|
|
origin: "http://localhost:3000",
|
|
|
|
});
|
|
|
|
Cal.ns["inline-routing-form"]([
|
|
|
|
"inline",
|
|
|
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
|
|
//@ts-ignore
|
|
|
|
{
|
|
|
|
elementOrSelector: "#cal-booking-place-inline-routing-form .place",
|
|
|
|
calLink: "forms/948ae412-d995-4865-875a-48302588de03",
|
|
|
|
config: {
|
|
|
|
iframeAttrs: {
|
|
|
|
id: "cal-booking-place-inline-routing-form-iframe",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (only === "all" || only === "hideEventTypeDetails") {
|
|
|
|
const identifier = "hideEventTypeDetails";
|
|
|
|
Cal("init", identifier, {
|
|
|
|
debug: true,
|
|
|
|
origin: "http://localhost:3000",
|
|
|
|
});
|
|
|
|
|
|
|
|
Cal.ns.hideEventTypeDetails(
|
|
|
|
[
|
|
|
|
"inline",
|
|
|
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
|
|
//@ts-ignore
|
|
|
|
{
|
|
|
|
elementOrSelector: `#cal-booking-place-${identifier} .place`,
|
|
|
|
calLink: "free/30min",
|
|
|
|
config: {
|
|
|
|
iframeAttrs: {
|
|
|
|
id: `cal-booking-place-${identifier}-iframe`,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"ui",
|
|
|
|
{
|
|
|
|
hideEventTypeDetails: true,
|
|
|
|
},
|
|
|
|
]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-05-16 19:41:47 +00:00
|
|
|
if (only === "conflicting-theme") {
|
|
|
|
Cal("init", "conflictingTheme", {
|
|
|
|
debug: true,
|
|
|
|
origin: "http://localhost:3000",
|
|
|
|
});
|
|
|
|
|
|
|
|
Cal.ns.conflictingTheme("inline", {
|
|
|
|
elementOrSelector: "#cal-booking-place-conflicting-theme .dark",
|
|
|
|
calLink: "pro/30min",
|
|
|
|
config: {
|
|
|
|
theme: "dark",
|
|
|
|
},
|
|
|
|
});
|
|
|
|
Cal.ns.conflictingTheme("inline", {
|
|
|
|
elementOrSelector: "#cal-booking-place-conflicting-theme .light",
|
|
|
|
calLink: "pro/30min",
|
|
|
|
config: {
|
|
|
|
theme: "light",
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-03-28 18:17:40 +00:00
|
|
|
Cal("init", "popupDarkTheme", {
|
|
|
|
debug: true,
|
|
|
|
origin: "http://localhost:3000",
|
|
|
|
});
|
|
|
|
|
2023-10-10 03:10:04 +00:00
|
|
|
Cal("init", "e2ePopupLightTheme", {
|
|
|
|
debug: true,
|
|
|
|
origin: "http://localhost:3000",
|
|
|
|
});
|
|
|
|
|
2023-03-28 18:17:40 +00:00
|
|
|
Cal("init", "popupHideEventTypeDetails", {
|
|
|
|
debug: true,
|
|
|
|
origin: "http://localhost:3000",
|
|
|
|
});
|
|
|
|
|
|
|
|
Cal.ns.popupHideEventTypeDetails("ui", {
|
|
|
|
hideEventTypeDetails: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
Cal("init", "popupReschedule", {
|
|
|
|
debug: true,
|
|
|
|
origin: "http://localhost:3000",
|
|
|
|
});
|
|
|
|
|
|
|
|
Cal("init", "popupAutoTheme", {
|
|
|
|
debug: true,
|
|
|
|
origin: "http://localhost:3000",
|
|
|
|
});
|
2023-05-16 19:41:47 +00:00
|
|
|
|
2023-03-28 18:17:40 +00:00
|
|
|
Cal("init", "popupTeamLinkLightTheme", {
|
|
|
|
debug: true,
|
|
|
|
origin: "http://localhost:3000",
|
|
|
|
});
|
2023-05-16 19:41:47 +00:00
|
|
|
|
2023-03-28 18:17:40 +00:00
|
|
|
Cal("init", "popupTeamLinkDarkTheme", {
|
|
|
|
debug: true,
|
|
|
|
origin: "http://localhost:3000",
|
|
|
|
});
|
|
|
|
|
|
|
|
Cal("init", "popupTeamLinkDarkTheme", {
|
|
|
|
debug: true,
|
|
|
|
origin: "http://localhost:3000",
|
|
|
|
});
|
|
|
|
|
|
|
|
Cal("init", "popupTeamLinksList", {
|
|
|
|
debug: true,
|
|
|
|
origin: "http://localhost:3000",
|
|
|
|
});
|
|
|
|
|
|
|
|
Cal("init", "popupPaidEvent", {
|
|
|
|
debug: true,
|
|
|
|
origin: "http://localhost:3000",
|
|
|
|
});
|
|
|
|
|
|
|
|
Cal("init", "floatingButton", {
|
|
|
|
debug: true,
|
|
|
|
origin: "http://localhost:3000",
|
|
|
|
});
|
|
|
|
|
|
|
|
Cal("init", "routingFormAuto", {
|
|
|
|
debug: true,
|
|
|
|
origin: "http://localhost:3000",
|
|
|
|
});
|
|
|
|
|
|
|
|
Cal("init", "routingFormDark", {
|
|
|
|
debug: true,
|
|
|
|
origin: "http://localhost:3000",
|
|
|
|
});
|
|
|
|
|
|
|
|
if (only === "all" || only == "ns:floatingButton") {
|
2023-10-10 03:10:04 +00:00
|
|
|
if (prerender == "true") {
|
|
|
|
Cal.ns.floatingButton("prerender", {
|
|
|
|
calLink: calLink || "pro",
|
|
|
|
type: "floatingButton",
|
|
|
|
});
|
|
|
|
}
|
2023-03-28 18:17:40 +00:00
|
|
|
Cal.ns.floatingButton("floatingButton", {
|
2023-07-18 01:02:42 +00:00
|
|
|
calLink: calLink || "pro",
|
2023-05-19 20:10:19 +00:00
|
|
|
config: {
|
|
|
|
iframeAttrs: {
|
|
|
|
id: "floatingtest",
|
|
|
|
},
|
|
|
|
name: "John",
|
|
|
|
email: "johndoe@gmail.com",
|
|
|
|
notes: "Test Meeting",
|
|
|
|
guests: ["janedoe@example.com", "test@example.com"],
|
2023-07-18 01:02:42 +00:00
|
|
|
...(theme ? { theme } : {}),
|
2023-05-19 20:10:19 +00:00
|
|
|
},
|
2023-03-28 18:17:40 +00:00
|
|
|
});
|
|
|
|
}
|
2023-06-26 15:24:19 +00:00
|
|
|
|
2023-06-28 13:45:39 +00:00
|
|
|
if (only === "all" || only == "ns:monthView") {
|
|
|
|
// Create a namespace "second". It can be accessed as Cal.ns.second with the exact same API as Cal
|
|
|
|
Cal("init", "monthView", {
|
|
|
|
debug: true,
|
|
|
|
origin: "http://localhost:3000",
|
|
|
|
});
|
|
|
|
|
|
|
|
Cal.ns.monthView(
|
|
|
|
"inline",
|
|
|
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
|
|
//@ts-ignore
|
|
|
|
{
|
|
|
|
elementOrSelector: "#cal-booking-place-monthView .place",
|
|
|
|
calLink: "pro/paid",
|
|
|
|
config: {
|
|
|
|
iframeAttrs: {
|
|
|
|
id: "cal-booking-place-monthView-iframe",
|
|
|
|
},
|
|
|
|
layout: "month_view",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
);
|
|
|
|
Cal.ns.monthView("on", {
|
|
|
|
action: "*",
|
|
|
|
callback,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-06-26 15:24:19 +00:00
|
|
|
if (only === "all" || only == "ns:weekView") {
|
|
|
|
// Create a namespace "second". It can be accessed as Cal.ns.second with the exact same API as Cal
|
|
|
|
Cal("init", "weekView", {
|
|
|
|
debug: true,
|
|
|
|
origin: "http://localhost:3000",
|
|
|
|
});
|
|
|
|
|
|
|
|
Cal.ns.weekView(
|
|
|
|
"inline",
|
|
|
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
|
|
//@ts-ignore
|
|
|
|
{
|
|
|
|
elementOrSelector: "#cal-booking-place-weekView .place",
|
|
|
|
calLink: "pro/paid",
|
|
|
|
config: {
|
|
|
|
iframeAttrs: {
|
|
|
|
id: "cal-booking-place-weekView-iframe",
|
|
|
|
},
|
|
|
|
layout: "week_view",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
);
|
|
|
|
Cal.ns.weekView("on", {
|
|
|
|
action: "*",
|
|
|
|
callback,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (only === "all" || only == "ns:columnView") {
|
|
|
|
// Create a namespace "second". It can be accessed as Cal.ns.second with the exact same API as Cal
|
|
|
|
Cal("init", "columnView", {
|
|
|
|
debug: true,
|
|
|
|
origin: "http://localhost:3000",
|
|
|
|
});
|
|
|
|
|
|
|
|
Cal.ns.columnView(
|
|
|
|
"inline",
|
|
|
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
|
|
//@ts-ignore
|
|
|
|
{
|
|
|
|
elementOrSelector: "#cal-booking-place-columnView .place",
|
|
|
|
calLink: "pro/paid",
|
|
|
|
config: {
|
|
|
|
iframeAttrs: {
|
|
|
|
id: "cal-booking-place-columnView-iframe",
|
|
|
|
},
|
|
|
|
layout: "column_view",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
);
|
|
|
|
Cal.ns.columnView("on", {
|
|
|
|
action: "*",
|
|
|
|
callback,
|
|
|
|
});
|
|
|
|
}
|