Skip to content

Instantly share code, notes, and snippets.

View shutUp.js
function shutUp(name) {
var i=1;
setInterval(function(){
console.log("%cHow about you stfu, " + name, "color: red; font-family: sans-serif; font-size: 4.5em; font-weight: bolder; text-shadow: #000 1px 1px;" + (i++));
}, 100);
}
@myles91
myles91 / minibasket.js
Created May 7, 2016
basic vanilla JS minibasket, some ES6
View minibasket.js
var _btn = document.getElementsByClassName("buy"),
_basketItems = document.getElementById("basketItems"),
_basketArr = [];
if(_basketItems !== null) {
_basketItems.addEventListener("click", getBtn);
}
for (var i=0; i<_btn.length; i++) {
_btn[i].addEventListener("click", btnClicked);
@myles91
myles91 / appCheckBasket.js
Created Sep 29, 2015
check the previously generated basket url for out of stock products when building the site basket
View appCheckBasket.js
/*
* app -> site basket item validation
* alert user if sku's missing, presumed out of stock
/
/*
* example of multi with missing sku: ?log=22&ex=co_wizr-shopcart&mode=addmul&param1=bulk&qtylist=2&itemlist=azz1368510520&qtylist=1&itemlist=azz2199912835&itemlist=azz111111&itemlist=azz111112
* example of single sku ?log=22&ex=co_wizr-shopcart&mode=addmul&param1=bulk&qtylist=2&itemlist=azz1368510520&qtylist=1&itemlist=azz2199912835
* example of multi sku ?log=22&ex=co_wizr-shopcart&mode=addmul&param1=bulk&qtylist=1&itemlist=azz1368510520&
*/
@myles91
myles91 / hideStuff.js
Created Aug 11, 2015
hide elm based on contained text from arr
View hideStuff.js
var _hideStr = ["Shirts", "Jeans", "Shoes"];
$.map(_hideStr, function( val, i ) {
$("#mm_ul .js-mm-sub li a:contains(" + val + ")" ).css( "display", "none" );
});
@myles91
myles91 / sizePrefs.js
Last active Aug 29, 2015
Allow users to specify size preferences up-front, localstorage retains sizes for both male & female prefs.
View sizePrefs.js
/*
* size prefs up-front filter
*/
/*
* test current category to establish gender, prevent test running on excluded categories
*/
var testString = '|' + $( '#js-cattree' ).text() + '|',
maleTerms = /\|mens clothing\|/i,
femaleTerms = /\|clothing\|/i,
@myles91
myles91 / mixmatch.js
Last active Aug 29, 2015
Allow users to cycle through categories and products in a mix & match carousel to create an outfit
View mixmatch.js
/*
* mix and match js
*/
$( document ).ready(function() {
/*
* these need to be accessible outside of the function
*/
@myles91
myles91 / quickBuy.js
Last active Aug 29, 2015
Allow users to buy from the category via lightbox instead of going through to product detail page
View quickBuy.js
/*
* quickbuy js - enable users to fire lightbox from category and add to basket without entering product detail page
*/
jQuery(document).ready(function() {
function checkWidth() {
var windowSize = $(window).width();
if (windowSize >= 960) {
@myles91
myles91 / bottom_promo_animate.js
Last active Aug 29, 2015
bottom strip promotion, checks for css3 animation availability with fallback
View bottom_promo_animate.js
/*
* bottom strip promotion
*/
jQuery(document).ready(function() {
( function( $, window, undefined ){
var didScroll = false,
uped = false,
@myles91
myles91 / new_cust_check.js
Last active Aug 29, 2015
check whether customer is new (has one or less orders) or existing (has greater than one order)
View new_cust_check.js
/*
* establish whether customer is new (~1 order) or existing (>1 order)
*/
function isThisNewCust() {
// check session
var SMjar = new CookieJar( {expires: '', path: '/', domain: 'url.uat.url.com'} ),
SMjarTwo = new CookieJar( {expires: 60 * 60 * 24 * 7, path: '/', domain: 'url.uat.url.com'} ),
precust = SMjarTwo.get( 'usertype' ),
Smset = SMjar.get( 'newCustCheck' ),
@myles91
myles91 / sticky_banner.js
Last active Aug 29, 2015
sticky top menu/banner/strip
View sticky_banner.js
/*
* sticky header js
*/
/*
* check if account/checkout area of website
*/
if(window.location.href.indexOf("bin") > -1) {
} else {
You can’t perform that action at this time.