Permalink
Browse files

Proper indentation using tabs (both HTML and JS)

  • Loading branch information...
1 parent 8de6643 commit f1b4f9a32fba9a9566395f16bedbb5f91623a4d2 Lars Kappert committed Feb 1, 2012
Showing with 3,875 additions and 3,800 deletions.
  1. +79 −79 code-reuse-patterns/borrowing-methods.html
  2. +47 −46 code-reuse-patterns/cp1-default.html
  3. +57 −57 code-reuse-patterns/cp2-rent-a-constructor.html
  4. +42 −42 code-reuse-patterns/cp3-rent-and-set-prototype.html
  5. +42 −41 code-reuse-patterns/cp4-share-the-prototype.html
  6. +63 −61 code-reuse-patterns/cp5-a-temporary-constructor.html
  7. +65 −65 code-reuse-patterns/inheritance-by-copying-properties.html
  8. +163 −154 code-reuse-patterns/klass.html
  9. +32 −32 code-reuse-patterns/mix-ins.html
  10. +63 −61 code-reuse-patterns/prototypal-inheritance.html
  11. +28 −28 design-patterns/builder.html
  12. +54 −54 design-patterns/chain-of-responsibility.html
  13. +41 −41 design-patterns/command.html
  14. +52 −52 design-patterns/decorator.html
  15. +22 −22 design-patterns/facade.html
  16. +83 −83 design-patterns/factory.html
  17. +62 −62 design-patterns/iterator.html
  18. +83 −83 design-patterns/mediator.html
  19. +70 −70 design-patterns/observer.html
  20. +236 −206 design-patterns/proxy.html
  21. +145 −146 design-patterns/singleton.html
  22. +113 −113 design-patterns/strategy.html
  23. +52 −52 dom-and-browser/event-handling.html
  24. +49 −48 function-patterns/callback.html
  25. +38 −38 function-patterns/callbacks-and-scope.html
  26. +20 −20 function-patterns/configuration-objects.html
  27. +165 −153 function-patterns/currying.html
  28. +19 −19 function-patterns/enforcing-new-in-constructors.html
  29. +21 −21 function-patterns/immediate-functions.html
  30. +31 −31 function-patterns/immediate-object-initialization.html
  31. +53 −53 function-patterns/init-time-branching.html
  32. +73 −73 function-patterns/memoization.html
  33. +34 −34 function-patterns/returning-functions.html
  34. +38 −38 function-patterns/self-defining-functions.html
  35. +17 −17 function-patterns/self-overwrite.html
  36. +20 −20 general-patterns/access-to-global-object.html
  37. +40 −40 general-patterns/avoiding-eval.html
  38. +41 −41 general-patterns/avoiding-implied-typecasting.html
  39. +26 −26 general-patterns/built-in-prototypes.html
  40. +104 −101 general-patterns/conditionals.html
  41. +66 −65 general-patterns/for-in-loops.html
  42. +49 −49 general-patterns/for-loops.html
  43. +24 −22 general-patterns/function-declarations.html
  44. +47 −47 general-patterns/globals.html
  45. +30 −30 general-patterns/hoisting.html
  46. +18 −18 general-patterns/minimizing-globals.html
  47. +27 −27 general-patterns/parseint.html
  48. +34 −34 general-patterns/single-var-pattern.html
  49. +34 −34 general-patterns/switch-pattern.html
  50. +32 −32 jquery-patterns/append.html
  51. +22 −22 jquery-patterns/cache-selector.html
  52. +21 −21 jquery-patterns/context-and-find.html
  53. +17 −17 jquery-patterns/data.html
  54. +19 −19 jquery-patterns/decending-from-id.html
  55. +18 −18 jquery-patterns/detach.html
  56. +17 −17 jquery-patterns/event-delegation.html
  57. +17 −17 jquery-patterns/left-and-right.html
  58. +26 −24 jquery-patterns/requery.html
  59. +17 −17 jquery-patterns/specific-when-needed.html
  60. +22 −22 jquery-patterns/universal-selector.html
  61. +58 −57 jquery-patterns/window-scroll-event.html
  62. +17 −17 literals-and-constructors/array-literal.html
  63. +52 −52 literals-and-constructors/enforcing-new.html
  64. +21 −21 literals-and-constructors/json.html
  65. +18 −18 literals-and-constructors/object-literal.html
  66. +52 −52 literals-and-constructors/primitive-wrappers.html
  67. +17 −17 literals-and-constructors/regular-expression-literal.html
  68. +31 −31 object-creation-patterns/chaining.html
  69. +19 −19 object-creation-patterns/declaring-dependencies.html
  70. +123 −123 object-creation-patterns/module.html
  71. +45 −45 object-creation-patterns/namespace.html
  72. +52 −52 object-creation-patterns/object-constants.html
  73. +38 −38 object-creation-patterns/private-properties-and-methods.html
  74. +48 −47 object-creation-patterns/revelation.html
  75. +90 −84 object-creation-patterns/sandbox.html
  76. +123 −122 object-creation-patterns/static-members.html
  77. +31 −30 object-creation-patterns/sugar-method.html
@@ -1,82 +1,82 @@
<!doctype html>
<html lang="en">
-<head>
-<title>JavaScript Patterns</title>
-<meta charset="utf-8">
-</head>
-<body>
-<script>
-/* Title: Borrowing Methods
- Description: reuse one or two methods of an existing object without forming a parent-child relationship with that object
-*/
-
-function f() {
- var args = [].slice.call(arguments, 1, 3);
- return args;
-}
-
-var one = {
- name: 'object',
- say: function (greet) {
- return greet + ', ' + this.name;
- }
-};
-
-// test
-console.log(one.say('hi')); // "hi, object"
-
-var two = {
- name: 'another object'
-};
-
-console.log(one.say.apply(two, ['hello'])); // "hello, another object"
-
-// assigning to a variable
-// `this` will point to the global object
-var say = one.say;
-console.log(say('hoho')); // "hoho, undefined"
-
-// passing as a callback
-var yetanother = {
- name: 'Yet another object',
- method: function (callback) {
- return callback('Hola');
- }
-};
-console.log(yetanother.method(one.say)); // "Holla, undefined"
-
-function bind(o, m) {
- return function () {
- return m.apply(o, [].slice.call(arguments));
- };
-}
-
-var twosay = bind(two, one.say);
-console.log(twosay('yo')); // "yo, another object"
-
-
-// ECMAScript 5 adds a method bind() to Function.prototype, making it just as easy to use as apply() and call().
-
-if (typeof Function.prototype.bind === 'undefined') {
- Function.prototype.bind = function (thisArg) {
- var fn = this,
- slice = Array.prototype.slice,
- args = slice.call(arguments, 1);
- return function () {
- return fn.apply(thisArg, args.concat(slice.call(arguments)));
- };
- };
-}
-
-var twosay2 = one.say.bind(two);
-console.log(twosay2('Bonjour')); // "Bonjour, another object"
-
-var twosay3 = one.say.bind(two, 'Enchanté');
-console.log(twosay3()); // "Enchanté, another object"
-
-
-// reference
-// http://shop.oreilly.com/product/9780596806767.do
-</script>
-</body>
+ <head>
+ <title>JavaScript Patterns</title>
+ <meta charset="utf-8">
+ </head>
+ <body>
+ <script>
+ /* Title: Borrowing Methods
+ Description: reuse one or two methods of an existing object without forming a parent-child relationship with that object
+ */
+
+ function f() {
+ var args = [].slice.call(arguments, 1, 3);
+ return args;
+ }
+
+ var one = {
+ name:'object',
+ say:function (greet) {
+ return greet + ', ' + this.name;
+ }
+ };
+
+ // test
+ console.log(one.say('hi')); // "hi, object"
+
+ var two = {
+ name:'another object'
+ };
+
+ console.log(one.say.apply(two, ['hello'])); // "hello, another object"
+
+ // assigning to a variable
+ // `this` will point to the global object
+ var say = one.say;
+ console.log(say('hoho')); // "hoho, undefined"
+
+ // passing as a callback
+ var yetanother = {
+ name:'Yet another object',
+ method:function (callback) {
+ return callback('Hola');
+ }
+ };
+ console.log(yetanother.method(one.say)); // "Holla, undefined"
+
+ function bind(o, m) {
+ return function () {
+ return m.apply(o, [].slice.call(arguments));
+ };
+ }
+
+ var twosay = bind(two, one.say);
+ console.log(twosay('yo')); // "yo, another object"
+
+
+ // ECMAScript 5 adds a method bind() to Function.prototype, making it just as easy to use as apply() and call().
+
+ if (typeof Function.prototype.bind === 'undefined') {
+ Function.prototype.bind = function (thisArg) {
+ var fn = this,
+ slice = Array.prototype.slice,
+ args = slice.call(arguments, 1);
+ return function () {
+ return fn.apply(thisArg, args.concat(slice.call(arguments)));
+ };
+ };
+ }
+
+ var twosay2 = one.say.bind(two);
+ console.log(twosay2('Bonjour')); // "Bonjour, another object"
+
+ var twosay3 = one.say.bind(two, 'Enchanté');
+ console.log(twosay3()); // "Enchanté, another object"
+
+
+ // reference
+ // http://shop.oreilly.com/product/9780596806767.do
+ </script>
+ </body>
</html>
@@ -1,49 +1,50 @@
<!doctype html>
<html lang="en">
-<head>
-<title>JavaScript Patterns</title>
-<meta charset="utf-8">
-</head>
-<body>
-<script>
-/* Title: Classical Pattern #1 - The Default Pattern (a pattern that should be generally avoided)
- Description: create an object using the Parent() constructor and assign this object to the Child()'s prototype
-*/
-
-function inherit(C, P) {
- C.prototype = new P();
-}
-
-// the parent constructor
-function Parent(name) {
- this.name = name || 'Adam';
-}
-// adding functionality to the prototype
-Parent.prototype.say = function () {
- return this.name;
-};
-// empty child constructor
-function Child(name) {}
-
-// inheritance magic happens here
-inherit(Child, Parent);
-
-var kid = new Child();
-console.log(kid.say()); // "Adam"
-
-// Drawback 1: own properties added to `this` is inherited
-var kiddo = new Child();
-kiddo.name = "Patrick";
-console.log(kiddo.say()); // "Patrick"
-
-
-// Drawback 2: it doesn't enable you to pass parameters to the child constructor
-var s = new Child('Seth');
-console.log(s.say()); // "Adam"
-
-
-// reference
-// http://shop.oreilly.com/product/9780596806767.do
-</script>
-</body>
+ <head>
+ <title>JavaScript Patterns</title>
+ <meta charset="utf-8">
+ </head>
+ <body>
+ <script>
+ /* Title: Classical Pattern #1 - The Default Pattern (a pattern that should be generally avoided)
+ Description: create an object using the Parent() constructor and assign this object to the Child()'s prototype
+ */
+
+ function inherit(C, P) {
+ C.prototype = new P();
+ }
+
+ // the parent constructor
+ function Parent(name) {
+ this.name = name || 'Adam';
+ }
+ // adding functionality to the prototype
+ Parent.prototype.say = function () {
+ return this.name;
+ };
+ // empty child constructor
+ function Child(name) {
+ }
+
+ // inheritance magic happens here
+ inherit(Child, Parent);
+
+ var kid = new Child();
+ console.log(kid.say()); // "Adam"
+
+ // Drawback 1: own properties added to `this` is inherited
+ var kiddo = new Child();
+ kiddo.name = "Patrick";
+ console.log(kiddo.say()); // "Patrick"
+
+
+ // Drawback 2: it doesn't enable you to pass parameters to the child constructor
+ var s = new Child('Seth');
+ console.log(s.say()); // "Adam"
+
+
+ // reference
+ // http://shop.oreilly.com/product/9780596806767.do
+ </script>
+ </body>
</html>
@@ -1,60 +1,60 @@
<!doctype html>
<html lang="en">
-<head>
-<title>JavaScript Patterns</title>
-<meta charset="utf-8">
-</head>
-<body>
-<script>
-/* Title: Classical Pattern #2 - Rent a Constructor (a pattern that should be generally avoided)
- Description: it borrows the parent constructor, passing the child object to be bound to this and also forwarding any arguments
-*/
-
-// the parent constructor
-function Parent(name) {
- this.name = name || 'Adam';
-}
-
-// adding functionality to the prototype
-Parent.prototype.say = function () {
- return this.name;
-};
-
-// child constructor
-function Child(name) {
- Parent.apply(this, arguments);
-}
-
-var kid = new Child("Patrick");
-console.log(kid.name); // "Patrick"
-
-// Drawback 1: nothing from the prototype gets inherited
-console.log(typeof kid.say); // "undefined"
-
-// Multiple Inheritance by Borrowing Constructors
-function Cat() {
- this.legs = 4;
- this.say = function () {
- return "meaowww";
- }
-}
-
-function Bird() {
- this.wings = 2;
- this.fly = true;
-}
-
-function CatWings() {
- Cat.apply(this);
- Bird.apply(this);
-}
-
-var jane = new CatWings();
-console.dir(jane);
-
-
-// reference
-// http://shop.oreilly.com/product/9780596806767.do
-</script>
-</body>
+ <head>
+ <title>JavaScript Patterns</title>
+ <meta charset="utf-8">
+ </head>
+ <body>
+ <script>
+ /* Title: Classical Pattern #2 - Rent a Constructor (a pattern that should be generally avoided)
+ Description: it borrows the parent constructor, passing the child object to be bound to this and also forwarding any arguments
+ */
+
+ // the parent constructor
+ function Parent(name) {
+ this.name = name || 'Adam';
+ }
+
+ // adding functionality to the prototype
+ Parent.prototype.say = function () {
+ return this.name;
+ };
+
+ // child constructor
+ function Child(name) {
+ Parent.apply(this, arguments);
+ }
+
+ var kid = new Child("Patrick");
+ console.log(kid.name); // "Patrick"
+
+ // Drawback 1: nothing from the prototype gets inherited
+ console.log(typeof kid.say); // "undefined"
+
+ // Multiple Inheritance by Borrowing Constructors
+ function Cat() {
+ this.legs = 4;
+ this.say = function () {
+ return "meaowww";
+ }
+ }
+
+ function Bird() {
+ this.wings = 2;
+ this.fly = true;
+ }
+
+ function CatWings() {
+ Cat.apply(this);
+ Bird.apply(this);
+ }
+
+ var jane = new CatWings();
+ console.dir(jane);
+
+
+ // reference
+ // http://shop.oreilly.com/product/9780596806767.do
+ </script>
+ </body>
</html>
Oops, something went wrong.

0 comments on commit f1b4f9a

Please sign in to comment.