background preloader

Javascript

Facebook Twitter

Extending Paul Irish’s comprehensive DOM-ready execution | Viget Inspire. Way back in March of '09, the intelligent (and dashing!) Paul Irish laid forth a markup-based means of executing JavaScript on page load. If you're unfamiliar with the technique, the basics are: Use class and id attributes on your document's body element that map to keys in an object literal. Create initializing and executing functions in your JavaScript that parse those classes and ids and call the appropriate functions. The method is noteworthy in that it enforces a sense of organization in both your JavaScript and your HTML. On a recent Ruby on Rails project, I iterated on Paul's method (dubbed the Garber-Irish Implementation by some), adding a touch of HTML5 and making use of some built-in Rails magic.

The Garber-Irish Implementation First off, it'd be negligent to not mention that I'm a huge fan of HTML5's data-* attributes. <span data-lat="38.8951" data-lng="-77.0363"> 1600 Pennsylvania Ave. <body data-controller="<%= controller_name %>" data-action="<%= action_name %>"> Alex MacCaw - Asynchronous UIs - the future of web user interfaces. It's an interesting time to be working on the frontend now. We have new technologies such as HTML5, CSS3, Canvas and WebGL; all of which greatly increase the possibilities for web application development. The world is our oyster! However, there's also another trend I've noticed. Web developers are still stuck in the request/response mindset. I call it the 'click and wait' approach - where every UI interaction results in a delay before another interaction can be performed.

That's the process they've used their entire careers so it's no wonder most developers are blinkered to the alternatives. Speed matters; a lot. Amazon: 100 ms of extra load time caused a 1% drop in sales (source: Greg Linden, Amazon).Google: 500 ms of extra load time caused 20% fewer searches (source: Marrissa Mayer, Google).Yahoo! Yet, despite all this evidence, developers still insist on using the request/response model.

A good example of the problem is Gmail's 'sending' notification; how is this useful to people? Underscore.js. Underscore is a JavaScript library that provides a whole mess of useful functional programming helpers without extending any built-in objects. It’s the answer to the question: “If I sit down in front of a blank HTML page, and want to start being productive immediately, what do I need?” … and the tie to go along with jQuery's tux and Backbone's suspenders. Underscore provides 80-odd functions that support both the usual functional suspects: map, select, invoke — as well as more specialized helpers: function binding, javascript templating, deep equality testing, and so on.

It delegates to built-in functions, if present, so modern browsers will use the native implementations of forEach, map, reduce, filter, every, some and indexOf. The project is hosted on GitHub. You can report bugs and discuss features on the issues page, on Freenode in the #documentcloud channel, or send tweets to @documentcloud. Collection Functions (Arrays or Objects) _.every([true, 1, null, 'yes'], _.identity); => false. Using keyboard shortcuts in Javascript - CatsWhoCode.com. Keyboard shorcuts on the web, let’s talk about it The most important thing to think about when implementing Javascript keyboard shortcuts on a web app is to avoid redefining shortcuts provided by the client’s browser. Imagine that you’re using a web app, you want to close the tab by pressing Cmd+W, and the web app trigger an action, just because the developer redefined a keyboard shortcut used by your browser…How annoying.

This is why I recommend to avoid using the Ctrl (Windows) or Cmd (Mac) key for your web app shortcuts. You should definitely use another key as such as F1, for example. As you may already know, Javascript have lots of useful event listeners. Keyboard codes are simple code consisting of 2 or 3 numbers. For a full reference of keyboard keys, scroll down to the end of this post.

Examples In the following example, we’re simply going to verify the key pressed down by the user. First example, without JQuery: Example with the JQuery framework: Keyboard codes reference. You Don?t Know Anything About Regular Expressions: A Complete Guide. Regular expressions can be scary...really scary. Fortunately, once you memorize what each symbol represents, the fear quickly subsides. If you fit the title of this article, there's much to learn! Let's get started. The key to learning how to effectively use regular expressions is to just take a day and memorize all of the symbols. This is the best advice I can possibly offer. Sit down, create some flash cards, and just memorize them! Here are the most common: . Yep - it's not fun, but just memorize them. You can be certain that you'll want to rip your hair out at one point or another when an expression doesn't work, no matter how much it should - or you think it should!

The next step is to learn how to actually use these symbols! In this final section, we'll review a handful of the most important JavaScript methods for working with regular expressions. This one accepts a single string parameter and returns a boolean indicating whether or not a match has been found. Thanks for reading! Regular Expressions for Dummies: Screencast Series.

Generating Graphics, Charts

jQuery. Galleria - a Javascript Image Gallery | DevKick Lab. FS Gallery. HTML5 API. Editor. Javascript Serveur-side : Node-Js.