Skip to content

Instantly share code, notes, and snippets.

@jjmu15
jjmu15 / in_viewport.js
Created January 27, 2014 10:19
check if element is in viewport - vanilla JS. Use by adding a “scroll” event listener to the window and then calling isInViewport().
// Determine if an element is in the visible viewport
function isInViewport(element) {
var rect = element.getBoundingClientRect();
var html = document.documentElement;
return (
rect.top >= 0 &&
rect.left >= 0 &&
rect.bottom <= (window.innerHeight || html.clientHeight) &&
rect.right <= (window.innerWidth || html.clientWidth)
);
@croisillon
croisillon / javascript.translit.js
Last active April 27, 2024 10:28
JavaScript translater russian to translit
function rus_to_latin ( str ) {
var ru = {
'а': 'a', 'б': 'b', 'в': 'v', 'г': 'g', 'д': 'd',
'е': 'e', 'ё': 'e', 'ж': 'j', 'з': 'z', 'и': 'i',
'к': 'k', 'л': 'l', 'м': 'm', 'н': 'n', 'о': 'o',
'п': 'p', 'р': 'r', 'с': 's', 'т': 't', 'у': 'u',
'ф': 'f', 'х': 'h', 'ц': 'c', 'ч': 'ch', 'ш': 'sh',
'щ': 'shch', 'ы': 'y', 'э': 'e', 'ю': 'u', 'я': 'ya'
}, n_str = [];
@cesarkohl
cesarkohl / youtube-pause.js
Last active January 17, 2018 19:06 — forked from cferdinandi/stop-video.js
Youtube Pause Video
var youtube_video = $('iframe');
var url = youtube_video.attr('src'); // 1. First get the iframe URL
youtube_video.attr('src', ''); // 2. Then assign the src to null, this then stops the video been playing
youtube_video.attr('src', url); // If you need to reassign the URL back to your iframe, so when you hide and load it again you still have the link
@c-kick
c-kick / hnl.mobileConsole.js
Last active January 14, 2024 18:24
NOTE: V2 Released! Seehttps://github.com/c-kick/mobileConsole hnl.mobileConsole.js - extends JavaScript's console to display a visual console inside the webpage. Very usefull for debugging JS on mobile devices with no real console. Info and demo: http://www.hnldesign.nl/work/code/mobileconsole-javascript-console-for-mobile-devices/
/*!
*
* NEW VERSION AT https://github.com/c-kick/mobileConsole
*
* hnl.mobileConsole - javascript mobile console - v1.3.8 - 04/01/2021
* Adds html console to webpage. Especially useful for debugging JS on mobile devices.
* Supports 'log', 'trace', 'info', 'warn', 'error', 'group', 'groupEnd', 'table', 'assert', 'clear'
* Inspired by code by Jakub Fiala (https://gist.github.com/jakubfiala/8fe3461ab6508f46003d)
* Licensed under the MIT license
*
@nekman
nekman / polyfill.js
Last active December 3, 2021 19:35
polyfill.io IE11
/* Polyfill service v3.16.0
* For detailed credits and licence information see https://github.com/financial-times/polyfill-service.
*
* UA detected: ie/11.0.0
* Features requested: default
*
* - Array.from, License: CC0 (required by "default")
* - Array.of, License: MIT (required by "default")
* - Array.prototype.fill, License: CC0 (required by "default")
* - Event, License: CC0 (required by "default", "CustomEvent", "Promise")