forked from andyburke/autonomous.contact
		
	
		
			
				
	
	
		
			35 lines
		
	
	
	
		
			1,018 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			35 lines
		
	
	
	
		
			1,018 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| const VIMEO_ID_EXTRACTOR =
 | |
| 	/(?<video_domain>vimeo\.com)(?:\/(?<action>video|embed|watch|shorts|v))?.*(?:(?:\/|v=)(?<video_id>[A-Za-z0-9._%-]*))\S*/gi;
 | |
| 
 | |
| function embed_vimeo(link_info) {
 | |
| 	const is_vimeo_link = ["vimeo.com"].includes(link_info.domain?.toLowerCase());
 | |
| 
 | |
| 	if (!is_vimeo_link) {
 | |
| 		return;
 | |
| 	}
 | |
| 
 | |
| 	VIMEO_ID_EXTRACTOR.lastIndex = 0;
 | |
| 
 | |
| 	const {
 | |
| 		groups: { video_domain, action, video_id },
 | |
| 	} = VIMEO_ID_EXTRACTOR.exec(link_info.url) ?? { groups: {} };
 | |
| 
 | |
| 	if (!video_id) {
 | |
| 		return;
 | |
| 	}
 | |
| 
 | |
| 	return `
 | |
| 	<div class="embed-container iframe letterbox vimeo">
 | |
| 		<div class="embed-actions-container">
 | |
| 			<button class="icon plus" onclick="console.log(\"close\");"/>
 | |
| 			<button class="icon pause" onclick="console.log(\"stop\");"/>
 | |
| 		</div>
 | |
| 		<iframe
 | |
| 		src="https://player.vimeo.com/video/${video_id}"
 | |
| 		frameborder="0"
 | |
| 		allow="fullscreen; picture-in-picture; clipboard-write; encrypted-media; web-share"
 | |
| 		referrerpolicy="strict-origin-when-cross-origin"
 | |
| 		title="Star Trek: Legacy"
 | |
| 		loading="lazy"></iframe>
 | |
| 	</div>`;
 | |
| }
 |