Detect user events on obscured elements.
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
content = content | |
// Replace hypen, if between number, with en-dash | |
.replace(/(\d+)-(\d+)/ig, '$1–$2') | |
// Replace hypen, if between spaces, with em-dash | |
.replace(/( +)-+( +)/ig, '$1—$2') | |
// Replace smart double quotes with straight double quotes | |
.replace(/“|”|„|‟|″|‶/ig, '"') | |
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
// Source: http://stackoverflow.com/a/13455920/2502532 | |
// ------------------------------------------------------------------- | |
// Add prototype for 'window.location.query([source])' which contain an object | |
// of querystring keys and their values | |
// ------------------------------------------------------------------- | |
if(!window.location.query) { | |
window.location.query = function(source){ | |
var map = {}; | |
source = source || this.search; |
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
/* Based on: http://stackoverflow.com/a/901144/2502532 */ | |
var getParam = function(key) { | |
key = key.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]'); | |
var val = window.location.search.match(new RegExp('[\\?&]' + key + '=([^&#]*)')); | |
return val === null ? '' : decodeURIComponent(val[1].replace(/\+/g, ' ')); | |
}; | |
console.log(getParam('foo')); |
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
<div class="button-list namespace"> | |
<h2>$('selector').tooltip()</h2> | |
<ul> | |
<li> | |
<span>Lorem Ipsum Dolar Sit</span> | |
<button type="button">+ | |
<span class="tooltip" role="tooltip">Hello World again and again and again and again.</span> | |
</button> | |
</li> | |
<li> |
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
/* Define new prototype methods on Date object. */ | |
// Returns Date as a String in YYYY-MM-DD format. | |
Date.prototype.toISODateString = function () { | |
return this.toISOString().substr(0,10); | |
}; | |
// Returns new Date object offset `n` days from current Date object. | |
Date.prototype.toDateFromDays = function (n) { | |
n = parseInt(n) || 0; | |
var newDate = new Date(this.getTime()); |
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
Math.isPrime = function (n) { | |
if (n === 2) { return true; } | |
if (n % 2 === 0) { return false; } | |
for(let i = 3, s = Math.sqrt(n); i <= s; i += 2) { | |
if (n % i === 0) { return false; } | |
} | |
return n !== 1; | |
}; | |
// Based on this StackOverflow answer: https://stackoverflow.com/a/40200710/2502532 |
OlderNewer