2017-11-04 19:38:50 -04:00
|
|
|
"use strict";
|
|
|
|
|
2017-11-29 23:30:35 -05:00
|
|
|
function reloadApp() {
|
|
|
|
window.location.reload(true);
|
|
|
|
}
|
|
|
|
|
2017-11-26 12:56:07 -05:00
|
|
|
function showMessage(message) {
|
|
|
|
console.log("message: ", message);
|
|
|
|
|
|
|
|
$.notify({
|
|
|
|
// options
|
|
|
|
message: message
|
|
|
|
},{
|
|
|
|
// settings
|
|
|
|
type: 'success',
|
2017-11-26 17:04:18 -05:00
|
|
|
delay: 3000
|
2017-11-26 12:56:07 -05:00
|
|
|
});
|
2017-08-13 21:42:10 -04:00
|
|
|
}
|
|
|
|
|
2017-11-26 12:56:07 -05:00
|
|
|
function showError(message) {
|
|
|
|
console.log("error: ", message);
|
|
|
|
|
|
|
|
$.notify({
|
|
|
|
// options
|
|
|
|
message: message
|
|
|
|
},{
|
|
|
|
// settings
|
|
|
|
type: 'danger',
|
|
|
|
delay: 10000
|
|
|
|
});
|
2017-09-06 22:06:43 -04:00
|
|
|
}
|
|
|
|
|
2017-12-06 19:53:23 -05:00
|
|
|
function throwError(message) {
|
2017-12-06 20:11:45 -05:00
|
|
|
messaging.logError(message);
|
|
|
|
|
|
|
|
throw new Error(message);
|
2017-12-06 19:53:23 -05:00
|
|
|
}
|
|
|
|
|
2017-09-30 22:36:14 -04:00
|
|
|
function getDateFromTS(timestamp) {
|
|
|
|
// Date accepts number of milliseconds since epoch so UTC timestamp works without any extra handling
|
|
|
|
// see https://stackoverflow.com/questions/4631928/convert-utc-epoch-to-local-date-with-javascript
|
2017-10-24 18:57:00 -04:00
|
|
|
return new Date(timestamp * 1000);
|
2017-09-30 22:36:14 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function formatTime(date) {
|
|
|
|
return (date.getHours() <= 9 ? "0" : "") + date.getHours() + ":" + (date.getMinutes() <= 9 ? "0" : "") + date.getMinutes();
|
|
|
|
}
|
|
|
|
|
|
|
|
function formatDate(date) {
|
|
|
|
return date.getDate() + ". " + (date.getMonth() + 1) + ". " + date.getFullYear();
|
|
|
|
}
|
|
|
|
|
|
|
|
function formatDateTime(date) {
|
|
|
|
return formatDate(date) + " " + formatTime(date);
|
2017-11-30 19:58:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
function isElectron() {
|
|
|
|
return window && window.process && window.process.type;
|
2017-06-11 16:04:07 -04:00
|
|
|
}
|