2018-07-17 19:32:22 +02:00
|
|
|
/*
|
2018-07-13 18:39:55 +02:00
|
|
|
* Place copyright or other info here...
|
|
|
|
*/
|
|
|
|
|
|
|
|
(function(global, $){
|
|
|
|
|
|
|
|
// Define core
|
|
|
|
var codiad = global.codiad,
|
|
|
|
scripts= document.getElementsByTagName('script'),
|
|
|
|
path = scripts[scripts.length-1].src.split('?')[0],
|
|
|
|
curpath = path.split('/').slice(0, -1).join('/')+'/';
|
|
|
|
|
|
|
|
// Instantiates plugin
|
|
|
|
$(function() {
|
|
|
|
codiad.tela_auto_save.init();
|
|
|
|
});
|
|
|
|
|
|
|
|
codiad.tela_auto_save = {
|
|
|
|
|
|
|
|
// Allows relative `this.path` linkage
|
|
|
|
path: curpath,
|
|
|
|
|
|
|
|
init: function() {
|
|
|
|
|
|
|
|
// Start your plugin here...
|
2018-07-17 19:32:22 +02:00
|
|
|
//let editor = document.getElementsByClassName( 'ace_content' )[0];
|
2018-07-13 18:39:55 +02:00
|
|
|
let auto_save_trigger = setInterval( this.auto_save, 500 );
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* This is where the core functionality goes, any call, references,
|
|
|
|
* script-loads, etc...
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
auto_save: function() {
|
|
|
|
|
2018-07-17 19:32:22 +02:00
|
|
|
if ( codiad.active.getPath() === null ) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
2018-07-13 18:39:55 +02:00
|
|
|
let tabs = document.getElementsByClassName( "tab-item" );
|
|
|
|
let path = codiad.active.getPath();
|
2018-07-17 19:32:22 +02:00
|
|
|
let content = codiad.editor.getContent();
|
2018-07-13 18:39:55 +02:00
|
|
|
|
|
|
|
codiad.active.save;
|
2018-07-17 19:32:22 +02:00
|
|
|
codiad.filemanager.saveFile(path, content, localStorage.removeItem(path), false);
|
2018-07-13 18:39:55 +02:00
|
|
|
var session = codiad.active.sessions[path];
|
|
|
|
if(typeof session != 'undefined') {
|
2018-07-17 19:32:22 +02:00
|
|
|
session.untainted = content;
|
|
|
|
session.serverMTime = session.serverMTime;
|
2018-07-13 18:39:55 +02:00
|
|
|
if (session.listThumb) session.listThumb.removeClass('changed');
|
|
|
|
if (session.tabThumb) session.tabThumb.removeClass('changed');
|
2018-07-17 19:32:22 +02:00
|
|
|
}
|
2018-07-13 18:39:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2018-07-17 19:32:22 +02:00
|
|
|
})(this, jQuery);
|