castopod/app/Resources/js/modules/ThemePicker.ts
Yassine Doghri 37c54d2477 feat: build hashed static files to renew browser cache
- replace rollup config with vitejs
- use vite dev server during development to take advantage of
hot module replacement (HMR)
- add vite service using Vite library to load css and js assets
- update package.json scripts and remove unnecessary
dependencies
- update scripts/bundle-prepare.sh

closes #107
2021-07-12 17:47:56 +00:00

31 lines
1.0 KiB
TypeScript

const ThemePicker = (): void => {
const buttons: NodeListOf<HTMLButtonElement> | null = document.querySelectorAll(
"button[data-type='theme-picker']"
);
const iframe: HTMLIFrameElement | null = document.querySelector(
`iframe[id="embeddable_player"]`
);
const iframeTextArea: HTMLTextAreaElement | null = document.querySelector(
`textarea[id="iframe"]`
);
const urlTextArea: HTMLTextAreaElement | null = document.querySelector(
`textarea[id="url"]`
);
if (buttons && iframe && iframeTextArea && urlTextArea) {
for (let i = 0; i < buttons.length; i++) {
const button: HTMLButtonElement = buttons[i];
const url: string | undefined = button.dataset.url;
if (url) {
button.addEventListener("click", () => {
iframeTextArea.value = `<iframe width="100%" height="280" frameborder="0" scrolling="no" style="width: 100%; height: 280px; overflow: hidden;" src="${url}"></iframe>`;
urlTextArea.value = url;
iframe.src = url;
});
}
}
}
};
export default ThemePicker;