performance tab enable/disable persists with the cookie setting

test-unit-sauce
Brian Ford 12 years ago
parent bc238f9198
commit c7123216cc

@ -8,7 +8,7 @@ panelApp.filter('sortByTime', function () {
panelApp.controller('PerfCtrl', function PerfCtrl($scope, appContext, filesystem) { panelApp.controller('PerfCtrl', function PerfCtrl($scope, appContext, filesystem) {
$scope.enable = false; //$scope.enable = false;
$scope.histogram = []; $scope.histogram = [];
$scope.timeline = []; $scope.timeline = [];
@ -21,23 +21,25 @@ panelApp.controller('PerfCtrl', function PerfCtrl($scope, appContext, filesystem
filesystem.exportJSON('file.json', $scope.histogram); filesystem.exportJSON('file.json', $scope.histogram);
}; };
var first = true; appContext.getDebug(function (result) {
$scope.$watch('enable', function (newVal, oldVal) { $scope.enable = result;
// prevent refresh on initial pageload $scope.$watch('enable', function (newVal, oldVal) {
if (first) { // prevent refresh on initial pageload
first = false; if (first) {
} else { first = false;
appContext.setDebug(newVal); } else {
} appContext.setDebug(newVal);
if (newVal) { }
//updateTimeline(); if (newVal) {
updateHistogram(); //updateTimeline();
} updateHistogram();
}
});
}); });
$scope.log = false; var first = true;
$scope.$watch('log', function (newVal, oldVal) { $scope.$watch('log', function (newVal, oldVal) {
appContext.setLog(newVal); appContext.setLog(newVal);

@ -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 // takes a bool
setLog: function (setting) { setLog: function (setting) {
chromeExtension.eval('function (window) {' + chromeExtension.eval('function (window) {' +