Skip to content

Instantly share code, notes, and snippets.

View neodigm's full-sized avatar
💯
Product Designer ⚡ Interactive Storyteller

Scott C. Krause neodigm

💯
Product Designer ⚡ Interactive Storyteller
View GitHub Profile
@neodigm
neodigm / snippet_left_nav_audit.js
Created November 16, 2017 19:17
Get product counts from categories (Left Navigation Audit) - recursive
(function() {
$("#main-content .sub-cat > a").each(function(){
$Ak = $(this);
if( $Ak.attr("href") !== "#"){
var sURI = $Ak.attr("href");
var sName = $Ak.text();
try {
var sID = $.ajax( { dataType: "html", type: "GET", url: sURI, async: false } );
var nPloc = sID.responseText.indexOf( "sizeTotalNumRecs" );
if( nPloc >= 1){
@neodigm
neodigm / temp_access_to_ghpages.js
Last active February 13, 2018 15:27
A quick and simple way to limit the amount of time a gh-pages prototype can be viewed.
(function( doc, dNow ){
var bOk = false;
var urlParams = new URLSearchParams( window.location.search );
if( urlParams.has( "token" ) ){
var sToken = urlParams.get( "token" );
var nDiff = ( dNow.getTime() - Number( sToken ) ) / 1000;
if( nDiff >= 3000 || isNaN( nDiff ) ){
bOk = false;
}else{
bOk = true;
@neodigm
neodigm / jquery_easy_migration.js
Created April 10, 2018 00:03
Easy jQuery migration to vanilla JavaScript
// jQuery
$(".review").addClass("hide");
// JavaScript
[].slice.call( document.querySelectorAll(".review") ).filter( function( _e ){
_e.classList.add("hide");
});
@neodigm
neodigm / simple_image_lazy_load.js
Last active September 27, 2018 19:58
JavaScript Lazy Load
"use strict";
var fLazy = (function(doc){
return { "init" : function( _bMobl ){
var _aE = [].slice.call( doc.querySelectorAll( "[data-lz-src]" ) );
_aE.filter( function( _e ){
if( _bMobl ){ // isMobile
if( _e.dataset.lzM ){ // data-lz-m
_e.src = _e.dataset.lzSrc;
}
}else{
@neodigm
neodigm / force_footer.css
Created June 6, 2018 19:58
Force the footer to float to the bottom post framework hack
@neodigm
neodigm / microsoft_ie11_flexbox.css
Last active October 7, 2019 20:42
Microsoft IE11 Flexbox Monkey Patch
@media screen and (-ms-high-contrast: active), screen and (-ms-high-contrast: none) { /*ms*/
.flex__item:nth-child(2) { flex-basis: 88% }
}
@supports (display: grid) {
.l-productthumb>section {
display: grid;
justify-content: center;
grid-template-columns: repeat(auto-fill, 242px);
}
}
@neodigm
neodigm / change_brand.js
Last active December 8, 2019 03:01
Toggle brand
// JavaScript
[].slice.call( document.querySelectorAll(".js-mybutton") ).filter( function( _e ){
_e.addEventListener("click", function( e ){
document.body.dataset.brand = ( document.body.dataset.brand == "LS" ) ? "LTD" : "FF";
}, true);
});
@neodigm
neodigm / extract_long_tail_keywords_google_ai.js
Last active July 12, 2020 07:47
Persist Long Tail Keywords from the Google Drop-down
// Persist Long Tail Key Words from Google SERP
var fLong = (function(){
var _aPKW = localStorage.getItem( "gogl_ai_keywords" );
if( _aPKW ){
_aPKW = JSON.parse( _aPKW );
}else{
_aPKW = [];
}
return {
doit : function(){
@neodigm
neodigm / page_fade.js
Created November 19, 2018 20:49
Fade a page so that it is difficult for shoulder surfers to see. On the DL.
// Run as a Chrome Snippet
document.body.style = "opacity: 0.2;filter:grayscale(100%);";
@neodigm
neodigm / blinked_class.js
Last active December 7, 2018 21:09
Vanilla JavaScript Blink Class
// Add and Remove a class repeatedly for a set duration for a set number of times (blinking or animating).
// This is good for blinking an element for a few seconds to attract attention to it.
var fBlinkClass = function( _sQuery, _sClass, _nItra, _nDura ){
var eChevr = document.querySelector( _sQuery ), _nCur = 0, _si;
eChevr.classList.add( _sClass );
_si = window.setInterval(function(){
if( ++_nCur <= _nItra ){
if( eChevr.classList.contains( _sClass ) ){
eChevr.classList.remove( _sClass );
}else{