diff --git a/www/i18n/locale-en.json b/www/i18n/locale-en.json index b78afa8c784f1522d6a79609d1b1e9752fd43718..5096ba86b515f1048a2da7f98cd75fe530cb444a 100644 --- a/www/i18n/locale-en.json +++ b/www/i18n/locale-en.json @@ -36,11 +36,11 @@ }, "CURRENCY": { "SELECT": { - "TITLE": "Explore", + "TITLE": "Currencies", "CURRENCIES": "Known currencies" }, "VIEW": { - "TITLE": "Explore", + "TITLE": "Currency", "TAB_CURRENCY": "Currency", "TAB_WOT": "Community", "TAB_NETWORK": "Network", diff --git a/www/i18n/locale-fr-FR.json b/www/i18n/locale-fr-FR.json index 035d378498abaa11d7308669436681036351493a..d797d4788aab7757ebd9b6405afcef175a4c753a 100644 --- a/www/i18n/locale-fr-FR.json +++ b/www/i18n/locale-fr-FR.json @@ -37,11 +37,11 @@ }, "CURRENCY": { "SELECT": { - "TITLE": "Explorer", + "TITLE": "Monnaies", "CURRENCIES": "Monnaies connues" }, "VIEW": { - "TITLE": "Explorer", + "TITLE": "Monnaie", "TAB_CURRENCY": "Monnaie", "TAB_WOT": "Communauté", "TAB_NETWORK": "Réseau", diff --git a/www/js/config.js b/www/js/config.js index 437d7cce65fa81eac0d849c9ff8363fdf87eb156..a9011c9ff73f490957749ae6413ba83cebfca2ee 100644 --- a/www/js/config.js +++ b/www/js/config.js @@ -10,9 +10,8 @@ angular.module("cesium.config", []) .constant("APP_CONFIG", { "UCOIN_NODE": "twiced.fr:9330", - "UCOIN_NODE_ES": "es.ucoin.fr", "VERSION": "0.0.1", - "BUILD_DATE": "2016-04-15T16:07:41.437Z" + "BUILD_DATE": "2016-04-16T10:55:03.367Z" }) ; \ No newline at end of file diff --git a/www/js/controllers/app-controllers.js b/www/js/controllers/app-controllers.js index 8a4d557ce4306bf939a933a7a2b611b28c33cdfc..d1a472cf0ce4939b23efeb55a983136ed44e2207 100644 --- a/www/js/controllers/app-controllers.js +++ b/www/js/controllers/app-controllers.js @@ -177,8 +177,10 @@ function LoginController($scope, $ionicModal, Wallet, CryptoUtils, UIUtils, $q, } -function AppController($scope, $ionicModal, $state, $ionicSideMenuDelegate, UIUtils, $q, $timeout, CryptoUtils, BMA, Wallet, Registry, APP_CONFIG, ionicMaterialInk, $ionicHistory, - $cordovaClipboard) { +function AppController($scope, $ionicModal, $state, $ionicSideMenuDelegate, UIUtils, $q, $timeout, + CryptoUtils, BMA, Wallet, Registry, APP_CONFIG, ionicMaterialInk, $ionicHistory, + $cordovaClipboard, + $cordovaBarcodeScanner) { // With the new view caching in Ionic, Controllers are only called // when they are recreated or on app start, instead of every page change. @@ -204,7 +206,7 @@ function AppController($scope, $ionicModal, $state, $ionicSideMenuDelegate, UIUt LoginController.call(this, $scope, $ionicModal, Wallet, CryptoUtils, UIUtils, $q, $state, $timeout, $ionicSideMenuDelegate, $ionicHistory); - TransferModalController.call(this, $scope, $ionicModal, $state, BMA, Wallet, UIUtils, ionicMaterialInk); + TransferModalController.call(this, $scope, $ionicModal, $state, BMA, Wallet, UIUtils, ionicMaterialInk, $cordovaBarcodeScanner, $timeout); //////////////////////////////////////// // Load currencies diff --git a/www/js/controllers/currency-controllers.js b/www/js/controllers/currency-controllers.js index a4a085a237d52d01c05bcd81b810bc292f990699..7f60aaeaa96dfcf56568efbfd4a9c81bc2245f6a 100644 --- a/www/js/controllers/currency-controllers.js +++ b/www/js/controllers/currency-controllers.js @@ -84,14 +84,20 @@ function CurrencyLookupController($scope, $state, $q, $timeout, UIUtils, APP_CON }; } -function CurrencyViewController($scope, $rootScope, $state, BMA, $q, UIUtils, $interval, $timeout, Registry, ionicMaterialInk) { +function CurrencyViewController($scope, $rootScope, $state, BMA, $q, UIUtils, $interval, $timeout, Registry, ionicMaterialInk, $cordovaBarcodeScanner) { var USE_RELATIVE_DEFAULT = true; - WotLookupController.call(this, $scope, BMA, $state); + WotLookupController.call(this, $scope, BMA, $state, $cordovaBarcodeScanner, UIUtils, $timeout); PeersController.call(this, $scope, $rootScope, BMA, UIUtils, $q, $interval, $timeout); - $scope.search = { text: '', results: {} }; + $scope.search = { + text: '', + results: {}, + options: { + listInset: true + } + }; $scope.formData = { useRelative: false }; $scope.knownBlocks = []; $scope.id = null; diff --git a/www/js/controllers/registry-controllers.js b/www/js/controllers/registry-controllers.js index fc32ce36afca47cacc30a17d5af5a6ed61495aa4..285efbfdefc1998c95b4b331387d3389d8ab997c 100644 --- a/www/js/controllers/registry-controllers.js +++ b/www/js/controllers/registry-controllers.js @@ -193,10 +193,10 @@ function RegistryLookupController($scope, $state, $ionicModal, $focus, $q, $time size: 20, _source: ["title", "description", "time", "location", "pictures", "issuer", "isCompany", "category"] }; - var text = $scope.search.text.toLowerCase(); + var text = $scope.search.text.toLowerCase().trim(); var matches = []; var filters = []; - if ($scope.search.text.length > 1) { + if (text.length > 1) { matches.push({match : { title: text}}); matches.push({match : { description: text}}); matches.push({prefix : { issuer: text}}); diff --git a/www/js/controllers/settings-controllers.js b/www/js/controllers/settings-controllers.js index 6a689a4843038abbfa8584e41a63e4b5f2e756c5..a87261db3aa2c63e2ef1ca7c69d4131196563217 100644 --- a/www/js/controllers/settings-controllers.js +++ b/www/js/controllers/settings-controllers.js @@ -5,7 +5,7 @@ angular.module('cesium.settings.controllers', ['cesium.services', 'cesium.curren $stateProvider .state('app.settings', { - url: "/wallet", + url: "/settings", views: { 'menuContent': { templateUrl: "templates/settings/settings.html", @@ -19,288 +19,20 @@ angular.module('cesium.settings.controllers', ['cesium.services', 'cesium.curren .controller('SettingsCtrl', SettingsController) ; -function SettingsController($scope, $state, $q, Wallet, $translate) { +function SettingsController($scope, $state, UIUtils) { $scope.walletData = {}; $scope.$on('$ionicView.enter', function(e, $state) { - if (!$scope.isLogged()) { - return; - } - UIUtils.loading.show(); $scope.loadWallet() .then(function(wallet) { - UIUtils.loading.hide(); - }); - }); - - $scope.$watch('walletData.useRelative', $scope.refreshConvertedBalance, true); - - // Update view - $scope.updateWalletView = function(wallet) { - $scope.walletData = wallet; - $scope.hasCredit = (!!$scope.walletData.balance && $scope.walletData.balance > 0); - if (!$scope.walletData.requirements || !$scope.walletData.requirements.uid) { - $scope.needSelf = true; - $scope.needMembership = true; - $scope.needRenew = false; - } - else { - $scope.needSelf = false; - $scope.needMembership = ($scope.walletData.requirements.membershipExpiresIn == 0 - && $scope.walletData.requirements.membershipPendingExpiresIn <= 0 ); - $scope.needRenew = !$scope.needMembership && ($scope.walletData.requirements.membershipExpiresIn < 129600 - && $scope.walletData.requirements.membershipPendingExpiresIn <= 0 ); - } - $scope.isMember = !$scope.needSelf && !$scope.needMembership; - }; - - // Has credit - $scope.hasCredit= function() { - return $scope.balance > 0; - }; - - // Transfer click - $scope.transfer= function() { - $state.go('app.new_transfer'); - }; - - $scope.setRegisterForm = function(registerForm) { - $scope.registerForm = registerForm; - }; - - // Send self identity - $scope.self= function() { - - $translate(['ACCOUNT.NEW.TITLE', 'ACCOUNT.POPUP_REGISTER.TITLE', 'ACCOUNT.POPUP_REGISTER.HELP', 'COMMON.BTN_ADD_ACCOUNT', 'COMMON.BTN_CANCEL']) - .then(function (translations) { - - // Choose UID popup - $ionicPopup.show({ - templateUrl: 'templates/account/popup_register.html', - title: translations['ACCOUNT.POPUP_REGISTER.TITLE'], - subTitle: translations['ACCOUNT.POPUP_REGISTER.HELP'], - scope: $scope, - buttons: [ - { text: translations['COMMON.BTN_CANCEL'] }, - { - text: translations['COMMON.BTN_ADD_ACCOUNT'] /*'<b>Send</b>'*/, - type: 'button-positive', - onTap: function(e) { - $scope.registerForm.$submitted=true; - if(!$scope.registerForm.$valid || !$scope.walletData.uid) { - //don't allow the user to close unless he enters a uid - e.preventDefault(); - } else { - return $scope.walletData.uid; - } - } - } - ] - }) - .then(function(uid) { - if (!uid) { // user cancel - $scope.walletData.uid = null; - UIUtils.loading.hide(); - return; - } - - var doSelf = function() { - Wallet.self(uid) - .then(function() { - UIUtils.loading.hide(); - }) - .catch(UIUtils.onError('ERROR.SEND_IDENTITY_FAILED')); - }; - // Check uid is not used by another member - UIUtils.loading.show(); - BMA.wot.lookup({ search: uid }) - .then(function(res) { - var found = typeof res.results != "undefined" && res.results != null && res.results.length > 0 - && res.results.some(function(pub){ - return typeof pub.uids != "undefined" && pub.uids != null && pub.uids.length > 0 - && pub.uids.some(function(idty){ - return (idty.uid == uid); - }); - }); - if (found) { // uid is already used : display a message and reopen the popup - UIUtils.loading.hide(); - UIUtils.alert.info('ACCOUNT.NEW.MSG_UID_ALREADY_USED') - .then(function(){ - $scope.self(); // loop - }); - } - else { - doSelf(); - } - }) - .catch(function() { - doSelf(); - }); - }); - }); - }; - - // Send membership IN - $scope.membershipIn= function() { - UIUtils.loading.show(); - Wallet.membership(true) - .then(function() { - - UIUtils.loading.hide(); - }) - .catch(UIUtils.onError('ERROR.SEND_MEMBERSHIP_IN_FAILED')); - }; - - // Send membership IN - $scope.membershipOut = function() { - UIUtils.loading.show(); - Wallet.membership(false) - .then(function() { - UIUtils.loading.hide(); - }) - .catch(UIUtils.onError('ERROR.SEND_MEMBERSHIP_OUT_FAILED')); - }; - - // Updating wallet data - $scope.doUpdate = function() { - UIUtils.loading.show(); - Wallet.refreshData() - .then(function() { - UIUtils.loading.hide(); - }) - .catch(UIUtils.onError('ERROR.REFRESH_WALLET_DATA')); - }; - - // Triggered on a button click, or some other target - $scope.showActionsheet = function() { - - $translate(['ACCOUNT.BTN_MEMBERSHIP_OUT', 'COMMON.BTN_CANCEL.TITLE', 'ACCOUNT.POPUP_REGISTER.HELP', 'COMMON.BTN_ADD_ACCOUNT', 'COMMON.BTN_CANCEL']) - .then(function (translations) { - // Show the action sheet - var hideMenu = $ionicActionSheet.show({ - buttons: [ - { text: translations['ACCOUNT.BTN_MEMBERSHIP_OUT'] }, - { text: 'Move' } - ], - titleText: translations['ACCOUNT.MENU_TITLE'], - cancelText: translations['COMMON.BTN_CANCEL'], - cancel: function() { - // add cancel code.. - }, - buttonClicked: function(index) { - return true; - } - }); - - // For example's sake, hide the sheet after two seconds - $timeout(function() { - hideMenu(); - }, 2000); - }); - }; -} - -function TransferController($scope, $ionicModal, $state, $ionicHistory, BMA, Wallet, UIUtils) { - - $scope.walletData = {}; - $scope.convertedBalance = 0; - $scope.formData = { - destPub: null, - amount: null, - comments: null - }; - $scope.dest = null; - $scope.udAmount = null; - - WotLookupController.call(this, $scope, BMA, $state); - - $scope.$on('$ionicView.enter', function(e, $state) { - if ($state.stateParams != null - && $state.stateParams.pubkey != null - && $state.stateParams.pubkey != "undefined") { - $scope.destPub = $state.stateParams.pubkey; - if ($state.stateParams.uid != null - && $state.stateParams.uid != "undefined") { - $scope.dest = $state.stateParams.uid; - } - else { - $scope.dest = $scope.destPub; - } - } - - // Login and load wallet - $scope.loadWallet() - .then(function(walletData) { - $scope.walletData = walletData; - $scope.onUseRelativeChanged(); + $scope.walletData = wallet; UIUtils.loading.hide(); }); }); - // When chaing use relative UD - $scope.onUseRelativeChanged = function() { - if ($scope.walletData.useRelative) { - $scope.convertedBalance = $scope.walletData.balance / $scope.walletData.currentUD; - $scope.udAmount = $scope.amount * $scope.walletData.currentUD; - $scope.unit = 'universal_dividend'; - $scope.udUnit = $scope.walletData.currency; - } else { - $scope.convertedBalance = $scope.walletData.balance; - $scope.formData.amount = ($scope.formData.amount != "undefined" && $scope.formData.amount != null) - ? Math.floor(parseFloat($scope.formData.amount.replace(new RegExp('[,]'), '.'))) - : null; - $scope.udAmount = $scope.amount / $scope.walletData.currentUD; - $scope.unit = $scope.walletData.currency; - $scope.udUnit = ''; - } - }; - $scope.$watch('walletData.useRelative', $scope.onUseRelativeChanged, true); - $scope.$watch('walletData.balance', $scope.onUseRelativeChanged, true); - - $ionicModal.fromTemplateUrl('templates/wot/modal_lookup.html', { - scope: $scope, - focusFirstInput: true - }).then(function(modal) { - $scope.lookupModal = modal; - $scope.lookupModal.hide(); - }); - - $scope.openSearch = function() { - $scope.lookupModal.show(); - } - - $scope.doTransfer = function() { - UIUtils.loading.show(); - - var amount = $scope.formData.amount; - if ($scope.walletData.useRelative - && amount != "undefined" - && amount != null) { - amount = $scope.walletData.currentUD - * amount.replace(new RegExp('[.,]'), '.'); - } - - Wallet.transfer($scope.formData.destPub, amount, $scope.formData.comments) - .then(function() { - UIUtils.loading.hide(); - $ionicHistory.goBack() - }) - .catch(UIUtils.onError('Could not send transaction')); + $scope.setSettingsForm = function(settingsForm) { + $scope.settingsForm = settingsForm; }; - $scope.closeLookup = function() { - $scope.lookupModal.hide(); - } - - $scope.doSelectIdentity = function(pub, uid) { - if (uid != "undefined" && uid != null) { - $scope.dest = uid; - } - else { - $scope.dest = uid; - } - $scope.formData.destPub = pub; - $scope.lookupModal.hide(); - } } diff --git a/www/js/controllers/transfer-controllers.js b/www/js/controllers/transfer-controllers.js index a3e9358d5f14ecc6a51ab7098a9305e2c758c74d..aa6330460d3ceb658183e65a1f3cfe4e9ddf9d73 100644 --- a/www/js/controllers/transfer-controllers.js +++ b/www/js/controllers/transfer-controllers.js @@ -28,13 +28,12 @@ angular.module('cesium.transfer.controllers', ['cesium.services', 'cesium.curren .controller('TransferCtrl', TransferController) ; -function TransferController($scope, $ionicModal, $state, BMA, Wallet, UIUtils, ionicMaterialInk) { +function TransferController($scope, $ionicModal, $state, BMA, Wallet, UIUtils, ionicMaterialInk, $cordovaBarcodeScanner, $timeout) { - TransferModalController.call(this, $scope, $ionicModal, $state, BMA, Wallet, UIUtils, ionicMaterialInk) + TransferModalController.call(this, $scope, $ionicModal, $state, BMA, Wallet, UIUtils, ionicMaterialInk, $cordovaBarcodeScanner, $timeout); $scope.$on('$ionicView.enter', function(e, $state) { - if (!!$state.stateParams - && !!$state.stateParams.pubkey) { + if (!!$state.stateParams && !!$state.stateParams.pubkey) { $scope.formData.destPub = $state.stateParams.pubkey; if (!!$state.stateParams.uid) { $scope.dest = $state.stateParams.uid; @@ -51,11 +50,9 @@ function TransferController($scope, $ionicModal, $state, BMA, Wallet, UIUtils, i UIUtils.loading.hide(); }); }); - } - -function TransferModalController($scope, $ionicModal, $state, BMA, Wallet, UIUtils, ionicMaterialInk) { +function TransferModalController($scope, $ionicModal, $state, BMA, Wallet, UIUtils, ionicMaterialInk, $cordovaBarcodeScanner, $timeout) { $scope.walletData = {}; $scope.transferForm = {}; @@ -68,7 +65,7 @@ function TransferModalController($scope, $ionicModal, $state, BMA, Wallet, UIUti $scope.dest = null; $scope.udAmount = null; - WotLookupController.call(this, $scope, BMA, $state); + WotLookupController.call(this, $scope, BMA, $state, $cordovaBarcodeScanner, UIUtils, $timeout); // Create the login modal that we will use later $ionicModal.fromTemplateUrl('templates/wallet/modal_transfer.html', { @@ -102,7 +99,7 @@ function TransferModalController($scope, $ionicModal, $state, BMA, Wallet, UIUti $scope.setTransferForm = function(transferForm) { $scope.transferForm = transferForm; - } + }; // Open transfer modal $scope.transfer = function(destPub, dest, callback) { @@ -140,16 +137,15 @@ function TransferModalController($scope, $ionicModal, $state, BMA, Wallet, UIUti } else { $scope.convertedBalance = $scope.walletData.balance; // Convert to number - $scope.formData.amount = (!!$scope.formData.amount && typeof $scope.formData.amount == "string") - ? Math.floor(parseFloat($scope.formData.amount.replace(new RegExp('[,]'), '.'))) - : $scope.formData.amount; + $scope.formData.amount = (!!$scope.formData.amount && typeof $scope.formData.amount == "string") ? + Math.floor(parseFloat($scope.formData.amount.replace(new RegExp('[,]'), '.'))) : + $scope.formData.amount; // Compute UD - $scope.udAmount = (!!$scope.formData.amount - && typeof $scope.formData.amount == "number" - && !!$scope.walletData.currentUD - && typeof $scope.walletData.currentUD == "number") - ? $scope.formData.amount / $scope.walletData.currentUD - : null; + $scope.udAmount = (!!$scope.formData.amount && + typeof $scope.formData.amount == "number" && + !!$scope.walletData.currentUD && + typeof $scope.walletData.currentUD == "number") ? + $scope.formData.amount / $scope.walletData.currentUD :null; $scope.unit = $scope.walletData.currency; $scope.udUnit = ''; } @@ -159,17 +155,16 @@ function TransferModalController($scope, $ionicModal, $state, BMA, Wallet, UIUti $scope.openWotLookup = function() { $scope.lookupModal.show(); - } + }; $scope.doTransfer = function() { UIUtils.loading.show(); var amount = $scope.formData.amount; - if ($scope.walletData.useRelative - && !!amount - && typeof amount == "string") { - amount = $scope.walletData.currentUD - * amount.replace(new RegExp('[.,]'), '.'); + if ($scope.walletData.useRelative && !!amount && + typeof amount == "string") { + amount = $scope.walletData.currentUD * + amount.replace(new RegExp('[.,]'), '.'); } Wallet.transfer($scope.formData.destPub, amount, $scope.formData.comments) @@ -193,16 +188,16 @@ function TransferModalController($scope, $ionicModal, $state, BMA, Wallet, UIUti $scope.closeLookup = function() { $scope.lookupModal.hide(); - } + }; $scope.doSelectIdentity = function(pub, uid) { - if (uid != "undefined" && uid != null) { + if (uid) { $scope.dest = uid; } else { - $scope.dest = uid; + $scope.dest = pub; } $scope.formData.destPub = pub; $scope.lookupModal.hide(); - } + }; } diff --git a/www/js/controllers/wallet-controllers.js b/www/js/controllers/wallet-controllers.js index d9fb7222b03937289827281bec10f1b578baf66d..8d3dbe6e3354558b1a2949f743cf1c4ea3123e12 100644 --- a/www/js/controllers/wallet-controllers.js +++ b/www/js/controllers/wallet-controllers.js @@ -71,10 +71,10 @@ function WalletController($scope, $state, $q, $ionicPopup, $ionicActionSheet, $t } else { $scope.needSelf = false; - $scope.needMembership = ($scope.walletData.requirements.membershipExpiresIn == 0 - && $scope.walletData.requirements.membershipPendingExpiresIn <= 0 ); - $scope.needRenew = !$scope.needMembership && ($scope.walletData.requirements.membershipExpiresIn < 129600 - && $scope.walletData.requirements.membershipPendingExpiresIn <= 0 ); + $scope.needMembership = ($scope.walletData.requirements.membershipExpiresIn === 0 && + $scope.walletData.requirements.membershipPendingExpiresIn <= 0 ); + $scope.needRenew = !$scope.needMembership && ($scope.walletData.requirements.membershipExpiresIn < 129600 && + $scope.walletData.requirements.membershipPendingExpiresIn <= 0 ); $scope.needMembershipOut = ($scope.walletData.requirements.membershipExpiresIn > 0); } $scope.isMember = !$scope.needSelf && !$scope.needMembership; @@ -142,12 +142,13 @@ function WalletController($scope, $state, $q, $ionicPopup, $ionicActionSheet, $t UIUtils.loading.show(); BMA.wot.lookup({ search: uid }) .then(function(res) { - var found = typeof res.results != "undefined" && res.results != null && res.results.length > 0 - && res.results.some(function(pub){ - return pub.pubkey != $scope.walletData.pubkey - && typeof pub.uids != "undefined" && pub.uids != null && pub.uids.length > 0 - && pub.uids.some(function(idty){ - return (idty.uid == uid); + var found = res.results && + res.results.length > 0 && + res.results.some(function(pub){ + return pub.pubkey !== $scope.walletData.pubkey && + pub.uids && pub.uids.length > 0 && + pub.uids.some(function(idty){ + return (idty.uid === uid); }); }); if (found) { // uid is already used : display a message and reopen the popup @@ -194,7 +195,7 @@ function WalletController($scope, $state, $q, $ionicPopup, $ionicActionSheet, $t $scope.showUidPopup() .then(function (uid) { UIUtils.loading.show(); - if ($scope.walletData.blockUid == null) { + if (!$scope.walletData.blockUid) { Wallet.self(uid, false/*do NOT load membership here*/) .then(function() { doMembershipIn(); @@ -247,8 +248,8 @@ function WalletController($scope, $state, $q, $ionicPopup, $ionicActionSheet, $t // add cancel code.. }, buttonClicked: function(index) { - if (index == 0) { - $scope.membershipIn(); + if (index === 0) { + $scope.membershipOut(); } return true; } diff --git a/www/js/controllers/wot-controllers.js b/www/js/controllers/wot-controllers.js index fa69450de9fa5470786b1fdf2009c4ec4b6137d3..7a0cbf63e3c0750edb53d2385d7868cc66b7a316 100644 --- a/www/js/controllers/wot-controllers.js +++ b/www/js/controllers/wot-controllers.js @@ -12,6 +12,7 @@ angular.module('cesium.wot.controllers', ['cesium.services']) } } }) + ; }) .controller('IdentityCtrl', IdentityController) @@ -19,22 +20,42 @@ angular.module('cesium.wot.controllers', ['cesium.services']) .controller('WotLookupCtrl', WotLookupController) ; -function WotLookupController($scope, BMA, $state, $cordovaBarcodeScanner, UIUtils) { +function WotLookupController($scope, BMA, $state, $cordovaBarcodeScanner, UIUtils, $timeout) { $scope.options = { scanQrCode : { enable: true } - } + }; + + ionic.Platform.ready(function() { + $scope.options.scanQrCode.enable = !(!$cordovaBarcodeScanner || !$cordovaBarcodeScanner.scan); + }); $scope.searchChanged = function() { - $scope.search.text = $scope.search.text.toLowerCase(); - if ($scope.search.text.length > 1) { - $scope.search.looking = true; - return BMA.wot.lookup({ search: $scope.search.text }) + $scope.search.typing = $scope.search.text; + $scope.search.looking = true; + $timeout( + function() { + if ($scope.search.typing === $scope.search.text) { + $scope.search.typing = null; + $scope.doSearch(); + } + }, + 1000); + }; + + $scope.doSearch = function() { + $scope.search.looking = true; + var text = $scope.search.text.toLowerCase().trim(); + if (text.length === 0) { + $scope.search.results = []; + $scope.search.looking = false; + } + else { + return BMA.wot.lookup({ search: text }) .then(function(res){ - $scope.search.looking = false; - $scope.search.results = res.results.reduce(function(idties, res) { + var idties = res.results.reduce(function(idties, res) { return idties.concat(res.uids.reduce(function(uids, idty) { var blocUid = idty.meta.timestamp.split('-', 2); return uids.concat({ @@ -42,28 +63,23 @@ function WotLookupController($scope, BMA, $state, $cordovaBarcodeScanner, UIUtil pub: res.pubkey, number: blocUid[0], hash: blocUid[1] - }) + }); }, [])); }, []); + $scope.search.results = idties; + $scope.search.looking = false; }) .catch(function() { - $scope.search.looking = false; $scope.search.results = []; + $scope.search.looking = false; }); } - else { - $scope.search.results = []; - } }; $scope.doSelectIdentity = function(pub, uid) { $state.go('app.view_identity', {pub: pub}); }; - ionic.Platform.ready(function() { - $scope.options.scanQrCode.enable = !(!$cordovaBarcodeScanner || !$cordovaBarcodeScanner.scan); - }); - $scope.scanQrCode = function(){ if ($scope.options.scanQrCode.enable) { $cordovaBarcodeScanner.scan() @@ -75,7 +91,7 @@ function WotLookupController($scope, BMA, $state, $cordovaBarcodeScanner, UIUtil UIUtils.alert.error('Could no scan: ' + error); }); } - } + }; } function IdentityController($scope, $state, BMA, Wallet, UIUtils, $q, ionicMaterialMotion, $timeout, ionicMaterialInk) { @@ -102,7 +118,7 @@ function IdentityController($scope, $state, BMA, Wallet, UIUtils, $q, ionicMater revoked: idty.revoked, revokedSig: idty.revocation_sig, sig: idty.self - }) + }); }, [])); }, [])[0]; $scope.hasSelf = ($scope.identity.uid && $scope.identity.sigDate && $scope.identity.sig); diff --git a/www/js/services/market-services.js b/www/js/services/market-services.js index c0724e8cfb3b4c55d5ce20bc79ac80201d462d49..6bcc37504288f076d9a278fe1b486a0c33d8902f 100644 --- a/www/js/services/market-services.js +++ b/www/js/services/market-services.js @@ -212,7 +212,7 @@ angular.module('cesium.market.services', ['ngResource', 'cesium.services', 'cesi }; } - var ESNodeConfigured = !("undefined" === typeof APP_CONFIG.UCOIN_NODE_ES); + var ESNodeConfigured = !!APP_CONFIG.UCOIN_NODE_ES; if (!ESNodeConfigured) { return null; } diff --git a/www/js/services/registry-services.js b/www/js/services/registry-services.js index 4618fe4aafe077267b15c4ecaa28c0b00d1bfdbc..267c5df5a88ae7756ff776488812e41248b04de4 100644 --- a/www/js/services/registry-services.js +++ b/www/js/services/registry-services.js @@ -211,7 +211,7 @@ angular.module('cesium.registry.services', ['ngResource', 'cesium.services']) }; } - var ESNodeConfigured = !("undefined" === typeof APP_CONFIG.UCOIN_NODE_ES); + var ESNodeConfigured = !!APP_CONFIG.UCOIN_NODE_ES; if (!ESNodeConfigured) { return null; } diff --git a/www/js/services/wallet-services.js b/www/js/services/wallet-services.js index 64922425a64b5d771af496f7951c7d83b8fc7a28..c6814b147a9c70ec81c6aad87cae094cf702ebcc 100644 --- a/www/js/services/wallet-services.js +++ b/www/js/services/wallet-services.js @@ -72,8 +72,8 @@ angular.module('cesium.wallet.services', ['ngResource', 'cesium.bma.services', ' var outputArray = output.split(':',3); var outputAmount = parseInt(outputArray[0]); var outputCondArray = outputArray[2].split('(', 3); - var outputReceiver = (outputCondArray.length == 2 && outputCondArray[0] == 'SIG') - ? outputCondArray[1].substring(0,outputCondArray[1].length-1) : ''; + var outputReceiver = (outputCondArray.length == 2 && outputCondArray[0] == 'SIG') ? + outputCondArray[1].substring(0,outputCondArray[1].length-1) : ''; if (outputReceiver == data.pubkey) { // user is the receiver return sum + outputAmount; } @@ -126,10 +126,10 @@ angular.module('cesium.wallet.services', ['ngResource', 'cesium.bma.services', ' }, isSourceEquals = function(arg1, arg2) { - return arg1.type == arg2.type - && arg1.fingerprint == arg2.fingerprint - && arg1.number == arg2.number - && arg1.amount == arg2.amount; + return arg1.type == arg2.type && + arg1.fingerprint == arg2.fingerprint && + arg1.number == arg2.number && + arg1.amount == arg2.amount; }, loadRequirements = function() { @@ -367,7 +367,8 @@ angular.module('cesium.wallet.services', ['ngResource', 'cesium.bma.services', ' var sourceAmount = 0; var outputBase = 0; var inputs = []; - for (var i = 0; i<data.sources.length; i++) { + var i; + for (i = 0; i<data.sources.length; i++) { var input = data.sources[i]; if (!input.consumed){ // if D : D:PUBLIC_KEY:BLOCK_ID @@ -392,17 +393,17 @@ angular.module('cesium.wallet.services', ['ngResource', 'cesium.bma.services', ' return; } - tx += 'Unlocks:\n' - for (var i=0; i<inputs.length; i++) { + tx += 'Unlocks:\n'; + for (i=0; i<inputs.length; i++) { // INPUT_INDEX:UNLOCK_CONDITION tx += i + ':SIG(0)\n'; } - tx += 'Outputs:\n' - // AMOUNT:BASE:CONDITIONS - + amount + ':'+outputBase+':SIG('+destPub+')\n'; + tx += 'Outputs:\n'; + // AMOUNT:BASE:CONDITIONS + tx += amount + ':'+outputBase+':SIG('+destPub+')\n'; if (sourceAmount > amount) { - tx += (sourceAmount-amount)+':'+outputBase+':SIG('+data.pubkey+')\n' + tx += (sourceAmount-amount)+':'+outputBase+':SIG('+data.pubkey+')\n'; } tx += "Comment: "+ (!!comments?comments:"") + "\n"; @@ -429,12 +430,12 @@ angular.module('cesium.wallet.services', ['ngResource', 'cesium.bma.services', ' BMA.blockchain.current() .then(function(block) { // Create identity to sign - var identity = 'Version: 2\n' - + 'Type: Identity\n' - + 'Currency: ' + data.currency + '\n' - + 'Issuer: ' + data.pubkey + '\n' - + 'UniqueID: ' + uid + '\n' - + 'Timestamp: ' + block.number + '-' + block.hash + '\n'; + var identity = 'Version: 2\n' + + 'Type: Identity\n' + + 'Currency: ' + data.currency + '\n' + + 'Issuer: ' + data.pubkey + '\n' + + 'UniqueID: ' + uid + '\n' + + 'Timestamp: ' + block.number + '-' + block.hash + '\n'; CryptoUtils.sign(identity, data.keypair) .then(function(signature) { @@ -467,14 +468,14 @@ angular.module('cesium.wallet.services', ['ngResource', 'cesium.bma.services', ' BMA.blockchain.current() .then(function(block) { // Create membership to sign - var membership = 'Version: 2\n' - + 'Type: Membership\n' - + 'Currency: ' + data.currency + '\n' - + 'Issuer: ' + data.pubkey + '\n' - + 'Block: ' + block.number + '-' + block.hash + '\n' - + 'Membership: ' + (!!sideIn ? "IN" : "OUT" ) + '\n' - + 'UserID: ' + data.uid + '\n' - + 'CertTS: ' + data.blockUid + '\n'; + var membership = 'Version: 2\n' + + 'Type: Membership\n' + + 'Currency: ' + data.currency + '\n' + + 'Issuer: ' + data.pubkey + '\n' + + 'Block: ' + block.number + '-' + block.hash + '\n' + + 'Membership: ' + (!!sideIn ? "IN" : "OUT" ) + '\n' + + 'UserID: ' + data.uid + '\n' + + 'CertTS: ' + data.blockUid + '\n'; CryptoUtils.sign(membership, data.keypair) .then(function(signature) { @@ -502,19 +503,19 @@ angular.module('cesium.wallet.services', ['ngResource', 'cesium.bma.services', ' BMA.blockchain.current() .then(function(block) { // Create the self part to sign - var self = 'UID:' + uid + '\n' - + 'META:TS:' + timestamp + '\n' - + signature /*+"\n"*/; + var self = 'UID:' + uid + '\n' + + 'META:TS:' + timestamp + '\n' + + signature /*+"\n"*/; - var cert = self + '\n' - + 'META:TS:' + block.number + '-' + block.hash + '\n'; + var cert = self + '\n' + + 'META:TS:' + block.number + '-' + block.hash + '\n'; CryptoUtils.sign(cert, data.keypair) .then(function(signature) { - var inlineCert = data.pubkey - + ':' + pubkey - + ':' + block.number - + ':' + signature + '\n'; + var inlineCert = data.pubkey + + ':' + pubkey + + ':' + block.number + + ':' + signature + '\n'; BMA.wot.add({pubkey: pubkey, self: self, other: inlineCert}) .then(function(result) { resolve(result); @@ -529,9 +530,9 @@ angular.module('cesium.wallet.services', ['ngResource', 'cesium.bma.services', ' */ toJson = function() { return $q(function(resolve, reject) { - var json = JSON.stringify(data); - resolve(json); - }) + var json = JSON.stringify(data); + resolve(json); + }); }, /** @@ -539,51 +540,52 @@ angular.module('cesium.wallet.services', ['ngResource', 'cesium.bma.services', ' */ fromJson = function(json) { return $q(function(resolve, reject) { - var obj = JSON.parse(json || '{}'); - if (obj.keypair != "undefined" - && obj.keypair != null) { - var keypair = obj.keypair; + var obj = JSON.parse(json || '{}'); + if (obj.keypair) { + var keypair = obj.keypair; + var i; - // Convert to Uint8Array type - var signPk = new Uint8Array(32); - for (var i = 0; i < 32; i++) signPk[i] = keypair.signPk[i]; - keypair.signPk = signPk; + // Convert to Uint8Array type + var signPk = new Uint8Array(32); + for (i = 0; i < 32; i++) signPk[i] = keypair.signPk[i]; + keypair.signPk = signPk; - var signSk = new Uint8Array(64); - for (var i = 0; i < 64; i++) signSk[i] = keypair.signSk[i]; - keypair.signSk = signSk; + var signSk = new Uint8Array(64); + for (i = 0; i < 64; i++) signSk[i] = keypair.signSk[i]; + keypair.signSk = signSk; - data.pubkey = obj.pubkey; - data.keypair = keypair; + data.pubkey = obj.pubkey; + data.keypair = keypair; - resolve(); - } - else { - reject('Not a valid Wallet.data object'); - } - }) + resolve(); + } + else { + reject('Not a valid Wallet.data object'); + } + }); }; return { - id: id, - data: data, - // auth - login: login, - logout: logout, - isLogin: isLogin, - getData: getData, - loadData: loadData, - refreshData: refreshData, - // operations - transfer: transfer, - self: self, - membership: membership, - sign: sign, - // serialization - toJson: toJson, - fromJson: fromJson - } - } + id: id, + data: data, + // auth + login: login, + logout: logout, + isLogin: isLogin, + getData: getData, + loadData: loadData, + refreshData: refreshData, + // operations + transfer: transfer, + self: self, + membership: membership, + sign: sign, + // serialization + toJson: toJson, + fromJson: fromJson + }; + }; + var service = Wallet('default'); service.instance = service; return service; diff --git a/www/templates/currency/view_currency.html b/www/templates/currency/view_currency.html index 3271a2d0c15f0723733a6103679c28d7a1cb2400..4d91717576fa8e44feb9aa1528395178a3134343 100644 --- a/www/templates/currency/view_currency.html +++ b/www/templates/currency/view_currency.html @@ -1,4 +1,4 @@ -<ion-view view-title="{{'CURRENCY.VIEW.TITLE' | translate}}" left-buttons="leftButtons" class="pane"> +<ion-view view-title="{{id}}" left-buttons="leftButtons" class="pane"> <ion-nav-buttons side="secondary"> <button class="button button-icon button-clear icon ion-loop" ng-click="doUpdate()"> </button> diff --git a/www/templates/currency/view_currency_lg.html b/www/templates/currency/view_currency_lg.html index ecacf9f9bc2a4612619021b7ccc42b18d630f1f4..7baedaf06adfca1ab44551b0b3a38896974aa4d6 100644 --- a/www/templates/currency/view_currency_lg.html +++ b/www/templates/currency/view_currency_lg.html @@ -1,4 +1,4 @@ -<ion-view view-title="{{'CURRENCY.VIEW.TITLE' | translate}}" left-buttons="leftButtons" class="pane"> +<ion-view view-title="{{'CURRENCY.VIEW.TITLE' | translate}} {{id}}" left-buttons="leftButtons" class="pane"> <ion-nav-buttons side="secondary"> <button class="button button-icon button-clear icon ion-loop" ng-click="doUpdate()"> </button> diff --git a/www/templates/menu.html b/www/templates/menu.html index 0ac89a1d278a3747f8fb9ea62fc0a2c0165e74fa..9483b0c8021e2d98fda26fd8691db6c901d33602 100644 --- a/www/templates/menu.html +++ b/www/templates/menu.html @@ -1,7 +1,7 @@ <ion-side-menus enable-menu-with-back-views="true"> <!-- MENU --> - <ion-side-menu side="left" id="menu"> + <ion-side-menu side="left" id="menu" expose-aside-when="large" enable-menu-with-back-views="false"> <ion-header-bar class="bar"> <h1 class="title" translate> MENU.TITLE @@ -18,13 +18,14 @@ <span translate>MENU.CURRENCIES</span> </ion-item> - <div class="item item-divider"></div> + <div class="item item-divider" + ng-show="options.market.enable || options.market.enable"></div> - <ion-item menu-close class="item item-icon-left" href="#/app/registry" ng-if="options.registry.enable"> + <ion-item menu-close class="item item-icon-left" href="#/app/registry" ng-show="options.registry.enable"> <i class="icon ion-person-stalker"></i> <span translate>MENU.REGISTRY</span> </ion-item> - <ion-item menu-close class="item item-icon-left" href="#/app/market" ng-if="options.market.enable"> + <ion-item menu-close class="item item-icon-left" href="#/app/market" ng-show="options.market.enable"> <i class="icon ion-bag"></i> <span translate>MENU.MARKET</span> </ion-item> @@ -62,7 +63,7 @@ </ion-nav-back-button> <ion-nav-buttons side="left"> - <button class="button button-icon button-clear icon ion-navicon" menu-toggle="left" ></button> + <button class="button button-icon button-clear icon ion-navicon visible-xs" menu-toggle="left" ></button> </ion-nav-buttons> </ion-nav-bar> <ion-nav-view name="menuContent"></ion-nav-view> diff --git a/www/templates/wot/lookup_form.html b/www/templates/wot/lookup_form.html index bdbd16bd72961e6120629ad3e80e63e1144149fc..ab752a453dc370ed2545d23c0fc894d6a05a9a45 100644 --- a/www/templates/wot/lookup_form.html +++ b/www/templates/wot/lookup_form.html @@ -8,13 +8,18 @@ <button class="button button-icon button-clear icon ion-qr-scanner visible-xs" ng-click="scanQrCode()"></button> </div> - <div class="list" ng-if="search.text && search.text.length > 0"> + <div class="list" + ng-class="{'list-inset': search.options.listInset}" + ng-if="search.text && search.text.length > 0"> - <label class="item center" ng-if="search.looking"> + <label class="item center text-left" ng-if="search.looking"> <ion-spinner icon="android"></ion-spinner> </label> - <a class="item item-icon-left item-avatar ink" ng-repeat="found in search.results" ng-click="doSelectIdentity('{{found.pub}}', '{{found.uid}}')"> + <a ng-if="!search.looking" + ng-repeat="found in search.results" + class="item item-icon-left item-avatar ink" + ng-click="doSelectIdentity('{{found.pub}}', '{{found.uid}}')"> <i class="icon ion-person"></i> <h2>{{found.uid}}</h2> <span class="badge">{{found.pub | formatPubkey}}</span>