mirror of
https://github.com/xevidos/codiad.git
synced 2024-11-10 21:26:35 +01:00
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:
parent
f0f9f3a89e
commit
7e8e292882
@ -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}` );
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -62,6 +62,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
settings['codiad.settings.autosave'] = auto_save;
|
||||
settings['codiad.settings.system.sync'] = sync_system;
|
||||
settings['codiad.settings.plugin.sync'] = sync_plugin;
|
||||
|
||||
|
@ -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() {
|
||||
|
@ -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 );
|
||||
}
|
||||
}
|
||||
|
74
js/jsend.js
74
js/jsend.js
@ -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);
|
||||
|
@ -1,3 +0,0 @@
|
||||
# Codiad Plugin
|
||||
Tela Auto Save
|
||||
Saves your current working file every 500ms.
|
@ -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);
|
@ -1,6 +0,0 @@
|
||||
[{
|
||||
"author": "Isaac Brown",
|
||||
"version": "1.0.0",
|
||||
"name": "Tela Auto Save",
|
||||
"url": "https://telaaedifex.com"
|
||||
}]
|
@ -1 +0,0 @@
|
||||
/* Any needed CSS directives... */
|
Loading…
Reference in New Issue
Block a user