From c7123216cc5b0b313a0a6ae80f98f72540f6b0eb Mon Sep 17 00:00:00 2001 From: Brian Ford Date: Tue, 10 Jul 2012 14:08:32 -0700 Subject: [PATCH] performance tab enable/disable persists with the cookie setting --- js/controllers/PerfCtrl.js | 32 +++++++++++++++++--------------- js/services/appContext.js | 6 ++++++ 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/js/controllers/PerfCtrl.js b/js/controllers/PerfCtrl.js index c3aea93..82ff328 100644 --- a/js/controllers/PerfCtrl.js +++ b/js/controllers/PerfCtrl.js @@ -8,7 +8,7 @@ panelApp.filter('sortByTime', function () { panelApp.controller('PerfCtrl', function PerfCtrl($scope, appContext, filesystem) { - $scope.enable = false; + //$scope.enable = false; $scope.histogram = []; $scope.timeline = []; @@ -21,23 +21,25 @@ panelApp.controller('PerfCtrl', function PerfCtrl($scope, appContext, filesystem filesystem.exportJSON('file.json', $scope.histogram); }; - var first = true; - $scope.$watch('enable', function (newVal, oldVal) { + appContext.getDebug(function (result) { + $scope.enable = result; - // prevent refresh on initial pageload - if (first) { - first = false; - } else { - appContext.setDebug(newVal); - } - if (newVal) { - //updateTimeline(); - updateHistogram(); - } + $scope.$watch('enable', function (newVal, oldVal) { + // prevent refresh on initial pageload + if (first) { + first = false; + } else { + appContext.setDebug(newVal); + } + if (newVal) { + //updateTimeline(); + updateHistogram(); + } + }); }); - $scope.log = false; - + var first = true; + $scope.$watch('log', function (newVal, oldVal) { appContext.setLog(newVal); diff --git a/js/services/appContext.js b/js/services/appContext.js index fc57260..ff8e18c 100644 --- a/js/services/appContext.js +++ b/js/services/appContext.js @@ -265,6 +265,12 @@ panelApp.factory('appContext', function(chromeExtension) { } }, + getDebug: function (cb) { + chromeExtension.eval(function (window) { + return document.cookie.indexOf('__ngDebug=true') != -1; + }, cb); + }, + // takes a bool setLog: function (setting) { chromeExtension.eval('function (window) {' +