app.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. var yltApp = angular.module('YellowLabTools', [
  2. 'ngRoute',
  3. 'ngSanitize',
  4. 'ngAnimate',
  5. 'indexCtrl',
  6. 'dashboardCtrl',
  7. 'queueCtrl',
  8. 'ruleCtrl',
  9. 'screenshotCtrl',
  10. 'timelineCtrl',
  11. 'runsFactory',
  12. 'resultsFactory',
  13. 'apiService',
  14. 'menuService',
  15. 'settingsService',
  16. 'gradeDirective',
  17. 'offendersDirectives',
  18. 'LocalStorageModule'
  19. ]);
  20. yltApp.run(['$rootScope', '$location', function($rootScope, $location) {
  21. $rootScope.isTouchDevice = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(window.navigator.userAgent);
  22. $rootScope.loadedRunId = null;
  23. var oldHash;
  24. // We don't want the hash to be kept between two pages
  25. $rootScope.$on('$locationChangeStart', function(param1, param2, param3, param4){
  26. var newHash = $location.hash();
  27. if (newHash === oldHash) {
  28. $location.hash(null);
  29. }
  30. oldHash = newHash;
  31. });
  32. // Google Analytics
  33. $rootScope.$on('$routeChangeSuccess', function(){
  34. if (ga) {
  35. ga('send', 'pageview', {'page': $location.path()});
  36. }
  37. });
  38. // GitHub star button (asynchronously loaded iframe)
  39. window.addEventListener('load', function() {
  40. window.document.getElementById('ghbtn').src = 'https://ghbtns.com/github-btn.html?user=gmetais&repo=YellowLabTools&type=star&count=true&size=large';
  41. });
  42. }]);
  43. yltApp.config(['$routeProvider', '$locationProvider',
  44. function($routeProvider, $locationProvider) {
  45. $routeProvider.
  46. when('/', {
  47. templateUrl: 'views/index.html',
  48. controller: 'IndexCtrl'
  49. }).
  50. when('/queue/:runId', {
  51. templateUrl: 'views/queue.html',
  52. controller: 'QueueCtrl'
  53. }).
  54. when('/about', {
  55. templateUrl: 'views/about.html'
  56. }).
  57. when('/result/:runId', {
  58. templateUrl: 'views/dashboard.html',
  59. controller: 'DashboardCtrl'
  60. }).
  61. when('/result/:runId/timeline', {
  62. templateUrl: 'views/timeline.html',
  63. controller: 'TimelineCtrl'
  64. }).
  65. when('/result/:runId/screenshot', {
  66. templateUrl: 'views/screenshot.html',
  67. controller: 'ScreenshotCtrl'
  68. }).
  69. when('/result/:runId/rule/:policy', {
  70. templateUrl: 'views/rule.html',
  71. controller: 'RuleCtrl'
  72. }).
  73. otherwise({
  74. redirectTo: '/'
  75. });
  76. $locationProvider.html5Mode(true);
  77. }
  78. ]);
  79. // Disable debugging https://docs.angularjs.org/guide/production
  80. yltApp.config(['$compileProvider', function ($compileProvider) {
  81. $compileProvider.debugInfoEnabled(false);
  82. }]);