Removed auto save plugin, Finished integrating auto save, Fixed JSEND error on first load, added checks for incompatible files and plugins on update.

This commit is contained in:
xevidos 2018-07-26 16:50:47 -04:00
parent f0f9f3a89e
commit 7e8e292882
9 changed files with 84 additions and 110 deletions

View File

@ -26,6 +26,7 @@
codiad.auto_save = {
// Allows relative `this.path` linkage
auto_save_trigger: null,
path: curpath,
saving: false,
settings: {
@ -36,8 +37,12 @@
init: function() {
this.get_settings();
//console.log( this.settings.autosave );
// Check if the auto save setting is true or false
if( this.settings.autosave === false || this.settings.autosave === "false" ) {
window.clearInterval( this.auto_save_trigger );
console.log( 'Auto save disabled' );
return;
}
@ -55,8 +60,9 @@
console.log( 'Auto save paused' );
});
console.log( 'Auto save Enabled' );
//let editor = document.getElementsByClassName( 'ace_content' )[0];
let auto_save_trigger = setInterval( this.auto_save, 256 );
this.auto_save_trigger = setInterval( this.auto_save, 256 );
},
/**
@ -87,7 +93,7 @@
codiad.active.save;
codiad.filemanager.saveFile(path, content, localStorage.removeItem(path), false);
var session = codiad.active.sessions[path];
if(typeof session != 'undefined') {
if( typeof session != 'undefined' ) {
session.untainted = content;
session.serverMTime = session.serverMTime;
if (session.listThumb) session.listThumb.removeClass('changed');
@ -105,6 +111,7 @@
var localValue = localStorage.getItem('codiad.settings.' + key);
if (localValue !== null) {
_this.settings[key] = localValue;
//console.log( `${key}, ${localValue}` );
}
});
}

View File

@ -62,6 +62,7 @@
}
}
settings['codiad.settings.autosave'] = auto_save;
settings['codiad.settings.system.sync'] = sync_system;
settings['codiad.settings.plugin.sync'] = sync_plugin;

View File

@ -148,7 +148,7 @@ class Update {
//echo var_dump( $response );
//return "[".formatJSEND("success", array("currentversion"=>$local[0]['version'],"remoteversion"=>$latest,"message"=>$message,"archive"=>$archive,"nightly"=>$nightly,"name"=>$local[0]['name']))."]";
return "[".formatJSEND("success", array("currentversion"=>$current_version,"remoteversion"=>$response["name"],"message"=>$response["message"],"archive"=>$archive,"nightly"=>$nightly,"name"=>$response["author_name"]))."]";
return "[".formatJSEND("success", array("currentversion"=>$current_version,"remoteversion"=>$response["name"],"message"=>$response["release"]["description"],"archive"=>$archive,"nightly"=>$nightly,"name"=>$response["commit"]["author_name"]))."]";
}
function CheckProtocol() {

View File

@ -199,6 +199,41 @@ class updater {
mkdir( $sessions, 755 );
}
/**
* If any directories in the array below are still set delete them.
*
*/
$folder_conflictions = array(
$this->path . "/plugins/auto_save",
$this->path . "/plugins/Codiad-Auto-Save",
$this->path . "/plugins/Codiad-Auto-Save-master",
$this->path . "/plugins/Codiad-CodeSettings",
$this->path . "/plugins/Codiad-CodeSettings-master",
);
foreach( $folder_conflictions as $dir ) {
$this->remove_directory( $dir );
}
/**
* If any files in the array below are still set delete them.
*
*/
$file_conflictions = array(
$this->path . "/.travis.yml",
$this->path . "/codiad-master/.travis.yml",
);
foreach( $folder_conflictions as $file ) {
unlink( $file );
}
$src = $this->path . "/codiad-master/";
$src_folder = $this->path . "/codiad-master";
$dest = $this->path . "/";
@ -207,7 +242,6 @@ class updater {
echo "<script>document.getElementById('progress').innerHTML = '<p class=\"status_box\">Removing Update ... </p>';</script>";
unlink( $src . ".travis.yml" );
$this->remove_directory( $src );
}
}

View File

@ -1,36 +1,38 @@
(function(global, $){
var codiad = global.codiad;
//////////////////////////////////////////////////////////////////////
// Parse JSEND Formatted Returns
//////////////////////////////////////////////////////////////////////
codiad.jsend = {
parse: function(d) { // (Data)
var obj = $.parseJSON(d);
if( obj !== undefined && obj !== null ) {
return;
}
if (obj.debug !== undefined && Array.isArray(obj.debug)) {
var debug = obj.debug.join('\nDEBUG: ');
if(debug !== '') {
debug = 'DEBUG: ' + debug;
}
console.log(debug);
}
if (obj.status == 'error') {
codiad.message.error(obj.message);
return 'error';
} else {
return obj.data;
}
}
};
})(this, jQuery);
(function(global, $){
var codiad = global.codiad;
//////////////////////////////////////////////////////////////////////
// Parse JSEND Formatted Returns
//////////////////////////////////////////////////////////////////////
codiad.jsend = {
parse: function(d) {
// (Data)
var obj = $.parseJSON(d);
if ( obj === undefined || obj === null ) {
return 'error';
}
if (obj !== undefined && obj !== null && Array.isArray(obj.debug)) {
var debug = obj.debug.join('\nDEBUG: ');
if(debug !== '') {
debug = 'DEBUG: ' + debug;
}
console.log(debug);
}
if ( obj.status == 'error' ) {
codiad.message.error(obj.message);
return 'error';
} else {
return obj.data;
}
}
};
})(this, jQuery);

View File

@ -1,3 +0,0 @@
# Codiad Plugin
Tela Auto Save
Saves your current working file every 500ms.

View File

@ -1,60 +0,0 @@
/*
* 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() {
if ( codiad.active.getPath() === null ) {
return;
}
let tabs = document.getElementsByClassName( "tab-item" );
let path = codiad.active.getPath();
let content = codiad.editor.getContent();
codiad.active.save;
codiad.filemanager.saveFile(path, content, localStorage.removeItem(path), false);
var session = codiad.active.sessions[path];
if(typeof session != 'undefined') {
session.untainted = content;
session.serverMTime = session.serverMTime;
if (session.listThumb) session.listThumb.removeClass('changed');
if (session.tabThumb) session.tabThumb.removeClass('changed');
}
}
};
})(this, jQuery);

View File

@ -1,6 +0,0 @@
[{
"author": "Isaac Brown",
"version": "1.0.0",
"name": "Tela Auto Save",
"url": "https://telaaedifex.com"
}]

View File

@ -1 +0,0 @@
/* Any needed CSS directives... */