2018-04-21 20:22:13 +00:00
|
|
|
/**
|
|
|
|
* Formats a date.
|
|
|
|
* @param {date} date - toggle decorations
|
|
|
|
* @param {params} params -
|
|
|
|
*/
|
|
|
|
function formatDate( date, params ) {
|
|
|
|
var options = {
|
|
|
|
weekday: "short",
|
|
|
|
year: "numeric",
|
|
|
|
month: "long",
|
|
|
|
day: "numeric",
|
|
|
|
hour: "2-digit",
|
|
|
|
minute: "2-digit",
|
|
|
|
timeZone: "UTC",
|
|
|
|
timeZoneName: "short",
|
|
|
|
};
|
|
|
|
|
|
|
|
options = [options, params].reduce(function (r, o) {
|
|
|
|
Object.keys(o).forEach(function (k) { r[k] = o[k]; });
|
|
|
|
return r;
|
|
|
|
}, {});
|
|
|
|
|
|
|
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString
|
|
|
|
return new Date( date ).toLocaleString( 'en-US', options );
|
|
|
|
}
|
2018-04-28 13:17:36 +00:00
|
|
|
|
|
|
|
function isNumeric(n) {
|
|
|
|
return !isNaN(parseFloat(n)) && isFinite(n);
|
2018-07-18 14:51:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function showSeedPage() {
|
|
|
|
// Shows `Settings->Seed & keys`. Prompts a password dialog.
|
|
|
|
passwordDialog.onAcceptedCallback = function() {
|
|
|
|
if(walletPassword === passwordDialog.password){
|
|
|
|
if(currentWallet.seedLanguage == "") {
|
|
|
|
console.log("No seed language set. Using English as default");
|
|
|
|
currentWallet.setSeedLanguage("English");
|
|
|
|
}
|
|
|
|
// Load keys page
|
2018-09-27 14:01:14 +00:00
|
|
|
appWindow.showPageRequest("Keys");
|
2018-07-18 14:51:56 +00:00
|
|
|
} else {
|
2018-10-24 03:50:56 +00:00
|
|
|
passwordDialog.showError(qsTr("Wrong password"));
|
2018-07-18 14:51:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
passwordDialog.onRejectedCallback = function() {
|
2018-09-27 14:01:14 +00:00
|
|
|
leftPanel.selectItem(middlePanel.state);
|
2018-07-18 14:51:56 +00:00
|
|
|
}
|
|
|
|
passwordDialog.open();
|
|
|
|
if(isMobile) hideMenu();
|
|
|
|
updateBalance();
|
2018-12-08 15:55:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function ago(epoch) {
|
|
|
|
// Returns '<delta> [seconds|minutes|hours|days] ago' string given an epoch
|
|
|
|
|
|
|
|
var now = new Date().getTime() / 1000;
|
|
|
|
var delta = now - epoch;
|
|
|
|
|
|
|
|
if(delta < 60) {
|
2019-01-10 08:58:36 +00:00
|
|
|
if (delta <= 1) {
|
|
|
|
return 1 + " " + qsTr("second ago")
|
|
|
|
} else {
|
|
|
|
return Math.floor(delta) + " " + qsTr("seconds ago")
|
|
|
|
}
|
2018-12-08 15:55:29 +00:00
|
|
|
} else if (delta >= 60 && delta <= 3600) {
|
|
|
|
if(delta >= 60 && delta < 120){
|
|
|
|
return 1 + " " + qsTr("minute ago")
|
|
|
|
} else {
|
|
|
|
return parseInt(Math.floor(delta / 60)) + " " + qsTr("minutes ago")
|
|
|
|
}
|
|
|
|
} else if (delta >= 3600 && delta <= 86400) {
|
|
|
|
if(delta >= 3600 && delta < 7200) {
|
|
|
|
return 1 + " " + qsTr("hour ago")
|
|
|
|
} else {
|
|
|
|
return parseInt(Math.floor(delta / 60 / 60)) + " " + qsTr("hours ago")
|
|
|
|
}
|
|
|
|
} else if (delta >= 86400){
|
|
|
|
if(delta >= 86400 && delta < 172800) {
|
|
|
|
return 1 + " " + qsTr("day ago")
|
|
|
|
} else {
|
|
|
|
var _delta = parseInt(Math.floor(delta / 24 / 60 / 60));
|
|
|
|
if(_delta === 1) {
|
|
|
|
return 1 + " " + qsTr("day ago")
|
|
|
|
} else {
|
|
|
|
return _delta + " " + qsTr("days ago")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|