diff --git a/front/src/js/app.js b/front/src/js/app.js index 4fcfa1a..f981a02 100644 --- a/front/src/js/app.js +++ b/front/src/js/app.js @@ -22,6 +22,17 @@ yltApp.run(['$rootScope', '$location', function($rootScope, $location) { $rootScope.isTouchDevice = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(window.navigator.userAgent); $rootScope.loadedRunId = null; + var oldHash; + + // We don't want the hash to be kept between two pages + $rootScope.$on('$locationChangeStart', function(param1, param2, param3, param4){ + var newHash = $location.hash(); + if (newHash === oldHash) { + $location.hash(null); + } + oldHash = newHash; + }); + // Google Analytics $rootScope.$on('$routeChangeSuccess', function(){ ga('send', 'pageview', {'page': $location.path()}); diff --git a/front/src/js/controllers/timelineCtrl.js b/front/src/js/controllers/timelineCtrl.js index 0dac9eb..509774e 100644 --- a/front/src/js/controllers/timelineCtrl.js +++ b/front/src/js/controllers/timelineCtrl.js @@ -4,14 +4,6 @@ timelineCtrl.controller('TimelineCtrl', ['$scope', '$rootScope', '$routeParams', $scope.runId = $routeParams.runId; $scope.Menu = Menu.setCurrentPage('timeline', $scope.runId); - $scope.warningsFilterOn = false; - $scope.warningsFilters = { - queryWithoutResults: true, - jQueryCallOnEmptyObject: true, - eventNotDelegated: true, - jsError: true - }; - function loadResults() { // Load result if needed if (!$rootScope.loadedResult || $rootScope.loadedResult.runId !== $routeParams.runId) { @@ -27,12 +19,40 @@ timelineCtrl.controller('TimelineCtrl', ['$scope', '$rootScope', '$routeParams', } function render() { + initFilters(); initScriptFiltering(); initExecutionTree(); initTimeline(); $timeout(initProfiler, 100); } + function initFilters() { + var hash = $location.hash(); + var filter = null; + + if (hash.indexOf('filter=') === 0) { + filter = hash.substr(7); + } + + $scope.warningsFilterOn = (filter !== null); + $scope.warningsFilters = { + queryWithoutResults: (filter === null || filter === 'queryWithoutResults'), + jQueryCallOnEmptyObject: (filter === null || filter === 'jQueryCallOnEmptyObject'), + eventNotDelegated: (filter === null || filter === 'eventNotDelegated'), + jsError: (filter === null || filter === 'jsError') + }; + + // If a filter is defined in the hash (ie: "/result/xxxxx/timeline#filter=queryWithoutResults") + var hash = $location.hash(); + if (hash.indexOf('filter=') === 0) { + var filter = hash.substr(7); + $scope.warningsFilterOn = true; + for (var key in $scope.warningsFilter) { + + } + } + } + function initScriptFiltering() { var offenders = $scope.result.rules.jsCount.offendersObj.list; $scope.scripts = []; diff --git a/front/src/views/rule.html b/front/src/views/rule.html index 7f1b693..5a4c884 100644 --- a/front/src/views/rule.html +++ b/front/src/views/rule.html @@ -30,10 +30,6 @@
{{offender.id}}: {{offender.occurrences}} occurrences
- -
- {{offender.query}} (in ) using {{offender.fn}} -
{{offender.query}} (in ) using {{offender.fn}}: {{offender.count}} queries @@ -214,10 +210,15 @@
-

Offenders

+

{{rule.value}} offenders

Please open the JS timeline
+
+

{{rule.value}} offenders

+ Please open the JS timeline, filtered by "Queries without results" +
+

404

Rule "{{policyName}}"" not found diff --git a/lib/metadata/policies.js b/lib/metadata/policies.js index a0a2b19..8c44614 100644 --- a/lib/metadata/policies.js +++ b/lib/metadata/policies.js @@ -73,37 +73,16 @@ var policies = { "isOkThreshold": 50, "isBadThreshold": 1500, "isAbnormalThreshold": 3000, - "hasOffenders": true + "hasOffenders": false }, - "DOMqueriesWithoutResults": { - "tool": "phantomas", - "label": "DOM queries without result", - "message": "

Number of queries that return no result.

It suggests the query is not used on the page, probably because it is some dead code.

Or maybe the code is trying to find an HTML block that is not always here. Look at the JS Timeline to see if the scripts correctly figures out the HTML block is not here and immediatly stops interacting further with the DOM.

", + "queriesWithoutResults": { + "tool": "jsExecutionTransformer", + "label": "Queries without result", + "message": "

Number of queries that return no result. Both native and jQuery DOM requests are counted.

It suggests the query is not used on the page, probably because it is some dead code.

Or maybe the code is trying to find an HTML block that is not always here. Look at the JS Timeline to see if the scripts correctly figures out the HTML block is not here and immediatly stops interacting further with the DOM.

", "isOkThreshold": 0, "isBadThreshold": 100, "isAbnormalThreshold": 200, - "hasOffenders": true, - "offendersTransformFn": function(offenders) { - return { - count: offenders.length, - list: offenders.map(function(offender) { - var parts = /^(.*) ?\(in ?(.*)\) ?using ?(.*)$/.exec(offender); - - if (!parts) { - debug('DOMqueriesWithoutResults offenders transform function error with "%s"', offender); - return { - parseError: offender - }; - } - - return { - query: parts[1], - context: offendersHelpers.domPathToDomElementObj(parts[2]), - fn: parts[3] - }; - }) - }; - } + "hasOffenders": false }, "DOMqueriesAvoidable": { "tool": "phantomas", diff --git a/lib/metadata/scoreProfileGeneric.json b/lib/metadata/scoreProfileGeneric.json index b4be55e..77af6ee 100644 --- a/lib/metadata/scoreProfileGeneric.json +++ b/lib/metadata/scoreProfileGeneric.json @@ -13,7 +13,7 @@ "label": "DOM manipulations", "policies": { "DOMaccesses": 3, - "DOMqueriesWithoutResults": 1, + "queriesWithoutResults": 1, "DOMqueriesAvoidable": 1 } },