-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp.js
89 lines (79 loc) · 2.36 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
(function () {
'use strict';
/* Handle nodejs exceptions */
if (typeof process != 'undefined') {
process.on('uncaughtException', function(err) {
console.log('Caught exception: ' + err);
});
}
var module = angular.module('WeP.base', [
'ngAnimate',
'ngSanitize',
'ngTouch',
'ngTable',
'ngRoute',
'ngCookies',
'ui.bootstrap',
'ui.validate',
'pascalprecht.translate',
'infinite-scroll',
'ngClipboard',
'noCAPTCHA'
]);
module.config(function(noCAPTCHAProvider, $translateProvider) {
noCAPTCHAProvider.setSiteKey('6Le7pBITAAAAANPHWrIsoP_ZvlxWr0bSjOPrlszc');
noCAPTCHAProvider.setTheme('light');
noCAPTCHAProvider.setLanguage($translateProvider.preferredLanguage());
});
module.run(function ($log, $rootScope, $translate, plugins, serverService) {
$log.log('WeP.base application started');
if (isNodeJS) {
var win = require('nw.gui').Window.get();
win.on('close', function (event) {
var self = this;
plugins.get('alerts').confirm({
title: 'Close WePesawallet',
message: 'Are you sure you want to exit WePesa?'
}).then(
function (confirmed) {
if (confirmed) {
var count = 0;
angular.forEach(['TYPE_NXT','TYPE_FIM'], function (id) {
if (serverService.isRunning(id)) {
serverService.addListener(id, 'exit', function () {
count--;
if (count == 0) {
self.close(true);
}
});
count++;
serverService.stopServer(id);
}
});
if (count == 0) {
self.hide();
self.close(true);
}
else {
plugins.get('alerts').wait({
title: "Please wait",
message: "Shutting down"
});
}
}
}
);
});
}
});
module.config(function($translateProvider, $httpProvider) {
$translateProvider.useSanitizeValueStrategy(null);
$translateProvider.useStaticFilesLoader({ prefix: './i18n/', suffix: '.json' });
$translateProvider.preferredLanguage('en');
$translateProvider.useLocalStorage();
delete $httpProvider.defaults.headers.common['X-Requested-With'];
});
module.config(['ngClipProvider', function(ngClipProvider) {
ngClipProvider.setPath("ZeroClipboard.swf");
}]);
})();