This file contains hidden or 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
document.documentElement //<HTML> tag | |
document.body //<Body> tag | |
document.documentElement.scrollHeight //Total page height | |
document.documentElement.clientHeight || window.innerHeight //Viewport height | |
window.scrollY || document.documentElement.scrollTop //How much the document is scrolled |
This file contains hidden or 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
/* | |
Thanks to: https://gist.github.com/davidtheclark/5515733#gistcomment-2113205 | |
*/ | |
function isAnyPartOfElementInViewport(el) { | |
const rect = el.getBoundingClientRect(); | |
// DOMRect { x: 8, y: 8, width: 100, height: 100, top: 8, right: 108, bottom: 108, left: 8 } | |
const windowHeight = (window.innerHeight || document.documentElement.clientHeight); | |
const windowWidth = (window.innerWidth || document.documentElement.clientWidth); |
This file contains hidden or 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
{ | |
"name": "gulp-boilerplate", | |
"version": "1.0.0", | |
"description": "", | |
"main": "gulpfile.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "Taimur", | |
"license": "ISC", |
This file contains hidden or 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 gulp = require("gulp"); | |
var clean = require('gulp-clean'); | |
var concat = require("gulp-concat"); | |
var sourcemaps = require('gulp-sourcemaps'); | |
var minifyHtml = require("gulp-minify-html"); | |
var critical = require('critical').stream; | |
var cleanCSS = require('gulp-clean-css'); |
This file contains hidden or 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
$.each(myJSON, function(key, value) { | |
//read key and value here | |
}); |
This file contains hidden or 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 getUrlVars() { | |
var vars = [], | |
hash; | |
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); | |
for (var i = 0; i < hashes.length; i++) { | |
hash = hashes[i].split('='); | |
vars.push(hash[0]); | |
vars[hash[0]] = hash[1]; | |
} | |
return vars; |
This file contains hidden or 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 capitalizeFirstLetter(string) { | |
return string.charAt(0).toUpperCase() + string.slice(1); | |
} | |
// use it like capitalizeFirstLetter('hello') | |
// returns Hello |
This file contains hidden or 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 storeItem(itemName, data) { | |
localStorage.setItem(itemName, btoa(JSON.stringify(data))); | |
} | |
function retrieveItem(itemName) { | |
var x = localStorage.getItem(itemName); | |
if (!x) { console.log("Element not found in local storage"); return false; } | |
localStorage.removeItem('x'); | |
x = atob(x); | |
return $.parseJSON(x); |
NewerOlder