-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathapp.js
69 lines (58 loc) · 2.05 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
angular.element(document.body).ready(function () {
angular.bootstrap(document.body, ['app'])
});
angular
.module('app', [
'ngRoute'
])
.component('app', {
templateUrl: 'app.html'
})
.config(routeConfig)
.run(run);
function routeConfig($locationProvider, $routeProvider) {
$locationProvider.hashPrefix('!');
$locationProvider.html5Mode({enabled: false, requireBase: false});
$routeProvider
.when('/', {template: '<intro-page></intro-page>', containerClass: 'container'})
.when('/hash', {template: '<hash-page></hash-page>', containerClass: 'container'})
.when('/block', {template: '<block-page></block-page>', containerClass: 'container'})
.when('/blockchain', {template: '<blockchain-page></blockchain-page>', containerClass: 'container-fluid'})
.when('/distributed', {template: '<distributed-page></distributed-page>', containerClass: 'container-fluid'})
.when('/tokens', {template: '<tokens-page></tokens-page>', containerClass: 'container-fluid'})
.when('/coinbase', {template: '<coinbase-page></coinbase-page>', containerClass: 'container-fluid'})
.otherwise({redirectTo: '/'})
}
function run($location, $rootScope, $route) {
var id = 0;
$rootScope.difficulty = 4;
$rootScope.$route = $route;
$rootScope.sha256 = function (input) {
return CryptoJS.SHA256(input).toString();
};
$rootScope.isActive = function (route) {
return route === $location.path();
};
$rootScope.newId = function () {
return (id++);
};
$rootScope.difficultyPrefix = function (difficulty) {
var diff = difficulty || $rootScope.difficulty;
var result = '';
for (var i = 1; i <= diff; i++) {
result += '0';
}
return result;
};
$rootScope.formatString = function (str) {
var args = [].slice.call(arguments, 1),
i = 0;
return str.replace(/%s/g, function () {
return args[i++];
});
};
$rootScope.round = function (number, digits) {
var exp = Math.pow(10, digits);
return (Math.round(number * exp) / exp).toString().replace(/\B(?=(\d{3})+(?!\d))/g, '\'');
};
}