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
//self-executing anonymous function | |
(function (window, document, undefined) { | |
var d=document; w=window; //aliases to save bytes | |
//do something | |
}(window, document)); | |
//remove comments, put in a bookmark preceded by "javascript:" |
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($){ | |
$.fn.myPluginMethod = function() { | |
// keep it chainable, jQuery objects | |
// include multiple DOM elements | |
return this.each(function(){ | |
// do something | |
}); | |
}; | |
}(jQuery)); |
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 integerBetween = function(x, y) { | |
if ( typeof x !== "number" || typeof y !== "number") { | |
console.log('integerBetween cannot accept NaN values'); | |
return false; | |
} | |
else { | |
var lowerBound = Math.floor(x); | |
var upperBound = Math.floor(y); | |
return Math.floor(Math.random() * (upperBound - lowerBound + 1) + lowerBound); | |
}; |
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
<!-- redirect based on screen width --> | |
<script type="text/javascript"> | |
console.log('Screen width: '+screen.width); | |
if (screen.width <= 699 && !sessionStorage.getItem("redirecting")) { | |
window.location.replace("./m/index.html"); //path to your mobile site | |
} | |
</script> | |
<!-- redirect bypass on the mobile site | |
such that users don't get caught in a redirect loop | |
uses jQuery cuz mobile site is jQuery Mobile |
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
<h3>Last.fm Scrobbles</h3> | |
<!-- div below will be filled in with formatted contents of API response --> | |
<div id="recent-tracks" style="display:none;"><a href="http://last.fm/">Last.fm</a> data hasn't loaded yet.</div> | |
<!-- leave as display:none for the fade in effect --> |
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
// | |
//taken verbatim from jQuery Fundamentals | |
//which is at http://jqfundamentals.com/ (see chap. 8) | |
//and has an unmaintained github repo at https://github.com/rmurphey/jqfundamentals | |
// | |
// create closure | |
// | |
(function($) { | |
// | |
// plugin definition |
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
/* puts a gray overlay over the entire page | |
just turn on display when dialog pops up */ | |
.modal-overlay { | |
display: none; | |
position: absolute; | |
top: 0; right: 0; bottom: 0; left: 0; | |
background-color: rgba(0,0,0,0.35); | |
} |
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
if (typeof String.prototype.trim !== 'function') { | |
String.prototype.trim = function() { | |
return this.replace( | |
/^\s*(\S*(?:\s+\S+)*)\s*$/, | |
"$1"); | |
}; | |
} |
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
<style> | |
#dagger { | |
/* important to have a serif font for the dagger | |
sans-serif will look like a cross | |
see: http://en.wikipedia.org/wiki/File:Daggers.svg */ | |
font-family: "Old English Text MT", "Times New Roman", Times; | |
-moz-transform: rotate(180deg); | |
-webkit-transform: rotate(180deg); | |
-o-transform: rotate(180deg); | |
-ms-transform: rotate(180deg); |
OlderNewer