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
{ | |
"Condition statement": { | |
"prefix": "cond", | |
"body": [ | |
"${_} { ${0}; break }" | |
], | |
"description": "Switch condition statement" | |
}, | |
"Condition single quoted string statement": { |
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 (!navigator.geolocation) { | |
navigator.geolocation = (function (window, document) { | |
function getCurrentPosition(callback) { | |
var geourl = 'http://www.google.com/jsapi?' + Math.random(), | |
iframe = document.createElement('iframe'), | |
doc, win; | |
iframe.style.display = 'none'; | |
window.document.body.appendChild(iframe); |
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
setInterval((function () { | |
console.log(new Date()); // run some arbitrary code | |
return arguments.callee; // here be the magic | |
})(), 1000); | |
// ^---- and that runs the function, and the return val is assign to the interval |
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
//EnhanceJS isIE test idea | |
//detect IE and version number through injected conditional comments (no UA detect, no need for cond. compilation / jscript check) | |
//version arg is for IE version (optional) | |
//comparison arg supports 'lte', 'gte', etc (optional) | |
function isIE(version, comparison) { | |
var cc = 'IE', | |
b = document.createElement('B'), |
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
// dbjdbj@gmail.com | |
// Based on work by http://github.com/dieseltravis | |
(function () { | |
var trimLeft = /^\s+/, trimRight = /\s+$/; | |
// Verify that \s matches non-breaking spaces (IE fails on this test) | |
if ( !/\s/.test( "\xA0" ) ) { | |
trimLeft = /^[\s\xA0]+/; | |
trimRight = /[\s\xA0]+$/; | |
} | |
// Use native String.prototype.trim function wherever possible |
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
/* | |
* jQuery fasterTrim Plugin | |
* version: 1.0.5 | |
* @requires jQuery v1.0.x or later | |
* | |
* dual licensed under the MIT and GPL licenses: | |
* http://www.opensource.org/licenses/mit-license.php | |
* http://www.opensource.org/licenses/gpl-2.0.php | |
* | |
* @version $Id: jquery.fastertrim.js 5 2010-03-12 12:00:00Z $ |
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
// bookmarklet to introspect the source of current page | |
javascript:(function(d,h){h=d.documentElement.innerHTML;d.open();d.write('<pre>'+('<!DOCTYPE html><html>'+h+'</html>').replace(/[<>]/g,function(m){return{'<':'<','>':'>'}[m]})+'</pre>')})(document); |