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 getViewPercentage(element) { | |
const viewport = { | |
top: window.pageYOffset, | |
bottom: window.pageYOffset + window.innerHeight | |
}; | |
const elementBoundingRect = element.getBoundingClientRect(); | |
const elementPos = { | |
top: elementBoundingRect.y + window.pageYOffset, | |
bottom: elementBoundingRect.y + elementBoundingRect.height + window.pageYOffset |
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
/* Polyfill indexOf. */ | |
var indexOf; | |
if (typeof Array.prototype.indexOf === 'function') { | |
indexOf = function (haystack, needle) { | |
return haystack.indexOf(needle); | |
}; | |
} else { | |
indexOf = function (haystack, needle) { | |
var i = 0, length = haystack.length, idx = -1, found = false; |
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 strict"; | |
// By Mahmoud Eskandari @ MIT license | |
function validateCard(card) { | |
if (typeof card === 'undefined' | |
|| card === null | |
|| card.length !== 16) { | |
return false; | |
} | |
let cardTotal = 0; | |
for (let i = 0; i < 16; i += 1) { |