Author: Ari Lerner.
AngularJS offers a single framework that can be used to build dynamic, client-centric applications. It provides:
- Module support
- DOM manipulation
- Animations
- Templating
Author: Ari Lerner.
AngularJS offers a single framework that can be used to build dynamic, client-centric applications. It provides:
#System Design Cheatsheet
Picking the right architecture = Picking the right battles + Managing trade-offs
##Basic Steps
| Whether you use 2 spaces or 4 spaces, there are a few simple things that can make your node.js code easier to read. We've been using them in all the hapi modules for over 4 years now to great results. This list is by no means complete but it highlights the most useful elements that will give you immediate value in reducing bugs. | |
| ### Required modules | |
| JavaScript makes it harder than most languages to know where variables are coming from. Variables assigned required modules are particularly important because they represent a singleton object shared with the entire application. There are also globals and module globals, along with function variables and arguments. | |
| Traditionally, variables starting with an uppercase letter represent a class that must be instantiated using `new`. This was an important semantic in the early days of JavaScript but at this point, if you don't know `Date` requires `new Date()` you are probably very new. We have adopted Upper Camel Case variable names for all module global variables |
| * {} | |
| tag {} | |
| [attribute] {} | |
| [attribute="value"] {} | |
| .class {} |
| // JS Module Pattern: | |
| // http://j.mp/module-pattern | |
| // Redefine: $, window, document, undefined. | |
| var APP = (function($, window, document, undefined) { | |
| // Automatically calls all functions in APP.init | |
| $(document).ready(function() { | |
| APP.go(); | |
| }); |
| // | |
| // Regular Expression for URL validation | |
| // | |
| // Author: Diego Perini | |
| // Updated: 2010/12/05 | |
| // License: MIT | |
| // | |
| // Copyright (c) 2010-2013 Diego Perini (http://www.iport.it) | |
| // | |
| // Permission is hereby granted, free of charge, to any person |
| // Refer to https://gist.github.com/remy/350433 | |
| try { | |
| // Test webstorage existence. | |
| if (!window.localStorage || !window.sessionStorage) throw "exception"; | |
| // Test webstorage accessibility - Needed for Safari private browsing. | |
| localStorage.setItem('storage_test', 1); | |
| localStorage.removeItem('storage_test'); | |
| } catch(e) { | |
| (function () { | |
| var Storage = function (type) { |
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8" /> | |
| <title>Calculating zoom using Javascript</title> | |
| <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js"></script> | |
| <script> | |
| function hasPageBeenResized() { | |
| var isResized; |
| // Create a jquery plugin that prints the given element. | |
| jQuery.fn.print = function(){ | |
| // NOTE: We are trimming the jQuery collection down to the | |
| // first element in the collection. | |
| if (this.size() > 1){ | |
| this.eq( 0 ).print(); | |
| return; | |
| } else if (!this.size()){ | |
| return; | |
| } |
| // It is important to declare your variables. | |
| (function() { | |
| var foo = 'Hello, world!'; | |
| print(foo); //=> Hello, world! | |
| })(); | |
| // Because if you don't, the become global variables. | |
| (function() { |