run js-beautify on everything
...with two spaces. Command: js-beautify -s 2 -r [filename]
This commit is contained in:
parent
da445e7c69
commit
ea2e2d4e19
49 changed files with 859 additions and 682 deletions
|
|
@ -6,7 +6,7 @@ var BackupService = function(notification) {
|
|||
};
|
||||
|
||||
BackupService.prototype.getName = function(wallet) {
|
||||
return (wallet.name ? (wallet.name+'-') : '') + wallet.id;
|
||||
return (wallet.name ? (wallet.name + '-') : '') + wallet.id;
|
||||
};
|
||||
|
||||
BackupService.prototype.download = function(wallet) {
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ angular.module('copayApp.services')
|
|||
});
|
||||
}, 3000);
|
||||
});
|
||||
w.on('txProposalEvent', function(e){
|
||||
w.on('txProposalEvent', function(e) {
|
||||
switch (e.type) {
|
||||
case 'signed':
|
||||
var user = w.publicKeyRing.nicknameForCopayer(e.cId);
|
||||
|
|
@ -297,7 +297,7 @@ angular.module('copayApp.services')
|
|||
Socket.emit('subscribe', 'inv');
|
||||
Socket.on('block', function(block) {
|
||||
root.updateBalance(function() {
|
||||
$rootScope.$digest();
|
||||
$rootScope.$digest();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,19 +3,19 @@
|
|||
// Detect mobile devices
|
||||
var isMobile = {
|
||||
Android: function() {
|
||||
return !! navigator.userAgent.match(/Android/i);
|
||||
return !!navigator.userAgent.match(/Android/i);
|
||||
},
|
||||
BlackBerry: function() {
|
||||
return !! navigator.userAgent.match(/BlackBerry/i);
|
||||
return !!navigator.userAgent.match(/BlackBerry/i);
|
||||
},
|
||||
iOS: function() {
|
||||
return !! navigator.userAgent.match(/iPhone|iPad|iPod/i);
|
||||
return !!navigator.userAgent.match(/iPhone|iPad|iPod/i);
|
||||
},
|
||||
Opera: function() {
|
||||
return !! navigator.userAgent.match(/Opera Mini/i);
|
||||
return !!navigator.userAgent.match(/Opera Mini/i);
|
||||
},
|
||||
Windows: function() {
|
||||
return !! navigator.userAgent.match(/IEMobile/i);
|
||||
return !!navigator.userAgent.match(/IEMobile/i);
|
||||
},
|
||||
any: function() {
|
||||
return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
|
||||
|
|
|
|||
|
|
@ -1,40 +1,61 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.services').
|
||||
factory('notification', ['$timeout',function($timeout){
|
||||
factory('notification', ['$timeout',
|
||||
function($timeout) {
|
||||
|
||||
var notifications = JSON.parse(localStorage.getItem('notifications')) || [],
|
||||
queue = [];
|
||||
queue = [];
|
||||
|
||||
var settings = {
|
||||
info: { duration: 5000, enabled: true },
|
||||
funds: { duration: 5000, enabled: true },
|
||||
warning: { duration: 5000, enabled: true },
|
||||
error: { duration: 1e10, enabled: true },
|
||||
success: { duration: 5000, enabled: true },
|
||||
progress: { duration: 0, enabled: true },
|
||||
custom: { duration: 35000, enabled: true },
|
||||
info: {
|
||||
duration: 5000,
|
||||
enabled: true
|
||||
},
|
||||
funds: {
|
||||
duration: 5000,
|
||||
enabled: true
|
||||
},
|
||||
warning: {
|
||||
duration: 5000,
|
||||
enabled: true
|
||||
},
|
||||
error: {
|
||||
duration: 1e10,
|
||||
enabled: true
|
||||
},
|
||||
success: {
|
||||
duration: 5000,
|
||||
enabled: true
|
||||
},
|
||||
progress: {
|
||||
duration: 0,
|
||||
enabled: true
|
||||
},
|
||||
custom: {
|
||||
duration: 35000,
|
||||
enabled: true
|
||||
},
|
||||
details: true,
|
||||
localStorage: false,
|
||||
html5Mode: false,
|
||||
html5DefaultIcon: 'img/favicon.ico'
|
||||
};
|
||||
|
||||
function html5Notify(icon, title, content, ondisplay, onclose){
|
||||
if(window.webkitNotifications.checkPermission() === 0){
|
||||
if(!icon){
|
||||
function html5Notify(icon, title, content, ondisplay, onclose) {
|
||||
if (window.webkitNotifications.checkPermission() === 0) {
|
||||
if (!icon) {
|
||||
icon = 'img/favicon.ico';
|
||||
}
|
||||
var noti = window.webkitNotifications.createNotification(icon, title, content);
|
||||
if(typeof ondisplay === 'function'){
|
||||
if (typeof ondisplay === 'function') {
|
||||
noti.ondisplay = ondisplay;
|
||||
}
|
||||
if(typeof onclose === 'function'){
|
||||
if (typeof onclose === 'function') {
|
||||
noti.onclose = onclose;
|
||||
}
|
||||
noti.show();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
settings.html5Mode = false;
|
||||
}
|
||||
}
|
||||
|
|
@ -44,53 +65,50 @@ angular.module('copayApp.services').
|
|||
|
||||
/* ========== SETTINGS RELATED METHODS =============*/
|
||||
|
||||
disableHtml5Mode: function(){
|
||||
disableHtml5Mode: function() {
|
||||
settings.html5Mode = false;
|
||||
},
|
||||
|
||||
disableType: function(notificationType){
|
||||
disableType: function(notificationType) {
|
||||
settings[notificationType].enabled = false;
|
||||
},
|
||||
|
||||
enableHtml5Mode: function(){
|
||||
enableHtml5Mode: function() {
|
||||
// settings.html5Mode = true;
|
||||
settings.html5Mode = this.requestHtml5ModePermissions();
|
||||
},
|
||||
|
||||
enableType: function(notificationType){
|
||||
enableType: function(notificationType) {
|
||||
settings[notificationType].enabled = true;
|
||||
},
|
||||
|
||||
getSettings: function(){
|
||||
getSettings: function() {
|
||||
return settings;
|
||||
},
|
||||
|
||||
toggleType: function(notificationType){
|
||||
toggleType: function(notificationType) {
|
||||
settings[notificationType].enabled = !settings[notificationType].enabled;
|
||||
},
|
||||
|
||||
toggleHtml5Mode: function(){
|
||||
toggleHtml5Mode: function() {
|
||||
settings.html5Mode = !settings.html5Mode;
|
||||
},
|
||||
|
||||
requestHtml5ModePermissions: function(){
|
||||
if (window.webkitNotifications){
|
||||
requestHtml5ModePermissions: function() {
|
||||
if (window.webkitNotifications) {
|
||||
if (window.webkitNotifications.checkPermission() === 0) {
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
window.webkitNotifications.requestPermission(function(){
|
||||
if(window.webkitNotifications.checkPermission() === 0){
|
||||
} else {
|
||||
window.webkitNotifications.requestPermission(function() {
|
||||
if (window.webkitNotifications.checkPermission() === 0) {
|
||||
settings.html5Mode = true;
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
settings.html5Mode = false;
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
|
@ -98,38 +116,38 @@ angular.module('copayApp.services').
|
|||
|
||||
/* ============ QUERYING RELATED METHODS ============*/
|
||||
|
||||
getAll: function(){
|
||||
getAll: function() {
|
||||
// Returns all notifications that are currently stored
|
||||
return notifications;
|
||||
},
|
||||
|
||||
getQueue: function(){
|
||||
getQueue: function() {
|
||||
return queue;
|
||||
},
|
||||
|
||||
/* ============== NOTIFICATION METHODS ==============*/
|
||||
|
||||
info: function(title, content, userData){
|
||||
info: function(title, content, userData) {
|
||||
return this.awesomeNotify('info', 'info', title, content, userData);
|
||||
},
|
||||
|
||||
funds: function(title, content, userData){
|
||||
|
||||
funds: function(title, content, userData) {
|
||||
return this.awesomeNotify('funds', 'bitcoin', title, content, userData);
|
||||
},
|
||||
|
||||
error: function(title, content, userData){
|
||||
error: function(title, content, userData) {
|
||||
return this.awesomeNotify('error', 'x', title, content, userData);
|
||||
},
|
||||
|
||||
success: function(title, content, userData){
|
||||
success: function(title, content, userData) {
|
||||
return this.awesomeNotify('success', 'check', title, content, userData);
|
||||
},
|
||||
|
||||
warning: function(title, content, userData){
|
||||
warning: function(title, content, userData) {
|
||||
return this.awesomeNotify('warning', 'alert', title, content, userData);
|
||||
},
|
||||
|
||||
awesomeNotify: function(type, icon, title, content, userData){
|
||||
awesomeNotify: function(type, icon, title, content, userData) {
|
||||
/**
|
||||
* Supposed to wrap the makeNotification method for drawing icons using font-awesome
|
||||
* rather than an image.
|
||||
|
|
@ -143,13 +161,13 @@ angular.module('copayApp.services').
|
|||
return this.makeNotification(type, false, icon, title, content, userData);
|
||||
},
|
||||
|
||||
notify: function(image, title, content, userData){
|
||||
notify: function(image, title, content, userData) {
|
||||
// Wraps the makeNotification method for displaying notifications with images
|
||||
// rather than icons
|
||||
return this.makeNotification('custom', image, true, title, content, userData);
|
||||
},
|
||||
|
||||
makeNotification: function(type, image, icon, title, content, userData){
|
||||
makeNotification: function(type, image, icon, title, content, userData) {
|
||||
var notification = {
|
||||
'type': type,
|
||||
'image': image,
|
||||
|
|
@ -161,16 +179,15 @@ angular.module('copayApp.services').
|
|||
};
|
||||
notifications.push(notification);
|
||||
|
||||
if(settings.html5Mode){
|
||||
html5Notify(image, title, content, function(){
|
||||
if (settings.html5Mode) {
|
||||
html5Notify(image, title, content, function() {
|
||||
// inner on display function
|
||||
}, function(){
|
||||
}, function() {
|
||||
// inner on close function
|
||||
});
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
queue.push(notification);
|
||||
$timeout(function removeFromQueueTimeout(){
|
||||
$timeout(function removeFromQueueTimeout() {
|
||||
queue.splice(queue.indexOf(notification), 1);
|
||||
}, settings[type].duration);
|
||||
|
||||
|
|
@ -183,80 +200,77 @@ angular.module('copayApp.services').
|
|||
|
||||
/* ============ PERSISTENCE METHODS ============ */
|
||||
|
||||
save: function(){
|
||||
save: function() {
|
||||
// Save all the notifications into localStorage
|
||||
if(settings.localStorage){
|
||||
if (settings.localStorage) {
|
||||
localStorage.setItem('notifications', JSON.stringify(notifications));
|
||||
}
|
||||
},
|
||||
|
||||
restore: function(){
|
||||
restore: function() {
|
||||
// Load all notifications from localStorage
|
||||
},
|
||||
|
||||
clear: function(){
|
||||
clear: function() {
|
||||
notifications = [];
|
||||
this.save();
|
||||
}
|
||||
|
||||
};
|
||||
}]).
|
||||
directive('notifications', function(notification, $compile){
|
||||
/**
|
||||
*
|
||||
* It should also parse the arguments passed to it that specify
|
||||
* its position on the screen like "bottom right" and apply those
|
||||
* positions as a class to the container element
|
||||
*
|
||||
* Finally, the directive should have its own controller for
|
||||
* handling all of the notifications from the notification service
|
||||
*/
|
||||
var html =
|
||||
'<div class="dr-notification-wrapper" ng-repeat="noti in queue">' +
|
||||
'<div class="dr-notification-close-btn" ng-click="removeNotification(noti)">' +
|
||||
'<i class="fi-x"></i>' +
|
||||
'</div>' +
|
||||
'<div class="dr-notification">' +
|
||||
'<div class="dr-notification-image dr-notification-type-{{noti.type}}" ng-switch on="noti.image">' +
|
||||
'<i class="fi-{{noti.icon}}" ng-switch-when="false"></i>' +
|
||||
'<img ng-src="{{noti.image}}" ng-switch-default />' +
|
||||
'</div>' +
|
||||
'<div class="dr-notification-content">' +
|
||||
'<h3 class="dr-notification-title">{{noti.title}}</h3>' +
|
||||
'<p class="dr-notification-text">{{noti.content}}</p>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</div>';
|
||||
}
|
||||
]).
|
||||
directive('notifications', function(notification, $compile) {
|
||||
/**
|
||||
*
|
||||
* It should also parse the arguments passed to it that specify
|
||||
* its position on the screen like "bottom right" and apply those
|
||||
* positions as a class to the container element
|
||||
*
|
||||
* Finally, the directive should have its own controller for
|
||||
* handling all of the notifications from the notification service
|
||||
*/
|
||||
var html =
|
||||
'<div class="dr-notification-wrapper" ng-repeat="noti in queue">' +
|
||||
'<div class="dr-notification-close-btn" ng-click="removeNotification(noti)">' +
|
||||
'<i class="fi-x"></i>' +
|
||||
'</div>' +
|
||||
'<div class="dr-notification">' +
|
||||
'<div class="dr-notification-image dr-notification-type-{{noti.type}}" ng-switch on="noti.image">' +
|
||||
'<i class="fi-{{noti.icon}}" ng-switch-when="false"></i>' +
|
||||
'<img ng-src="{{noti.image}}" ng-switch-default />' +
|
||||
'</div>' +
|
||||
'<div class="dr-notification-content">' +
|
||||
'<h3 class="dr-notification-title">{{noti.title}}</h3>' +
|
||||
'<p class="dr-notification-text">{{noti.content}}</p>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</div>';
|
||||
|
||||
|
||||
function link(scope, element, attrs){
|
||||
var position = attrs.notifications;
|
||||
position = position.split(' ');
|
||||
element.addClass('dr-notification-container');
|
||||
for(var i = 0; i < position.length ; i++){
|
||||
element.addClass(position[i]);
|
||||
}
|
||||
function link(scope, element, attrs) {
|
||||
var position = attrs.notifications;
|
||||
position = position.split(' ');
|
||||
element.addClass('dr-notification-container');
|
||||
for (var i = 0; i < position.length; i++) {
|
||||
element.addClass(position[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return {
|
||||
restrict: 'A',
|
||||
scope: {},
|
||||
template: html,
|
||||
link: link,
|
||||
controller: ['$scope', function NotificationsCtrl( $scope ){
|
||||
return {
|
||||
restrict: 'A',
|
||||
scope: {},
|
||||
template: html,
|
||||
link: link,
|
||||
controller: ['$scope',
|
||||
function NotificationsCtrl($scope) {
|
||||
$scope.queue = notification.getQueue();
|
||||
|
||||
$scope.removeNotification = function(noti){
|
||||
$scope.removeNotification = function(noti) {
|
||||
$scope.queue.splice($scope.queue.indexOf(noti), 1);
|
||||
};
|
||||
}
|
||||
]
|
||||
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -38,8 +38,12 @@ angular.module('copayApp.services').factory('Socket',
|
|||
var ret = {};
|
||||
|
||||
var addrList = listeners
|
||||
.filter(function(i) { return i.event != 'block'; })
|
||||
.map(function(i) {return i.event;});
|
||||
.filter(function(i) {
|
||||
return i.event != 'block';
|
||||
})
|
||||
.map(function(i) {
|
||||
return i.event;
|
||||
});
|
||||
|
||||
for (var i in addrList) {
|
||||
ret[addrList[i]] = 1;
|
||||
|
|
@ -47,7 +51,9 @@ angular.module('copayApp.services').factory('Socket',
|
|||
return ret;
|
||||
},
|
||||
isListeningBlocks: function() {
|
||||
return listeners.filter(function(i) { return i.event == 'block'; }).length > 0;
|
||||
return listeners.filter(function(i) {
|
||||
return i.event == 'block';
|
||||
}).length > 0;
|
||||
},
|
||||
emit: function(event, data, callback) {
|
||||
socket.emit(event, data, function() {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.services').value('walletFactory', new copay.WalletFactory(config, copay.version));
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue