date format optimize

pull/510/head
WittBulter 7 years ago
parent 21beaa9e74
commit 98bce7a7bc

@ -84,8 +84,7 @@ class SimpleMDE extends Action {
this.element = options.element; this.element = options.element;
} else if(options.element === null) { } else if(options.element === null) {
// This means that the element option was specified, but no element was found // This means that the element option was specified, but no element was found
console.log("SimpleMDE: Error. No element was found."); return console.log("SimpleMDE: Error. No element was found.");
return;
} }
// Handle toolbar // Handle toolbar
@ -93,7 +92,6 @@ class SimpleMDE extends Action {
// Initialize // Initialize
options.toolbar = []; options.toolbar = [];
// Loop over the built in buttons, to get the preferred order // Loop over the built in buttons, to get the preferred order
for(let key in toolbarBuiltInButtons) { for(let key in toolbarBuiltInButtons) {
if(toolbarBuiltInButtons.hasOwnProperty(key)) { if(toolbarBuiltInButtons.hasOwnProperty(key)) {
@ -297,21 +295,16 @@ class SimpleMDE extends Action {
let el = document.getElementById("autosaved"); let el = document.getElementById("autosaved");
if(el != null && el != undefined && el != "") { if(el != null && el != undefined && el != "") {
let d = new Date(); const d = new Date();
let hh = d.getHours(); const hh = d.getHours();
let m = d.getMinutes(); const mm = d.getMinutes();
let dd = "am";
let h = hh; // date format, output example: Autosaved: 5:45 pm
if(h >= 12) { const dd = hh >= 12 ? 'pm' : 'am'
h = hh - 12; const h = hh == 0 ? 12 : hh > 12 ? hh - 12 : hh;
dd = "pm"; const m = mm < 10 ? `0${mm}` : mm;
}
if(h == 0) {
h = 12;
}
m = m < 10 ? "0" + m : m;
el.innerHTML = "Autosaved: " + h + ":" + m + " " + dd; el.innerHTML = `Autosaved: ${h}:${m} ${dd}`;
} }
this.autosaveTimeoutId = setTimeout(function() { this.autosaveTimeoutId = setTimeout(function() {

Loading…
Cancel
Save