Skip to content

Instantly share code, notes, and snippets.

<!doctype html>
<html>
<head>
<title>Flix</title>
<script src="mobile/js/redirect.js"></script>
<script>redirectMobileTo('mobile/index.html');</script>
</head>
<body>
<h1>Flix Homepage</h1>
<p><a href="mobile/index.html">Mobile</a></p>
@mediamichael
mediamichael / side-swipe.css
Created February 14, 2014 03:31
Mobile List with Swipe, Horizontal Scroll
.items li {
padding: 0px;
display: inline-block;
white-space: nowrap;
overflow: scroll;
-webkit-overflow-scrolling:touch;
}
@mediamichael
mediamichael / appendCSS
Created October 20, 2014 20:32
Append CSS with JS
var css = '@import url(http://fonts.googleapis.com/css?family=Roboto:400,100,100italic,300,300italic,400italic,900,700,500,500italic,700italic,900italic);',
header = document.getElementsByTagName("head")[0],
style = document.createElement('style');
style.type = 'text/css';
if (style.styleSheet){
style.styleSheet.cssText = css;
} else {
style.appendChild(document.createTextNode(css));
}
// http://www.smashingmagazine.com/2013/08/09/absolute-horizontal-vertical-centering-css
// center
.Absolute-Center {
margin: auto;
position: absolute;
top: 0; left: 0; bottom: 0; right: 0;
}
// within container
/* ---------------------------------------------------------------------------
Boilerplate CSS Media Queries
Encoding: UTF-8
Author: PaulUnd (http://www.paulund.co.uk/boilerplate-css-media-queries)
--------------------------------------------------------------------------- */
/* =Smartphones (portrait and landscape)
--------------------------------------------------------------------------- */
@media only screen
@mediamichael
mediamichael / ie_browser_detect
Created September 17, 2013 19:04
IE browser detect, including ie version, and ie document mode.
var ua = navigator.userAgent;
var isIE = ua.indexOf("MSIE") != -1;
var ieVersion;
var mode = document.documentMode ||
((/back/i).test(document.compatMode || "") ? 5 : ieVersion) ||
((/MSIE\s*(\d+\.?\d*)/i).test(navigator.userAgent || "") ? parseFloat(RegExp.$1, 10) : null);
function getIEVersion(dataString) {
var index = dataString.indexOf("MSIE");
if (index == -1) return;
return parseFloat(dataString.substring(index+5));
@mediamichael
mediamichael / console.log
Created September 17, 2013 18:53
IE console.log fallback support
var alertFallback = true;
if ( typeof console === "undefined" || typeof console.log === "undefined" ) {
console = {};
if (alertFallback) {
console.log = function(msg) {
alert(msg);
};
} else {
console.log = function() {};
}
@mediamichael
mediamichael / script_loader
Created September 17, 2013 19:16
Script and CSS style loader to manage the load order and detect when complete.
var numLoaded=0;
var minimumToLoad=1;
function loadScript( file, type, title ) {
//console.log( "javascript: " + "loadScript: " + file );
if ( type == 'js' ){
var script = document.createElement( 'script' );
script.type = 'text/javascript';
script.src = file;
if (script.readyState){
@mediamichael
mediamichael / isYouTube
Created September 17, 2013 22:21
Confirm if string is a YouTube URL, strip the youtube ID, and convert the url to a specific format and security.
var youTubeID;
var videoURL = "http://youtube.com/v/youtubeid"
if ( isYoutubeFile( videoURL ) == true ) {
//do something
}
function isYoutubeFile(vidURL) {
//console.log( "javascript: isYoutubeFile: vidURL: " +vidURL );
var videoURL;
@mediamichael
mediamichael / dynamic_object_name
Created September 17, 2013 22:27
Create an object from a dynamic variable name and assign a global class.
var rnd = Math.floor(Math.random()*10000000000);
var myVar = "myString" + "_" + rnd;
window[ myVar + "_optionalID"] = new classname();