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
// jQuery AJAX simulator | |
var $ = { | |
ajax: function(opts, returnData, throwError) { | |
console.log(`Request URL: ${opts.url}`); | |
console.log(`Request data: ${opts.data}`); | |
var timer = Math.round() * 10 + 1; | |
if (throwError && typeof opts.error === '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
// jQuery AJAX simulator | |
var $ = { | |
ajax: function(opts, returnData, throwError) { | |
console.log(`Request URL: ${opts.url}`); | |
console.log(`Request data: ${opts.data}`); | |
var timer = Math.round() * 10 + 1; | |
if (throwError && typeof opts.error === '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
// jQuery Ajax simulator | |
var $ = { | |
ajax: function(opts, returnData, throwError) { | |
console.log(`Request URL: ${opts.url}`); | |
console.log(`Request data: ${opts.data}`); | |
var timer = Math.round() * 10 + 1; | |
if (throwError && typeof opts.error === '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
function *generator() { | |
yield 'hello'; | |
yield 'world'; | |
} | |
// Usage | |
var iter = generator(); | |
console.log(iter.next()); | |
console.log(iter.next()); |
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 createIterator(items) { | |
var currentIndex = 0; | |
return { | |
next: function() { | |
if (items[currentIndex]) { | |
return { value: items[currentIndex], done: false }; | |
} else { | |
return { value: undefined, done: true }; |
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
// Notes: | |
// 1. Use the second parameter to simulate a response data. | |
// 2. Use the third (boolean) parameter to simulate a failed request. | |
// jQuery's AJAX simulator | |
var $ = { | |
ajax: function(opts, returnData, throwError) { | |
console.group('AJAX Request'); | |
console.log('Request URL: ', opts.url); |
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 search(searchQuery, data) { | |
if(searchQuery instanceof Array) { | |
return searchQuery.reduce(function(prev, current, index, array) { | |
return prev.concat(search(current, data)); | |
}, []); | |
} | |
var results = data.filter(function(el) { | |
for(var prop in searchQuery) { | |
if(searchQuery[prop] instanceof Array) { |
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
input[type="checkbox"] { | |
-webkit-appearance: none; | |
border: 2px solid #bdbdbd; | |
width: 61px; | |
height: 27px; | |
border-radius: 2px; | |
display: inline-block; | |
position: relative; | |
outline: none; | |
cursor: pointer; |
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
/** | |
* Created by Karlen on 13-Aug-14. | |
*/ | |
var imageContext = document.getElementById('imageCanvas').getContext('2d'), | |
lutContext = document.getElementById('lutCanvas').getContext('2d'); | |
function applyLUT(image, lut) { | |
var imageData, lutData, iData, lData; |