futher refactoring or services
parent
fd7ac46a12
commit
34adac7951
@ -1,6 +1,9 @@
|
||||
panelApp.controller('DepsCtrl', function DepsCtrl($scope, appContext) {
|
||||
appContext.watchPoll(function () {
|
||||
$scope.deps = appContext.getDeps();
|
||||
panelApp.controller('DepsCtrl', function DepsCtrl($scope, appDeps, poll) {
|
||||
$scope.$on('poll', function () {
|
||||
appDeps.get(function (deps) {
|
||||
$scope.$apply(function () {
|
||||
$scope.deps = deps;
|
||||
});
|
||||
});
|
||||
});
|
||||
$scope.deps = appContext.getDeps();
|
||||
});
|
||||
|
@ -0,0 +1,26 @@
|
||||
// Service for retrieving and caching application dependencies
|
||||
panelApp.factory('appDeps', function (chromeExtension, appContext) {
|
||||
|
||||
var _depsCache = [];
|
||||
|
||||
// clear cache on page refresh
|
||||
appContext.watchRefresh(function () {
|
||||
_depsCache = [];
|
||||
});
|
||||
|
||||
return {
|
||||
get: function (callback) {
|
||||
chromeExtension.eval(function (window) {
|
||||
if (window.__ngDebug) {
|
||||
return window.__ngDebug.getDeps();
|
||||
}
|
||||
},
|
||||
function (data) {
|
||||
if (data) {
|
||||
_depsCache = data;
|
||||
}
|
||||
callback(_depsCache);
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
@ -0,0 +1,67 @@
|
||||
// Service for running code in the context of the application being debugged
|
||||
panelApp.factory('appInfo', function (chromeExtension, appContext) {
|
||||
|
||||
var _versionCache = null,
|
||||
_srcCache = null;
|
||||
|
||||
// clear cache on page refresh
|
||||
appContext.watchRefresh(function () {
|
||||
_versionCache = null;
|
||||
_srcCache = null;
|
||||
});
|
||||
|
||||
return {
|
||||
getAngularVersion: function (callback) {
|
||||
if (_versionCache) {
|
||||
setTimeout(function () {
|
||||
callback(_versionCache);
|
||||
}, 0);
|
||||
} else {
|
||||
chromeExtension.eval(function () {
|
||||
return window.angular.version.full +
|
||||
' ' +
|
||||
window.angular.version.codeName;
|
||||
}, function (data) {
|
||||
_versionCache = data;
|
||||
callback(_versionCache);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
getAngularSrc: function (callback) {
|
||||
if (_srcCache) {
|
||||
setTimeout(function () {
|
||||
callback(_srcCache);
|
||||
}, 0);
|
||||
} else {
|
||||
chromeExtension.eval(function (window, args) {
|
||||
if (!window.angular) {
|
||||
return 'info';
|
||||
}
|
||||
var elts = window.angular.element('script[src]');
|
||||
var re = /\/angular(-\d+(\.(\d+))+(rc)?)?(\.min)?\.js$/;
|
||||
var elt;
|
||||
for (i = 0; i < elts.length; i++) {
|
||||
elt = elts[i];
|
||||
if (re.exec(elt.src)) {
|
||||
if (elt.src.indexOf('code.angularjs.org') !== -1) {
|
||||
return 'error';
|
||||
} else if (elt.src.indexOf('ajax.googleapis.com') !== -1) {
|
||||
return 'good';
|
||||
} else {
|
||||
return 'info';
|
||||
}
|
||||
}
|
||||
}
|
||||
return 'info';
|
||||
}, function (src) {
|
||||
if (src) {
|
||||
_srcCache = src;
|
||||
}
|
||||
callback(_srcCache);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
});
|
@ -0,0 +1,44 @@
|
||||
// Service for running code in the context of the application being debugged
|
||||
panelApp.factory('appModel', function (chromeExtension, appContext) {
|
||||
|
||||
var _scopeCache = {},
|
||||
_rootScopeCache = [];
|
||||
|
||||
|
||||
// clear cache on page refresh
|
||||
appContext.watchRefresh(function () {
|
||||
_scopeCache = {};
|
||||
_rootScopeCache = [];
|
||||
});
|
||||
|
||||
return {
|
||||
getRootScopes: function (callback) {
|
||||
chromeExtension.eval(function (window) {
|
||||
if (!window.__ngDebug) {
|
||||
return;
|
||||
}
|
||||
return window.__ngDebug.getRootScopeIds();
|
||||
},
|
||||
function (data) {
|
||||
if (data) {
|
||||
_rootScopeCache = data;
|
||||
}
|
||||
callback(_rootScopeCache);
|
||||
});
|
||||
},
|
||||
|
||||
getModelTree: function (id, callback) {
|
||||
if (!id) {
|
||||
return;
|
||||
}
|
||||
chromeExtension.eval(function (window, args) {
|
||||
return window.__ngDebug.getScopeTree(args.id);
|
||||
}, {id: id}, function (tree) {
|
||||
if (tree) {
|
||||
_scopeCache[id] = tree;
|
||||
}
|
||||
callback(_scopeCache[id]);
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
@ -0,0 +1,22 @@
|
||||
// Service for running code in the context of the application being debugged
|
||||
panelApp.factory('appWatch', function (chromeExtension) {
|
||||
|
||||
var _watchCache = {};
|
||||
|
||||
// Public API
|
||||
// ==========
|
||||
return {
|
||||
|
||||
getWatchTree: function (id, callback) {
|
||||
chromeExtension.eval("function (window, args) {" +
|
||||
"return window.__ngDebug.getWatchTree(args.id);" +
|
||||
"}", {id: id}, function (tree) {
|
||||
if (tree) {
|
||||
_watchCache[id] = tree;
|
||||
}
|
||||
callback(_watchCache[id]);
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
});
|
@ -0,0 +1,11 @@
|
||||
// Service for broadcasting poll events
|
||||
panelApp.factory('poll', function ($rootScope) {
|
||||
|
||||
setInterval(function () {
|
||||
$rootScope.$broadcast('poll');
|
||||
}, 500);
|
||||
|
||||
return {
|
||||
setInterval: function (int) {}
|
||||
};
|
||||
});
|
Reference in New Issue