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
/** | |
* Product preview image in campaign header | |
* @type {Backbone View} | |
*/ | |
TS.Campaign.MainProductView = Backbone.View.extend({ |
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
<select id="option-style-select" name="option_style"> | |
<option value="Tee (American Apparel)" selected>Tee (American Apparel)</option> | |
<option value="Canvas Ringspun Tee">Canvas Ringspun Tee</option> | |
<option value="Bella Ladies Relaxed Fit Tee">Bella Ladies Relaxed Fit Tee</option> | |
</select> | |
<button>Open Select</button> | |
<script> | |
$("button").click(function() { |
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 fibo_useless = function(g, n) { | |
return n == 0 ? 0 : | |
n == 1 ? 1 : | |
g(n-1) + g(n-2); | |
}; | |
var cachify = function(f, cache) { | |
return function(n) { | |
if(!cache[n]) { | |
var g = cachify(f, cache); |
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 input = [1,2,3,4,5], | |
specArr = [0,2,1,4,3]; | |
function mutate(input, specArr) { | |
var visited = [0,2] | |
for(var i=0; i<specArr.length; i++) { | |
var tmp; | |
//keep track of array items we've already looped through (wouldn't want to mutate twice :D) |
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 findObjPropInArr(arr, prop, val) { | |
for(var i = 0; i<arr.length; i++) { | |
if(arr[i][prop] === val) { | |
return i; | |
} | |
} | |
return -1; | |
} | |
function findFirstNoRepeat(word) { |
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 myFunc = function (param) { | |
if (!myFunc.cache[param]) { | |
var result = {}; | |
// ... expensive operation ... | |
myFunc.cache[param] = result; | |
} | |
return myFunc.cache[param]; |
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
// the interface | |
var utils = { | |
addListener: null, | |
removeListener: null | |
}; | |
// the implementation | |
if (typeof window.addEventListener === 'function') { | |
utils.addListener = function (el, type, fn) { | |
el.addEventListener(type, fn, false); |
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 items = { | |
'a': 5, | |
'b': 10, | |
'c': 4, | |
'd': 11 | |
}, | |
tempArr = [], | |
returnArr = []; | |
function sortObject(items) { |
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 temp = []; | |
var answer = []; | |
return doIt(arr); | |
function doIt(a) { | |
var i, len, item; | |
for (i = 0, len = arr.length; i < len; i++) { | |
// remove the item at index i |
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
carousel = function(){ | |
var config = { | |
CSS:{ | |
classes:{ | |
current:'current', | |
scrollContainer:'scroll' | |
}, | |
IDs:{ | |
maincontainer:'carousel' | |
} |
NewerOlder