From 61f97f4856324a9c8146d70465eded7927ab6fd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20M=C3=A9tais?= Date: Wed, 3 Sep 2014 16:19:32 +0200 Subject: [PATCH] New notations on Summary : jQuery version and Events bound --- app/node_views/results.html | 10 ++++++- app/public/scripts/resultsCtrl.js | 47 ++++++++++++++++++++++++++++++- 2 files changed, 55 insertions(+), 2 deletions(-) diff --git a/app/node_views/results.html b/app/node_views/results.html index 5a8adb2..844012f 100644 --- a/app/node_views/results.html +++ b/app/node_views/results.html @@ -45,13 +45,21 @@
{{notations.domManipulations}}
DOM read and write Requests
+
+
{{notations.eventsBound}}
+
Events bound
+
{{notations.duplicatedDomQueries}}
Duplicated DOM queries
{{notations.badPractices}}
-
Javascript bad practices
+
Evil Javascript
+
+
+
{{notations.jQueryLoading}}
+
jQuery version
diff --git a/app/public/scripts/resultsCtrl.js b/app/public/scripts/resultsCtrl.js index 29d9210..239b7f2 100644 --- a/app/public/scripts/resultsCtrl.js +++ b/app/public/scripts/resultsCtrl.js @@ -67,7 +67,9 @@ app.controller('ResultsCtrl', function ($scope) { domComplexity: 'A', domManipulations: 'A', duplicatedDomQueries: 'A', - badPractices: 'A' + eventsBound: 'A', + badPractices: 'A', + jQueryLoading: 'A' }; var domComplexityScore = $scope.phantomasResults.metrics.DOMelementsCount @@ -108,6 +110,23 @@ app.controller('ResultsCtrl', function ($scope) { $scope.notations.domManipulations = 'F'; } + var eventsBoundScore = $scope.phantomasResults.metrics.eventsBound; + if (eventsBoundScore > 50) { + $scope.notations.eventsBound = 'B'; + } + if (eventsBoundScore > 100) { + $scope.notations.eventsBound = 'C'; + } + if (eventsBoundScore > 200) { + $scope.notations.eventsBound = 'D'; + } + if (eventsBoundScore > 500) { + $scope.notations.eventsBound = 'E'; + } + if (eventsBoundScore > 1000) { + $scope.notations.eventsBound = 'F'; + } + var duplicatedDomQueries = $scope.duplicatedQueriesCountAll; if (duplicatedDomQueries > 20) { $scope.notations.duplicatedDomQueries = 'B'; @@ -144,6 +163,32 @@ app.controller('ResultsCtrl', function ($scope) { if (badPracticesScore > 40) { $scope.notations.badPractices = 'F'; } + + $scope.notations.jQueryLoading = 'NA'; + if ($scope.phantomasResults.metrics.jQueryDifferentVersions > 1) { + $scope.notations.jQueryLoading = 'F'; + } else if ($scope.phantomasResults.metrics.jQueryVersion) { + if ($scope.phantomasResults.metrics.jQueryVersion.indexOf('1.10.') === 0 + || $scope.phantomasResults.metrics.jQueryVersion.indexOf('1.11.') === 0 + || $scope.phantomasResults.metrics.jQueryVersion.indexOf('1.12.') === 0 + || $scope.phantomasResults.metrics.jQueryVersion.indexOf('2.0.') === 0 + || $scope.phantomasResults.metrics.jQueryVersion.indexOf('2.1.') === 0 + || $scope.phantomasResults.metrics.jQueryVersion.indexOf('2.2.') === 0) { + $scope.notations.jQueryLoading = 'A'; + } else if ($scope.phantomasResults.metrics.jQueryVersion.indexOf('1.8.') === 0 + || $scope.phantomasResults.metrics.jQueryVersion.indexOf('1.9.') === 0) { + $scope.notations.jQueryLoading = 'B'; + } else if ($scope.phantomasResults.metrics.jQueryVersion.indexOf('1.6.') === 0 + || $scope.phantomasResults.metrics.jQueryVersion.indexOf('1.7.') === 0) { + $scope.notations.jQueryLoading = 'C'; + } else if ($scope.phantomasResults.metrics.jQueryVersion.indexOf('1.4.') === 0 + || $scope.phantomasResults.metrics.jQueryVersion.indexOf('1.5.') === 0) { + $scope.notations.jQueryLoading = 'D'; + } else if ($scope.phantomasResults.metrics.jQueryVersion.indexOf('1.2.') === 0 + || $scope.phantomasResults.metrics.jQueryVersion.indexOf('1.3.') === 0) { + $scope.notations.jQueryLoading = 'E'; + } + } } function initExecutionView() {