From 471754611a81c398e852c00674a5b5ab097ed010 Mon Sep 17 00:00:00 2001 From: liabru Date: Thu, 20 Mar 2014 15:10:48 +0000 Subject: [PATCH] demos are now jshinted --- Gruntfile.js | 2 +- demo/js/Demo.js | 102 ++++++++++++++++++++++++------------------ demo/js/DemoMobile.js | 19 ++++---- 3 files changed, 70 insertions(+), 53 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 7f31e38..332fe60 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -41,7 +41,7 @@ module.exports = function(grunt) { options: { jshintrc: '.jshintrc' }, - all: ['src/**/*.js', '!src/module/*'] + all: ['src/**/*.js', 'demo/js/*.js', '!src/module/*'] }, connect: { watch: { diff --git a/demo/js/Demo.js b/demo/js/Demo.js index a767ecc..49d6b34 100644 --- a/demo/js/Demo.js +++ b/demo/js/Demo.js @@ -174,20 +174,22 @@ var stack = Composites.stack(20, 20, 15, 4, 0, 0, function(x, y, column, row) { switch (Math.round(Common.random(0, 1))) { - case 0: - if (Math.random() < 0.8) { - return Bodies.rectangle(x, y, Common.random(20, 50), Common.random(20, 50)); - } else { - return Bodies.rectangle(x, y, Common.random(80, 120), Common.random(20, 30)); - } - case 1: - var sides = Math.round(Common.random(1, 8)); - // triangles can be a little unstable, so avoid until fixed - // TODO: make triangles more stable - sides = (sides === 3) ? 4 : sides; + case 0: + if (Math.random() < 0.8) { + return Bodies.rectangle(x, y, Common.random(20, 50), Common.random(20, 50)); + } else { + return Bodies.rectangle(x, y, Common.random(80, 120), Common.random(20, 30)); + } + break; + case 1: + var sides = Math.round(Common.random(1, 8)); - return Bodies.polygon(x, y, sides, Common.random(20, 50)); + // triangles can be a little unstable, so avoid until fixed + // TODO: make triangles more stable + sides = (sides === 3) ? 4 : sides; + + return Bodies.polygon(x, y, sides, Common.random(20, 50)); } }); @@ -203,14 +205,17 @@ var stack = Composites.stack(50, 50, 12, 3, 0, 0, function(x, y, column, row) { switch (Math.round(Common.random(0, 1))) { - case 0: - if (Math.random() < 0.8) { - return Bodies.rectangle(x, y, Common.random(20, 50), Common.random(20, 50)); - } else { - return Bodies.rectangle(x, y, Common.random(80, 120), Common.random(20, 30)); - } - case 1: - return Bodies.polygon(x, y, Math.round(Common.random(1, 8)), Common.random(20, 50)); + + case 0: + if (Math.random() < 0.8) { + return Bodies.rectangle(x, y, Common.random(20, 50), Common.random(20, 50)); + } else { + return Bodies.rectangle(x, y, Common.random(80, 120), Common.random(20, 30)); + } + break; + case 1: + return Bodies.polygon(x, y, Math.round(Common.random(1, 8)), Common.random(20, 50)); + } }); @@ -326,14 +331,17 @@ var stack = Composites.stack(50, 50, 12, 3, 0, 0, function(x, y, column, row) { switch (Math.round(Common.random(0, 1))) { - case 0: - if (Math.random() < 0.8) { - return Bodies.rectangle(x, y, Common.random(20, 50), Common.random(20, 50)); - } else { - return Bodies.rectangle(x, y, Common.random(80, 120), Common.random(20, 30)); - } - case 1: - return Bodies.polygon(x, y, Math.round(Common.random(1, 8)), Common.random(20, 50)); + + case 0: + if (Math.random() < 0.8) { + return Bodies.rectangle(x, y, Common.random(20, 50), Common.random(20, 50)); + } else { + return Bodies.rectangle(x, y, Common.random(80, 120), Common.random(20, 30)); + } + break; + case 1: + return Bodies.polygon(x, y, Math.round(Common.random(1, 8)), Common.random(20, 50)); + } }); @@ -351,14 +359,17 @@ var stack = Composites.stack(20, 20, 20, 5, 0, 0, function(x, y, column, row) { switch (Math.round(Common.random(0, 1))) { - case 0: - if (Math.random() < 0.8) { - return Bodies.rectangle(x, y, Common.random(20, 50), Common.random(20, 50)); - } else { - return Bodies.rectangle(x, y, Common.random(80, 120), Common.random(20, 30)); - } - case 1: - return Bodies.polygon(x, y, Math.round(Common.random(1, 8)), Common.random(20, 50)); + + case 0: + if (Math.random() < 0.8) { + return Bodies.rectangle(x, y, Common.random(20, 50), Common.random(20, 50)); + } else { + return Bodies.rectangle(x, y, Common.random(80, 120), Common.random(20, 30)); + } + break; + case 1: + return Bodies.polygon(x, y, Math.round(Common.random(1, 8)), Common.random(20, 50)); + } }); @@ -377,14 +388,17 @@ var stack = Composites.stack(20, 20, 20, 5, 0, 0, function(x, y, column, row) { switch (Math.round(Common.random(0, 1))) { - case 0: - if (Math.random() < 0.8) { - return Bodies.rectangle(x, y, Common.random(20, 50), Common.random(20, 50)); - } else { - return Bodies.rectangle(x, y, Common.random(80, 120), Common.random(20, 30)); - } - case 1: - return Bodies.polygon(x, y, Math.round(Common.random(1, 8)), Common.random(20, 50)); + + case 0: + if (Math.random() < 0.8) { + return Bodies.rectangle(x, y, Common.random(20, 50), Common.random(20, 50)); + } else { + return Bodies.rectangle(x, y, Common.random(80, 120), Common.random(20, 30)); + } + break; + case 1: + return Bodies.polygon(x, y, Math.round(Common.random(1, 8)), Common.random(20, 50)); + } }); diff --git a/demo/js/DemoMobile.js b/demo/js/DemoMobile.js index ef513c1..66f9634 100644 --- a/demo/js/DemoMobile.js +++ b/demo/js/DemoMobile.js @@ -136,14 +136,17 @@ var stack = Composites.stack(20, 20, 10, 5, 0, 0, function(x, y, column, row) { switch (Math.round(Common.random(0, 1))) { - case 0: - if (Math.random() < 0.8) { - return Bodies.rectangle(x, y, Common.random(20, 40), Common.random(20, 40), { friction: 0.01, restitution: 0.4 }); - } else { - return Bodies.rectangle(x, y, Common.random(80, 120), Common.random(20, 30), { friction: 0.01, restitution: 0.4 }); - } - case 1: - return Bodies.polygon(x, y, Math.round(Common.random(4, 6)), Common.random(20, 40), { friction: 0.01, restitution: 0.4 }); + + case 0: + if (Math.random() < 0.8) { + return Bodies.rectangle(x, y, Common.random(20, 40), Common.random(20, 40), { friction: 0.01, restitution: 0.4 }); + } else { + return Bodies.rectangle(x, y, Common.random(80, 120), Common.random(20, 30), { friction: 0.01, restitution: 0.4 }); + } + break; + case 1: + return Bodies.polygon(x, y, Math.round(Common.random(4, 6)), Common.random(20, 40), { friction: 0.01, restitution: 0.4 }); + } });