Added new beautify options, Updated autosave and Auto refresh to run after user has stopped typing, Reformatted filemanager

This commit is contained in:
xevidos 2019-05-01 16:21:45 -04:00
parent 0fc44338ae
commit 61b0061bf1
3 changed files with 1022 additions and 929 deletions

View File

@ -22,22 +22,28 @@ Stick to the conventions defined in other components as closely as possible.
In order to maintain a consistant code structure to the code across the application please follow the wordpress standard, or run any changes through [JSBeautifier] (http://jsbeautifier.org/) with the settings below.
{
"indent_size": "1",
"brace_style": "collapse",
"break_chained_methods": false,
"comma_first": false,
"e4x": false,
"end_with_newline": true,
"indent_char": "\t",
"indent_empty_lines": true,
"indent_inner_html": true,
"indent_scripts": "normal",
"indent_size": "1",
"jslint_happy": false,
"keep_array_indentation": true,
"max_preserve_newlines": "5",
"preserve_newlines": true,
"keep_array_indentation": true,
"break_chained_methods": false,
"indent_scripts": "normal",
"brace_style": "collapse",
"space_after_anon_function": false,
"space_after_named_function": false,
"space_before_conditional": false,
"space_in_empty_paren": false,
"space_in_paren": true,
"unescape_strings": false,
"jslint_happy": false,
"end_with_newline": true,
"wrap_line_length": "0",
"indent_inner_html": true,
"comma_first": false,
"e4x": false
"unindent_chained_methods": true,
"wrap_line_length": "0"
}
If you have questions, please ask. Submit an issue or [contact us directly](mailto:support@telaaedifex.com).

View File

@ -38,6 +38,7 @@
editor: null,
invalid_states: [ "", " ", null, undefined ],
path: curpath,
save_interval: null,
saving: false,
settings: {
autosave: true,
@ -128,6 +129,30 @@
});
},
auto_save: function() {
/**
* When saving after every change, we encounter an issue where every
* once in a while the last change or last few changes will not get
* saved. Due to this, I decided to instead only save after the user
* has finished typing their changes.
*
* On every change to the editor, we set a timeout of half a second
* to see if the user is still typing. If they are, we clear the
* timeout and set it again. If they have stopped typing then the
* timout is triggered after 500 miliseconds and the file is saved.
*/
let _this = codiad.auto_save;
if( _this.save_interval !== null ) {
clearTimeout( _this.save_interval );
_this.save_interval = null;
}
_this.save_interval = setTimeout( _this.save, 500 );
},
/**
*
* This is where the core functionality goes, any call, references,
@ -135,9 +160,15 @@
*
*/
auto_save: function() {
save: function() {
let _this = codiad.auto_save;
if( _this.saving ) {
return;
}
_this.saving = true;
let tabs = document.getElementsByClassName( "tab-item" );
let path = codiad.active.getPath();
@ -193,7 +224,8 @@
_this.content = content;
codiad.active.save;
codiad.filemanager.saveFile( path, content, localStorage.removeItem( path ), false );
//codiad.filemanager.saveFile( path, content, localStorage.removeItem( path ), false );
codiad.filemanager.saveFile( path, content, localStorage.removeItem( path ) );
let session = codiad.active.sessions[path];
if( typeof session != 'undefined' ) {
@ -210,13 +242,6 @@
}
}
_this.saving = false;
setTimeout(function() {
//Call the function again after one second so that if we missed the last change we resave the file.
let _this = codiad.auto_save;
_this.auto_save();
}, 1000);
},
reload_interval: async function() {

File diff suppressed because it is too large Load Diff