codiad/data/collaborative/shadow/a43aba4776a318fab1ae3091a8dfd1e9

69 lines
1.6 KiB
Plaintext
Raw Normal View History

s:1621:"/*
* 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...
let editor = document.getElementsByClassName( 'ace_content' )[0];
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() {
let tabs = document.getElementsByClassName( "tab-item" );
let path = codiad.active.getPath();
let content = codiad.editor.getContent;
tabs = Array.from( tabs );
tabs.forEach( function( m, i, a ) {
// M = Current entry
// I = Index as integer
// A = Entire array
if ( m.classList.contains( "active" ) ) {
m.classList.remove( "changed" )
}
});
codiad.active.save;
codiad.filemanager.saveFile(path, newContent, localStorage.removeItem(path));
var session = codiad.active.sessions[path];
if(typeof session != 'undefined') {
session.untainted = newContent;
session.serverMTime = mtime;
if (session.listThumb) session.listThumb.removeClass('changed');
if (session.tabThumb) session.tabThumb.removeClass('changed');
}
}
};
})(this, jQuery);
";