This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@mixin centerer { | |
position: absolute; | |
top: 50%; | |
left: 50%; | |
transform: translate(-50%, -50%); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h4>autoplay, with muted</h4> | |
<video autoplay muted loop> | |
<source src="chrome-clip.mp4" type="video/mp4"> | |
<p>Your browser does not support the video element.</p> | |
</video> | |
<h4>autoplay, without muted</h4> | |
<video autoplay loop> | |
<source src="chrome-clip.mp4" type="video/mp4"> | |
<p>Your browser does not support the video element.</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
navigator.sayswho= (function(){ | |
var ua= navigator.userAgent, tem, | |
M= ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || []; | |
if(/trident/i.test(M[1])){ | |
tem= /\brv[ :]+(\d+)/g.exec(ua) || []; | |
return 'IE '+(tem[1] || ''); | |
} | |
if(M[1]=== 'Chrome'){ | |
tem= ua.match(/\b(OPR|Edge)\/(\d+)/); | |
if(tem!= null) return tem.slice(1).join(' ').replace('OPR', 'Opera'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getViewport() { | |
var viewPortWidth; | |
var viewPortHeight; | |
// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight | |
if (typeof window.innerWidth != 'undefined') { | |
viewPortWidth = window.innerWidth, | |
viewPortHeight = window.innerHeight | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var QueryString = function () { | |
// This function is anonymous, is executed immediately and | |
// the return value is assigned to QueryString! | |
var query_string = {}; | |
var query = window.location.search.substring(1); | |
var vars = query.split("&"); | |
for (var i=0;i<vars.length;i++) { | |
var pair = vars[i].split("="); | |
// If first entry with this name | |
if (typeof query_string[pair[0]] === "undefined") { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script type="text/javascript" src="/jsv/jsvideo70.js"></script> | |
</head> | |
<body> | |
<video id="player" preload="auto" width="640" height="360" src="https://d1oa9tftava270.cloudfront.net/videos/iphone/samples/iphone-1b283-ec67e-18a42-6e8c3.jsv" data-audio="https://d1oa9tftava270.cloudfront.net/videos/iphone/samples/iphone-1b283-ec67e-18a42-6e8c3.mp3"></video> | |
<a id="play" href="javascript:void(0);">Play</a> | |
<script type="text/javascript"> | |
window.onload = function(){ | |
var player = document.getElementById("player"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var hideKeyboard = function() { | |
document.activeElement.blur(); | |
var inputs = document.querySelectorAll('input'); | |
for(var i=0; i < inputs.length; i++) { | |
inputs[i].blur(); | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function iOSversion() { | |
if (/iP(hone|od|ad)/.test(navigator.platform)) { | |
// supports iOS 2.0 and later: <http://bit.ly/TJjs1V> | |
var v = (navigator.appVersion).match(/OS (\d+)_(\d+)_?(\d+)?/); | |
return [parseInt(v[1], 10), parseInt(v[2], 10), parseInt(v[3] || 0, 10)]; | |
} | |
} | |
ver = iOSversion(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var isChrome = /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor); | |
var isSafari = /Safari/.test(navigator.userAgent) && /Apple Computer/.test(navigator.vendor); | |
if (isChrome) alert("You are using Chrome!"); | |
if (isSafari) alert("You are using Safari!"); |
OlderNewer