Skip to content
Snippets Groups Projects
Commit ef2b0124 authored by Benoit Lavenier's avatar Benoit Lavenier
Browse files

Revert variables using ES2015 (const/let)

parent 4310fca9
Branches
No related tags found
No related merge requests found
...@@ -243,7 +243,7 @@ angular.module('cesium.filters', ['cesium.config', 'cesium.platform', 'pascalpre ...@@ -243,7 +243,7 @@ angular.module('cesium.filters', ['cesium.config', 'cesium.platform', 'pascalpre
.filter('formatFromNowAndDate', function(filterTranslations) { .filter('formatFromNowAndDate', function(filterTranslations) {
return function(input, options) { return function(input, options) {
const m = input && moment.unix(parseInt(input)); var m = input && moment.unix(parseInt(input));
return m && (m.fromNow() + (options && options.separator || ' | ') + m.local().format(filterTranslations.DATE_PATTERN || 'YYYY-MM-DD HH:mm')) || ''; return m && (m.fromNow() + (options && options.separator || ' | ') + m.local().format(filterTranslations.DATE_PATTERN || 'YYYY-MM-DD HH:mm')) || '';
}; };
}) })
...@@ -334,7 +334,7 @@ angular.module('cesium.filters', ['cesium.config', 'cesium.platform', 'pascalpre ...@@ -334,7 +334,7 @@ angular.module('cesium.filters', ['cesium.config', 'cesium.platform', 'pascalpre
.filter('medianFromNowAndDate', function(filterTranslations) { .filter('medianFromNowAndDate', function(filterTranslations) {
return function(input, options) { return function(input, options) {
const m = input && moment.unix(parseInt(input)+filterTranslations.MEDIAN_TIME_OFFSET); var m = input && moment.unix(parseInt(input)+filterTranslations.MEDIAN_TIME_OFFSET);
return m && (m.fromNow() + (options && options.separator || ' | ') + m.local().format(filterTranslations.DATE_PATTERN || 'YYYY-MM-DD HH:mm')) || ''; return m && (m.fromNow() + (options && options.separator || ' | ') + m.local().format(filterTranslations.DATE_PATTERN || 'YYYY-MM-DD HH:mm')) || '';
}; };
}) })
......
...@@ -240,7 +240,7 @@ angular.module('cesium.currency.services', ['ngApi', 'cesium.bma.services']) ...@@ -240,7 +240,7 @@ angular.module('cesium.currency.services', ['ngApi', 'cesium.bma.services'])
.then(function(currentBlock) { .then(function(currentBlock) {
const now = moment().utc().unix(); var now = moment().utc().unix();
if (cache) { if (cache) {
if (currentBlock && (now - currentBlock.receivedAt) < 60/*1min*/) { if (currentBlock && (now - currentBlock.receivedAt) < 60/*1min*/) {
......
...@@ -128,24 +128,24 @@ angular.module('cesium.tx.services', ['ngApi', 'cesium.bma.services', ...@@ -128,24 +128,24 @@ angular.module('cesium.tx.services', ['ngApi', 'cesium.bma.services',
loadTx = function(pubkey, fromTime) { loadTx = function(pubkey, fromTime) {
return $q(function(resolve, reject) { return $q(function(resolve, reject) {
const nowInSec = moment().utc().unix(); var nowInSec = moment().utc().unix();
fromTime = fromTime || fromTime || (nowInSec - csSettings.data.walletHistoryTimeSecond); fromTime = fromTime || fromTime || (nowInSec - csSettings.data.walletHistoryTimeSecond);
const tx = { var tx = {
pendings: [], pendings: [],
validating: [], validating: [],
history: [], history: [],
errors: [] errors: []
}; };
const processedTxMap = {}; var processedTxMap = {};
const _reduceTx = function (res) { var _reduceTx = function (res) {
_reduceTxAndPush(pubkey, res.history.sent, tx.history, processedTxMap); _reduceTxAndPush(pubkey, res.history.sent, tx.history, processedTxMap);
_reduceTxAndPush(pubkey, res.history.received, tx.history, processedTxMap); _reduceTxAndPush(pubkey, res.history.received, tx.history, processedTxMap);
_reduceTxAndPush(pubkey, res.history.sending, tx.pendings, processedTxMap, true /*allow pendings*/); _reduceTxAndPush(pubkey, res.history.sending, tx.pendings, processedTxMap, true /*allow pendings*/);
_reduceTxAndPush(pubkey, res.history.pending, tx.pendings, processedTxMap, true /*allow pendings*/); _reduceTxAndPush(pubkey, res.history.pending, tx.pendings, processedTxMap, true /*allow pendings*/);
}; };
const jobs = [ var jobs = [
// get current block // get current block
csCurrency.blockchain.current(true), csCurrency.blockchain.current(true),
...@@ -160,7 +160,7 @@ angular.module('cesium.tx.services', ['ngApi', 'cesium.bma.services', ...@@ -160,7 +160,7 @@ angular.module('cesium.tx.services', ['ngApi', 'cesium.bma.services',
// get TX from a given time // get TX from a given time
if (fromTime > 0) { if (fromTime > 0) {
// Use slice, to be able to cache requests result // Use slice, to be able to cache requests result
const sliceTime = csSettings.data.walletHistorySliceSecond; var sliceTime = csSettings.data.walletHistorySliceSecond;
fromTime = fromTime - (fromTime % sliceTime); fromTime = fromTime - (fromTime % sliceTime);
for(var i = fromTime; i - sliceTime < nowInSec; i += sliceTime) { for(var i = fromTime; i - sliceTime < nowInSec; i += sliceTime) {
jobs.push(BMA.tx.history.times({pubkey: pubkey, from: i, to: i+sliceTime-1}) jobs.push(BMA.tx.history.times({pubkey: pubkey, from: i, to: i+sliceTime-1})
...@@ -220,7 +220,7 @@ angular.module('cesium.tx.services', ['ngApi', 'cesium.bma.services', ...@@ -220,7 +220,7 @@ angular.module('cesium.tx.services', ['ngApi', 'cesium.bma.services',
// Execute jobs // Execute jobs
$q.all(jobs) $q.all(jobs)
.then(function(res){ .then(function(res){
const current = res[0]; var current = res[0];
// sort by time desc // sort by time desc
tx.history.sort(function(tx1, tx2) { tx.history.sort(function(tx1, tx2) {
...@@ -264,7 +264,7 @@ angular.module('cesium.tx.services', ['ngApi', 'cesium.bma.services', ...@@ -264,7 +264,7 @@ angular.module('cesium.tx.services', ['ngApi', 'cesium.bma.services',
loadSourcesAndBalance = function(pubkey) { loadSourcesAndBalance = function(pubkey) {
return BMA.tx.sources({pubkey: pubkey}) return BMA.tx.sources({pubkey: pubkey})
.then(function(res){ .then(function(res){
const data = { var data = {
sources: [], sources: [],
sourcesIndexByKey: [], sourcesIndexByKey: [],
balance: 0 balance: 0
...@@ -281,7 +281,7 @@ angular.module('cesium.tx.services', ['ngApi', 'cesium.bma.services', ...@@ -281,7 +281,7 @@ angular.module('cesium.tx.services', ['ngApi', 'cesium.bma.services',
}, },
loadData = function(pubkey, fromTime) { loadData = function(pubkey, fromTime) {
const now = Date.now(); var now = Date.now();
return $q.all([ return $q.all([
...@@ -294,25 +294,25 @@ angular.module('cesium.tx.services', ['ngApi', 'cesium.bma.services', ...@@ -294,25 +294,25 @@ angular.module('cesium.tx.services', ['ngApi', 'cesium.bma.services',
.then(function(res) { .then(function(res) {
// Copy sources and balance // Copy sources and balance
const data = res[0]; var data = res[0];
data.tx = res[1]; data.tx = res[1];
const txPendings = []; var txPendings = [];
let txErrors = []; var txErrors = [];
const balanceFromSource = data.balance; var balanceFromSource = data.balance;
let balanceWithPending = data.balance; var balanceWithPending = data.balance;
function _processPendingTx(tx) { function _processPendingTx(tx) {
const consumedSources = []; var consumedSources = [];
let valid = true; var valid = true;
if (tx.amount > 0) { // do not check sources from received TX if (tx.amount > 0) { // do not check sources from received TX
valid = false; valid = false;
// TODO get sources from the issuer ? // TODO get sources from the issuer ?
} }
else { else {
_.forEach(tx.inputs, function(input) { _.forEach(tx.inputs, function(input) {
const inputKey = input.split(':').slice(2).join(':'); var inputKey = input.split(':').slice(2).join(':');
const srcIndex = data.sourcesIndexByKey[inputKey]; var srcIndex = data.sourcesIndexByKey[inputKey];
if (angular.isDefined(srcIndex)) { if (angular.isDefined(srcIndex)) {
consumedSources.push(data.sources[srcIndex]); consumedSources.push(data.sources[srcIndex]);
} }
...@@ -339,8 +339,8 @@ angular.module('cesium.tx.services', ['ngApi', 'cesium.bma.services', ...@@ -339,8 +339,8 @@ angular.module('cesium.tx.services', ['ngApi', 'cesium.bma.services',
} }
} }
let txs = data.tx.pendings; var txs = data.tx.pendings;
let retry = true; var retry = true;
while(txs && txs.length) { while(txs && txs.length) {
// process TX pendings // process TX pendings
_.forEach(txs, _processPendingTx); _.forEach(txs, _processPendingTx);
...@@ -371,7 +371,7 @@ angular.module('cesium.tx.services', ['ngApi', 'cesium.bma.services', ...@@ -371,7 +371,7 @@ angular.module('cesium.tx.services', ['ngApi', 'cesium.bma.services',
.then(function() { .then(function() {
console.debug('[tx] TX and sources loaded in '+ (Date.now()-now) +'ms'); console.debug('[tx] TX and sources loaded in '+ (Date.now()-now) +'ms');
return data; return data;
}) });
}); });
}, },
...@@ -398,12 +398,12 @@ angular.module('cesium.tx.services', ['ngApi', 'cesium.bma.services', ...@@ -398,12 +398,12 @@ angular.module('cesium.tx.services', ['ngApi', 'cesium.bma.services',
loadData(pubkey, options.fromTime) loadData(pubkey, options.fromTime)
]) ])
.then(function(result){ .then(function(result){
const translations = result[0]; var translations = result[0];
const currentBlock = result[1]; var currentBlock = result[1];
const currentTime = (currentBlock && currentBlock.medianTime) || moment().utc().unix(); var currentTime = (currentBlock && currentBlock.medianTime) || moment().utc().unix();
const currency = currentBlock && currentBlock.currency; var currency = currentBlock && currentBlock.currency;
const data = result[2]; var data = result[2];
// no TX // no TX
if (!data || !data.tx || !data.tx.history) { if (!data || !data.tx || !data.tx.history) {
...@@ -413,18 +413,18 @@ angular.module('cesium.tx.services', ['ngApi', 'cesium.bma.services', ...@@ -413,18 +413,18 @@ angular.module('cesium.tx.services', ['ngApi', 'cesium.bma.services',
return $translate('ACCOUNT.FILE_NAME', {currency: currency, pubkey: pubkey, currentTime : currentTime}) return $translate('ACCOUNT.FILE_NAME', {currency: currency, pubkey: pubkey, currentTime : currentTime})
.then(function(filename){ .then(function(filename){
const formatDecimal = $filter('formatDecimal'); var formatDecimal = $filter('formatDecimal');
const medianDate = $filter('medianDate'); var medianDate = $filter('medianDate');
const formatSymbol = $filter('currencySymbolNoHtml'); var formatSymbol = $filter('currencySymbolNoHtml');
const headers = [ var headers = [
translations['ACCOUNT.HEADERS.TIME'], translations['ACCOUNT.HEADERS.TIME'],
translations['COMMON.UID'], translations['COMMON.UID'],
translations['COMMON.PUBKEY'], translations['COMMON.PUBKEY'],
translations['ACCOUNT.HEADERS.AMOUNT'] + ' (' + formatSymbol(currency) + ')', translations['ACCOUNT.HEADERS.AMOUNT'] + ' (' + formatSymbol(currency) + ')',
translations['ACCOUNT.HEADERS.COMMENT'] translations['ACCOUNT.HEADERS.COMMENT']
]; ];
const content = data.tx.history.concat(data.tx.validating).reduce(function(res, tx){ var content = data.tx.history.concat(data.tx.validating).reduce(function(res, tx){
return res.concat([ return res.concat([
medianDate(tx.time), medianDate(tx.time),
tx.uid, tx.uid,
...@@ -434,7 +434,7 @@ angular.module('cesium.tx.services', ['ngApi', 'cesium.bma.services', ...@@ -434,7 +434,7 @@ angular.module('cesium.tx.services', ['ngApi', 'cesium.bma.services',
].join(';') + '\n'); ].join(';') + '\n');
}, [headers.join(';') + '\n']); }, [headers.join(';') + '\n']);
const file = new Blob(content, {type: 'text/plain; charset=utf-8'}); var file = new Blob(content, {type: 'text/plain; charset=utf-8'});
FileSaver.saveAs(file, filename); FileSaver.saveAs(file, filename);
}); });
}); });
......
...@@ -2133,8 +2133,8 @@ angular.module('cesium.wallet.services', ['ngApi', 'ngFileSaver', 'cesium.bma.se ...@@ -2133,8 +2133,8 @@ angular.module('cesium.wallet.services', ['ngApi', 'ngFileSaver', 'cesium.bma.se
checkAuthIdle = function(isAuthResult) { checkAuthIdle = function(isAuthResult) {
isAuthResult = angular.isDefined(isAuthResult) ? isAuthResult : isAuth(); isAuthResult = angular.isDefined(isAuthResult) ? isAuthResult : isAuth();
const newEnableAuthIdle = isAuthResult && settings.keepAuthIdle > 0 && settings.keepAuthIdle != csSettings.constants.KEEP_AUTH_IDLE_SESSION; var newEnableAuthIdle = isAuthResult && settings.keepAuthIdle > 0 && settings.keepAuthIdle != csSettings.constants.KEEP_AUTH_IDLE_SESSION;
const changed = (enableAuthIdle != newEnableAuthIdle); var changed = (enableAuthIdle != newEnableAuthIdle);
// need start/top watching // need start/top watching
if (changed) { if (changed) {
...@@ -2159,7 +2159,7 @@ angular.module('cesium.wallet.services', ['ngApi', 'ngFileSaver', 'cesium.bma.se ...@@ -2159,7 +2159,7 @@ angular.module('cesium.wallet.services', ['ngApi', 'ngFileSaver', 'cesium.bma.se
} }
// Make sure to store seckey, in the session storage for secret key -fix #372 // Make sure to store seckey, in the session storage for secret key -fix #372
const storeSecKey = isAuthResult && settings.keepAuthIdle == csSettings.constants.KEEP_AUTH_IDLE_SESSION && true; var storeSecKey = isAuthResult && settings.keepAuthIdle == csSettings.constants.KEEP_AUTH_IDLE_SESSION && true;
if (storeSecKey) { if (storeSecKey) {
sessionStorage.put(constants.STORAGE_SECKEY, CryptoUtils.base58.encode(data.keypair.signSk)); sessionStorage.put(constants.STORAGE_SECKEY, CryptoUtils.base58.encode(data.keypair.signSk));
} }
...@@ -2247,7 +2247,7 @@ angular.module('cesium.wallet.services', ['ngApi', 'ngFileSaver', 'cesium.bma.se ...@@ -2247,7 +2247,7 @@ angular.module('cesium.wallet.services', ['ngApi', 'ngFileSaver', 'cesium.bma.se
options.restore = angular.isDefined(options.restore) ? options.restore : (id === 'default'); options.restore = angular.isDefined(options.restore) ? options.restore : (id === 'default');
console.debug('[wallet] Starting...'); console.debug('[wallet] Starting...');
const now = Date.now(); var now = Date.now();
startPromise = $q.all([ startPromise = $q.all([
csSettings.ready() csSettings.ready()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment