xenia/debugger/assets/ui/code/code-tab.js

68 lines
1.8 KiB
JavaScript
Raw Normal View History

2013-12-22 08:21:35 +00:00
/**
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2013 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
'use strict';
var module = angular.module('xe.ui.code', [
'xe.log',
'xe.session'
]);
module.controller('CodeTabController', function(
$rootScope, $scope, app, log) {
2013-12-22 10:59:42 +00:00
$scope.moduleList = [];
$scope.selectedModule = null;
$scope.functionList = [];
2013-12-22 08:21:35 +00:00
function refresh() {
if (!app.session || !app.session.dataSource) {
$scope.moduleList = [];
return;
}
2013-12-22 08:21:35 +00:00
var dataSource = app.session.dataSource;
dataSource.getModuleList().then(function(list) {
2013-12-22 10:59:42 +00:00
$scope.moduleList = list;
if (!$scope.selectedModule) {
if (list.length) {
$scope.selectModule(list[0]);
}
} else {
$scope.selectModule($scope.selectedModule);
}
2013-12-22 08:21:35 +00:00
}, function(e) {
2013-12-22 10:59:42 +00:00
log.error('Unable to fetch module list');
2013-12-22 08:21:35 +00:00
});
console.log('refresh');
};
$rootScope.$on('refresh', refresh);
2013-12-22 10:59:42 +00:00
$scope.selectModule = function(module) {
var moduleChange = module != $scope.selectedModule;
$scope.selectedModule = module;
if (moduleChange) {
$scope.functionList = [];
}
var dataSource = app.session.dataSource;
dataSource.getFunctionList(module.name).then(function(list) {
$scope.functionList = list;
}, function(e) {
log.error('Unable to fetch function list');
});
};
if (app.session.dataSource) {
refresh();
}
2013-12-22 08:21:35 +00:00
});