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 prop(obj) { | |
return function(prop) { | |
return obj[prop]; | |
} | |
} |
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 makeNull(a) { | |
a = null; | |
console.log('makeNull?', a); | |
} | |
var obj = { a: 1 }; | |
makeNull(obj); | |
console.log('null?', obj); | |
var str = 'mike'; | |
makeNull(str); |
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
/* | |
var url = '//media.ao.com/cdnbundle/client/4.0.90.0/bundled/BTS/css/MasterStructure.css'; | |
var ajax = new XMLHttpRequest(); | |
ajax.onreadystatechange = function() { | |
if(this.readyState === 4 && this.status === 200) { | |
console.log(this.responseText); | |
} | |
}; | |
ajax.open('GET', url, true); | |
ajax.send(); |
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
/* | |
Check for presence of computing promo blocks (hidden by default) | |
Check the cookie and search through SKUs to see if any anti-virus or MS office are in basket | |
If no MS office display add to basket block and initiliase add to basket | |
or if MS office show added to basket block | |
If no antivirus display add to basket block and initiliase add to basket |
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
<style> | |
.buy { | |
margin-bottom: 20px; | |
} | |
</style> | |
<div class='container'> | |
<div class='mini-basket'> | |
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
// combine properties to base prototype | |
function Combine(target, fns = []) { | |
let protoCopy = Object.assign(target.prototype); | |
let extendedProto = (Array.isArray(fns) ? fns : [fns]).reduce((proto, fn) => { | |
Object.getOwnPropertyNames(fn.prototype).forEach(prop => { | |
if(!(protoCopy.hasOwnProperty(prop))) { | |
proto[prop] = fn.prototype[prop]; | |
} |
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
var selector = '#aoFooterSmallPrint'; | |
var addEvent = a => b => c => a.addEventListener(b, c); | |
var footerText = document.querySelector(selector); | |
var footerTextEvents = addEvent(footerText); | |
var footerTextOnClick = footerTextEvents('click'); | |
var footerTextOnMouseOver = footerTextEvents('mouseover'); | |
var log = evt => console.log(evt); | |
footerTextOnClick(log); | |
footerTextOnMouseOver(log); |
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
var jQuery = (function() { | |
function jQuery(selector, context = document) { | |
return new jQuery.fn.init(selector, context); | |
} | |
jQuery.fn = jQuery.prototype ; | |
jQuery.fn.css = function(prop, value) { | |
this.pushStack.forEach(el => el.style[prop] = value); |
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
const capitalise = f => replace(/\b[a-z]/g, f => f.toUpperCase()); | |
const lowercaseilise = f => replace(/\b[A-Z]/g, f => f.toLowerCase()); |
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
var PubSub = (function() { | |
let listeners = {}; | |
return { | |
listeners, | |
subscribe (evt, fn) { | |
if(!this.listeners.hasOwnProperty(evt)) { | |
this.listeners[evt] = []; | |
} | |
this.listeners[evt].push(fn); | |
return () => { |