Added option time format for autosave (12/24). Added option text for autosave.

pull/170/head
Dmitry Mazurov 4 years ago
parent 3096bbe291
commit ad83e77aee

@ -23,6 +23,8 @@ The editor is entirely customizable, from theming to toolbar buttons and javascr
## Quick access ## Quick access
- [EasyMDE - Markdown Editor](#easymde---markdown-editor)
- [Quick access](#quick-access)
- [Install EasyMDE](#install-easymde) - [Install EasyMDE](#install-easymde)
- [How to use](#how-to-use) - [How to use](#how-to-use)
- [Loading the editor](#loading-the-editor) - [Loading the editor](#loading-the-editor)
@ -122,6 +124,8 @@ easyMDE.value('New input for **EasyMDE**');
- **delay**: Delay between saves, in milliseconds. Defaults to `10000` (10s). - **delay**: Delay between saves, in milliseconds. Defaults to `10000` (10s).
- **submit_delay**: Delay before assuming that submit of the form failed and saving the text, in milliseconds. Defaults to `autosave.delay` or `10000` (10s). - **submit_delay**: Delay before assuming that submit of the form failed and saving the text, in milliseconds. Defaults to `autosave.delay` or `10000` (10s).
- **uniqueId**: You must set a unique string identifier so that EasyMDE can autosave. Something that separates this from other instances of EasyMDE elsewhere on your website. - **uniqueId**: You must set a unique string identifier so that EasyMDE can autosave. Something that separates this from other instances of EasyMDE elsewhere on your website.
- **timeFormat**: Time format 12/24. Defaults to 12.
- **text**: Set text for autosave.
- **blockStyles**: Customize how certain buttons that style blocks of text behave. - **blockStyles**: Customize how certain buttons that style blocks of text behave.
- **bold**: Can be set to `**` or `__`. Defaults to `**`. - **bold**: Can be set to `**` or `__`. Defaults to `**`.
- **code**: Can be set to ```` ``` ```` or `~~~`. Defaults to ```` ``` ````. - **code**: Can be set to ```` ``` ```` or `~~~`. Defaults to ```` ``` ````.
@ -206,6 +210,8 @@ var editor = new EasyMDE({
uniqueId: "MyUniqueID", uniqueId: "MyUniqueID",
delay: 1000, delay: 1000,
submit_delay: 5000, submit_delay: 5000,
timeFormat: 24,
text: "Autosaved: "
}, },
blockStyles: { blockStyles: {
bold: "__", bold: "__",

@ -2004,6 +2004,12 @@ EasyMDE.prototype.autosave = function () {
var m = d.getMinutes(); var m = d.getMinutes();
var dd = 'am'; var dd = 'am';
var h = hh; var h = hh;
var html = '';
var save = this.options.autosave.text == undefined ? 'Autosaved: ' : this.options.autosave.text;
m = m < 10 ? '0' + m : m;
if (this.options.autosave.timeFormat == undefined || this.options.autosave.timeFormat == 12) {
if (h >= 12) { if (h >= 12) {
h = hh - 12; h = hh - 12;
dd = 'pm'; dd = 'pm';
@ -2011,9 +2017,14 @@ EasyMDE.prototype.autosave = function () {
if (h == 0) { if (h == 0) {
h = 12; h = 12;
} }
m = m < 10 ? '0' + m : m;
el.innerHTML = 'Autosaved: ' + h + ':' + m + ' ' + dd; html = save + h + ':' + m + ' ' + dd;
}
if (this.options.autosave.timeFormat == 24) {
html = save + h + ':' + m;
}
el.innerHTML = html;
} }
this.autosaveTimeoutId = setTimeout(function () { this.autosaveTimeoutId = setTimeout(function () {

Loading…
Cancel
Save