From f14425da75843fbf260c831e7fca6ba0d173d885 Mon Sep 17 00:00:00 2001 From: Borys Levytskyi Date: Sat, 4 Apr 2015 19:27:52 +0300 Subject: [PATCH] Use strict everywhere --- app/bitwise/calc.js | 2 ++ app/bitwise/expression.js | 4 ++- app/bitwise/formatter.js | 47 ++++++++++++++------------------ app/commandsCatalog.js | 1 + app/controllers.js | 1 + app/dispatcher.js | 2 ++ app/modelViews.js | 1 + app/models.js | 1 + app/services.js | 1 + components/commandsFeature.js | 1 + components/controllersFeature.js | 1 + components/templatesFeature.js | 1 + components/viewsFeature.js | 2 ++ core/appShell.js | 3 +- core/bindr.js | 2 ++ core/di.js | 5 ++-- core/htmlBuilder.js | 1 + core/is.js | 2 ++ core/observable.js | 1 + core/should.js | 2 ++ 20 files changed, 50 insertions(+), 31 deletions(-) diff --git a/app/bitwise/calc.js b/app/bitwise/calc.js index 1a1763f..4be9450 100644 --- a/app/bitwise/calc.js +++ b/app/bitwise/calc.js @@ -1,4 +1,6 @@ app.compose(function() { + "use strict"; + var should = app.get('should') app.set('calc', { diff --git a/app/bitwise/expression.js b/app/bitwise/expression.js index bda01cf..40b465a 100644 --- a/app/bitwise/expression.js +++ b/app/bitwise/expression.js @@ -1,4 +1,6 @@ -app.compose(function(){ +app.compose(function() { + "use strict"; + var twoOperandsRegex = /^(\d+)\s*(<<|>>|\||\&|\^)\s*(\d+)$/; var numbersList = /^((\d*)+\s?)+$/; diff --git a/app/bitwise/formatter.js b/app/bitwise/formatter.js index 134d82c..00d1123 100644 --- a/app/bitwise/formatter.js +++ b/app/bitwise/formatter.js @@ -1,32 +1,27 @@ -(function(should, app){ +app.compose(function() { + "use strict"; - app.compose(function() { - var should = app.get('should'); - app.set("formatter", { - toBinaryString: function(num, totalLength) { + var should = app.get('should'); + app.set("formatter", { + toBinaryString: function(num, totalLength) { - var binaryStr = num.toString(2), - formatted = [], - i; + var binaryStr = num.toString(2), + formatted = [], + i; - if(totalLength != null) { - should.bePositiveInteger(totalLength); - } + if(totalLength != null) { + should.bePositiveInteger(totalLength); + } - for(i = 0; i formatted.length) { - formatted.unshift('0'); - } - - return formatted.join(''); - } - }); - }) - - -})(window.should, window.app); + for(i = 0; i formatted.length) { + formatted.unshift('0'); + } + return formatted.join(''); + } + }); +}) diff --git a/app/commandsCatalog.js b/app/commandsCatalog.js index 0aa38c8..a33f339 100644 --- a/app/commandsCatalog.js +++ b/app/commandsCatalog.js @@ -1,4 +1,5 @@ app.run(function() { + "use strict"; var dispatcher = app.get('dispatcher'); diff --git a/app/controllers.js b/app/controllers.js index 78259cc..4c1e9af 100644 --- a/app/controllers.js +++ b/app/controllers.js @@ -1,4 +1,5 @@ app.compose(function() { + "use strict"; app.controller('expressionInputCtrl', function (){ var dispatcher = app.get('dispatcher'); diff --git a/app/dispatcher.js b/app/dispatcher.js index dd58c05..387cffd 100644 --- a/app/dispatcher.js +++ b/app/dispatcher.js @@ -1,4 +1,6 @@ app.compose(function() { + "use strict"; + app.set('dispatcher', function() { var handlers = []; var is = app.get('is'); diff --git a/app/modelViews.js b/app/modelViews.js index cf73626..873d5fa 100644 --- a/app/modelViews.js +++ b/app/modelViews.js @@ -1,5 +1,6 @@ // Expression View app.compose(function () { + "use strict"; var formatter = app.get('formatter'); var calc = app.get('calc'); diff --git a/app/models.js b/app/models.js index 05c4789..6ce3599 100644 --- a/app/models.js +++ b/app/models.js @@ -1,4 +1,5 @@ (function(app) { + "use strict"; function BitwiseOperation () { } diff --git a/app/services.js b/app/services.js index 06e4bff..4973eae 100644 --- a/app/services.js +++ b/app/services.js @@ -1,4 +1,5 @@ (function(app, core){ + "use strict"; app.set('html', core.HtmlBuilder); app.set('is', core.is); diff --git a/components/commandsFeature.js b/components/commandsFeature.js index 6353f56..7ce4c51 100644 --- a/components/commandsFeature.js +++ b/components/commandsFeature.js @@ -1,4 +1,5 @@ (function(app, core){ + "use strict"; var should = core.should; diff --git a/components/controllersFeature.js b/components/controllersFeature.js index 1fc8196..08a5ca7 100644 --- a/components/controllersFeature.js +++ b/components/controllersFeature.js @@ -1,4 +1,5 @@ (function(app, core) { + "use strict"; var should = core.should; diff --git a/components/templatesFeature.js b/components/templatesFeature.js index ed07d25..07c2b5e 100644 --- a/components/templatesFeature.js +++ b/components/templatesFeature.js @@ -1,4 +1,5 @@ (function(app) { + "use strict"; function Template(html) { this.html = html; diff --git a/components/viewsFeature.js b/components/viewsFeature.js index c086dbb..857500b 100644 --- a/components/viewsFeature.js +++ b/components/viewsFeature.js @@ -1,4 +1,6 @@ (function(app, is){ + "use strict"; + app.modelView = function (modelCtor, builder) { var name = getKey(modelCtor); app.di.register(name, builder); diff --git a/core/appShell.js b/core/appShell.js index d06859b..f3bbc3c 100644 --- a/core/appShell.js +++ b/core/appShell.js @@ -1,5 +1,6 @@ (function() { - + "use strict"; + function AppShell(diContainer) { this.models = {}; this.di = diContainer; diff --git a/core/bindr.js b/core/bindr.js index 6b0ba84..f4b80bf 100644 --- a/core/bindr.js +++ b/core/bindr.js @@ -1,4 +1,6 @@ (function(){ + "use strict"; + var bindr = {}; bindr.bindChildren = function(container, model) { diff --git a/core/di.js b/core/di.js index 04146b5..f907dd4 100644 --- a/core/di.js +++ b/core/di.js @@ -1,7 +1,6 @@ -// Problems: no check for the circular references - (function(core){ - + + "use strict"; var is = core.is; function Container(store) { diff --git a/core/htmlBuilder.js b/core/htmlBuilder.js index 7838099..31f1b36 100644 --- a/core/htmlBuilder.js +++ b/core/htmlBuilder.js @@ -1,4 +1,5 @@ (function(core){ + "use strict"; var HtmlBuilder = {}; var should = core.should; diff --git a/core/is.js b/core/is.js index 497c946..b78c0bf 100644 --- a/core/is.js +++ b/core/is.js @@ -1,4 +1,6 @@ (function(){ + "use strict"; + window.core.is = { plainObject: function(obj) { return typeof obj == "object" && obj instanceof Object; diff --git a/core/observable.js b/core/observable.js index 125b5c3..1bf1bec 100644 --- a/core/observable.js +++ b/core/observable.js @@ -1,4 +1,5 @@ (function(core){ + "use strict"; var is = core.is; function ObservableObject () { diff --git a/core/should.js b/core/should.js index 0fe97dd..5046ad2 100644 --- a/core/should.js +++ b/core/should.js @@ -1,4 +1,6 @@ (function(){ + "use strict"; + window.core.should = { beNumber: function (num, name) { this.check(typeof num == "number" && !isNaN(num), num + " is not a number");