Object.observe()

var beingWatched = {}; function whatHappened(change) { console.log(change.name + ” was ” + change.type + ” and is now ” + change.object[change.name]); } function somethingChanged(changes) { changes.forEach(whatHappened); } Object.observe(beingWatched, somethingChanged); beingWatched.a = “foo”; // new beingWatched.a = “bar”; // updated beingWatched.a = “bar”; // no change beingWatched.b = “amazing”; // new Object.observe() lets you add …

Fun with face detection, canvas and webcam video

With the getUser­Me­dia API, a video ele­ment, a can­vas ele­ment and LiuLiu’s excel­lent face detec­tion algo­rithm, we can eas­ily play around with web­cam video data in the browser, plug-in free. Mask over­lay experiment: Scaling content experiment: Cool! Fun with face detection, canvas and webcam video → Related: getUserMedia Moustache (via Webappers.com)

JAL – Just Another Loader for JavaScript

$loader .load(‘js/jquery.min.js’) .done(function(){ // Stop jQuery from triggering the “ready” event $.holdReady(true) }) .load([ ‘js/script-one.min.js’ , ‘js/script-two.min.js’ ]) .ready(function() { // Allow jQuery to trigger the “ready” event $.holdReady(false) // Start app }); We tested YepNope, which is a great loader, but felt it could be faster. It also had features we didn’t really need. …

Gamma Gallery: A Responsive Image Gallery

Gamma Gallery is an experimental responsive image gallery that attempts to provide an adjustable responsive images approach taking its grid layout and the full slideshow view into account. Both the grid and lightbox are responsive. Gamma Gallery: A Responsive Image Gallery Experiment → Gamma Gallery Demo →

A Few New Things Coming To JavaScript (ES6)

ECMAScript 6 contains a few new features. Addy Osmani gives a nice overview of things that are about to come: Modules (which can replace the revealing module pattern we’re familiar with) and Module Loader Classes (which merely is some syntactic sugar) Object.observe() Default Parameter Values (again syntactic sugar as we already know how to work …

Logging client-side errors

function logError(details) { $.ajax({ type: ‘POST’, url: ‘http://mydomain.com/api/1/errors’, data: JSON.stringify({context: navigator.userAgent, details: details}), contentType: ‘application/json; charset=utf-8’ }); } window.onerror = function(message, file, line) { logError(file + ‘:’ + line + ‘\n\n’ + message); }; Let’s keep this short. Too few websites log JavaScript errors. Let’s build a simple system to track client-side errors. Makes clever …