trilium/public/javascripts/utils.js

62 lines
1.2 KiB
JavaScript
Raw Normal View History

"use strict";
function reloadApp() {
window.location.reload(true);
}
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-08-14 09:42:10 +08:00
}
function showError(message, delay = 10000) {
console.log("error: ", message);
$.notify({
// options
message: message
},{
// settings
type: 'danger',
delay: delay
});
}
function throwError(message) {
messaging.logError(message);
throw new Error(message);
}
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
}