2017-11-05 07:38:50 +08:00
|
|
|
"use strict";
|
|
|
|
|
2017-11-30 12:30:35 +08:00
|
|
|
function reloadApp() {
|
|
|
|
window.location.reload(true);
|
|
|
|
}
|
|
|
|
|
2017-11-27 01:56:07 +08:00
|
|
|
function showMessage(message) {
|
|
|
|
console.log("message: ", message);
|
|
|
|
|
|
|
|
$.notify({
|
|
|
|
// options
|
|
|
|
message: message
|
|
|
|
},{
|
|
|
|
// settings
|
|
|
|
type: 'success',
|
2017-11-27 06:04:18 +08:00
|
|
|
delay: 3000
|
2017-11-27 01:56:07 +08:00
|
|
|
});
|
2017-08-14 09:42:10 +08:00
|
|
|
}
|
|
|
|
|
2017-12-13 12:47:17 +08:00
|
|
|
function showError(message, delay = 10000) {
|
2017-11-27 01:56:07 +08:00
|
|
|
console.log("error: ", message);
|
|
|
|
|
|
|
|
$.notify({
|
|
|
|
// options
|
|
|
|
message: message
|
|
|
|
},{
|
|
|
|
// settings
|
|
|
|
type: 'danger',
|
2017-12-13 12:47:17 +08:00
|
|
|
delay: delay
|
2017-11-27 01:56:07 +08:00
|
|
|
});
|
2017-09-07 10:06:43 +08:00
|
|
|
}
|
|
|
|
|
2017-12-07 08:53:23 +08:00
|
|
|
function throwError(message) {
|
2017-12-07 09:11:45 +08:00
|
|
|
messaging.logError(message);
|
|
|
|
|
|
|
|
throw new Error(message);
|
2017-12-07 08:53:23 +08:00
|
|
|
}
|
|
|
|
|
2017-12-11 04:31:43 +08:00
|
|
|
function parseDate(str) {
|
|
|
|
try {
|
|
|
|
return new Date(Date.parse(str));
|
|
|
|
}
|
|
|
|
catch (e) {
|
|
|
|
throw new Error("Can't parse date from " + str + ": " + e.stack);
|
|
|
|
}
|
2017-10-01 10:36:14 +08: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-12-01 08:58:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function isElectron() {
|
|
|
|
return window && window.process && window.process.type;
|
2017-06-12 04:04:07 +08:00
|
|
|
}
|