Skip to content

Instantly share code, notes, and snippets.

View stevedya's full-sized avatar
🤠

Steve Stein stevedya

🤠
View GitHub Profile
@stevedya
stevedya / video-embed.js
Created February 22, 2019 21:32
Vue filter for youtube and vimeo embeds
Vue.filter('videoUrl', function (url) {
//youtube
if (url.includes('youtube') || url.includes('youtu.be')) {
//Get id
url = url.split(/(vi\/|v=|\/v\/|youtu\.be\/|\/embed\/)/);
let id = (url[2] !== undefined) ? url[2].split(/[^0-9a-z_\-]/i)[0] : url[0];
return 'https://www.youtube.com/embed/' + id
} else if (url.includes('vimeo')) {
var url = url.match(/(?:www\.|player\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/(?:[^\/]*)\/videos\/|album\/(?:\d+)\/video\/|video\/|)(\d+)(?:[a-zA-Z0-9_\-]+)?/i);
return 'https://player.vimeo.com/video/' + url[1]
@stevedya
stevedya / CountWithCommas.js
Last active June 11, 2018 19:56
jQuery - Number Counter with Commas
//Call the function on scroll
$(window).scroll(numberCounter);
//Check if in viewport function
function inViewport(el, val) {
var docViewTop = $(window).scrollTop();
var docViewBottom = docViewTop + $(window).height();
var elTop = $(el).offset().top;
var elBottom = elTop + $(el).height();