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 scientificToDecimal(num) { | |
// if the number is in scientific notation remove it | |
if (/\d+\.?\d*e[\+\-]*\d+/i.test(num)) { | |
var zero = '0', | |
parts = String(num).toLowerCase().split('e'), // split into coeff and exponent | |
e = parts.pop(), // store the exponential part | |
l = Math.abs(e), // get the number of zeros | |
sign = e/l, | |
coeff_array = parts[0].split('.'); | |
if (sign === -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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title></title> | |
<style> | |
#drop-area { | |
width:500px; | |
height:180px; | |
border: 10px dashed #ccc; |
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
document.addEventListener('DOMContentLoaded', function() { | |
if (calledWithin(60)) { | |
return; | |
} | |
var elems = document.getElementsByClassName('fadein-firsttime'); | |
for (var i = 0; i < elems.length; i++) { | |
(function() { | |
var elem = elems.item(i); | |
elem.style.transition = ''; | |
elem.style.opacity = 0; |
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
document.addEventListener("DOMContentLoaded", function() { | |
var elems = document.getElementsByClassName("fadeout-as-scroll"); | |
for (var i = 0; i < elems.length; i++) { | |
(function() { | |
var elem = elems.item(i); | |
var wh = window.innerHeight; | |
var start = parseInt(elem.getAttribute("data-start")); | |
start = start || wh * 0.1; | |
var end = parseInt(elem.getAttribute("data-end")); | |
end = end || wh * 0.5; |
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
document.addEventListener("DOMContentLoaded", function() { | |
var elems = document.getElementsByClassName("fadein-after-load"); | |
for (var i = 0; i < elems.length; i++) { | |
(function() { | |
var elem = elems.item(i); | |
elem.style.transition = ""; | |
elem.style.opacity = 0; | |
window.addEventListener("load", function() { | |
var duration = elem.getAttribute("data-duration"); | |
duration = duration || "0.5s"; |
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
document.addEventListener("DOMContentLoaded", function() { | |
var elems = document.getElementsByClassName("hide-after-load"); | |
for (var i = 0; i < elems.length; i++) { | |
(function() { | |
var elem = elems.item(i); | |
window.addEventListener("load", function() { | |
elem.style.display = "none"; | |
}); | |
})(); | |
} |
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
document.addEventListener("DOMContentLoaded", function() { | |
var storage = window.sessionStorage; | |
try { | |
if (window.location.pathname.includes('#')) { | |
storage.removeItem('scroll-x'); | |
storage.removeItem('scroll-y'); | |
return; | |
} | |
var x = storage.getItem('scroll-x'); | |
var y = storage.getItem('scroll-y'); |
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
window.addEventListener("load", function() { | |
var perfData = window.performance.timing; | |
var renderTime = perfData.domComplete - perfData.domLoading; | |
console.log(renderTime); | |
}); |
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
window.addEventListener('load', function(event) { | |
var targetClassName = 'flex-wrap-anim'; | |
var defaultDuration = '0.3s'; | |
var dummyList = []; | |
function addDummy(item, duration) { | |
var top = item.offsetTop; | |
var left = item.offsetLeft; | |
setTimeout(function() { | |
item.style.position = 'absolute'; |
OlderNewer