diff --git a/www/i18n/locale-en-GB.json b/www/i18n/locale-en-GB.json index 40e1c0f6cbafd684d0fbced559a943fd4e005d18..5ee1cda1a8e32d1026034aa8318677e7c961b74f 100644 --- a/www/i18n/locale-en-GB.json +++ b/www/i18n/locale-en-GB.json @@ -49,6 +49,7 @@ "NO_ACCOUNT_QUESTION": "Not a member yet? Register now!", "SEARCH_NO_RESULT": "No result found", "LOADING": "Loading...", + "LOADING_WAIT": "Loading...<br/><small>(Waiting for node availability)</small>", "SEARCHING": "Searching...", "FROM": "From", "TO": "To", diff --git a/www/i18n/locale-en.json b/www/i18n/locale-en.json index 78c6f50845894743c713cd3d6ea06f9c7475b07e..1df269ec1dfefd374dcc6c3365595f9684788fed 100644 --- a/www/i18n/locale-en.json +++ b/www/i18n/locale-en.json @@ -49,6 +49,7 @@ "NO_ACCOUNT_QUESTION": "Not a member yet? Register now!", "SEARCH_NO_RESULT": "No result found", "LOADING": "Loading...", + "LOADING_WAIT": "Loading...<br/><small>(Waiting for node availability)</small>", "SEARCHING": "Searching...", "FROM": "From", "TO": "To", diff --git a/www/i18n/locale-es-ES.json b/www/i18n/locale-es-ES.json index ff2f7f6110fda1f1335e17a72c446335dc53bae6..e3a4c5e78e96c1732eec6aff36f6ad87c1f1b1e6 100644 --- a/www/i18n/locale-es-ES.json +++ b/www/i18n/locale-es-ES.json @@ -49,6 +49,7 @@ "NO_ACCOUNT_QUESTION": "¿TodavÃa no es miembro? ¡Crear una cuenta!", "SEARCH_NO_RESULT": "Ningún resultado encontrado", "LOADING": "Espere por favor...", + "LOADING_WAIT": "Espere por favor...<br/><small>(Esperando disponibilidad de nodo)</small>", "SEARCHING": "Búsqueda en proceso...", "FROM": "De", "TO": "A", diff --git a/www/i18n/locale-fr-FR.json b/www/i18n/locale-fr-FR.json index 4dbd339de19c5f2893d7753a6ce3c3c16938f3ce..d9c0ce9e18a196bb502a2a3dea8e02ad86df4715 100644 --- a/www/i18n/locale-fr-FR.json +++ b/www/i18n/locale-fr-FR.json @@ -49,6 +49,7 @@ "NO_ACCOUNT_QUESTION": "Pas de encore membre ? Créer un compte !", "SEARCH_NO_RESULT": "Aucun résultat trouvé", "LOADING": "Veuillez patienter...", + "LOADING_WAIT": "Veuillez patienter...<br/><small>(Attente de disponibilité du noeud)</small>", "SEARCHING": "Recherche en cours...", "FROM": "De", "TO": "À", diff --git a/www/js/controllers/currency-controllers.js b/www/js/controllers/currency-controllers.js index 79e23f674bf8698bf910a3e8b56ed5e90ce74e2d..4cc15a9672da76d31d5c8729166f10055e5ae64f 100644 --- a/www/js/controllers/currency-controllers.js +++ b/www/js/controllers/currency-controllers.js @@ -143,7 +143,7 @@ function CurrencyViewController($scope, $q, $timeout, $ionicPopover, Modals, BMA $scope.load = function() { // Load data from node - var data = {}, M, lastUDTime, now = new Date().getTime(); + var data = {}, M, lastUDTime, now = Date.now(); return $q.all([ // Get the currency parameters @@ -186,7 +186,7 @@ function CurrencyViewController($scope, $q, $timeout, $ionicPopover, Modals, BMA if (err && err.ucode == BMA.errorCodes.NO_CURRENT_BLOCK) { M = 0; data.N = 0; - data.medianTime = Math.trunc(new Date().getTime() / 1000); + data.medianTime = moment().utc().unix(); data.difficulty = 0; data.blockUid = null; return; @@ -232,7 +232,7 @@ function CurrencyViewController($scope, $q, $timeout, $ionicPopover, Modals, BMA // Apply to formData angular.extend($scope.formData, data); - console.debug("[currency] Parameters loaded in " + (new Date().getTime() - now) + 'ms' ); + console.debug("[currency] Parameters loaded in " + (Date.now() - now) + 'ms' ); $scope.loading = false; $scope.$broadcast('$$rebind::' + 'rebind'); // force bind of currency name diff --git a/www/js/controllers/wallet-controllers.js b/www/js/controllers/wallet-controllers.js index 8fdfa5a9807569080cfabf48ea822bc0b8d71915..b93aa02d54102ceac70d5b52449d3b1cecbd82bc 100644 --- a/www/js/controllers/wallet-controllers.js +++ b/www/js/controllers/wallet-controllers.js @@ -851,7 +851,7 @@ function WalletTxController($scope, $ionicPopover, $state, $timeout, $location, fromTime = fromTime || ($scope.formData.tx.fromTime - csSettings.data.walletHistoryTimeSecond) || - (Math.trunc(new Date().getTime() / 1000) - 2 * csSettings.data.walletHistoryTimeSecond); + (moment().utc().unix()- 2 * csSettings.data.walletHistoryTimeSecond); UIUtils.loading.show(); return wallet.refreshData({tx: {enable: true,fromTime: fromTime}}) diff --git a/www/js/controllers/wot-controllers.js b/www/js/controllers/wot-controllers.js index 977d46e35f52e7c177e1ec90a0229fb28d8bbe22..edbb07cf8b10a022fd887a8fe4b75dd67b64e0ec 100644 --- a/www/js/controllers/wot-controllers.js +++ b/www/js/controllers/wot-controllers.js @@ -1112,7 +1112,7 @@ function WotIdentityTxViewController($scope, $timeout, $q, BMA, csSettings, csWo fromTime = fromTime || ($scope.formData.tx.fromTime - csSettings.data.walletHistoryTimeSecond) || - (Math.trunc(new Date().getTime() / 1000) - 2 * csSettings.data.walletHistoryTimeSecond); + (moment().utc().unix() - 2 * csSettings.data.walletHistoryTimeSecond); UIUtils.loading.show(); return csTx.load($scope.pubkey, fromTime) diff --git a/www/js/services/bma-services.js b/www/js/services/bma-services.js index dda347d08b5cba373a3e3af66819429d0c078b5e..aea2a5914b5071b0091539a10ae1262bf9c0af11 100644 --- a/www/js/services/bma-services.js +++ b/www/js/services/bma-services.js @@ -2,7 +2,7 @@ angular.module('cesium.bma.services', ['ngApi', 'cesium.http.services', 'cesium.settings.services']) -.factory('BMA', function($q, $window, $rootScope, $timeout, csCrypto, Api, Device, csConfig, csSettings, csHttp) { +.factory('BMA', function($q, $window, $rootScope, $timeout, csCrypto, Api, Device, UIUtils, csConfig, csSettings, csHttp) { 'ngInject'; function BMA(host, port, useSsl, useCache) { @@ -64,7 +64,6 @@ angular.module('cesium.bma.services', ['ngApi', 'cesium.http.services', 'cesium. listeners, that = this; - that.date = {now: csHttp.date.now}; that.api = new Api(this, 'BMA-' + that.server); that.started = false; that.init = init; @@ -143,14 +142,14 @@ angular.module('cesium.bma.services', ['ngApi', 'cesium.http.services', 'cesium. cacheTime = that.useCache && cacheTime; var cacheKey = path + (cacheTime ? ('#'+cacheTime) : ''); - var getRequest = function(params) { + var getRequestFn = function(params) { if (!that.started) { if (!that._startPromise) { console.error('[BMA] Trying to get [{0}] before start()...'.format(path)); } return that.ready().then(function() { - return getRequest(params); + return getRequestFn(params); }); } @@ -164,10 +163,30 @@ angular.module('cesium.bma.services', ['ngApi', 'cesium.http.services', 'cesium. } that.cache.getByPath[cacheKey] = request; } - return request(params); + var execCount = 1; + return request(params) + .catch(function(err){ + // If node return too many requests error + if (err && err.ucode == exports.errorCodes.HTTP_LIMITATION) { + // If max number of retry not reach + if (execCount <= exports.constants.LIMIT_REQUEST_COUNT) { + if (execCount == 1) { + console.warn("[BMA] Too many HTTP requests: Will wait then retry..."); + // Update the loading message (if exists) + UIUtils.loading.update({template: "COMMON.LOADING_WAIT"}); + } + // Wait 1s then retry + return $timeout(function() { + execCount++; + return request(params); + }, exports.constants.LIMIT_REQUEST_DELAY); + } + } + throw err; + }); }; - return getRequest; + return getRequestFn; }; post = function(path) { @@ -280,7 +299,7 @@ angular.module('cesium.bma.services', ['ngApi', 'cesium.http.services', 'cesium. console.debug('[BMA] Starting [{0}]...'.format(that.server)); } - var now = new Date().getTime(); + var now = Date.now(); that._startPromise = $q.all([ csSettings.ready, @@ -299,7 +318,7 @@ angular.module('cesium.bma.services', ['ngApi', 'cesium.http.services', 'cesium. if (!listeners || listeners.length === 0) { addListeners(); } - console.debug('[BMA] Started in '+(new Date().getTime()-now)+'ms'); + console.debug('[BMA] Started in '+(Date.now()-now)+'ms'); that.api.node.raise.start(); that.started = true; @@ -633,10 +652,10 @@ angular.module('cesium.bma.services', ['ngApi', 'cesium.http.services', 'cesium. * @param blockNumbers a rray of block number */ exports.network.peering.peersByLeaves = function(leaves){ - return exports.raw.getHttpRecursive(exports.network.peering.peers, 'leaf', leaves, 0, 10, callbackFlush); + return exports.raw.getHttpRecursive(exports.network.peering.peers, 'leaf', leaves, 0, 10); }; - exports.raw.getHttpRecursive = function(httpGetRequest, paramName, paramValues, offset, size, callbackFlush) { + exports.raw.getHttpRecursive = function(httpGetRequest, paramName, paramValues, offset, size) { offset = angular.isDefined(offset) ? offset : 0; size = size || exports.constants.LIMIT_REQUEST_COUNT; return $q(function(resolve, reject) { diff --git a/www/js/services/crypto-services.js b/www/js/services/crypto-services.js index 7705997ac5c1af3ad5b272f1a75c786df2b8c9cb..9202d887822f7b8702f0c520ea97d79ec2a3425e 100644 --- a/www/js/services/crypto-services.js +++ b/www/js/services/crypto-services.js @@ -793,7 +793,7 @@ angular.module('cesium.crypto.services', ['cesium.utils.services']) ionicReady().then(function() { console.debug('[crypto] Starting...'); - var now = new Date().getTime(); + var now = Date.now(); var serviceImpl; @@ -815,7 +815,7 @@ angular.module('cesium.crypto.services', ['cesium.utils.services']) }) .then(function() { service.copy(serviceImpl); - console.debug('[crypto] Loaded \'{0}\' implementation in {1}ms'.format(service.id, new Date().getTime() - now)); + console.debug('[crypto] Loaded \'{0}\' implementation in {1}ms'.format(service.id, Date.now() - now)); }); }); @@ -1358,7 +1358,7 @@ angular.module('cesium.crypto.services', ['cesium.utils.services']) cypherFieldNames = [cypherFieldNames]; } - var now = new Date().getTime(); + var now = Date.now(); var issuerBoxPks = {}; // a map used as cache var jobs = [getBoxKeypair(keypair)]; @@ -1395,7 +1395,7 @@ angular.module('cesium.crypto.services', ['cesium.utils.services']) }, [])); }) .then(function() { - console.debug('[ES] [crypto] All record decrypted in ' + (new Date().getTime() - now) + 'ms'); + console.debug('[ES] [crypto] All record decrypted in ' + (Date.now() - now) + 'ms'); return records; }); diff --git a/www/js/services/currency-services.js b/www/js/services/currency-services.js index ab742bd41c8a6d2078e740f55e2f84c995f6d973..08447336270839a96e15bd652176b5c41ec2fcda 100644 --- a/www/js/services/currency-services.js +++ b/www/js/services/currency-services.js @@ -158,7 +158,7 @@ angular.module('cesium.currency.services', ['ngApi', 'cesium.bma.services']) console.debug('[currency] Received new block [' + block.number + '-' + block.hash + ']'); data.currentBlock = block; - data.currentBlock.receivedAt = Math.trunc(new Date().getTime() / 1000); + data.currentBlock.receivedAt = moment().utc().unix(); data.medianTime = block.medianTime; data.membersCount = block.membersCount; @@ -206,7 +206,7 @@ angular.module('cesium.currency.services', ['ngApi', 'cesium.bma.services']) function start() { console.debug('[currency] Starting...'); - var now = new Date().getTime(); + var now = Date.now(); startPromise = BMA.ready() @@ -217,7 +217,7 @@ angular.module('cesium.currency.services', ['ngApi', 'cesium.bma.services']) .then(function() { addListeners(); - console.debug('[currency] Started in ' + (new Date().getTime() - now) + 'ms'); + console.debug('[currency] Started in ' + (Date.now() - now) + 'ms'); started = true; startPromise = null; @@ -240,7 +240,7 @@ angular.module('cesium.currency.services', ['ngApi', 'cesium.bma.services']) .then(function(currentBlock) { - var now = Math.trunc(new Date().getTime() / 1000); + var now = moment().utc().unix(); if (cache) { if (currentBlock && (now - currentBlock.receivedAt) < 60/*1min*/) { @@ -258,7 +258,7 @@ angular.module('cesium.currency.services', ['ngApi', 'cesium.bma.services']) .catch(function(err){ // Special case for currency init (root block not exists): use fixed values if (err && err.ucode == BMA.errorCodes.NO_CURRENT_BLOCK) { - return {number: 0, hash: BMA.constants.ROOT_BLOCK_HASH, medianTime: Math.trunc(new Date().getTime() / 1000)}; + return {number: 0, hash: BMA.constants.ROOT_BLOCK_HASH, medianTime: moment().utc().unix()}; } throw err; }) @@ -284,7 +284,7 @@ angular.module('cesium.currency.services', ['ngApi', 'cesium.bma.services']) // Get time in second (UTC - medianTimeOffset) function getDateNow() { - return Math.trunc(new Date().getTime() / 1000) - (data.medianTimeOffset || constants.WELL_KNOWN_CURRENCIES.g1.medianTimeOffset); + return moment().utc().unix() - (data.medianTimeOffset || constants.WELL_KNOWN_CURRENCIES.g1.medianTimeOffset); } // TODO register new block event, to get new UD value diff --git a/www/js/services/http-services.js b/www/js/services/http-services.js index 017bf943b1c81198a7f8a2cac8e7316d9275e9cf..d3aef86810dcd567a07b073872f1abdd8237271f 100644 --- a/www/js/services/http-services.js +++ b/www/js/services/http-services.js @@ -164,12 +164,14 @@ angular.module('cesium.http.services', ['cesium.cache.services']) if (self.delegate.readyState == 3) { return $q.reject('Unable to connect to websocket ['+self.delegate.url+']'); } - console.debug('[http] Waiting websocket ['+self.path+'] opening...'); if (self.waitDuration >= timeout) { console.debug("[http] Will retry openning websocket later..."); self.waitRetryDelay = 2000; // 2 seconds } + else { + console.debug('[http] Waiting websocket ['+self.path+'] opening...'); + } return $timeout(function(){ self.waitDuration += self.waitRetryDelay; @@ -198,7 +200,7 @@ angular.module('cesium.http.services', ['cesium.cache.services']) self.delegate.onopen = function(e) { console.debug('[http] Listening on websocket ['+self.path+']...'); sockets.push(self); - self.delegate.openTime = new Date().getTime(); + self.delegate.openTime = Date.now(); }; self.delegate.onclose = function() { @@ -215,7 +217,7 @@ angular.module('cesium.http.services', ['cesium.cache.services']) // If unexpected close event, reopen the socket (fix #535) else { - console.debug('[http] Unexpected close of websocket ['+path+'] (open '+ (new Date().getTime() - self.delegate.openTime) +'ms ago): re-opening...'); + console.debug('[http] Unexpected close of websocket ['+path+'] (open '+ (Date.now() - self.delegate.openTime) +'ms ago): re-opening...'); self.delegate = null; @@ -376,7 +378,7 @@ angular.module('cesium.http.services', ['cesium.cache.services']) // Get time in second (UTC) function getDateNow() { - return Math.trunc(new Date().getTime() / 1000); + return moment().utc().unix(); } function isPositiveInteger(x) { diff --git a/www/js/services/network-services.js b/www/js/services/network-services.js index 7b29d9292d263f57fa5311513b4cf17880fec75a..859586479b857485f2dcc990fb12d0ef9faefa12 100644 --- a/www/js/services/network-services.js +++ b/www/js/services/network-services.js @@ -721,13 +721,13 @@ angular.module('cesium.network.services', ['ngApi', 'cesium.bma.services', 'cesi data.expertMode = angular.isDefined(options.expertMode) ? options.expertMode : data.expertMode; data.timeout = angular.isDefined(options.timeout) ? options.timeout : csConfig.timeout; console.info('[network] Starting network from [{0}]'.format(bma.server)); - var now = new Date().getTime(); + var now = Date.now(); addListeners(); return loadPeers() .then(function(peers){ - console.debug('[network] Started in '+(new Date().getTime() - now)+'ms'); + console.debug('[network] Started in '+(Date.now() - now)+'ms'); return peers; }); }); diff --git a/www/js/services/settings-services.js b/www/js/services/settings-services.js index 80679e0f8696f429aef17d9109dbd187e811307b..fc462b8fc08917d8965c518bceb224c963730d3b 100644 --- a/www/js/services/settings-services.js +++ b/www/js/services/settings-services.js @@ -218,7 +218,7 @@ angular.module('cesium.settings.services', ['ngApi', 'cesium.config']) }, restore = function() { - var now = new Date().getTime(); + var now = Date.now(); return $q.all([ localStorage.getObject(constants.OLD_STORAGE_KEY), // for version < v1.1 @@ -239,7 +239,7 @@ angular.module('cesium.settings.services', ['ngApi', 'cesium.config']) // Apply stored data applyData(storedData); - console.debug('[settings] Loaded from local storage in '+(new Date().getTime()-now)+'ms'); + console.debug('[settings] Loaded from local storage in '+(Date.now()-now)+'ms'); emitChangedEvent(); }); }, diff --git a/www/js/services/storage-services.js b/www/js/services/storage-services.js index 7034667da986834d4a7d2b5d02b24c444cdaf0fe..bc13a90c230a0f1ad38a997b69f12b13e22a9ec8 100644 --- a/www/js/services/storage-services.js +++ b/www/js/services/storage-services.js @@ -192,7 +192,7 @@ angular.module('cesium.storage.services', [ 'cesium.config']) function start() { if (startPromise) return startPromise; - var now = new Date().getTime(); + var now = Date.now(); // Use Cordova secure storage plugin if (isDevice) { @@ -207,7 +207,7 @@ angular.module('cesium.storage.services', [ 'cesium.config']) return startPromise .then(function() { - console.debug('[storage] Started in ' + (new Date().getTime() - now) + 'ms'); + console.debug('[storage] Started in ' + (Date.now() - now) + 'ms'); started = true; startPromise = null; }); diff --git a/www/js/services/tx-services.js b/www/js/services/tx-services.js index b0a3df8b6c3ad7f99f1f867f9858ab64b7a28741..425912f5dd50701d94bf4b3dc40f21fcbbfba885 100644 --- a/www/js/services/tx-services.js +++ b/www/js/services/tx-services.js @@ -133,8 +133,8 @@ angular.module('cesium.tx.services', ['ngApi', 'cesium.bma.services', var udHistory = []; var txPendings = []; - var nowInSec = Math.trunc(new Date().getTime() / 1000); // TODO test to replace using moment().utc().unix() - fromTime = fromTime || (nowInSec - csSettings.data.walletHistoryTimeSecond); + var nowInSec = moment().utc().unix(); + fromTime = fromTime || fromTime || (nowInSec - csSettings.data.walletHistoryTimeSecond); var processedTxMap = {}; var tx = {}; @@ -149,67 +149,72 @@ angular.module('cesium.tx.services', ['ngApi', 'cesium.bma.services', // get current block csCurrency.blockchain.current(true), - // get pendings history + // get pending tx BMA.tx.history.pending({pubkey: pubkey}) .then(_reduceTx) ]; // get TX history since - if (fromTime > 0) { - var sliceTime = csSettings.data.walletHistorySliceSecond; - fromTime = fromTime - (fromTime % sliceTime); - for(var i = fromTime; i - sliceTime < nowInSec; i += sliceTime) { - jobs.push(BMA.tx.history.times({pubkey: pubkey, from: i, to: i+sliceTime-1}) + if (fromTime !== 'pending') { + + // get TX from a given time + if (fromTime > 0) { + // Use slice, to be able to cache requests result + var sliceTime = csSettings.data.walletHistorySliceSecond; + fromTime = fromTime - (fromTime % sliceTime); + for(var i = fromTime; i - sliceTime < nowInSec; i += sliceTime) { + jobs.push(BMA.tx.history.times({pubkey: pubkey, from: i, to: i+sliceTime-1}) + .then(_reduceTx) + ); + } + + jobs.push(BMA.tx.history.timesNoCache({pubkey: pubkey, from: nowInSec - (nowInSec % sliceTime), to: nowInSec+999999999}) + .then(_reduceTx)); + } + + // get all TX + else { + jobs.push(BMA.tx.history.all({pubkey: pubkey}) .then(_reduceTx) ); } - jobs.push(BMA.tx.history.timesNoCache({pubkey: pubkey, from: nowInSec - (nowInSec % sliceTime), to: nowInSec+999999999}) - .then(_reduceTx)); - } - - // get all TX - else if (fromTime !== 'pending') { - jobs.push(BMA.tx.history.all({pubkey: pubkey}) - .then(_reduceTx) - ); - } - - // get UD history - if (csSettings.data.showUDHistory && fromTime > 0) { - /*jobs.push( - BMA.ud.history({pubkey: pubkey}) - .then(function(res){ - udHistory = !res.history || !res.history.history ? [] : - res.history.history.reduce(function(res, ud){ - if (ud.time < fromTime) return res; // skip to old UD - var amount = powBase(ud.amount, ud.base); - return res.concat({ - time: ud.time, - amount: amount, - isUD: true, - block_number: ud.block_number - }); - }, []); - }));*/ - // API extension - jobs.push( - api.data.raisePromise.loadUDs({ - pubkey: pubkey, - fromTime: fromTime - }) - .then(function(res) { - if (!res || !res.length) return; - udHistory = res.reduce(function(res, hits) { - return res.concat(hits); - }, udHistory); - }) - - .catch(function(err) { - console.debug('Error while loading UDs history, on extension point.'); - console.error(err); + // get UD history + if (csSettings.data.showUDHistory && fromTime > 0) { + /*jobs.push( + BMA.ud.history({pubkey: pubkey}) + .then(function(res){ + udHistory = !res.history || !res.history.history ? [] : + res.history.history.reduce(function(res, ud){ + if (ud.time < fromTime) return res; // skip to old UD + var amount = powBase(ud.amount, ud.base); + return res.concat({ + time: ud.time, + amount: amount, + isUD: true, + block_number: ud.block_number + }); + }, []); + }));*/ + // API extension + jobs.push( + api.data.raisePromise.loadUDs({ + pubkey: pubkey, + fromTime: fromTime }) - ); + .then(function(res) { + if (!res || !res.length) return; + udHistory = res.reduce(function(res, hits) { + return res.concat(hits); + }, udHistory); + }) + + .catch(function(err) { + console.debug('Error while loading UDs history, on extension point.'); + console.error(err); + }) + ); + } } // Execute jobs @@ -281,7 +286,7 @@ angular.module('cesium.tx.services', ['ngApi', 'cesium.bma.services', }, loadData = function(pubkey, fromTime) { - var now = new Date().getTime(); + var now = Date.now(); var data = {}; return $q.all([ @@ -363,14 +368,14 @@ angular.module('cesium.tx.services', ['ngApi', 'cesium.bma.services', return csWot.extendAll((data.tx.history || []).concat(data.tx.validating||[]).concat(data.tx.pendings||[]), 'pubkey'); }) .then(function() { - console.debug('[tx] TX and sources loaded in '+ (new Date().getTime()-now) +'ms'); + console.debug('[tx] TX and sources loaded in '+ (Date.now()-now) +'ms'); return data; }); - }, + }, - loadSources = function(pubkey) { - return loadData(pubkey, 'pending'); - }; + loadSources = function(pubkey) { + return loadData(pubkey, 'pending'); + }; // Download TX history file downloadHistoryFile = function(pubkey, options) { diff --git a/www/js/services/utils-services.js b/www/js/services/utils-services.js index dafea9adbc3c91fedc8e9dc0f456b756004f7c2f..20c30791e386b23fa47d3490f630b7647eaa7cba 100644 --- a/www/js/services/utils-services.js +++ b/www/js/services/utils-services.js @@ -138,6 +138,23 @@ angular.module('cesium.utils.services', []) return $ionicLoading.show(options); } + function updateLoading(options) { + return $ionicLoading._getLoader().then(function(loader) { + if (!loader || !loader.isShown) return; + // Translate template (if exists) + if (options && options.template) { + return $translate(options && options.template) + .then(function(template) { + options.template = template; + return loader; + }); + } + }) + .then(function(loader) { + if (loader && loader.isShown) return showLoading(options); + }); + } + function showToast(message, duration, position) { duration = duration || 'short'; position = position || 'bottom'; @@ -741,7 +758,8 @@ angular.module('cesium.utils.services', []) }, loading: { show: showLoading, - hide: hideLoading + hide: hideLoading, + update: updateLoading }, toast: { show: showToast diff --git a/www/js/services/wallet-services.js b/www/js/services/wallet-services.js index ab5e18ed91ab863b90086424fa3dbe331a82a20f..c811bdfac8b13626a5f2cce13231bdea30303ed9 100644 --- a/www/js/services/wallet-services.js +++ b/www/js/services/wallet-services.js @@ -383,7 +383,7 @@ angular.module('cesium.wallet.services', ['ngApi', 'ngFileSaver', 'cesium.bma.se if (isLogin() && settings.rememberMe) { - var now = new Date().getTime(); + var now = Date.now(); console.debug("[wallet] Storing..."); var jobs = []; @@ -409,7 +409,7 @@ angular.module('cesium.wallet.services', ['ngApi', 'ngFileSaver', 'cesium.bma.se return $q.all(jobs) .then(function() { - console.debug("[wallet] Stored in "+ (new Date().getTime() - now) +"ms"); + console.debug("[wallet] Stored in "+ (Date.now() - now) +"ms"); }); } else { @@ -706,7 +706,7 @@ angular.module('cesium.wallet.services', ['ngApi', 'ngFileSaver', 'cesium.bma.se .catch(function(err){ // Special case for currency init (root block not exists): use now if (err && err.ucode == BMA.errorCodes.BLOCK_NOT_FOUND && blockNumber === 0) { - data.sigDate = Math.trunc(new Date().getTime() / 1000); + data.sigDate = moment().utc().unix(); } else { throw err; @@ -2220,7 +2220,7 @@ angular.module('cesium.wallet.services', ['ngApi', 'ngFileSaver', 'cesium.bma.se options.restore = angular.isDefined(options.restore) ? options.restore : (id === 'default'); console.debug('[wallet] Starting...'); - var now = new Date().getTime(); + var now = Date.now(); startPromise = $q.all([ csSettings.ready() @@ -2238,7 +2238,7 @@ angular.module('cesium.wallet.services', ['ngApi', 'ngFileSaver', 'cesium.bma.se startPromise.then(function() { addListeners(); - console.debug('[wallet] Started in ' + (new Date().getTime() - now) + 'ms'); + console.debug('[wallet] Started in ' + (Date.now() - now) + 'ms'); started = true; startPromise = null; diff --git a/www/js/services/wot-services.js b/www/js/services/wot-services.js index c0c828fadfbda6ab6c2e406064b4f1cbabfb4b95..a3b740b3cd6c53b836150e0b330a9838a2922f41 100644 --- a/www/js/services/wot-services.js +++ b/www/js/services/wot-services.js @@ -329,7 +329,7 @@ angular.module('cesium.wot.services', ['ngApi', 'cesium.bma.services', 'cesium.c .catch(function(err){ // Special case for currency init (root block not exists): use now if (err && err.ucode == BMA.errorCodes.BLOCK_NOT_FOUND && identity.number === 0) { - identity.sigDate = Math.trunc(new Date().getTime() / 1000); + identity.sigDate = moment().utc().unix(); return identity; } else { @@ -597,7 +597,7 @@ angular.module('cesium.wot.services', ['ngApi', 'cesium.bma.services', 'cesium.c }; } - var now = new Date().getTime(); + var now = Date.now(); var parameters; var medianTime; @@ -617,7 +617,7 @@ angular.module('cesium.wot.services', ['ngApi', 'cesium.bma.services', 'cesium.c .catch(function(err){ // Special case for currency init (root block not exists): use now if (err && err.ucode == BMA.errorCodes.NO_CURRENT_BLOCK) { - medianTime = Math.trunc(new Date().getTime()/1000); + medianTime = Math.trunc(Date.now()/1000); } else { throw err; @@ -677,7 +677,7 @@ angular.module('cesium.wot.services', ['ngApi', 'cesium.bma.services', 'cesium.c if (!data.pubkey) return undefined; // not found delete data.lookup; // not need anymore identityCache.put(data.pubkey, data); // add to cache - console.debug('[wot] Identity '+ data.pubkey.substring(0, 8) +' loaded in '+ (new Date().getTime()-now) +'ms'); + console.debug('[wot] Identity '+ data.pubkey.substring(0, 8) +' loaded in '+ (Date.now()-now) +'ms'); return data; }); }, @@ -867,7 +867,7 @@ angular.module('cesium.wot.services', ['ngApi', 'cesium.bma.services', 'cesium.c getPending = function(offset, size) { offset = offset || 0; size = size || 20; - var now = new Date().getTime(); + var now = Date.now(); return $q.all([ BMA.wot.member.uids(), BMA.wot.member.pending() @@ -943,7 +943,7 @@ angular.module('cesium.wot.services', ['ngApi', 'cesium.bma.services', 'cesium.c extendAll(idties, 'pubkey', true/*skipAddUid*/) ]) .then(function() { - console.debug("[ES] [wot] Loaded {0}/{1} pending identities in {2} ms".format(idties && idties.length || 0, total, new Date().getTime() - now)); + console.debug("[ES] [wot] Loaded {0}/{1} pending identities in {2} ms".format(idties && idties.length || 0, total, Date.now() - now)); return { hits: idties, total: total diff --git a/www/plugins/es/js/controllers/blockchain-controllers.js b/www/plugins/es/js/controllers/blockchain-controllers.js index 10c675d03f8c0bed37c44292a1f2af24ecc8b172..5fc4be820e04df151ff6f18c2a4ae2563580a23f 100644 --- a/www/plugins/es/js/controllers/blockchain-controllers.js +++ b/www/plugins/es/js/controllers/blockchain-controllers.js @@ -134,7 +134,7 @@ function ESBlockLookupController($scope, $controller, $ionicPopover, $location, promise = esBlockchain.block.searchText($scope.currency, $scope.search.query, request); } - var time = new Date().getTime(); + var now = Date.now(); return promise .then(function(result) { // Apply transformation need by UI (e.g add avatar and name...) @@ -146,7 +146,7 @@ function ESBlockLookupController($scope, $controller, $ionicPopover, $location, .then(function(result) { $scope.showPubkey = ($scope.search.sort == 'issuer'); // Compute time only once (on first page) - $scope.search.took = (from === 0) ? (new Date().getTime() - time) : $scope.search.took; + $scope.search.took = (from === 0) ? (Date.now() - now) : $scope.search.took; // Keep previous total, when already computed (because of current, that is excluded only in the first page) var total = (from === 0) ? result.total : $scope.search.total; $scope.doDisplayResult(result.hits, from, total); diff --git a/www/plugins/es/js/controllers/group-controllers.js b/www/plugins/es/js/controllers/group-controllers.js index 2c75e3ebc9a4c1c5ec26377be447f60d4fca018b..229fc3316009195ac48cbf2100d3f4fb3a25cf3b 100644 --- a/www/plugins/es/js/controllers/group-controllers.js +++ b/www/plugins/es/js/controllers/group-controllers.js @@ -381,7 +381,7 @@ function ESGroupEditController($scope, esGroup, UIUtils, $state, $q, Device, .then(function(){ var json = $scope.formData; - json.time = esHttp.date.now(); + json.time = moment().utc().unix(); // Resize pictures json.picturesCount = $scope.pictures.length; @@ -411,7 +411,7 @@ function ESGroupEditController($scope, esGroup, UIUtils, $state, $q, Device, .then(function(json){ // Create if (!$scope.id) { - json.creationTime = esHttp.date.now(); + json.creationTime = moment().utc().unix(); return esGroup.record.add(json); } // Update diff --git a/www/plugins/es/js/controllers/invitation-controllers.js b/www/plugins/es/js/controllers/invitation-controllers.js index 84002729baa24e2a51380b0dc4627652a3036a65..2115260fd70c06cca75cd6d8de9fee1dc5b27c57 100644 --- a/www/plugins/es/js/controllers/invitation-controllers.js +++ b/www/plugins/es/js/controllers/invitation-controllers.js @@ -426,7 +426,7 @@ function NewInvitationModalController($scope, $q, Modals, UIUtils, csWallet, esH var confirm = res && res[1]; if (!keypair || !confirm) return; UIUtils.loading.show(); - var time = esHttp.date.now(); // use same date for each invitation + var time = moment().utc().unix(); // use same date for each invitation var comment = $scope.formData.useComment && $scope.formData.comment && $scope.formData.comment.trim(); return $q.all( $scope.recipients.reduce(function (res, recipient) { diff --git a/www/plugins/es/js/controllers/message-controllers.js b/www/plugins/es/js/controllers/message-controllers.js index 5cd8f2b4167f351a0c0dfc0a74a664fe7ca64ec6..3056a9ba69c5d14ce52aa77bcd375145c84db38e 100644 --- a/www/plugins/es/js/controllers/message-controllers.js +++ b/www/plugins/es/js/controllers/message-controllers.js @@ -576,7 +576,7 @@ function ESMessageComposeModalController($scope, Modals, UIUtils, csWallet, esHt recipient: $scope.formData.destPub, title: $scope.formData.title, content: $scope.formData.content, - time: esHttp.date.now() + time: moment().utc().unix() }; esMessage.send(data, {wallet: wallet}) diff --git a/www/plugins/es/js/controllers/registry-controllers.js b/www/plugins/es/js/controllers/registry-controllers.js index 218a4adba30c8b2035d72852bd554056a505eac4..cd790cd43e9bf86d97fe87cf4e16cb79f97d92ff 100644 --- a/www/plugins/es/js/controllers/registry-controllers.js +++ b/www/plugins/es/js/controllers/registry-controllers.js @@ -1207,7 +1207,7 @@ function ESRegistryRecordEditController($scope, $timeout, $state, $q, $ionicHis if (!$scope.needCategory()) { delete json.category; } - json.time = esHttp.date.now(); + json.time = moment().utc().unix(); // geo point if (json.geoPoint && json.geoPoint.lat && json.geoPoint.lon) { diff --git a/www/plugins/es/js/controllers/wot-controllers.js b/www/plugins/es/js/controllers/wot-controllers.js index fd2ea719202343e63ab0c490b76c52abe65c561c..28b4e62fa873733f11c8bd67ab3470b4499f8fde 100644 --- a/www/plugins/es/js/controllers/wot-controllers.js +++ b/www/plugins/es/js/controllers/wot-controllers.js @@ -163,7 +163,7 @@ function ESWotIdentityViewController($scope, $ionicPopover, $q, $controller, UIU var keypair = res[0]; var confirm = res[1]; if (!confirm) return; - var time = esHttp.date.now(); // use same date for each invitation + var time = moment().utc().unix(); // use same date for each invitation return $q.all( identities.reduce(function(res, identity){ return res.concat( @@ -225,7 +225,7 @@ function ESWotIdentityViewController($scope, $ionicPopover, $q, $controller, UIU var keypair = res && res[0]; var confirm = res && res[1]; if (!keypair || !confirm) return; - var time = esHttp.date.now(); // use same date for each invitation + var time = moment().utc().unix(); // use same date for each invitation return $q.all(identities.reduce(function(res, identity){ return res.concat( esInvitation.send({ diff --git a/www/plugins/es/js/services/comment-services.js b/www/plugins/es/js/services/comment-services.js index f1ae520c6609958d3a213ef0cd6dedf8a316d0cf..339b3b752986396371165a49c92f6d337803e017 100644 --- a/www/plugins/es/js/services/comment-services.js +++ b/www/plugins/es/js/services/comment-services.js @@ -196,7 +196,7 @@ angular.module('cesium.es.comment.services', ['ngResource', 'cesium.services', }); // Open websocket - var time = new Date().getTime(); + var time = Date.now(); console.info("[ES] [comment] Starting websocket to listen comments on [{0}/record/{1}]".format(index, recordId.substr(0,8))); var wsChanges = exports.raw.wsChanges(); return wsChanges.open() @@ -208,7 +208,7 @@ angular.module('cesium.es.comment.services', ['ngResource', 'cesium.services', // Listen changes .then(function(){ - console.debug("[ES] [comment] Websocket opened in {0} ms".format(new Date().getTime() - time)); + console.debug("[ES] [comment] Websocket opened in {0} ms".format(Date.now() - time)); wsChanges.on(function(change) { if (!change) return; scope.$applyAsync(function() { @@ -267,7 +267,7 @@ angular.module('cesium.es.comment.services', ['ngResource', 'cesium.services', // Preparing JSON to sent var id = comment.id; var json = { - creationTime: id ? comment.creationTime || comment.time/*for compat*/ : esHttp.date.now(), + creationTime: id ? comment.creationTime || comment.time/*for compat*/ : moment().utc().unix(), message: comment.message, record: recordId, issuer: csWallet.data.pubkey diff --git a/www/plugins/es/js/services/crypto-services.js b/www/plugins/es/js/services/crypto-services.js index 1ddf3feaef45ae2daea41b8ee2e82a07a22b7a32..c715451e53e42525a67bbb59ea58c010136b71fd 100644 --- a/www/plugins/es/js/services/crypto-services.js +++ b/www/plugins/es/js/services/crypto-services.js @@ -92,7 +92,7 @@ angular.module('cesium.es.crypto.services', ['ngResource', 'cesium.services']) cypherFieldNames = [cypherFieldNames]; } - var now = new Date().getTime(); + var now = Date.now(); var issuerBoxPks = {}; // a map used as cache var jobs = [getBoxKeypair(keypair)]; @@ -129,7 +129,7 @@ angular.module('cesium.es.crypto.services', ['ngResource', 'cesium.services']) }, [])); }) .then(function() { - console.debug('[ES] [crypto] All record decrypted in ' + (new Date().getTime() - now) + 'ms'); + console.debug('[ES] [crypto] All record decrypted in ' + (Date.now() - now) + 'ms'); return records; }); diff --git a/www/plugins/es/js/services/document-services.js b/www/plugins/es/js/services/document-services.js index 7eb8d2f1df6ba47cc78bfd3392537e14724981b4..fc58393ba5dd17d2da15b0cd61c98c435c6404aa 100644 --- a/www/plugins/es/js/services/document-services.js +++ b/www/plugins/es/js/services/document-services.js @@ -147,7 +147,7 @@ angular.module('cesium.es.document.services', ['ngResource', 'cesium.platform', options.index, options.type )); - var now = new Date().getTime(); + var now = Date.now(); return raw.searchText(request) .then(function(res) { @@ -158,7 +158,7 @@ angular.module('cesium.es.document.services', ['ngResource', 'cesium.platform', options.index, options.type, res && res.hits && res.hits.length || 0, - new Date().getTime() - now + Date.now() - now )); return res; }); diff --git a/www/plugins/es/js/services/geo-services.js b/www/plugins/es/js/services/geo-services.js index 960977828319dfa65a18fa5c2e281d3369bde617..ae8e870a1b427654dc6088dedf2c2ed3d4e2c77b 100644 --- a/www/plugins/es/js/services/geo-services.js +++ b/www/plugins/es/js/services/geo-services.js @@ -88,7 +88,7 @@ angular.module('cesium.es.geo.services', ['cesium.services', 'cesium.es.http.ser query.addressdetails = 1; // need address field - var now = new Date(); + var now = Date.now(); //console.debug('[ES] [geo] Searching position...', query); return that.raw.osm.search(query) @@ -116,7 +116,7 @@ angular.module('cesium.es.geo.services', ['cesium.services', 'cesium.es.http.ser }); }, []); - console.debug('[ES] [geo] Found {0} address position(s)'.format(res && res.length || 0, new Date().getTime() - now.getTime()), res); + console.debug('[ES] [geo] Found {0} address position(s)'.format(res && res.length || 0, Date.now() - now), res); return res.length ? res : undefined; }) @@ -156,7 +156,7 @@ angular.module('cesium.es.geo.services', ['cesium.services', 'cesium.es.http.ser return that.raw.freegeoip.search({ip: ip}) .then(function(res) { - //console.debug('[ES] [geo] Found IP {0} position in {0}ms'.format(res ? 1 : 0, new Date().getTime() - now.getTime())); + //console.debug('[ES] [geo] Found IP {0} position in {0}ms'.format(res ? 1 : 0, Date.now() - now.getTime())); return res ? { lat: res.latitude, lng: res.longitude diff --git a/www/plugins/es/js/services/http-services.js b/www/plugins/es/js/services/http-services.js index f3ec90094d84db79fb2284c5129eae7ad42dfa40..d5e5780b978d19bd0553df84e3800eba94fa67b3 100644 --- a/www/plugins/es/js/services/http-services.js +++ b/www/plugins/es/js/services/http-services.js @@ -138,11 +138,6 @@ angular.module('cesium.es.http.services', ['ngResource', 'ngApi', 'cesium.servic return that.start(true /*skipInit*/); }; - - - // Get time (UTC) - that.date = { now : csHttp.date.now }; - that.getUrl = function(path) { return csHttp.getUrl(that.host, that.port, path, that.useSsl); }; @@ -284,7 +279,7 @@ angular.module('cesium.es.http.services', ['ngResource', 'ngApi', 'cesium.servic that.server, (that.useSsl ? ' (SSL on)' : '') )); - var now = new Date().getTime(); + var now = Date.now(); return that.checkNodeAlive() .then(function(alive) { @@ -300,7 +295,7 @@ angular.module('cesium.es.http.services', ['ngResource', 'ngApi', 'cesium.servic // Add listeners addListeners(); - console.debug('[ES] [http] Started in '+(new Date().getTime()-now)+'ms'); + console.debug('[ES] [http] Started in '+(Date.now()-now)+'ms'); that.api.node.raise.start(); @@ -453,11 +448,11 @@ angular.module('cesium.es.http.services', ['ngResource', 'ngApi', 'cesium.servic return (wallet.isAuth() ? $q.when(wallet.data) : wallet.auth({silent: true, minData: true})) .then(function() { if (options.creationTime && !record.creationTime) { - record.creationTime = that.date.now(); + record.creationTime = moment().utc().unix(); } // Always update the time - fix #572 // Make sure time is always > previous (required by ES node) - var now = that.date.now(); + var now = moment().utc().unix(); record.time = (!record.time || record.time < now) ? now : (record.time+1); var obj = angular.copy(record); @@ -507,7 +502,7 @@ angular.module('cesium.es.http.services', ['ngResource', 'ngApi', 'cesium.servic type: type, id: id, issuer: walletData.pubkey, - time: that.date.now() + time: moment().utc().unix() }; var str = JSON.stringify(obj); return CryptoUtils.util.hash(str) diff --git a/www/plugins/es/js/services/invitation-services.js b/www/plugins/es/js/services/invitation-services.js index 98ae24b1a2e9f3de9887a9340b03f465753d500e..f10946c8f9eadfa79b034888a51ba4601b48af5f 100644 --- a/www/plugins/es/js/services/invitation-services.js +++ b/www/plugins/es/js/services/invitation-services.js @@ -55,7 +55,7 @@ angular.module('cesium.es.invitation.services', ['cesium.platform', return deferred.promise; } - var now = new Date().getTime(); + var now = Date.now(); var time = Math.trunc(now / 1000); // Skip if loaded less than 1 min ago @@ -74,7 +74,7 @@ angular.module('cesium.es.invitation.services', ['cesium.platform', data.invitations = data.invitations || {}; data.invitations.unreadCount = unreadCount; data.invitations.time = time; - console.debug('[ES] [invitation] Loaded count (' + unreadCount + ') in '+(new Date().getTime()-now)+'ms'); + console.debug('[ES] [invitation] Loaded count (' + unreadCount + ') in '+(Date.now()-now)+'ms'); deferred.resolve(data); }) .catch(function(err){ @@ -305,7 +305,7 @@ angular.module('cesium.es.invitation.services', ['cesium.platform', type = type || 'certification'; console.debug('[ES] [invitation] Deleting all invitations...'); - var now = new Date().getTime(); + var now = Date.now(); var countBeforeDeletion = (csWallet.data.invitations && csWallet.data.invitations.count) || 0; var unreadCountBeforeDeletion = (csWallet.data.invitations && csWallet.data.invitations.unreadCount) || 0; @@ -337,7 +337,7 @@ angular.module('cesium.es.invitation.services', ['cesium.platform', csWallet.data.invitations.unreadCount = 0; } - console.debug('[ES] [invitation] All invitations deleted in {0}ms'.format(new Date().getTime()-now)); + console.debug('[ES] [invitation] All invitations deleted in {0}ms'.format(Date.now()-now)); }); }); } diff --git a/www/plugins/es/js/services/message-services.js b/www/plugins/es/js/services/message-services.js index 853c78e8e69dea8dfcd7bf150de01e2483f924d8..26439b291e6b511a29daf0f612709ea19f604bf8 100644 --- a/www/plugins/es/js/services/message-services.js +++ b/www/plugins/es/js/services/message-services.js @@ -52,7 +52,7 @@ angular.module('cesium.es.message.services', ['ngResource', 'cesium.platform', return deferred.promise; } - var now = new Date().getTime(); + var now = Date.now(); var time = Math.trunc(now / 1000); // Skip if loaded less than 1 min ago @@ -71,7 +71,7 @@ angular.module('cesium.es.message.services', ['ngResource', 'cesium.platform', data.messages = data.messages || {}; data.messages.unreadCount = unreadCount; data.messages.time = time; - console.debug('[ES] [message] Loaded count (' + unreadCount + ') in '+(new Date().getTime()-now)+'ms'); + console.debug('[ES] [message] Loaded count (' + unreadCount + ') in '+(Date.now()-now)+'ms'); deferred.resolve(data); }) .catch(function(err){ @@ -329,7 +329,7 @@ angular.module('cesium.es.message.services', ['ngResource', 'cesium.platform', function decryptMessages(messages, keypair, withSummary) { - var now = new Date().getTime(); + var now = Date.now(); var issuerBoxPks = {}; // a map used as cache var jobs = [esWallet.box.getKeypair(keypair)]; @@ -380,7 +380,7 @@ angular.module('cesium.es.message.services', ['ngResource', 'cesium.platform', }, [])); }) .then(function() { - console.debug('[ES] [message] All messages decrypted in ' + (new Date().getTime() - now) + 'ms'); + console.debug('[ES] [message] All messages decrypted in ' + (Date.now() - now) + 'ms'); return messages; }); @@ -592,7 +592,7 @@ angular.module('cesium.es.message.services', ['ngResource', 'cesium.platform', console.info("[ES] [message] Sending logs to developers..."); message.issuer = csWallet.data.pubkey; message.title = message.title || 'Sending log'; - message.time = esHttp.date.now(); + message.time = moment().utc().unix(); csWallet.getKeypair() .then(function(keypair) { diff --git a/www/plugins/es/js/services/notification-services.js b/www/plugins/es/js/services/notification-services.js index 6ba475cad14c5810f5f29cf92f6d5fd64657c6b8..466f4322eb3e7611100852b39bf34990f27466ab 100644 --- a/www/plugins/es/js/services/notification-services.js +++ b/www/plugins/es/js/services/notification-services.js @@ -249,7 +249,7 @@ angular.module('cesium.es.notification.services', ['cesium.platform', 'cesium.es return deferred.promise; } - var now = new Date().getTime(); + var now = Date.now(); var time = Math.trunc(now / 1000); // Skip if loaded less than 1 min ago @@ -276,7 +276,7 @@ angular.module('cesium.es.notification.services', ['cesium.platform', 'cesium.es data.notifications.unreadCount = unreadCount; data.notifications.warnCount = countWarnEvents(data); - console.debug('[ES] [notification] Loaded count (' + unreadCount + ') in '+(new Date().getTime()-now)+'ms'); + console.debug('[ES] [notification] Loaded count (' + unreadCount + ') in '+(Date.now()-now)+'ms'); deferred.resolve(data); }) .catch(deferred.reject); diff --git a/www/plugins/es/js/services/settings-services.js b/www/plugins/es/js/services/settings-services.js index 21724f6cde3f1848a8befe05a5356e1012ff97a9..5b8756a7e1a5b02bf10d4b24a60d4e407308ad74 100644 --- a/www/plugins/es/js/services/settings-services.js +++ b/www/plugins/es/js/services/settings-services.js @@ -122,7 +122,7 @@ angular.module('cesium.es.settings.services', ['cesium.services', 'cesium.es.htt // Load settings function loadSettings(pubkey, boxKeypair) { - var now = new Date().getTime(); + var now = Date.now(); return that.get({id: pubkey}) .catch(function(err){ if (err && err.ucode && err.ucode == 404) { @@ -139,7 +139,7 @@ angular.module('cesium.es.settings.services', ['cesium.services', 'cesium.es.htt var record = res._source; // Do not apply if same version if (record.time === csSettings.data.time) { - console.debug('[ES] [settings] Loaded in '+ (new Date().getTime()-now) +'ms, but already up to date'); + console.debug('[ES] [settings] Loaded in '+ (Date.now()-now) +'ms, but already up to date'); return; } var nonce = CryptoUtils.util.decode_base58(record.nonce); @@ -148,7 +148,7 @@ angular.module('cesium.es.settings.services', ['cesium.services', 'cesium.es.htt .then(function(json) { var settings = JSON.parse(json || '{}'); settings.time = record.time; - console.debug('[ES] [settings] Loaded and decrypted in '+ (new Date().getTime()-now) +'ms'); + console.debug('[ES] [settings] Loaded and decrypted in '+ (Date.now()-now) +'ms'); return settings; }) // if error: skip stored content @@ -250,7 +250,7 @@ angular.module('cesium.es.settings.services', ['cesium.services', 'cesium.es.htt return storeSettingsLocally(); } - var time = esHttp.date.now(); // always update time + var time = moment().utc().unix(); // always update time console.debug('[ES] [settings] Saving user settings remotely...'); return $q.all([ @@ -297,7 +297,7 @@ angular.module('cesium.es.settings.services', ['cesium.services', 'cesium.es.htt // Update settings version, then store (on local store only) data.time = time; previousRemoteData = filteredData; - console.debug('[ES] [settings] Saved user settings remotely in ' + (esHttp.date.now() - time) + 'ms'); + console.debug('[ES] [settings] Saved user settings remotely in ' + (moment().utc().unix() - time) + 'ms'); return storeSettingsLocally(); }) .catch(function(err) { diff --git a/www/plugins/es/js/services/tx-services.js b/www/plugins/es/js/services/tx-services.js index 886495fc8834362cc7f3a75d20c754d6b202b75f..b4aa8e5c409f865f0b1351ae5ea0d1cfbb64a942 100644 --- a/www/plugins/es/js/services/tx-services.js +++ b/www/plugins/es/js/services/tx-services.js @@ -43,8 +43,6 @@ angular.module('cesium.es.tx.services', ['ngResource', 'cesium.services', 'cesiu var memberships = res[1]; if (!currency || !memberships || !memberships.length) return; - console.debug(memberships); - // Filter memberships using options.fromTime if (options.fromTime !== -1) { memberships = memberships.reduce(function(res, membership) { diff --git a/www/plugins/es/js/services/wallet-services.js b/www/plugins/es/js/services/wallet-services.js index 705780a9669548c6559f24d46441ee85908d91f8..a498bba037d42a10f06356f1d8ac985f2129d986 100644 --- a/www/plugins/es/js/services/wallet-services.js +++ b/www/plugins/es/js/services/wallet-services.js @@ -56,7 +56,7 @@ angular.module('cesium.es.wallet.services', ['ngResource', 'cesium.platform', 'c } console.debug('[ES] [wallet] Loading user avatar+name...'); - var now = new Date().getTime(); + var now = Date.now(); esProfile.getAvatarAndName(data.pubkey) .then(function(profile) { @@ -64,7 +64,7 @@ angular.module('cesium.es.wallet.services', ['ngResource', 'cesium.platform', 'c data.name = profile.name; data.avatarStyle = profile.avatarStyle; data.avatar = profile.avatar; - console.debug('[ES] [wallet] Loaded user avatar+name in '+ (new Date().getTime()-now) +'ms'); + console.debug('[ES] [wallet] Loaded user avatar+name in '+ (Date.now()-now) +'ms'); } else { console.debug('[ES] [wallet] No user avatar+name found'); @@ -90,7 +90,7 @@ angular.module('cesium.es.wallet.services', ['ngResource', 'cesium.platform', 'c } console.debug('[ES] [wallet] Loading full user profile...'); - var now = new Date().getTime(); + var now = Date.now(); // Load full profile esProfile.get(data.pubkey) @@ -100,7 +100,7 @@ angular.module('cesium.es.wallet.services', ['ngResource', 'cesium.platform', 'c data.avatar = profile.avatar; data.profile = profile.source; data.profile.description = profile.description; - console.debug('[ES] [wallet] Loaded full user profile in '+ (new Date().getTime()-now) +'ms'); + console.debug('[ES] [wallet] Loaded full user profile in '+ (Date.now()-now) +'ms'); } deferred.resolve(); }); diff --git a/www/plugins/graph/js/controllers/common-controllers.js b/www/plugins/graph/js/controllers/common-controllers.js index 1f79881825fa04ffe562d5921a9043b6031cfbc7..55ee0d5e61ad1cf6479e963fa5c29c68e2722171 100644 --- a/www/plugins/graph/js/controllers/common-controllers.js +++ b/www/plugins/graph/js/controllers/common-controllers.js @@ -71,7 +71,7 @@ function GpCurrencyAbstractController($scope, $filter, $ionicPopover, $ionicHist if (!$scope.formData.firstBlockTime){ console.warn('[graph] currency.firstBlockTime not loaded ! Should have been loaded by currrency service!'); } - $scope.formData.currencyAge = _truncDate(esHttp.date.now()) - $scope.formData.firstBlockTime; + $scope.formData.currencyAge = _truncDate(moment().utc().unix()) - $scope.formData.firstBlockTime; return $scope.enter(e, state); }); diff --git a/www/plugins/map/js/controllers/wot-controllers.js b/www/plugins/map/js/controllers/wot-controllers.js index 7626ed09d2b38d8ce7da17ffd910c9cf102c214f..c11884f2900195517de2e6ed5bb1c595f507ec65 100644 --- a/www/plugins/map/js/controllers/wot-controllers.js +++ b/www/plugins/map/js/controllers/wot-controllers.js @@ -150,7 +150,7 @@ function MapWotViewController($scope, $filter, $templateCache, $interpolate, $ti }, true); // Load the map (and init if need) - var now = new Date().getTime(); + var now = Date.now(); $scope.loadMap() .then($scope.load) .then(function() { diff --git a/www/plugins/map/js/services/registry-services.js b/www/plugins/map/js/services/registry-services.js index 3ca5df42a564a1321b1a75e6cac92228d4b2e67a..30cc657f1024c1e50c923cecb44d5e4cbb49a294 100644 --- a/www/plugins/map/js/services/registry-services.js +++ b/www/plugins/map/js/services/registry-services.js @@ -168,7 +168,7 @@ angular.module('cesium.map.registry.services', ['cesium.services']) // Resolve missing positions by addresses (only if google API enable) if (searchAddressItems.length) { - var now = new Date().getTime(); + var now = Date.now(); console.debug('[map] [registry] Search positions of {0} addresses...'.format(searchAddressItems.length)); var counter = 0; @@ -189,7 +189,7 @@ angular.module('cesium.map.registry.services', ['cesium.services']) .catch(function() {/*silent*/})); }, [])) .then(function(){ - console.debug('[map] [registry] Resolved {0}/{1} addresses in {2}ms'.format(counter, searchAddressItems.length, new Date().getTime()-now)); + console.debug('[map] [registry] Resolved {0}/{1} addresses in {2}ms'.format(counter, searchAddressItems.length, Date.now()-now)); return items; }); } diff --git a/www/plugins/map/js/services/wot-services.js b/www/plugins/map/js/services/wot-services.js index b46ccf9656b7100f3215d77e12fed29382ced8cd..62c7a885b15e1477fe87abe69764d386117ba342 100644 --- a/www/plugins/map/js/services/wot-services.js +++ b/www/plugins/map/js/services/wot-services.js @@ -196,7 +196,7 @@ angular.module('cesium.map.wot.services', ['cesium.services']) // Resolve missing positions by addresses (only if google API enable) if (searchAddressItems.length) { - var now = new Date().getTime(); + var now = Date.now(); console.debug('[map] [wot] Search positions of {0} addresses...'.format(searchAddressItems.length)); var counter = 0; @@ -217,7 +217,7 @@ angular.module('cesium.map.wot.services', ['cesium.services']) .catch(function() {/*silent*/})); }, [])) .then(function(){ - console.debug('[map] [wot] Resolved {0}/{1} addresses in {2}ms'.format(counter, searchAddressItems.length, new Date().getTime()-now)); + console.debug('[map] [wot] Resolved {0}/{1} addresses in {2}ms'.format(counter, searchAddressItems.length, Date.now()-now)); return items; }); }